BanditBBS wrote:my own custom metric changes every update :)
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.
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;
}
This is kinda the only way we can address the infinite ways a given plugin could express its output in regards to determining what it is checking. So if you have a custom plugin, you would want to make sure its output fits the above conditions, either in perfdata, status output, or command.