Page 1 of 3

Not getting data in Nagios mobile

PostPosted: Fri Feb 21, 2014 5:39 pm
by balothia
Hi,

I just configured the nagiosmobile with NagiosXI but its doesnt seems to work. I am getting below error in apache error_log. I did looked into other posts similar to this but the nagios permissions and config looks correct.

[Fri Feb 21 16:20:37 2014] [error] [client 192.168.10.30] PHP Warning: Variable passed to each() is not an array or object in /usr/local/nagiosmobile/includes/functions.inc.php on line 187

[root@ nagiosmobile]# ls -l "/usr/local/nagios/var/status.dat"
-rw-rw-r-- 1 nagios nagios 789693 Feb 21 16:25 /usr/local/nagios/var/status.dat
[root@ nagiosmobile]# ls -l /usr/local/nagios/var/rw/nagios.cmd
prw-rw---- 1 nagios nagcmd 0 Feb 21 16:20 /usr/local/nagios/var/rw/nagios.cmd
[root@ nagiosmobile]# ls -l /usr/local/nagios/etc/cgi.cfg
-rw-rw-r-- 1 apache nagios 828 Jul 3 2013 /usr/local/nagios/etc/cgi.cfg
[root@ nagiosmobile]# ls -l /usr/local/nagios/var/objects.cache
-rw-r--r--. 1 nagios nagios 509497 Feb 21 16:20 /usr/local/nagios/var/objects.cache
[root@ nagiosmobile]# grep nagios /etc/group
nagios:x:500:apache,nagios
nagcmd:x:501:apache,nagios
shutdowngroup:x:503:nagios
[root@ nagiosmobile]#

I am using Nagios XI 2012R2.7 on CentOS release 6.3.
SELinux is disabled as well.

Is there anything i am missing, I ofcourse followed the installation doc.

Thanks,
Gautam

Re: Not getting data in Nagios mobile

PostPosted: Mon Feb 24, 2014 11:44 am
by lmiltchev
Is there anything i am missing, I ofcourse followed the installation doc.


Can you provide us with a link to this document? Nagios Mobile *should* be included and you should be able to log in by using: http://<ip address>/nagiosmobile.

Username: nagiosadmin
Password: <your password>

Re: Not getting data in Nagios mobile

PostPosted: Mon Feb 24, 2014 11:49 am
by tmcdonald
Please also run the following and post the output:

Code: Select all
sed -n 180,200p /usr/local/nagiosmobile/includes/functions.inc.php

Re: Not getting data in Nagios mobile

PostPosted: Mon Feb 24, 2014 1:48 pm
by balothia
lmiltchev wrote:
Is there anything i am missing, I ofcourse followed the installation doc.


Can you provide us with a link to this document? Nagios Mobile *should* be included and you should be able to log in by using: http://<ip address>/nagiosmobile.

Username: nagiosadmin
Password: <your password>


The installation document.
viewtopic.php?f=21&t=4994
http://assets.nagios.com/downloads/exch ... Mobile.pdf

I am able to login to Nagios mobile but not getting any data.

Thanks,
Gautam

Re: Not getting data in Nagios mobile

PostPosted: Mon Feb 24, 2014 1:51 pm
by balothia
tmcdonald wrote:Please also run the following and post the output:

Code: Select all
sed -n 180,200p /usr/local/nagiosmobile/includes/functions.inc.php


Thanks for you inputs, this is what i get.
[root@ ~]# sed -n 180,200p /usr/local/nagiosmobile/includes/functions.inc.php
"service_unknown" => 0,
"service_pending" => 0,
"service_unhandled" => 0,
"service_problems" => 0,
"service_acknowledged"=> 0,
);

