Nagios Plugin for Cacti (NPC) 2.0.4

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
miky_willis
Posts: 20
Joined: Tue Apr 25, 2006 6:08 am

Post by miky_willis »

THANKS A LOT !!

Ok great I use TCP and Nagios starts great

My npc tables appear in cacti database...

Let's see then how to populate them
Ubuntu / Cacti 0.8.7g / PIA 2.9
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

If nagios is running and you re-enabled the broker:

broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg

And you have the ndo2db daemon running then... you should have some data in your npc_ tables :)

Let me know how it goes.

~Billy
miky_willis
Posts: 20
Joined: Tue Apr 25, 2006 6:08 am

Post by miky_willis »

oh damned... I talk too fast.... :oops: :oops:

with the broker nagios does not starts like before

sorry then.
Ubuntu / Cacti 0.8.7g / PIA 2.9
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

The good news is that I just got this all running on a clean FC8 install without any issues at all. So now the trick is to figure out whats different with your setup.

Here is what I did:

Install the needed mysql stuff
yum install mysql-server mysql mysql-devel

Added nagios user/group
useradd nagios
groupadd nagcmd

Install nagios-3.0
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config

Install nagios-plugins-1.4.11
./configure
make
make install

Install ndoutils-1.4b7
./configure
make
cp src/ndo2db-3x /usr/local/nagios/bin/ndo2db
cp src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
cp config/ndo2db.cfg /usr/local/nagios/etc
cp config/ndomod.cfg /usr/local/nagios/etc

Configure Nagios and NDO

nagios.cfg add the following line:
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg


ndo2db.cfg:

ndo2db_user=nagios
ndo2db_group=nagios
socket_type=tcp
socket_name=/usr/local/nagios/var/ndo.sock
tcp_port=5668
db_servertype=mysql
db_host=localhost
db_port=3306
db_name=cacti
db_prefix=npc_
db_user=cacti
db_pass=passw0rd
max_timedevents_age=1440
max_systemcommands_age=10080
max_servicechecks_age=10080
max_hostchecks_age=10080
max_eventhandlers_age=44640
debug_level=0
debug_verbosity=1
debug_file=/usr/local/nagios/var/ndo2db.debug
max_debug_file_size=1000000



ndomod.cfg:

instance_name=default
output_type=tcpsocket
output=127.0.0.1
tcp_port=5668
output_buffer_items=5000
buffer_file=/usr/local/nagios/var/ndomod.tmp
file_rotation_interval=14400
file_rotation_timeout=60
reconnect_interval=15
reconnect_warning_interval=15
data_processing_options=-1
config_output_options=2


PHP components:
php-cli-5.2.4-3
php-common-5.2.4-3
php-pdo-5.2.4-3
php-mysql-5.2.4-3
php-ldap-5.2.4-3
php-5.2.4-3

MySQL components:
mysql-devel-5.0.45-6.fc8
mysql-5.0.45-6.fc8
mysql-libs-5.0.45-6.fc8
mysql-server-5.0.45-6.fc8


Check out my configs and double check yours.
rmcclain
Posts: 9
Joined: Fri Mar 28, 2008 3:16 am

Post by rmcclain »

The database is populating now. I had turned on debugging and run ndo2db as root. It then creates the debug file owned by root, and then calls setuid nagios, and is unable to write the debug file. That seemed to be the source of my problems somehow. I fixed that and data started flowing.

But now I have another one.. When I click on a hostgroup and select a template in N2C, nothing happens. Firebug tells me there is one error when I click import:

On ext-all.js, line 24

Invalid flag after regular expression
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/var/www/cacti-0....

Any ideas? Thanks ;)
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

Just to be clear on exactly where it is failing for you. When you click a cell in the template column a drop down select box should render and then the available templates are loaded into the select box via a call to the server.

I attached a screenshot with and without the template selection box rendered. When you click in the template sell does the drop down box get rendered?

Also, to get some better debugging make the following change for me:

Edit plugins/npc/controllers/layout.php

Change the line that looks like this (line 44)
<script type="text/javascript" src="<?php echo $config["url_path"]; ?>plugins/npc/js/ext/ext-all.js"></script>

to this:

<script type="text/javascript" src="<?php echo $config["url_path"]; ?>plugins/npc/js/ext/ext-all-debug.js"></script>

The difference between the 2 lines is that ext-all.js is changed to ext-all-debug.js. This sets up NPC to use a none minimized vresion of EXT. Shoot me the results of a firebug error after that change.

~Billy
Attachments
n2c without a template selection
n2c without a template selection
no_selection.png (9.61 KiB) Viewed 16153 times
N2C with template selection box rendered
N2C with template selection box rendered
template_combobox.png (17.06 KiB) Viewed 16153 times
colejv
Posts: 46
Joined: Wed Mar 19, 2008 10:50 am

Post by colejv »

I was having issues with no data being displayed, although it was present in the database and in the drop-down box on the devices page, the solution for me was to install the PHP extension pdo_mysql (see hostinfo below)

I seem to be suffering from performance issues but I have not pinpointed them yet, services and hosts never load on the first attempt and what the dashboard displays seems to be hit or miss. I do have a decent sized system (currently 160hosts 261services) so I may have just pushed our hardware too far, I also have not really tuned my configs for nagios 3.0 yet either.

