How can I see how much CPU Pro is saving me?

This page assumes that you have Pro installed and functioning correctly.

At a high level, what we are going to run through to get this information is:

  • Turn on usage stats
  • Collect usage stats whilst Pro’s CPU saving options are enabled
  • Collect usage stats whilst Pro’s CPU saving options are disabled
  • Compare the stats

Turn on Usage Stats

In the Check WMI Plus Conf file make sure
$collect_usage_info=1;
is set

Now, when Check WMI Plus runs it will log usage stats into the directory specified by the Conf file setting:
$wmi_data_dir (by default the data directory is is the same directory as the plugin)
into a file called
$usage_db_file (this is setting in the Conf file)

Check to see that the file exists and is growing as Check WMI Plus runs.

Enable Pro CPU Saving Options

In the Conf file ensure the following settings are set:
$force_wmic_command=0;
$use_compiled_ini_files=1;

Start Collecting Stats

We want to collect usage stats to a nice clean usage file. To do this switch to a new usage file.
check_wmi_plus.pl --logswitch --logsuffix proenabled
(or check_wmi_plus.pl --logswitch --logsuffix prodisabled if you are performing that test)

The output will tell you the name of the new usage file being used. Remember the name of this file because we will want it later.
Now leave it to collect usage stats. Ideally, you want to collect usages stats from at least 2 complete cycles of all your Check WMI Plus checks. For example, if you have it scheduled across a range of servers every 5 minutes, leave it for at least 10 minutes. The longer you leave this, the more stats you collect, the more accurate your comparison result will be.

Stop Collecting Stats

When you have waited long enough, we want to close off the usage stats file. To do this switch to a new usage file.
check_wmi_plus.pl --logswitch
The output will tell you the name of the new usage file being used. We don’t care about the new file. We care about the usage file you remembered the name of when you first switched to it.

Disable Pro CPU Saving Options

In the Conf file ensure the following settings are set:
$force_wmic_command=1;
$use_compiled_ini_files=0;

Now go back and repeat the starting and stopping of stats collection. This will give you another usage stats file ending with a prodisabled suffix.

Now you can Re-enable the Pro CPU saving options and optionally undo the changes you made to enable the usage stats

Compare the Stats

Now you have 2 usagedb files, one with a suffix proenabled and one with a suffix prodisabled. Run a simple SQL query on each of the files and compare the results.
sqlite3 -header -column
/opt/nagios/bin/plugins/check_wmi_plus.data/check_wmi_plus.usagedb.proenabled
"select count(*) as 'Checks',round(sum(elapsedtime)/count(*),3) as
'Avg Elapsed (sec)',round(sum(totalcpu)/count(*),3) as 'AvgCPU
(sec)',round(julianday(max(timestamp))-julianday(min(timestamp)),4) as
'Days',sum(iniused) as 'Ini Checks' from usage"

And run it again using the .prodisabled file.

From the proenabled stats you should see an output similar to the following:

Checks      Avg Elapsed (sec)  AvgCPU (sec)  Days        Ini Checks
----------  -----------------  ------------  ----------  ----------
123         1.804              0.059         0.0017      52         

and from the prodisabled stats you should see an output similar to the following:

Checks      Avg Elapsed (sec)  AvgCPU (sec)  Days        Ini Checks
----------  -----------------  ------------  ----------  ----------
135         5.782              0.207         0.0004      60        

You should be able to clearly see an increase in the AvgCPU figure (the average amount of CPU consumed per check) and probably also the Avg Elapsed figures.