Cactiusers.org


It is currently Tue Feb 07, 2012 5:36 pm




Post new topic Reply to topic  [ 2 posts ] 
 NPC shows blank page and apache errors 
Author Message
New User

Joined: Sun Oct 04, 2009 2:41 pm
Posts: 2
Post NPC shows blank page and apache errors
Hi All,

I've been using Nagios for several years but I'm totally new to Cacti and NPC. I'm using CentOS 5 as that's our standard platform @ work and we're fairly familiar with it.

Code:
# cat /etc/redhat-release
CentOS release 5.2 (Final)


Code:
# uname -a
Linux xxxx.xx.xxxx.SPAM 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 12:03:43 EST 2008 i686 i686 i386 GNU/Linux


I've followed the instructions here (mostly to the letter): http://trac2.assembla.com/npc/wiki/QuickStartGuide

* On the PHP section I also had to 'yum install rpm-build gcc-c++' to get the php-json build to work

Code:
# php -i | grep json
/etc/php.d/json.ini,
json
json support => enabled
json version => 1.2.1


When I got to the "Click the NPC tab" part, instead of the expected screen, I just get blankness. Looking in the Apache error log I see the following lines: -

Code:
[error] PHP Notice:  Undefined index:  action in /var/www/cacti/plugins/npc/top_graph_header.php on line 95, referer: http://cacti/index.php
[error] PHP Notice:  Undefined index:  action in /var/www/cacti/plugins/npc/top_graph_header.php on line 95, referer: http://cacti/index.php
[error] PHP Notice:  Undefined index:  action in /var/www/cacti/plugins/npc/top_graph_header.php on line 95, referer: http://cacti/index.php
[error] PHP Fatal error:  Call to undefined function json_encode() in /var/www/cacti/plugins/npc/controllers/layout.php on line 67, referer: http://cacti/plugins/npc/npc.php


These are lines 94, 95 & 96 of /var/www/cacti/plugins/npc/top_graph_header.php: -

Code:
<td id="gtabs" align="right" nowrap>
<?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["graph_settings"] == "on")) { print '<a href="'. $config['url_path'] . 'graph_settings.php"><img src="'. $config['url_path'] . 'images/tab_settings'; if (basename($_SERVER["PHP_SELF"]) == "graph_settings.php") { print "_down"; } print '.gif" border="0" alt="Settings" align="absmiddle"></a>';}?>&nbsp;&nbsp;<?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_tree"] == "on")) {?><a href="<?php echo $config['url_path']; ?>graph_view.php?action=tree"><img src="<?php echo $config['url_path']; ?>images/tab_mode_tree<?php if ($_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="<?php echo $config['url_path']; ?>graph_view.php?action=list"><img src="<?php echo $config['url_path']; ?>images/tab_mode_list<?php if ($_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="<?php echo $config['url_path']; ?>graph_view.php?action=preview"><img src="<?php echo $config['url_path']; ?>images/tab_mode_preview<?php if ($_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?>&nbsp;<br>
</td>


I hope this means something to someone!

These are lines 66 & 67 of /var/www/cacti/plugins/npc/controllers/layout.php

Code:
<?php $state = unserialize(db_fetch_cell('SELECT settings FROM npc_settings WHERE user_id = ' . $_SESSION['sess_user_id'])); ?>
var ExtState = Ext.decode('<?php echo json_encode($state); ?>');


I'm logged in as admin (user_id=1) and there are settings in the SQL...

Looking in all the files in 'cacti', I don't think I can see a function json_encode(): -

Code:
# grep -R json_encode cacti/*|grep -v return
cacti/plugins/npc/lib/Doctrine/Parser/Json.php:        $data = json_encode($array);
cacti/plugins/npc/js/src/plugins/Ext.state.HttpProvider.js:   var ExtState = Ext.decode('<?php echo json_encode($state); ?>');
cacti/plugins/npc/controllers/layout.php:            var ExtState = Ext.decode('<?php echo json_encode($state); ?>');
cacti/plugins/npc/controllers/layoutDev.php:            var ExtState = Ext.decode('<?php echo json_encode($state); ?>');
cacti/plugins/npc/npc.php.debug:$jsonString = json_encode($dId[0]);
cacti/plugins/npc/npc.php.debug:cacti_log("DEBUG [NPCTEST] json_encode reports: $jsonString", false, 'NPC');


I'm not sure how to move forward. Please can some help me?

Cheers,
--

ChrisP


Sun Oct 04, 2009 3:54 pm
New User

Joined: Sun Oct 04, 2009 2:41 pm
Posts: 2
Post Re: NPC shows blank page and apache errors
I just had an ephphany while lying awake at stupid o'clock in the morning.

I remembered that in order for Apache to be able to take advantage of newly installed php programs or configuration changes, it needs to be restarted (a 'graceful' restart is not enough).

At no point after installing php-json, had I restarted Apache... The following command fixed the blank screen problem: -

Code:
# apachectl restart


I still see the 3x PHP Notices about the undefined index and I am now seeing 2 more PHP Notices regarding "undefined offset: 0 in cacti/plugins/npc/controllers/nagios.php" on lines 105 & 111, which repeats at 90 second intervale (the refresh setting).

It'd be nice to know if these messages require my attention or not...

I also notice that my graphs pre-NPC setup, my graphs showed data but they suddenly stopped. I have not configured any hosts otherr than the default localhost unix checks. How can I debug this? I attach an example graph...


Attachments:
LoadAverage.png
LoadAverage.png [ 35.89 KiB | Viewed 2099 times ]
Sun Oct 04, 2009 10:19 pm
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: