Page 1 of 1

Metrics unusable

Posted: Fri Mar 14, 2014 8:40 am
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?

Re: Metrics unusable

Posted: Fri Mar 14, 2014 9:10 am
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.

Re: Metrics unusable

Posted: Fri Mar 14, 2014 9:23 am
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.

Re: Metrics unusable

Posted: Fri Mar 14, 2014 10:18 am
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.

Re: Metrics unusable

Posted: Fri Mar 14, 2014 10:23 am
by BanditBBS
yeah, that will help once the tab issue is resolved. It crashed my httpd when trying to run it :(

Re: Metrics unusable

Posted: Fri Mar 14, 2014 11:04 am
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

Re: Metrics unusable

Posted: Fri Mar 14, 2014 11:18 am
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

Re: Metrics unusable

Posted: Fri Mar 14, 2014 11:28 am
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...

Re: Metrics unusable

Posted: Fri Mar 14, 2014 11:33 am
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.