N2C has remained without data blank this may be from the performance issues above.

N2C does not display properly on IE7(Vista) the input button and header is missing just the tab and a horizontal scrollbar display,not that it really matters to me (I thought maybe my 64bit browser was causing a problem so I tried my windows box)

Overall it looks very promising
Cacti Version - 0.8.7b
Plugin Architecture - 2.1
Poller Type - Cactid v
Server Info - FreeBSD 6.1-RELEASE-p11
Web Server - Apache/2.2.4 (FreeBSD) mod_ssl/2.2.4 OpenSSL/0.9.7e-p1 DAV/2 PHP/5.2.3 with Suhosin-Patch
PHP - 5.2.3
PHP Extensions - session, Reflection, date, libxml, apache2handler, ctype, pcre, SimpleXML, SPL, dom, filter, hash, iconv, json, mysql, PDO, pdo_sqlite, posix, standard, SQLite, tokenizer, xml, xmlreader, xmlwriter, sockets, snmp, pdo_mysql
MySQL - 5.0.51a-log
RRDTool - 1.2.23
SNMP - 5.3.1
Plugins
  • Thresholds (thold - v0.3.9)
    Global Plugin Settings (settings - v0.3)
    Network Tools (tools - v0.2)
    Host Info (hostinfo - v0.2)
    Nagios plugin for Cacti (npc - v2.0.0a)
rmcclain
Posts: 9
Joined: Fri Mar 28, 2008 3:16 am

Post by rmcclain »

It does show the dropdown list, and I select the ucd template. I added the debugging js and have attached a screenshot of the firebug output. Thanks
Attachments
snapshot1.png
snapshot1.png (143.73 KiB) Viewed 16133 times
miky_willis
Posts: 20
Joined: Tue Apr 25, 2006 6:08 am

Post by miky_willis »

Thanks for your step by step divagater !

that's great I will retry and "reverify" all this when I got time perhaps not before monday :(

have all a nice evening by testing this wonderfull plugin ;)
Ubuntu / Cacti 0.8.7g / PIA 2.9
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

rmcclain, thanks for the screenshot, that helped a lot.

If you don't mind, try to do a sync again selecting the same hostgroup. Only this time in firebug show me the post data for the ajax request by selecting the post tab just to the left of the request tab.

What is happening is that the selected hostgroup is either not being sent to the server at all or there are some special charachters in the hostgroup name that is breaking the json_decode on the server side. Seeing the posted data should get us close to the issue.

Thanks for helping to troubleshoot...

~Billy
rmcclain
Posts: 9
Joined: Fri Mar 28, 2008 3:16 am

Post by rmcclain »

Here is the POST data:

action getHosts
module sync
p_data {"0":{"alias":"Unix Servers","template":"3"}}

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

Post by divagater »

Ok, so you are submitting a well formed json string to the server. This puts the problem in 1 of 2 possible places. Either the post data is failing to be read in or json_decode() is failing to decode the json string.

I am working on another alpha release that will include configurable logging using the existing Cacti logging mechanism. The should help greatly with troubleshooting.

In the meantime if you are inclined could you copy the attached file (sync.txt) to npc/controllers/sync.php? I had to call the file sync.txt to get it to attach here. This will overwrite the existing sync.php. I added 3 debugs that will show what was posted and the data string retrieved from the post prior to and after the json_decode(). The debug will be written to /tmp/NPC.debug.

After dropping in the file, attempt to do a sync again and then shoot me the contents of /tmp/NPC.debug. There wont be a lot of data so you could just cat the file and post the contents in a reply.

~Billy
Attachments
sync.txt
sync.php with some debugging added.
(6.14 KiB) Downloaded 500 times
keefe007
Posts: 24
Joined: Fri Sep 23, 2005 11:33 pm

Post by keefe007 »

Anyone have a guide on how to get this working from scratch if I don't already have nagios installed?
rmcclain
Posts: 9
Joined: Fri Mar 28, 2008 3:16 am

Post by rmcclain »

Here ya go. As you can see, nothing shows up under JSON_DECODE:


POST: Array
(
[module] => sync
[action] => getHosts
[p_data] => {"0":{"alias":"Unix Servers","template":"3"}}
)



DATA: {"0":{"alias":"Unix Servers","template":"3"}}


JSON_DECODE:
rmcclain
Posts: 9
Joined: Fri Mar 28, 2008 3:16 am

Post by rmcclain »

I changed your debug code to fprintf a file instead of echo so I could see if there are any special characters not passing through the shell. I ended up with:

{\"0\":{\"alias\":\"Linux Servers\",\"template\":\"3\"}}

It seems that the json_decode works fine without all the slashes, but returns null with them:

<?php
$data1 = '{"0":{"alias":"Unix Servers","template":"3"}}';
$data2 = '{\"0\":{\"alias\":\"Linux Servers\",\"template\":\"3\"}}';
$arr1 = json_decode($data1);
$arr2 = json_decode($data2);
echo "arr1\n";
print_r($arr1);
echo "arr2\n";
print_r($arr2);
?>

Results in
arr1
stdClass Object
(
[0] => stdClass Object
(
[alias] => Unix Servers
[template] => 3
)

)
arr2
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests