{"id":151,"date":"2019-05-29T06:51:03","date_gmt":"2019-05-29T06:51:03","guid":{"rendered":"http:\/\/edcint.co.nz\/checkwmiplus\/?post_type=faq&#038;p=151"},"modified":"2019-05-30T00:53:11","modified_gmt":"2019-05-30T00:53:11","slug":"how-can-i-see-how-much-cpu-pro-is-saving-me","status":"publish","type":"faq","link":"https:\/\/edcint.co.nz\/checkwmiplus\/faq\/how-can-i-see-how-much-cpu-pro-is-saving-me\/","title":{"rendered":"How can I see how much CPU Pro is saving me?"},"content":{"rendered":"<div class=\"field field-name-body field-type-text-with-summary field-label-hidden view-mode-full\">\n<div class=\"field-items\">\n<div class=\"field-item even\">\n<p>This page assumes that you have Pro installed and functioning correctly.<\/p>\n<p>At a high level, what we are going to run through to get this information is:<\/p>\n<ul>\n<li>Turn on usage stats<\/li>\n<li>Collect usage stats whilst Pro&#8217;s CPU saving options are enabled<\/li>\n<li>Collect usage stats whilst Pro&#8217;s CPU saving options are disabled<\/li>\n<li>Compare the stats<\/li>\n<\/ul>\n<p><a id=\"enableusagestats\" name=\"enableusagestats\"><\/a><\/p>\n<h3>Turn on Usage Stats<\/h3>\n<p>In the Check WMI Plus Conf file make sure<br \/>\n<code>$collect_usage_info=1;<\/code><br \/>\nis set<\/p>\n<p>Now, when Check WMI Plus runs it will log usage stats into the directory specified by the Conf file setting:<br \/>\n<code>$wmi_data_dir<\/code> (by default the data directory is is the same directory as the plugin)<br \/>\ninto a file called<br \/>\n<code>$usage_db_file<\/code> (this is setting in the Conf file)<\/p>\n<p>Check to see that the file exists and is growing as Check WMI Plus runs.<\/p>\n<h3 id=enablepro>Enable Pro CPU Saving Options<\/h3>\n<p>In the Conf file ensure the following settings are set:<br \/>\n<code>$force_wmic_command=0;<\/code><br \/>\n<code>$use_compiled_ini_files=1; <\/code><\/p>\n<p><a id=\"start\" name=\"start\"><\/a><\/p>\n<h3>Start Collecting Stats<\/h3>\n<p>We want to collect usage stats to a nice clean usage file. To do this switch to a new usage file.<br \/>\n<code>check_wmi_plus.pl --logswitch --logsuffix proenabled<\/code><br \/>\n(or <code>check_wmi_plus.pl --logswitch --logsuffix prodisabled<\/code> if you are performing that test)<\/p>\n<p>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.<br \/>\nNow 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.<\/p>\n<p><a id=\"stop\" name=\"stop\"><\/a><\/p>\n<h3>Stop Collecting Stats<\/h3>\n<p>When you have waited long enough, we want to close off the usage stats file. To do this switch to a new usage file.<br \/>\n<code>check_wmi_plus.pl --logswitch<\/code><br \/>\nThe output will tell you the name of the new usage file being used. We don&#8217;t care about the new file. We care about the usage file you remembered the name of when you first switched to it.<\/p>\n<h3>Disable Pro CPU Saving Options<\/h3>\n<p>In the Conf file ensure the following settings are set:<br \/>\n<code>$force_wmic_command=1;<\/code><br \/>\n<code>$use_compiled_ini_files=0; <\/code><\/p>\n<p>Now go back and repeat the <a href=\"#start\">starting<\/a> and <a href=\"#stop\">stopping<\/a> of stats collection. This will give you another usage stats file ending with a prodisabled suffix.<\/p>\n<p>Now you can <a href=\"#enablepro\">Re-enable the Pro CPU saving options<\/a> and optionally undo the changes you made to <a href=\"#enableusagestats\">enable the usage stats<\/a><\/p>\n<h3>Compare the Stats<\/h3>\n<p>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.<br \/>\n<code>sqlite3 -header -column<br \/>\n\/opt\/nagios\/bin\/plugins\/check_wmi_plus.data\/check_wmi_plus.usagedb.proenabled<br \/>\n\"select count(*) as 'Checks',round(sum(elapsedtime)\/count(*),3) as<br \/>\n'Avg Elapsed (sec)',round(sum(totalcpu)\/count(*),3) as 'AvgCPU<br \/>\n(sec)',round(julianday(max(timestamp))-julianday(min(timestamp)),4) as<br \/>\n'Days',sum(iniused) as 'Ini Checks' from usage\"<\/code><br \/>\nAnd run it again using the .prodisabled file.<\/p>\n<p>From the proenabled stats you should see an output similar to the following:<\/p>\n<pre>Checks      Avg Elapsed (sec)  AvgCPU (sec)  Days        Ini Checks\r\n----------  -----------------  ------------  ----------  ----------\r\n123         1.804              0.059         0.0017      52         \r\n<\/pre>\n<p>and from the prodisabled stats you should see an output similar to the following:<\/p>\n<pre>Checks      Avg Elapsed (sec)  AvgCPU (sec)  Days        Ini Checks\r\n----------  -----------------  ------------  ----------  ----------\r\n135         5.782              0.207         0.0004      60        \r\n<\/pre>\n<p>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.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"template":"","faq_groups":[9],"class_list":["post-151","faq","type-faq","status-publish","hentry","faq-group-pro"],"_links":{"self":[{"href":"https:\/\/edcint.co.nz\/checkwmiplus\/wp-json\/wp\/v2\/faqs\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/edcint.co.nz\/checkwmiplus\/wp-json\/wp\/v2\/faqs"}],"about":[{"href":"https:\/\/edcint.co.nz\/checkwmiplus\/wp-json\/wp\/v2\/types\/faq"}],"author":[{"embeddable":true,"href":"https:\/\/edcint.co.nz\/checkwmiplus\/wp-json\/wp\/v2\/users\/1"}],"wp:attachment":[{"href":"https:\/\/edcint.co.nz\/checkwmiplus\/wp-json\/wp\/v2\/media?parent=151"}],"wp:term":[{"taxonomy":"faq-group","embeddable":true,"href":"https:\/\/edcint.co.nz\/checkwmiplus\/wp-json\/wp\/v2\/faq_groups?post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}