Closed squidsoup closed 9 years ago
I've got the same issue. The refresh seems to work just fine if any alerts come and go, but I've disabled the refresh spinner as that seems to come up and never disappear.
PHP Version: PHP 5.4.16 (cli) (built: Aug 6 2014 13:12:28) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
My machine is running CentOS 7.
Thanks Sam
These seem to be two problems. I think we have to use $api_columns
instead of raw state
to fix the first one. @squidsoup can you confirm when you curl nagios-api that hosts come back with a current_state
attribute?
The second one seems to be because we don't fill out the curl stats for the nagios-api implementation. I opened https://github.com/lozzd/Nagdash/issues/29 to fix it.
Hi mrtazz, thanks for looking into it.
I'm definitely seeing current_state
from nagios-api:
"myhost": {
"active_checks_enabled": "1",
"comments": {},
"current_attempt": "1",
"current_state": "0",
"downtimes": {},
"last_check": "1407877916",
"last_hard_state": "0",
"last_notification": "0",
"last_state_change": "1407218857",
"max_attempts": "10",
"notifications_enabled": "1",
"performance_data": {
"pl": "0%",
"rta": "0.260000ms"
}, ... etc
If you have a minute, could you test if the current master HEAD fixes this for you?
Well, appears to have changed the error, so progress? :smile:
Undefined offset: 1 in /stor/srv/www/nagdash/phplib/utils.php on line 267
Undefined variable: prospect in /stor/srv/www/nagdash/phplib/timeago.php on line 40
Undefined index: objects in /stor/srv/www/nagdash/htdocs/nagdash.php on line 176
urgh ok, I'll try to test this against a nagios-api instance and see what's up there.
I've been playing around with this today and hit the same errors reported by @squidsoup and added some workarounds to see if they were causing the problem:
Undefined offset: 1 in /stor/srv/www/nagdash/phplib/utils.php on line 267
Wrapped line 267 in an if (isset(...)) same was required for https://github.com/lozzd/Nagdash/blob/master/phplib/utils.php#L221 to eliminate the errors.
Undefined variable: prospect in /stor/srv/www/nagdash/phplib/timeago.php on line 40
This appears to be logic fail in resulting in $prospect never being set. I just forced it to " ago" for testing.
Undefined index: objects in /stor/srv/www/nagdash/htdocs/nagdash.php on line 176
I just removed the nagios stats for now.
After all that refresh still wasn't working. In fact looking at the js console it was never firing. So I called load_nagios_data(false);
from the js console and it started working and updating as expected.
Disabling the spinner in config causes it to work fine as well as. This looks like it might be a .js logic issue.
Right after more digging I believe I've found the issue in nagdash.js:
Here is the load_nagios_data function:
function load_nagios_data(show_spinner) {
$("#nagioscontainer").load("nagdash.php", function() { $("#spinner").fadeOut("fast"); });
var refreshId = setInterval(function() {
if (show_spinner) {
$("#spinner").fadeIn("fast");
} else {
$("#nagioscontainer").load("nagdash.php", function() { $("#spinner").fadeOut("fast"); });
}
}, 20000);
$.ajaxSetup({ cache: false });
}
When the page loads load_nagios_data(true)
is called which updates the screen then sets up the interval timer to run every 20 seconds to run this block of code:
if (show_spinner) {
$("#spinner").fadeIn("fast");
} else {
$("#nagioscontainer").load("nagdash.php", function() { $("#spinner").fadeOut("fast"); });
}
Clearly if $show_spinner == true
all it's every going to do is display the spinner and not actually make the call to nadash.php
The easy fix is this:
if (show_spinner) {
$("#spinner").fadeIn("fast");
$("#nagioscontainer").load("nagdash.php", function() { $("#spinner").fadeOut("fast"); });
} else {
$("#nagioscontainer").load("nagdash.php", function() { $("#spinner").fadeOut("fast"); });
}
but I think it needs a quick refactor - If i get chance later tonight I'll have a go.
Refactor wasn't necessary - just remove the else condition.
Here is my fix: https://github.com/lozzd/Nagdash/pull/36
The JS side fix is merged into master. Please let me know if your problems still occur.
closing this, if the problem persists please reopen.
Receiving the following errors with php 5.5.14-1, curl, enable_short_tags and nagios-api 1.2.2:
Service status is rendering correctly, but doesn't refresh.
I have
$api_type = "nagios-api";
defined in config.php.Thanks.