Go to main content

Resource Management and Oracle® Solaris Zones Developer's Guide

Exit Print View

Updated: February 2021
 
 

API for Zones Monitoring Statistics

libzonestat.so.1 is a public API used by the zonestat command to retrieve and compute zone-related resource utilization information, with sorting and filtering options available. The zonestat library reports system wide and per-zone utilization of physical memory, virtual memory, and CPU resources. The zonestat command is documented in the zonestat(1) man page.

libzonestat computes commonly needed values, such as differences between two samples, and percentage used quantities. These statistics eliminate the need for consumers to do complex calculations. In addition to usage of physical resources, libzonestat also reports resource usage relative to each zone's configured resource limits.

The basic usage of libzonestat is as follows:

zs_ctl_t zsctl;
     zs_usage_t usage;

     /* open the statistics facility */
     zsctl = zs_open();

     for (;;) {
                   /* read the current usage */
              usage = zs_usage_read(ctl);

              ... Interrogate the usage object for desired information ...
              …

              if (quit)
                     break;
              sleep(some_interval);
     }
     zs_close(zsctl);