while (list($host,$host_status) = each($status["hosts"]))
{
//handle fix for users who are auth to see services but not the host
if(isset($host_status['current_state']) )
{

switch ($host_status["current_state"])
{
case HOST_UP:
$global_stats["host_up"]++;
break;
case HOST_DOWN:
$global_stats["host_down"]++;
break;

Thanks,
Gautam

Re: Not getting data in Nagios mobile

PostPosted: Mon Feb 24, 2014 2:00 pm
by tmcdonald
In some instances the browser can cause issues. What device/browser are you testing on? Is it possible to try on a different one?

http://stackoverflow.com/questions/1430 ... -or-object

Re: Not getting data in Nagios mobile

PostPosted: Mon Feb 24, 2014 2:32 pm
by balothia
tmcdonald wrote:In some instances the browser can cause issues. What device/browser are you testing on? Is it possible to try on a different one?

http://stackoverflow.com/questions/1430 ... -or-object


Hi, I tried with Moziall, IE & Chrome. In iPad i tried with Mozilla, Safari and Chrome as well. But didnt worked at all.
This time we have a new error as well.

[Mon Feb 24 13:27:32 2014] [error] [client x.x.x.x] PHP Notice: Undefined index: hosts in /usr/local/nagiosmobile/includes/displayfunctions.inc.php on line 320, referer: http://x.x.x.x/nagiosmobile/
[Mon Feb 24 13:27:32 2014] [error] [client x.x.x.x] PHP Warning: Invalid argument supplied for foreach() in /usr/local/nagiosmobile/includes/displayfunctions.inc.php on line 320, referer: http://x.x.x.x/nagiosmobile/


Thanks,
Gautam

Re: Not getting data in Nagios mobile

PostPosted: Mon Feb 24, 2014 4:22 pm
by tmcdonald
Same deal as before, let's look at that line in the code. Run the following and post the output:

Code: Select all
sed -n 300,350p /usr/local/nagiosmobile/includes/displayfunctions.inc.php

Re: Not getting data in Nagios mobile

PostPosted: Tue Feb 25, 2014 3:31 pm
by balothia
tmcdonald wrote:Same deal as before, let's look at that line in the code. Run the following and post the output:

Code: Select all
sed -n 300,350p /usr/local/nagiosmobile/includes/displayfunctions.inc.php


This is what I got...

Code: Select all
[root@ ~]# sed -n 300,350p /usr/local/nagiosmobile/includes/displayfunctions.inc.php

//      for($i=0; $i<7; $i++)
//      {
        $content .='
                <div data-role="page" id="hosts_'.$i.'" data-theme="a">
                  <div data-role="header">
                                  <!-- back button -->
                  <a data-icon="arrow-l" data-rel="back" class="ui-btn-left ui-btn ui-btn-icon-left ui-btn-corner-all ui-shadow ui-btn-up-a" href="#" data-theme="a">
                        <span class="ui-btn-inner ui-btn-corner-all">
                                <span class="ui-btn-text">Back</span>
                                <span class="ui-icon ui-icon-arrow-l ui-icon-shadow"></span>
                        </span>
                  </a>
                 
                        <h1>Hosts</h1>
                        <a href="index.php" alax-load="false" data-icon="home" data-iconpos="notext" class="ui-btn-right">Home</a>
                  </div>
                        <ul data-role="listview" data-inset="false" data-theme="f" data-dividertheme="a">
                        ';
                         
                foreach($status["hosts"] as $host_id => $host_status)
                {
                        $host = $host_status["host_name"];
                        //print "<pre>".print_r($host_status,true)."</pre>"; 
                        if(!isset($host_status['services']) ) //handle unset array
                                $host_status['services'] =array();

                        $class = class_by_state(service_state_of($host_status['services']) );
                        $count = count($host_status['services']);

                        if(!isset($host_status["current_state"])) continue; //skip bad array indeces. XXX TODO: find the source of these.

                        switch($i){
                        case 0:
                        case 1:
                        case 2:
                                if($host_status["current_state"]==$i)
                                        $content .= get_host_list_item($class,$host,$count);
                                break;
                        case 3:
                                if($host_status["has_been_checked"]==0)
                                        $content .= get_host_list_item($class,$host,$count);
                                break;
                        case 4:
                                if($host_status["current_state"]>0 && $host_status["scheduled_downtime_depth"]==0
                                        && $host_status["problem_has_been_acknowledged"]==0)
                                        $content .= get_host_list_item($class,$host,$count);
                                break;
                        case 5:
                                if($host_status["current_state"]==1 || $host_status["current_state"] == 2)
                                        $content .= get_host_list_item($class,$host,$count);
[root@ ~]#


Thanks,
Gautam

Re: Not getting data in Nagios mobile

PostPosted: Wed Feb 26, 2014 12:32 pm
by sreinhardt
Since both issues revolve around issues with parsing status.dat or are at least generated by an array object that is not being created properly, but relies on status.dat, I think we should look there first. Could you return the following output please.

Code: Select all
grep -i 'nag' /etc/group
ls -lvad /usr/local/nagios/var
ls -lvad /usr/local/nagios


Could you also show us the /usr/local/nagiosmobile/include.inc.php file please.