For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > November 2005 > Trying to get iostat statistics AIX 5l v 5.3 help!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Trying to get iostat statistics AIX 5l v 5.3 help!
troophous

2005-11-10, 7:01 pm

Hi folks,
I've been trying to get the address of dkstat via dkstatp and the
dk_cnt value but I think there is a problem because, dk_cnt get
113022504 where actually it is 2 and the same way I think the address
dkstatp is pointing to, does not represent a real dkstat structure
address. Here below it is an extract from my code where I got the
problem:


#define N_VALUE(index) ((caddr_t)kernelnames[index].n_value)
#define NLIST_IOSTAT 0


static struct nlist kernelnames[] =3D {
{"iostat", 0, 0, 0, 0, 0},
{NULL, 0, 0, 0, 0, 0}
};
//----function
body-----------------------------------------------------------------------=
=AD-



knlist(kernelnames, 1, sizeof(struct nlist));
struct iostat _iostat;


if ((_kmem =3D open("/dev/kmem", O_RDONLY)) < 0) {
perror("kmem could not be accessed");
exit(1);
}
//geting iostat structure from kernel...
ls(_kmem, (off_t) N_VALUE(NLIST_IOSTAT), SEEK_SET);
read(_kmem, &_iostat, sizeof(struct iostat));


int _disk_count =3D _iostat.dk_cnt; /*an unexpected value is
returned: 113022504 */


struct dkstat* dk =3D (struct dkstat *) malloc(sizeof(struct dkstat)));


//geting dkstat structure from kernel...


ls(_kmem, (off_t) _iostat.dkstatp, SEEK_SET);
int n =3D read(_kmem, dk, sizeof(struct dkstat)); /*here it
is the crash*/
//--------end of function
body-----------------------------------------------------------------------=
=AD------------------------



so when I run the program and it tries to get dkstat structure it
result that n is -1 and a segmentation fault(coredump) is arised.


when I check for the iostat kernel symbol
$kdb
(0)> nm iostat
Symbol Address : 02C24D00
TOC Address : 0146E190
(0)> d 02C24D00
02C24D00: F100 0800 06BC 9628 0000 0000 0000 0005


So 0xF100 0800 is an unreal dkstat address and 0x06BC 9628 (113022504)

is not the real dk_cnt value.
I think it is related to AIX v5.3 because with earlier versions it
worked fine.


I would appreciate a lot that someone help me out on this.
Thanks=20
Daniel

troophous

2005-11-18, 7:01 pm

The problem you has had is due to a wrong compilation:
AiX v5.3 on a RS/6000 support both 64bit an 32bit kernel, so if you has
a 64bit kernel you will need to force the compilation to 64 bit using
the command -q64, because the address of the structures like dkstat is
64bit. Remember that by default the xlC compile for 32 bit.

Let prove it..
Regards.



troophous wrote:
> Hi folks,
> I've been trying to get the address of dkstat via dkstatp and the
> dk_cnt value but I think there is a problem because, dk_cnt get
> 113022504 where actually it is 2 and the same way I think the address
> dkstatp is pointing to, does not represent a real dkstat structure
> address. Here below it is an extract from my code where I got the
> problem:
>
>
> #define N_VALUE(index) ((caddr_t)kernelnames[index].n_value)
> #define NLIST_IOSTAT 0
>
>
> static struct nlist kernelnames[] =3D {
> {"iostat", 0, 0, 0, 0, 0},
> {NULL, 0, 0, 0, 0, 0}
> };
> //----function
> body---------------------------------------------------------------------=

--=AD-
>
>
>
> knlist(kernelnames, 1, sizeof(struct nlist));
> struct iostat _iostat;
>
>
> if ((_kmem =3D open("/dev/kmem", O_RDONLY)) < 0) {
> perror("kmem could not be accessed");
> exit(1);
> }
> //geting iostat structure from kernel...
> ls(_kmem, (off_t) N_VALUE(NLIST_IOSTAT), SEEK_SET);
> read(_kmem, &_iostat, sizeof(struct iostat));
>
>
> int _disk_count =3D _iostat.dk_cnt; /*an unexpected value is
> returned: 113022504 */
>
>
> struct dkstat* dk =3D (struct dkstat *) malloc(sizeof(struct dkstat)));
>
>
> //geting dkstat structure from kernel...
>
>
> ls(_kmem, (off_t) _iostat.dkstatp, SEEK_SET);
> int n =3D read(_kmem, dk, sizeof(struct dkstat)); /*here it
> is the crash*/
> //--------end of function
> body---------------------------------------------------------------------=

--=AD------------------------
>
>
>
> so when I run the program and it tries to get dkstat structure it
> result that n is -1 and a segmentation fault(coredump) is arised.
>
>
> when I check for the iostat kernel symbol
> $kdb
> (0)> nm iostat
> Symbol Address : 02C24D00
> TOC Address : 0146E190
> (0)> d 02C24D00
> 02C24D00: F100 0800 06BC 9628 0000 0000 0000 0005
>
>
> So 0xF100 0800 is an unreal dkstat address and 0x06BC 9628 (113022504)
>
> is not the real dk_cnt value.
> I think it is related to AIX v5.3 because with earlier versions it
> worked fine.
>
>
> I would appreciate a lot that someone help me out on this.
> Thanks=20
> Daniel


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com