perfstat_partial_reset Interface
The perfstat_partial_reset interface resets the specified cached metrics that are stored by the libperfstat API.
The perfstat_partial_reset interface can also reset
the system's minimum and maximum counters related to disks and paths.
The following table summarizes the various actions of the perfstat_partial_reset interface:
The resetmask value | Action taken when the value of name is NULL | Action taken when the value of name is not NULL and a single resetmask value is set |
---|---|---|
FLUSH_CPUTOTAL | Flushes the speed and description values
in the perfstat_cputotal_t structure. |
Error. The value of errno is set to EINVAL. |
FLUSH_DISK | Flushes the description , adapter , size , free ,
and vgname values in every perfstat_disk_t structure.Flushes
the list of disk adapters. Flushes the size , free ,
and description values in everyperfstat_diskadapter_t structure. |
Flushes the description , adapter , size , free ,
and vgname values in the specified perfstat_disk_t structure.
Flushes the adapter value in every perfstat_diskpath_t structure
that matches the disk name that is followed by the _Path identifier.
Flushes the size , free , and description values
of each perfstat_diskadapter_t structure that is linked to
a path leading to the disk or to the disk itself. |
RESET_DISK_MINMAX | Resets the following values in every perfstat_diskadapter_t structure:
|
Error. The value of errno is set to ENOTSUP. |
FLUSH_DISKADAPTER | Flushes the list of disk adapters. Flushes the size , free ,
and description values in every perfstat_diskadapter_t structure.
Flushes the adapter value in every perfstat_diskpath_t structure.
Flushes the description and adapter values
in every perfstat_disk_t structure. |
Flushes the list of disk adapters. Flushes the size , free ,
and description values in every perfstat_diskadapter_t structure.Flushes
the adapter value in every perfstat_diskpath_t structure.
Flushes the description and adapter values
in every perfstat_disk_t structure. |
FLUSH_DISKPATH | Flushes the adapter value in
every perfstat_diskpath_t structure. |
Flushes the adapter value in
the specified perfstat_diskpath_t structure. |
FLUSH_PAGINGSPACE | Flushes the list of paging spaces. Flushes the automatic , type , lpsize , mbsize , hostname , filename ,
and vgname values in every perfstat_pagingspace_t structure. |
Flushes the list of paging spaces. Flushes the automatic , type , lpsize , mbsize , hostname , filename ,
and vgname values in the specified perfstat_pagingspace_t structure. |
FLUSH_NETINTERFACE | Flushes the description value
in every perfstat_netinterface_t structure. |
Flushes the description value
in the specified perfstat_netinterface_t structure. |
FLUSH_LOGICALVOLUME | Flushes the description value
in every perfstat_logicalvolume_t structure. |
Flushes the description value
in every perfstat_logicalvolume_t structure. |
FLUSH_VOLUMEGROUP | Flushes the description value
in every perfstat_volumegroup_t structure. |
Flushes the description value
in every perfstat_volumegroup_t structure. |
You can see how to use the perfstat_partial_reset interface
in the following example code:
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(int argc, char *argv[]) {
int i, retcode;
perfstat_id_t diskname;
perfstat_disk_t *statp;
/* set name of the disk */
strcpy(diskname.name, "hdisk0");
/* we will now reset global system min/max metrics
* Be careful as this could interact with other programs.
*/
perfstat_partial_reset(NULL, RESET_DISK_MINMAX);
/* min/max values are now reset.
* We can now wait for some time before checking the variation range.
*/
sleep(10);
retcode = perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0);
statp = calloc (retcode,sizeof(perfstat_disk_t));
/* get disk metrics - min/max counters illustrate variations during the
* last 60 seconds unless someone else reset these
* values in the meantime.
*/
retcode = perfstat_disk(&diskname, statp, sizeof(perfstat_disk_t), 1);
/* At this point, we assume the disk free part changes due to chfs for example */
/* if we get disk metrics here, the free field will be wrong as it was
* cached by the libperfstat.
*/
/* That is why we reset cached metrics */
perfstat_partial_reset("hdisk0", FLUSH_DISK);
/* we can now get updated disk metrics */
retcode = perfstat_disk(&diskname, statp, sizeof(perfstat_disk_t), 1);
for(i=0;i<retcode;i++){
printf("Name of the disk=%s\n",statp[i].name);
printf("Disk description=%s\n",statp[i].description);
printf("Volume group name=%s\n",statp[i].vgname);
printf("Size of the disk=%lld\n",statp[i].size);
printf("Free portion of the disk=%lld\n",statp[i].free);
printf("Disk block size=%lld\n",statp[i].bsize);
}
}
The program displays an output that is similar to the
following example output:Name of the disk=hdisk0
Disk description=Virtual SCSI Disk Drive
Volume group name=rootvg
Size of the disk=25568
Free portion of the disk=18752
Disk block size=512