Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trying to get iostat statistics AIX 5l v 5.3

7 views
Skip to first unread message

Daniel

unread,
Nov 9, 2005, 4:07:08 PM11/9/05
to
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[] = {
{"iostat", 0, 0, 0, 0, 0},
{NULL, 0, 0, 0, 0, 0}
};
//----function
body------------------------------------------------------------------------

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

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

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

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

//geting dkstat structure from kernel...

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


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
Daniel

0 new messages