Nagios Plugin for Cacti (NPC) 2.0.4

General discussion about Plugins for Cacti

Moderators: Moderators, Developers

Post Reply
Author
Message
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

#76 Post by sonartribe » Tue Apr 08, 2008 10:35 am

n2o_2k,

I'm the one who had the previous error, and I worked around it (before upgrading php) by modifying the line in controllers.php from

return(json_encode(array('success' => false, 'msg' => "An error occurred in $class->$method. See error logs for detail.")));

to

return(json_encode(array('success' => false, 'msg' => "An error occurred in class->method. See error logs for detail.")));

Regards

Ian

n2o_2k
Posts: 7
Joined: Tue Apr 08, 2008 10:18 am

#77 Post by n2o_2k » Tue Apr 08, 2008 10:44 am

sonartribe wrote:n2o_2k,

I'm the one who had the previous error, and I worked around it (before upgrading php) by modifying the line in controllers.php from

return(json_encode(array('success' => false, 'msg' => "An error occurred in $class->$method. See error logs for detail.")));

to

return(json_encode(array('success' => false, 'msg' => "An error occurred in class->method. See error logs for detail.")));

Regards

Ian
Thanks for the quick reply, it fixed my problem. Now time to move to the next step.


Edit:
After looking at the statement causing the problem: $class->$method, you need to make sure that there is a space between $class and -> so that php doesn't think that you are trying to access a member of $class. Two ways I tested it and it worked fine:

Code: Select all

return(json_encode(array('success' => false, 'msg' => "An error occurred in {$class}->{$method}. See error logs for detail.")));
or (PS: note the space before and after -> )

Code: Select all

return(json_encode(array('success' => false, 'msg' => "An error occurred in $class -> $method. See error logs for detail.")));
Hope this help.

User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

#78 Post by divagater » Tue Apr 08, 2008 11:58 am

After looking at the statement causing the problem: $class->$method, you need to make sure that there is a space between $class and -> so that php doesn't think that you are trying to access a member of $class.
Great catch. the double quotes should have prevented the $class->$method from being interpreted as an actual method. The error is directly related to the json_module's incorrect interpretation and it not an issue in json above 5.2 however, you suggestion for reformatting that line makes perfect sense and will allow for json support at and below 5.2.0. This will be corrected in the next release coming soon.

Cheers,
Billy

User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

#79 Post by divagater » Tue Apr 08, 2008 12:14 pm

gimpel wrote:Hi,

first I want to thank for this great nagios frontend. This really makes nagios look good for our not-so-tech staff to show off server and website status.

I'm testing this on an openSUSE-10.3 VM in ESX - and so far it works just fine.
I have one question regarding N2C and creating graphs.

Is there something missing?
I somehow fail on seeing how to get performance data from NPC. Over to the graphs in Cacti
gimpel, you are on the right track. If a particular service is returning performance data then when you view the 'Service State Information' screen for that service you will see a button on the tool bar that says 'Data Input Method'. Click that button and acknowledge the confirmation. Then the data input method will have been created.

You get the service state information screen by double clicking on a service. I attached a screen shot as an example. If you don't see the button it is because there is not any performance data available for that service (or host).

~Billy
Attachments
npc_data_import.png
Data Input Method button on the service state information screen.
npc_data_import.png (46.34 KiB) Viewed 5834 times

gimpel
Posts: 5
Joined: Tue Apr 08, 2008 9:19 am

#80 Post by gimpel » Wed Apr 09, 2008 4:57 am

Aah, now I got it. Thank you very much, Billy.

The point where I failed to find the way was actually, that I have to double-click on a service in the Services tab to enter the Service State Information menu. I didn't know that this menu actually exists.

From there it's clear how to proceed. Maybe adding a button or an entry in the right-click menu like "View Service State Information" would make that more obvious to find.

Wow, that's superb! For an alpha, this already works very well!
Thanks again!

jointheclub76
Posts: 3
Joined: Tue Apr 01, 2008 3:29 pm

Non Paging Extjs Grid & filtering

#81 Post by jointheclub76 » Wed Apr 09, 2008 4:43 pm

Can you add in the option to specify whether I want to use a (extjs that is) paging grid, or a non-paging grid. And/or allow me to specify how many items I want it to display per page? Using this in a large noc environment, the service problems view is very important. However if I can only see 20 services per page it makes it hard. This would apply to other grid pages as well.

Another option is the concept of a livegrid, no paging just scrolling.
http://www.siteartwork.de/livegrid/

Also, filtering on the grid would be great too. Saving the filers so that they can be used by other users would be great. e.g. an acknowledged filter, and a "new alert" filter etc.

If these could be added as enhancement requests that would be great.

User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Re: Non Paging Extjs Grid & filtering

#82 Post by divagater » Wed Apr 09, 2008 7:38 pm

Thanks for the feature requests.

Code: Select all

Can you add in the option to specify whether I want to use a (extjs that is) paging grid, or a non-paging grid. And/or allow me to specify how many items I want it to display per page?
User configurable setting for items per page will be available in the beta release of NPC coming soon. Some of the code for this is in place already but I disabled it for the alpha release because it wasn't fully implemented.

I did have the grid rows under Cacti->Console->Settings for portlets and full page grids but that was system wide and I want to do this per user. I think I will end up adding a top toolbar with a settings option to the full page grids like hosts, services etc. The portlets already have a configuration icon that is simply hidden at the moment.
Another option is the concept of a livegrid, no paging just scrolling.
This idea has merit and I will see what I can do to get it into 2.1.0. I have frozen major features for 2.0.0 so I could get a GA release out.
Also, filtering on the grid would be great too. Saving the filers so that they can be used by other users would be great. e.g. an acknowledged filter, and a "new alert" filter etc.
Another good idea that I had not considered. I will open enhancement request for this and the live grid and add them to the 2.1.0 milestone.

