Holy *Beep*!
I somehow hacked at it enough to get what I want for now!
- To remove the "details" column in metrics(optional):
In /usr/local/nagiosxi/html/includes/components/metrics/metrics.inc.php
Change
Code: Select all
<tr><th>'.gettext('Host').' </th><th>'.gettext('Service').' </th><th><div style="width: 160px; height: 1px;">'.get_metric_value_description($ metric).'</div> </th><th>'.gettext('Details').' </th></tr>
to
Code: Select all
<tr><th>'.gettext('Host').' </th><th>'.gettext('Service').' </th><th><div style="width: 160px; height: 1px;">'.get_metric_value_descrip tion($metric).'</div> </th></tr>
remark out lines
Code: Select all
$output.='<td>';
$output.=$arr["output"];
$output.='</td>';
- To display CPU and Memory metrics for perfdata that looks like this:
Code: Select all
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)
Code: Select all
179 case "cpu-ld":
180 if (preg_match("/Idle/", $perfdata) > 0) // Linux
181 return true;
182 break;
183 case "memory-tuf":
184 if (preg_match("/USED/", $perfdata) > 0) // Linux
185 return true;
186 break;
Code: Select all
260 case "cpu-ld":
261 if (preg_match("/Idle/", $perfdata) > 0) { // NSClient++;
262 metrics_split_perfdata($perfdata, $current, $uom, $warn, $crit, $min, $max, $sortval, $displayval, "%", $metric);
263 return true;
264 }
265 break;
266 case "memory-tuf":
267 if (preg_match("/USED/", $perfdata) > 0) { // NSClient++;
268 metrics_split_perfdata($perfdata, $current, $uom, $warn, $crit, $min, $max, $sortval, $displayval, "%", $metric);
269 return true;
270 }
271 break;
Code: Select all
309 $perfpartsc = explode(";", $perfpartsa[2]);
310 $perfpartsd = explode(";", $perfpartsa[3]);
Code: Select all
331 case "cpu-ld":
332 $cpuuser = floatval(grab_array_var($perfpartsb, 0, 0));
333 $cpusystem = floatval(grab_array_var($perfpartsc, 0, 0));
334 $cpuiowait = floatval(grab_array_var($perfpartsd, 0, 0));
335 $warn = floatval(grab_array_var($perfpartsb, 1, 0));
336 $crit = floatval(grab_array_var($perfpartsb, 2, 0));
337 $usage = number_format(($cpuuser + $cpusystem + $cpuiowait), 1);
338 break;
339 case "memory-tuf":
340 $current = floatval(grab_array_var($perfpartsc, 0, 0));
341 $uom = "";
342 $warn = floatval(grab_array_var($perfpartsc, 1, 0));
343 $crit = floatval(grab_array_var($perfpartsc, 2, 0));
344 $min = floatval(grab_array_var($perfpartsb, 3, 0));
345 $max = floatval(grab_array_var($perfpartsb, 0, 0));
346 $usage = number_format(100-(($max - $current) / $max * 100), 1);
347 break;
Code: Select all
396 $metrics = array(
397 "disk" => "Disk Usage",
398 "cpu" => "CPU Usage",
399 "cpu-ld" => "CPU Usage - Linux Detail",
400 "memory" => "Memory Usage",
401 "memory-tuf" => "Memory Usage - T/U/F",
402 "load" => "Load",
403 "swap" => "Swap",
404 );
405
406 return $metrics;
407 }
408
409 /**
410 * @param $name
411 *
412 * @return string
413 */
414 function get_metric_value_description($name)
415 {
416
417 $metrics = array(
418 "disk" => "% Utilization",
419 "cpu" => "% Utilization",
420 "cpu-ld" => "% Utilization",
421 "memory" => "% Utilization",
422 "memory-tuf" => "% Utilization",
423 "load" => "Load",
424 "swap" => "Swap Utilization",
425 );