CPU and Memory metrics % not adding
CPU and Memory metrics % not adding
I tried two different CPU plugins. Notice how it is not showing anything in the percent column! The memory check is going same thing under metrics. All others are working fine.
You do not have the required permissions to view the files attached to this post.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Re: CPU and Memory metrics % not adding
What plugins are you using specifically? I would have to confirm with a developer, but I am pretty sure only a select group of plugins will be valid here since XI doesn't inherently know what a given service is monitoring.
Former Nagios employee
Re: CPU and Memory metrics % not adding
Trevor, can you just tell me which CPU and memory plugin is specifically supported out of the box so I can just use them. This is for a new install for another company so don't want to have to keep doing my own custom metric changes every updatetmcdonald wrote:What plugins are you using specifically? I would have to confirm with a developer, but I am pretty sure only a select group of plugins will be valid here since XI doesn't inherently know what a given service is monitoring.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Re: CPU and Memory metrics % not adding
Going out on a limb here and assuming you mean the changes to function service_matches_metric() inside of /usr/local/nagiosxi/html/includes/utils-metrics.inc.php? If so, unfortunately that is what needs to be done to match a custom/non-standard plugin.BanditBBS wrote:my own custom metric changes every update :)
Explanation: Within the above-mentioned file and function is a large switch statement used to determine if the output of a given check belongs to load, disk, cpu, swap, or memory, or if the perfdata or command matches ($servicename is not actually used):
Code: Select all
function service_matches_metric($metric, $hostname, $servicename, $output, $perfdata, $command)
{
$count = 0;
switch ($metric) {
case "load":
if (preg_match("/^load1=/", $perfdata) > 0) //NRPE
return true;
if (preg_match("/check_xi_service_snmp/", $command) > 0) {//SNMP
//display by matching the load OID
if (preg_match("/.1.3.6.1.4.1.2021.10.1.3.1/", $command) > 0)
return true;
}
break;
case "disk":
if (preg_match("/[A-Z]:\\\\ Used Space/", $perfdata) > 0) // NSClient++
return true;
if (preg_match("/[A-Z]: Space/", $perfdata) > 0) // WMI
return true;
if (preg_match("/[0-9]*% inode=[0-9]*%/", $output) > 0) // Linux
return true;
if (preg_match("/disk\/logical\/.*\/used_percent/", $command) > 0) // NCPA
return true;
if (preg_match("/check_xi_service_snmp_\w+_storage/", $command) > 0) // SNMP
return true;
/*
DISK OK - free space: / 1462 MB (22% inode=92%):
/=5005MB;5455;6137;0;6819
*/
break;
case "cpu":
if (preg_match("/check_xi_service_nsclient/", $command) > 0) { //NSclient
if (preg_match("/CPULOAD/", $command) > 0) {
return true;
}
} else if (preg_match("/check_nrpe/", $command) > 0) { //NRPE
if (preg_match("/check_cpu_stats/", $command) > 0) {
return true;
}
} else if (preg_match("/check_xi_ncpa_agent/", $command) > 0) { //NCPA
if (preg_match("/cpu\/percent/", $command) > 0) {
return true;
}
} else if (preg_match("/check_xi_service_wmiplus/", $command) > 0) { //WMI
if (preg_match("/checkcpu/", $command) > 0) {
return true;
}
} else if (preg_match("/check_xi_service_snmp_\w+_load/", $command) > 0) { //SNMP
return true;
}
break;
case "swap":
if (preg_match("/^swap=/", $perfdata) > 0 || preg_match("/Swap_space/", $perfdata) > 0) // Linux
return true;
if (preg_match("/check_xi_ncpa_agent/", $command) > 0) {// Linux
if (preg_match("/memory\/swap\/percent/", $command) > 0) {
return true;
}
}
break;
case "memory":
if (preg_match("/check_xi_service_nsclient/", $command) > 0) { //NSclient
if (preg_match("/MEMUSE/", $command) > 0) {
return true;
}
} else if (preg_match("/check_nrpe/", $command) > 0) { //NRPE
if (preg_match("/check_mem/", $command) > 0) {
return true;
}
} else if (preg_match("/check_xi_ncpa_agent/", $command) > 0) { //NCPA
if (preg_match("/memory\/virtual\/percent/", $command) > 0) {
return true;
}
} else if (preg_match("/check_xi_service_wmiplus/", $command) > 0) { //WMI
if (preg_match("/checkmem/", $command) > 0) {
return true;
}
} else if (preg_match("/check_xi_service_snmp_\w+_storage/", $command) > 0) { //SNMP
if (preg_match("/Physical\sMemory/", $command) > 0 || preg_match("/Memory/", $command) > 0 || preg_match("/Physical_memory/", $perfdata) > 0) {
return true;
}
}
//echo "NO MATCH: $perfdata<BR>";
break;
default:
break;
}
return false;
}
Former Nagios employee
Re: CPU and Memory metrics % not adding
I said screw it and used my mods:
Code: Select all
Adjustments to Metrics component
To display CPU and Memory metrics for perfdata that looks like this:
CpuUser=15.81%;90;95;0; CpuSystem=1.40%;90;95;0; CpuIowait=0.00%;90;95;0; CpuIdle=82.79%;0;0;0; CpuNice=0.00%;0;0;0; CpuSteal=0.00%;0;0;0;
TOTAL=16336836KB;;;; USED=830808KB;13069468;14703152;; FREE=15506028KB;;;; CACHES=5699240KB;;;;
In /usr/local/nagiosxi/html/includes/utils-metrics.inc.php - add/modify this code:(lines numbers may not be exactly the same for you)
Remove lines 515 - 536
Then remove lines 518 - 532
Then add these starting at 518:
//inserted by Bandit
$perfpartsa = explode("=", $perfdata);
$perfpartsb = explode(";", $perfpartsa[1]);
$perfpartsc = explode(";", $perfpartsa[2]);
$perfpartsd = explode(";", $perfpartsa[3]);
$cpuuser = floatval(grab_array_var($perfpartsb, 0, 0));
$cpusystem = floatval(grab_array_var($perfpartsc, 0, 0));
$cpuiowait = floatval(grab_array_var($perfpartsd, 0, 0));
$warn = floatval(grab_array_var($perfpartsb, 1, 0));
$crit = floatval(grab_array_var($perfpartsb, 2, 0));
$usage = number_format(($cpuuser + $cpusystem + $cpuiowait), 1);
//end insert
For memory I then do this:
remove lines 541 to 556
Then add at 541:
$perfpartsa = explode("=", $perfdata);
$perfpartsb = explode(";", $perfpartsa[1]);
$perfpartsc = explode(";", $perfpartsa[2]);
$perfpartsd = explode(";", $perfpartsa[3]);
$current = floatval(grab_array_var($perfpartsc, 0, 0));
$uom = "";
$warn = floatval(grab_array_var($perfpartsc, 1, 0));
$crit = floatval(grab_array_var($perfpartsc, 2, 0));
$min = floatval(grab_array_var($perfpartsb, 3, 0));
$max = floatval(grab_array_var($perfpartsb, 0, 0));
$usage = number_format(100-(($max - $current) / $max * 100), 1);2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Re: CPU and Memory metrics % not adding
Yea, for the time-being that is the way it needs to be done. I had made some suggestions to the devs but it will take a while to change the internals.
Mind if we close this up?
Mind if we close this up?
Former Nagios employee
Re: CPU and Memory metrics % not adding
Lock her up man!
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github