Page 1 of 1

Latest metrics component

Posted: Wed Oct 21, 2015 3:32 pm
by BanditBBS
Ok, so after every upgrade I used to heavily modify the /usr/local/nagiosxi/html/includes/utils-metrics.inc.php file to make it work like I needed. Basically I removed the details column and also made it work with my perfdata and settings. I of course no longer need to remove the details column(THANK YOU!) but the metrics still aren't working with my perfdata for either CPU or MEMORY, the two I need :(

Lets talk about CPU(for linux, using NRPE and the check_cpu_stats.sh plugin with the nrpe command of check_cpu):
I see it is checking the command for check_nrpe, which we are using that plugin and then further looking in that for check_cpu_stats. I changed all instances of check_cpu_stats to just check_cpu but no luck, nothing shows up when I run metrics for a hostgroup that contains about 8 servers that have a CPU service defined using the command I described above.

Any idea what else I am missing?

Re: Latest metrics component

Posted: Wed Oct 21, 2015 5:02 pm
by lmiltchev
The CPU checks are showing up for me.
example01.PNG
Maybe some of the files didn't get updated for you. Backup your XI server (snapshot it, etc.), remove the "Metrics" component then force upgrade:

Code: Select all

cd /tmp/nagiosxi
./upgrade -f
The "-f" flag should force the update of all components, wizards, dashlets, etc. Let me know if this helped.

Re: Latest metrics component

Posted: Wed Oct 21, 2015 5:59 pm
by BanditBBS
Ludmil, yeah, but your setup is probably exactly what its looking for, hence why I have to remove the _stats part as I said in opening post. Also though, look at your image, the bottom one(nrpe, which I want to use) is wrong. The percent used is 0 but if you add up the user and system it should be showing 5.56%, so there has to be an issue with it there anyway.

Also, I can verify all the files are fresh and the proper version.

Re: Latest metrics component

Posted: Thu Oct 22, 2015 8:59 am
by lmiltchev
Hm-m-m, you have a point. I will do some more digging into this and ask Luke to check this out. He was working on the Metrics component and will be able to find a solution.

Re: Latest metrics component

Posted: Thu Oct 22, 2015 9:51 am
by lmiltchev
I changed all instances of check_cpu_stats to just check_cpu but no luck, nothing shows up when I run metrics for a hostgroup that contains about 8 servers that have a CPU service defined using the command I described above.
BanditBBS, can you show us the actual config (with the mods you made)?

Re: Latest metrics component

Posted: Thu Oct 22, 2015 10:08 am
by BanditBBS
lmiltchev wrote:
I changed all instances of check_cpu_stats to just check_cpu but no luck, nothing shows up when I run metrics for a hostgroup that contains about 8 servers that have a CPU service defined using the command I described above.
BanditBBS, can you show us the actual config (with the mods you made)?
Hey, I fixed CPU for me. Here are the code changes I just made to make the metrics component work for me for CPU(working on memory now):

Code: Select all

189                 if (preg_match("/check_cpu_stats/", $command) > 0) {
to 
189                 if (preg_match("/check_cpu/", $command) > 0) {

318             } else if (preg_match("/check_cpu_stats/", $command) > 0) { // NRPE
to
318             } else if (preg_match("/check_cpu/", $command) > 0) { // NRPE

539     if (preg_match("/check_cpu_stats/", $command) > 0) {
to 
539     if (preg_match("/check_cpu/", $command) > 0) {
I then remove lines 516 - 536
I then remove lines 520 - 535

I then add these:

Code: Select all

520 //inserted by Bandit
521         $perfpartsa = explode("=", $perfdata);
522         $perfpartsb = explode(";", $perfpartsa[1]);
523         $perfpartsc = explode(";", $perfpartsa[2]);
524         $perfpartsd = explode(";", $perfpartsa[3]);
525         $cpuuser = floatval(grab_array_var($perfpartsb, 0, 0));
526         $cpusystem = floatval(grab_array_var($perfpartsc, 0, 0));
527         $cpuiowait = floatval(grab_array_var($perfpartsd, 0, 0));
528         $warn = floatval(grab_array_var($perfpartsb, 1, 0));
529         $crit = floatval(grab_array_var($perfpartsb, 2, 0));
530         $usage = number_format(($cpuuser + $cpusystem + $cpuiowait), 1);
531 //end insert
I realize this might just be for me, but many others may be using the same plugins I do and may not add the word "stats" to their nrpe command name. Working on memory fixes now :)

edit:

For memory I then do this:
remove lines 541 to 556
Then add:

Code: Select all

541         $perfpartsa = explode("=", $perfdata);
542         $perfpartsb = explode(";", $perfpartsa[1]);
543         $perfpartsc = explode(";", $perfpartsa[2]);
544         $perfpartsd = explode(";", $perfpartsa[3]);
545
546         $current = floatval(grab_array_var($perfpartsc, 0, 0));
547         $uom = "";
548         $warn = floatval(grab_array_var($perfpartsc, 1, 0));
549         $crit = floatval(grab_array_var($perfpartsc, 2, 0));
550         $min = floatval(grab_array_var($perfpartsb, 3, 0));
551         $max = floatval(grab_array_var($perfpartsb, 0, 0));
552         $usage = number_format(100-(($max - $current) / $max * 100), 1);

Re: Latest metrics component

Posted: Thu Oct 22, 2015 11:58 am
by lmiltchev
I posted an internal bug report about the "0% Utilization" issue in the Metrics component (TASK ID 6717).
I realize this might just be for me, but many others may be using the same plugins I do and may not add the word "stats" to their nrpe command name.
It is difficult to include all of the custom plugins and make them work with the Metrics component. We wouldn't even know how they handle perfdata and how to parse the output. However, we are planning on adding a section where you could input a custom command. I don't have an ETA on this - just wanted to give you heads up. Any other mods would be a "custom development".