Previous page

Next page

Locate page in Contents

Print this page

Receiving Periodic Reports

In this section, we will use Performance Monitor to receive the reports on a periodic basis. This functionality is provided by the perf_mon/start_monitor call. The following sample shows how to start monitoring of the CPU consumption by the specified server:

<packet version="4.0.0" id="2">

  <target>perf_mon</target>

  <data>

    <perf_mon>

      <start_monitor>

        <eid_list>

          <eid>39f40723-b3f5-8c41-8de9-7beefd5021fe</eid>

        </eid_list>

        <class>

          <name>counters_vz_cpu</name>

          <instance>

            <counter>counter_cpu_system</counter>

          </instance>

        </class>

        <report_period>20</report_period>

      </start_monitor>

    </perf_mon>

  </data>

</packet>

The call above starts the monitor with the 20 second intervals, which means that the client will be receiving a report every 20 seconds. The eid parameter contains the Server ID of the Virtuozzo Container to monitor. We are using just one counter from the counters_vz_cpu class in our call. If you wish, you can use all counters from this class. Simply remove the instance element together with the counter element. You can also add other classes and their counters and even monitor multiple servers at the same time (more on that later).

The first response that we receive from Agent contains the monitor ID. We will need this ID to stop the monitor later.

<packet id="2" version="4.0.0">

<origin>perf_mon</origin>

  <data>

    <perf_mon>

      <id>491d81b1-1cae-43ec-8b7c-41d873d15991</id>

    </perf_mon>

  </data>

</packet>

After that, the collector starts sending us the reports. The following is an example of one of the reports:

<packet id="2" priority="0" version="4.0.0">

  <origin>perf_mon</origin>

  <data>

    <perf_mon>

      <data>

        <eid>4d4dcb0c-9c1e-4f7c-af81-e33db3289f61</eid>

        <class>counters_cpu</class>

        <interval>

          <start_time>2006-06-20T05:01:09+0000</start_time>

          <end_time>2006-06-20T05:01:30+0000</end_time>

        </interval>

        <instance>

          <name></name>

          <counter>

            <name>counter_cpu_system</name>

            <value>

              <avg>477</avg>

              <min>477</min>

              <max>477</max>

              <cur>2504250</cur>

            </value>

          </counter>

        </instance>

      </data>

    </perf_mon>

  </data>

</packet>

As you can see, the report contains the current, average, minimum, and maximum values. Since this is an incremental counter (see previous section), the current value is the total system CPU time (the time spent by the processor to execute operating system tasks), and the average, minimum, and maximum values all contain the difference (the increase) between the current value and the value from the last report.

Because you are receiving the reports from the monitor, doesn't mean that you cannot send other requests and receive other replies at the same time. You can do anything that you would normally do, like sending on-demand requests or even starting another monitor or monitors. To correlate request and response messages, use the ID attribute. All responses that belong to a particular request will have the same message ID as the message ID of the request.

To stop the monitor, send the following message, passing the monitor ID:

<packet version="4.0.0" id="2">

  <target>perf_mon</target>

  <data>

    <perf_mon>

      <stop_monitor>

        <id>491d81b1-1cae-43ec-8b7c-41d873d15991</id>

      </stop_monitor>

    </perf_mon>

  </data>

</packet>

Please send us your feedback on this help page