Metrics Component

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Metrics Component

Post 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.
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
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Metrics Component

Post 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
Nagios XI 5.8.1
https://outsideit.net
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Metrics Component

Post 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!!!!
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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Metrics Component

Post 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!)
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Metrics Component

Post 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!
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Metrics Component

Post 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!
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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Metrics Component

Post 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?
Former Nagios employee
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Metrics Component

Post 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     );
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
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Metrics Component

Post 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
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
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: Metrics Component

Post by snapon_admin »

Ok, my interest has officially been piqued...
Locked