Metrics unusable

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

Metrics unusable

Post by BanditBBS »

I just put in a feature request for this, but I sort of need this fixed asap, so is there any code I can change myself to make the metrics not auto run when I go to the link? It is basically crashing because it has to go through so much data and I can't get the reports from there that I need to get. :x

Or is this source guardian protected?
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 unusable

Post by tmcdonald »

Not SG-protected. I'm taking a look in /usr/local/nagiosxi/html/includes/components/metrics right now. Looks like it is all handled in the index.php page. The whole page is rendered in a single PHP function it looks like (display_metrics). It's probably as easy as adding a button that re-visits the page with a certain GET variable applied, then it only runs the metrics with that variable defined.

Just got in so I have some things to take care of (tickets, emails, coffee) but that's a good place to get started.
Former Nagios employee
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Metrics unusable

Post by BanditBBS »

I just figured out the issue that's killing it. Even though its limited to top 50 it is still graphing and gauging ALL thousands of disk checks. Why aren't those tabs limited like the summary tab.
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 unusable

Post by tmcdonald »

This worked for me:

Code: Select all

<?php if(!isset($_GET['goButton'])) {exit;} ?>
Put that in the file I mentioned above, line 163 on my system (just below the section where they end the <form> tag). That will make it so nothing is really run until you hit the Update button. You will just see the Hostgroup/Servicegroup and Metrics down-downs until you hit Update for the first time.

Not too sure about the other tabs, will have to look further into that.
Former Nagios employee
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Metrics unusable

Post by BanditBBS »

yeah, that will help once the tab issue is resolved. It crashed my httpd when trying to run it :(
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 unusable

Post by tmcdonald »

Not gonna bother with a patch since I probably messed up the spacing, but you wanna look for the following in that same metrics.inc.php file:

Code: Select all

<div id="tab-graphs">
and

Code: Select all

<div id="tab-gauges">
They will have a foreach loop which should look like:

Code: Select all

<?php
  foreach($metricdata as $id => $arr){

    $hostname=$arr["host_name"];
    $servicename=$arr["service_name"];
and that will need to be changed to:

Code: Select all

<?php
  $current_items = 0;
  foreach($metricdata as $id => $arr){
    $current_item++;
    if($current_item>$_GET['maxitems'])
      break;

    $hostname=$arr["host_name"];
    $servicename=$arr["service_name"];
for both tab-gauges and tab-graphs sections.

Not sure why they don't respect the limit, but I just stole some code from the Summary section and applied it here. Bear in mind this does not do a lot of sanity checking, but it does still respect a limit of 0, so I figure it should be alright.

EDIT: Link back to tracker post for reference - http://tracker.nagios.com/view.php?id=515
Former Nagios employee
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Metrics unusable

Post by BanditBBS »

tmcdonald wrote:Not gonna bother with a patch since I probably messed up the spacing, but you wanna look for the following in that same metrics.inc.php file:
Umm, you mean same index.php

Also, this has made it usable now, but the gauges tab shows nothing after applying the fix. The graphs tab works great.

EDIT: I removed the 'fix' from the gauges tab and all gauges are shown but it no longer crashes me. So it was definitely the graphs tab doing it. I can live with this for now, but still would like these changes commited and also the gauges tab adhere to limit
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 unusable

Post by tmcdonald »

BanditBBS wrote:Umm, you mean same index.php
Yea, I meant index.php
BanditBBS wrote:Also, this has made it usable now, but the gauges tab shows nothing after applying the fix. The graphs tab works great.
I would check for typos. Specifically in my code >_>

I wrote "current_items" when they should all be "current_item". This is what it should be:

Code: Select all

    <?php
      $current_item = 0;
      foreach($metricdata as $id => $arr){
        $current_item++;
        if($current_item>$_GET['maxitems'])
          break;

        $hostname=$arr["host_name"];
        $servicename=$arr["service_name"];

Odd that the graphs tab would work though and the gauges tab would not...
Former Nagios employee
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Metrics unusable

Post by BanditBBS »

Who is the biggest idiot, you for the typo or me for blindly listening to you? :lol:

The graphs tab worked because the variable with an s would have been 0 starting out but would have been > the limit when it hit the gauge tab.

Please commit these changes :)

Lock this up!

EDIT: I thought about it, I'm the bigger one, LOL.
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
Locked