Page 1 of 3

Metrics Component

Posted: Mon Oct 20, 2014 1:14 pm
by BanditBBS
Before I copy the metrics component and highly modify for my(and anyone else who wants it) use, is any work being done on it that I should wait on? I have to make it more useful and able to manage more perf data and also make a few adjustments to the metric gauge dashlet. I just don't want to double up work that Nagios could already be doing.

If not, then I'm diving head first into this.

Re: Metrics Component

Posted: Mon Oct 20, 2014 3:43 pm
by WillemDH
In this thread, it seems like some developer is working to improve the Metrics component: http://support.nagios.com/forum/viewtop ... t=+metrics I made feature request to improve it some time ago http://tracker.nagios.com/view.php?id=471 and there also should be an internal feature request (TASK ID 3372).

Grtz

Willem

Re: Metrics Component

Posted: Mon Oct 20, 2014 3:59 pm
by BanditBBS
Yeah, I need this like yesterday, so I think I am going to attempt tackling this myself.

Just so you know what I am doing:
  • Adding ability to work with other memory and CPU checks
  • Adding ability to remove the label on the dashlet from the gauges tab
Those are two of the biggest changes I need to do. If I can get this done, then there is just one more thing for me to do and I can forget about having to use nagvis!!!!

Re: Metrics Component

Posted: Mon Oct 20, 2014 5:10 pm
by abrist
BanditBBS wrote:Those are two of the biggest changes I need to do.
If you updated the component to deal with more real world output syntax and share it, you deserve a medal. There is indeed a few feature requests, but we have not moved on them. (though we are just a week or two away from possibly entering a maint window on our products - with the goal of cleaning up tracker!)

Re: Metrics Component

Posted: Mon Oct 20, 2014 5:14 pm
by slansing
It's on the "longer term" to-do list, so nobody has been actively working on it recently. However, we'd love to hear more of your ideas for it, and if you are struggling with a specific portion of what you want to add we can definitely help you out and work it into the current component!

Re: Metrics Component

Posted: Tue Oct 21, 2014 8:47 am
by BanditBBS
slansing wrote:It's on the "longer term" to-do list, so nobody has been actively working on it recently. However, we'd love to hear more of your ideas for it, and if you are struggling with a specific portion of what you want to add we can definitely help you out and work it into the current component!
I'm basically going to add a second memory and second CPU selection. That is what I am going to do immediately and will share the code changes with Nagios in case you want to incorporate into production.

UGH - Sure wish I understood php better...at least as well as I understand bash and perl. Not having fun with this. If anyone on the forums understands php very well and wants to spend a few minutes today helping me...let me know!

Re: Metrics Component

Posted: Tue Oct 21, 2014 11:12 am
by tmcdonald
I might be able to help out with this. What specifically did you mean by adding a second CPU and memory selection? Just the Metric dropdown having (for example) CPU Usage Long and Memory Usage Long? What would you want them to display that is different from the current CPU and memory displays?

Re: Metrics Component

Posted: Tue Oct 21, 2014 11:22 am
by BanditBBS
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     );

Re: Metrics Component

Posted: Tue Oct 21, 2014 11:52 am
by BanditBBS
This is what part of my customer's dashboard is looking like now with the changes...buh-bye nagvis! (well, once I get another dashlet working)
Capture.PNG

Re: Metrics Component

Posted: Tue Oct 21, 2014 12:14 pm
by snapon_admin
Ok, my interest has officially been piqued...