1833461 Members
3078 Online
110052 Solutions
New Discussion

DISK STATISTICS

 
SOLVED
Go to solution
Hemant_7
Occasional Advisor

DISK STATISTICS

Hi
How to get the disk statistics of the devices same as v get through "sar -d 1 10" command . Actually i want to write a C funtion which give me all the details like device , %busy, avque, r+w/s, blks/s avwait , avserv.
Is there any structure in HPUX that gives all this information ??. If it is how to get info from it ??
The reason i cant use because sar command its not giving all the details of all the disk attached to the system.
Because if i c "/dev/dsk" directory there r 4 devices attached and sar is giving me only detail of 2.

Waiting for ur reply
hemant
6 REPLIES 6
Paula J Frazer-Campbell
Honored Contributor

Re: DISK STATISTICS

Hi

Sar -d will only give statistics on disks that have activity, so getting the %busy, avque, r+w/s, blks/s avwait , avserv on non active disks will result in nul/no activity results.

Because the disks do not appear in the sar -d output therefore does not mean that sar is incorrect, just that they are not in use at the time that sar was collecting data.


Paula
If you can spell SysAdmin then you is one - anon
Dietmar Konermann
Honored Contributor

Re: DISK STATISTICS

Hi!

The sar command uses the pstat(2) interface to get that information. In your case you should have a look at pstat_getdisk().

There are also examples in the man page.

Regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Hemant_7
Occasional Advisor

Re: DISK STATISTICS

Hi
Thanks for the reply .I tried using the pstat_getdisk function . But struct pst_diskinfo has no information about "device %busy , avque, r+w/s, blks/s , avwait , avserv " field . Please correct me if i m wrong !

thanks
hemant
Dietmar Konermann
Honored Contributor
Solution

Re: DISK STATISTICS

You are right... the metrics are not directly available. They need to be calculated.

Most of them are cumulative values... so you need to take 2 samples, get the differences then do some maths with it.

E.g.:

avwait = ( ( (float)DEV_DIFF_USEC(psd_dkwait) ) / 1000.0 ) /
(float)DEV_DIFF(psd_dkq_merged);

avserv = ( ( (float)DEV_DIFF_USEC(psd_dkresp) ) -
( (float)DEV_DIFF_USEC(psd_dkwait) ) );

So it's not trivial...

Regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Hemant_7
Occasional Advisor

Re: DISK STATISTICS

Hi there
Thats really a great ! thanks a lot for it !

Could u please tell me the algo for the %bsy and avque r+w/s field also . How to calculate it ?? . Where i can find this info for calculating it....

One more thing pstat_getdisk sycall , return the number of disk attached to the system is this true ??.

waiting for ur reply
thanks and regard
hemant

Dietmar Konermann
Honored Contributor

Re: DISK STATISTICS

Hi, Hermant!

The formulas are not documented explicitely... however, one may derive them from performance tuning guides. So it's not a big secret. :)

Here we are:

busy_percent = MAX( (float) DEV_DIFF (psd_dktime) / delta_time * 100.0 , 100 );

avque = (float)DEV_DIFF(psd_dkqlen) / (float)DEV_DIFF(psd_dkq_merged) -1;

rw = (float) DEV_DEV_DIFF(psd_dkq_merged) / delta_time * 100;

(delta_time is in ticks... 100 ticks/sec).

The syscall returns the number of structs it filled to buf. So it's:

MIN (#disks, elemcount)

Regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)