
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>';}?> <?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 }?> <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