Cheers,
Billy

lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

#83 Post by lavermil » Wed Apr 09, 2008 7:56 pm

I have NPC install but I get a blank screen when i click on the tab. Any idea?

P.S. I do not have the NDO util installed. Do i need that?

FYI for the people having issues getting json installed use

pecl install json

padawan
Posts: 25
Joined: Fri Nov 30, 2007 4:54 am

#84 Post by padawan » Thu Apr 10, 2008 9:02 am

very nice plugins !
i've been waiting a long time to get an issue to mix nagios and cacti!

installation is finish

i've got the bug on controller on line 363 too
i modify this line as :
return(json_encode(array('success' => false, 'msg' => "An error occurred in $class->method. See error logs for detail.")));
removing $method to method
it works fine now i got to add hosts services ect ect ^^
Last edited by padawan on Fri Apr 11, 2008 9:26 am, edited 1 time in total.

User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

#85 Post by divagater » Thu Apr 10, 2008 9:37 am

padawan wrote:very nice plugins !
i've been waiting a long time to get an issue to mix nagios and cacti!

installation is finish

i've got the but on controller on line 363 too
i modify this line as :
return(json_encode(array('success' => false, 'msg' => "An error occurred in $class->method. See error logs for detail.")));
removing $method to method
it works fine now i got to add hosts services ect ect ^^
There is a fix for this in the next release coming soon. The fix will update the line to read:

Code: Select all

return(json_encode(array('success' => false, 'msg' => "An error occurred in $class -> $method. See error logs for detail.")));
The difference is the white space before and after ->.

User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

#86 Post by divagater » Thu Apr 10, 2008 10:17 am

lavermil wrote:I have NPC install but I get a blank screen when i click on the tab. Any idea?

P.S. I do not have the NDO util installed. Do i need that?

FYI for the people having issues getting json installed use

pecl install json
Please check out the quick start guide for installation instructions. There are various requirements of which ndo2db is one. Thats not what is causing the blank page however. You are probably missing json or pdo support (or both).

~Billy

lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

#87 Post by lavermil » Thu Apr 10, 2008 11:39 am

divagater wrote:
lavermil wrote:I have NPC install but I get a blank screen when i click on the tab. Any idea?

P.S. I do not have the NDO util installed. Do i need that?

FYI for the people having issues getting json installed use

pecl install json
Please check out the quick start guide for installation instructions. There are various requirements of which ndo2db is one. Thats not what is causing the blank page however. You are probably missing json or pdo support (or both).

~Billy
billy,

thx for your reply.

I have PDO and json installed. Well lets say json is installed via pear. I don't get any code complaints about it missing like when I uninstall it. i have nagios 3.0.1 installed along with ndo. However the interesting part is NDO has some wierd issues. Any thoughts?

Code: Select all

Apr 10 09:37:15 iss-mon nagios: ndomod: Successfully reconnected to data sink!  0 items lost, 80 queued items to flush.
Apr 10 09:37:15 iss-mon nagios: ndomod: Successfully flushed 80 queued items to data sink.
Apr 10 09:37:15 iss-mon nagios: ndomod: Error writing to data sink!  Some output may get lost...

Code: Select all

[PHP Modules]
bz2
calendar
ctype
curl
date
exif
ftp
gd
gettext
gmp
hash
iconv
libxml
mime_magic
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
posix
pspell
Reflection
session
shmop
SimpleXML
snmp
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
zlib

[Zend Modules]

[[email protected] ~]# pecl install json
WARNING: channel "pear.php.net" has updated its protocols, use "channel-update pear.php.net" to update
Skipping package "pear/json", already installed as version 1.2.1

User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

#88 Post by divagater » Thu Apr 10, 2008 11:51 am

lavermil, edit plugins/npc/controllers/controller.php and find the following line around line 363:

Code: Select all

return(json_encode(array('success' => false, 'msg' => "An error occurred in $class->$method. See error logs for detail.")));
Change the line to:

Code: Select all

return(json_encode(array('success' => false, 'msg' => "An error occurred in $class -> $method. See error logs for detail.")));
I need to just get the latest trunk built so this will stop messing up people. This may niot be your issue but is a good candidate. If the issue persists tail the apache error logs and then click the npc tab. Look for any fatal errors and post here.

Cheers,
Billy

lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

#89 Post by lavermil » Thu Apr 10, 2008 12:48 pm

That got me a screen to look at. Now I have different errors. the new window displays the following now.

Code: Select all

// Add some properties to the params array npc.params.npc_portlet_refresh = 60; npc.params.npc_date_format = "Y-m-d"; npc.params.npc_time_format = "H:i:s"; npc.params.npc_nagios_url = "http://172.20.18.11/nagios/"; npc.params.userName = "admin"; var ExtState = Ext.decode('
I have the following in the httpd/error_log

Code: Select all

[Thu Apr 10 10:42:38 2008] [error] [client 172.20.19.254] PHP Fatal error:  Call to undefined function json_encode() in /var/www/cacti/plugins/npc/controllers/layout.php on line 58, referer: http://172.20.18.11/cacti/plugins/npc/npc.php

User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

#90 Post by divagater » Thu Apr 10, 2008 3:06 pm

[Thu Apr 10 10:42:38 2008] [error] [client 172.20.19.254] PHP Fatal error: Call to undefined function json_encode() in /var/www/cacti/plugins/npc/controllers/layout.php on line 58, referer: http://172.20.18.11/cacti/plugins/npc/npc.php
You are using the json support from pear. That will not be adequate as the pear json uses totally different method names etc. for encoding and decoding json objects.

NPC requires either PHP 5.2 and above with json support included or the php-json module to be installed.

~Billy

Post Reply