Cacti sending data to nagios/NPC

General discussion about Plugins for Cacti

Moderators: Moderators, Developers

Author
Message
schweet
Posts: 13
Joined: Thu Jun 04, 2009 11:12 am

Cacti sending data to nagios/NPC

#1 Post by schweet » Mon Jun 22, 2009 6:50 am

Hi Guys;

Under the FAQ for NPC:
Q: Do Nagios and Cacti/NPC need to be installed on the same server? ¶

For full functionality Nagios and NPC need to be on the same server because NPC needs to be able to write commands to the Nagios command file.

Can I configure cacti to send data into the NPC/Nagios server remotely? I would like to keep cacti and nagios on seperate physical hosts, receive and display data On the Nagios host under NPC tab. Can the data be sent from a remote cacti host and received in npc?

Any help instruction on how to do this would be greatly appreciated.


Thanks
Ali.

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

#2 Post by divagater » Mon Jun 22, 2009 7:18 am

Cacti and Nagios do not need to be on the same system. NPC gets all of its display data from the database so when you configure NDO2DB you simply point it to the host where your cacti database lives.

The one caveat is that in order to execute Nagios commands like comments, acknowledgments, enabling and disabling services etc. You will need to make the nagios command file available to cacti via nfs (or cifs). This is a simple and common way to do it.

The FAQ has been updated.

Cheers,
Billy
[url=http://forums.cacti.net/viewtopic.php?t=26540][b]NPC 2.0.4[/b][/url]
[url=http://trac2.assembla.com/npc][size=75]Trac[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=defect][size=75]Bugs[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=enhancement][size=75]Requests[/size][/url]

schweet
Posts: 13
Joined: Thu Jun 04, 2009 11:12 am

#3 Post by schweet » Mon Jun 22, 2009 7:37 am

Cheers fella!

schweet
Posts: 13
Joined: Thu Jun 04, 2009 11:12 am

Need help with NDO DB

#4 Post by schweet » Tue Jun 23, 2009 4:27 am

Hi Billy;

Can you help me out. I cant seem to see any traffic on the remote mysql host, I am using tcpdump to listen on mysql port. Nothing is coming through. Both the nagios host and cacti are on the same LAN. No firewall problems, no tcpwrappers, no iptunnels. Here are the configs and error messages I am seeing:

ERROR MESSAGE in nagios.log: [1245748290] ndomod: Still unable to connect to data sink. 678595 items lost, 5000 queued items to flush.

Configs:
#####################################################################
# NDO2DB DAEMON CONFIG FILE
#
# Last Modified: 10-29-2007
#####################################################################

# USER/GROUP PRIVILIGES
ndo2db_user=nagios
ndo2db_group=nagios

# SOCKET TYPE
# unix = Unix domain socket (default)
# tcp = TCP socket
socket_type=unix
#socket_type=tcp

# SOCKET NAME
socket_name=/opt/nagios/var/ndo.sock

# TCP PORT
# This option determines what port the daemon will listen for
# connections on. This option is only valid if the socket type
# specified above is "tcp".
#tcp_port=5668

# DATABASE SERVER TYPE
db_servertype=mysql

# DATABASE HOST
# This option specifies what host the DB server is running on.
db_host=1.1.1.1 (removed)

# DATABASE PORT
# 3306 = Default MySQL port
db_port=3306

# DATABASE NAME
db_name=cacti

# DATABASE TABLE PREFIX
db_prefix=npc_

# DATABASE USERNAME/PASSWORD
db_user=cacti
db_pass=password

## TABLE TRIMMING OPTIONS

# Keep timed events for 24 hours
max_timedevents_age=1440

# Keep system commands for 1 week
max_systemcommands_age=10080

# Keep service checks for 1 week
max_servicechecks_age=10080

# Keep host checks for 1 week
max_hostchecks_age=10080

# Keep event handlers for 31 days
max_eventhandlers_age=44640

# DEBUG LEVEL
# Values: -1 = Everything
# 0 = Nothing
# 1 = Process info
# 2 = SQL queries
debug_level=-1

# DEBUG VERBOSITY
# Values: 0 = Brief output
# 1 = More detailed
# 2 = Very detailed
debug_verbosity=2

# DEBUG FILE
# This option determines where the daemon should write debugging information.
debug_file=/opt/nagios/var/ndo2db.debug

# MAX DEBUG FILE SIZE
max_debug_file_size=1000000


#####################################################################
# NDOMOD CONFIG FILE
#
# Last Modified: 09-05-2007
#####################################################################
# INSTANCE NAME
instance_name=default

# OUTPUT TYPE
# file = standard text file
# tcpsocket = TCP socket
# unixsocket = UNIX domain socket (default)

#output_type=file
output_type=unixsocket
#output_type=tcpsocket

# OUTPUT
# connect to for sending output.
#output=/opt/nagios/var/ndo.dat
output=/opt/nagios/var/ndo.sock
#output=127.0.0.1

# TCP PORT
#tcp_port=5668

# OUTPUT BUFFER
output_buffer_items=5000

# BUFFER FILE
buffer_file=/opt/nagios/var/ndomod.tmp

# FILE ROTATION INTERVAL
file_rotation_interval=14400

# FILE ROTATION COMMAND
#file_rotation_command=rotate_ndo_log

# FILE ROTATION TIMEOUT
file_rotation_timeout=60

# RECONNECT INTERVAL
reconnect_interval=15

# RECONNECT WARNING INTERVAL
reconnect_warning_interval=15
#reconnect_warning_interval=900

# DATA PROCESSING OPTION
data_processing_options=-1

# CONFIG OUTPUT OPTION
config_output_options=2

What am I missing here? Any advise or help would be greatly appreciated.

Thanks
Ali.

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

#5 Post by divagater » Tue Jun 23, 2009 6:51 am

Hey Ali. Update your ndomod.cfg and ndo2db.cfg to use:

Code: Select all

socket_type=tcp
tcp_port=5668
In my experience the Unix domain socket is unreliable. So I suspect the reason you are not seeing any traffic is because none is being sent. When you change to tcp socket type make sure both configs are using the same port.

Cheers,
Billy
[url=http://forums.cacti.net/viewtopic.php?t=26540][b]NPC 2.0.4[/b][/url]
[url=http://trac2.assembla.com/npc][size=75]Trac[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=defect][size=75]Bugs[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=enhancement][size=75]Requests[/size][/url]

schweet
Posts: 13
Joined: Thu Jun 04, 2009 11:12 am

#6 Post by schweet » Tue Jun 23, 2009 7:22 am

Hi;

I have resolved this issue by editing /etc/my.cnf and putting the actual ip address of the mysql host to bind to.

Also, added privilege for cacti to login from remote ip:

I have checked the NPC_ tables and data is being written to the remote mysql table. The only problem now is NPC tab does not show any stats/data...

Any ideas?

Regards
Ali.

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

#7 Post by divagater » Tue Jun 23, 2009 7:39 am

Verify that you have json and pdo support for php and check your httpd error log for any fatal errors. If json and pdo are installed and you do not have any fatal errors let me know the following information:

OS distro and version
php version
php-pdo version
php-json version


Seems like some non redhat/fedora/centos users are having similar issues but I have not been able to reproduce yet. If you have the same problem I will try to build out the exact setup to reproduce the problem.

~Billy
[url=http://forums.cacti.net/viewtopic.php?t=26540][b]NPC 2.0.4[/b][/url]
[url=http://trac2.assembla.com/npc][size=75]Trac[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=defect][size=75]Bugs[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=enhancement][size=75]Requests[/size][/url]

schweet
Posts: 13
Joined: Thu Jun 04, 2009 11:12 am

#8 Post by schweet » Tue Jun 23, 2009 9:00 am

Hi Billy;

I have seen this error in apache error log:
PHP Fatal error: Call to undefined function json_encode() in /var/www/html/cacti/plugins/npc/controllers/layout.php on line 67, referer: http://1.1.1.1/plugins/npc/npc.php

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

# php -i |grep pdo
Configure Command => './configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-ncurses=shared' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' '--enable-dom=shared' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--enable-dbase=shared'
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
pdo_mysql
pdo_sqlite
PECL Module version => 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6 2006/01/01 12:50:12 sniper Exp $

PHP VERSION: PHP 5.1.6


I dont understand why json is erroring? Any ideas how I fix this? A test system where I had NPC etc working was using php 5.2. I suspect something in php5.2 fixed this problem? I really dont want to upgrade as this is a prod server.

Thanks
Ali.

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

#9 Post by divagater » Tue Jun 23, 2009 10:02 am

You shouldn't need php 5.2. My production systems are all 5.1.x.

So php indicates json support is enabled but the json_encode method is not available. There are several json libraries available for php. The official php library uses the json_encode method and the others seem to have their own different method names.

json support was not added to the core php until version 5.2 but the version of json that was added the core is available to download and add to earlier versions of PHP here: http://aurore.net/projects/php-json/

I suspect you may have some other json library installed. to see what the library is you should have some way to query the package for additional info. On Redhat/fedora/centos this does the trick:

Code: Select all

[[email protected] npc]# uname -a
Linux exlap600 2.6.9-42.ELsmp #1 SMP Sat Aug 12 09:39:11 CDT 2006 i686 i686 i386 GNU/Linux

[[email protected] npc]# rpm -qa | grep json
php-json-5.1.6_1.2.1-1.aurore

[[email protected] npc]# rpm -qi php-json
Name        : php-json                     Relocations: (not relocatable)
Version     : 5.1.6_1.2.1                       Vendor: (none)
Release     : 1.aurore                      Build Date: Fri 18 Apr 2008 02:13:53 PM CDT
Install Date: Fri 18 Apr 2008 02:14:39 PM CDT      Build Host: exlap600
Group       : Development/Languages         Source RPM: php-json-5.1.6_1.2.1-1.aurore.src.rpm
Size        : 22587                            License: PHP
Signature   : (none)
URL         : http://www.aurore.net/projects/php-json/
Summary     : PHP JSON (JavaScript Object Notation) implementation
Description :
php-json is an extremely fast PHP C extension for JSON (JavaScript Object Notation)
serialisation.

So on my 5.1.6 system I see that I have the aurore version of json support which is the version that was added to the core and documented in the php docs: http://us3.php.net/manual/en/book.json.php

Shoot me what you find.

Cheers,
Billy
[url=http://forums.cacti.net/viewtopic.php?t=26540][b]NPC 2.0.4[/b][/url]
[url=http://trac2.assembla.com/npc][size=75]Trac[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=defect][size=75]Bugs[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=enhancement][size=75]Requests[/size][/url]

schweet
Posts: 13
Joined: Thu Jun 04, 2009 11:12 am

#10 Post by schweet » Tue Jun 23, 2009 10:55 am

uname -a
Linux host 2.6.18-128.1.10.el5 #1 SMP Thu May 7 10:39:21 EDT 2009 i686 i686 i386 GNU/Linux
[[email protected] php-5.2.10]# rpm -qa | grep json

[[email protected] 210 php-5.2.10]# rpm -qi php-json
package php-json is not installed


The only json.so in the whole system is here:
find / -name *json*
/usr/lib/php/modules/json.so

and:
/etc/php.d/json.ini
[[email protected] php-5.2.10]# cat /etc/php.d/json.ini
; Enable json extension module
extension=json.so

Thats it. The way I compiled jason is using "pear install json.gz"
Exactly how I compiled on other systems.

Thanks
Ali.

linebacker2
Posts: 28
Joined: Fri May 08, 2009 11:34 am

#11 Post by linebacker2 » Tue Jun 23, 2009 11:59 am

I am having the exact same issues with installation of NPC and Cacti on the different servers.

When I do the following i get the output displayed below

[[email protected]]uname -a

Linux icstools.local 2.6.27.21-170.2.56.fc10.i686.PAE #1 SMP Mon Mar 23 23:24:26 EDT 2009 i686 i686 i386 GNU/Linux


[[email protected]]# rpm -qa | grep json


[[email protected]]find / -name *json*

/usr/share/smolt/client/simplejson
/usr/share/smolt/client/simplejson/jsonfilter.py
/usr/share/smolt/client/simplejson/jsonfilter.pyc
/usr/share/smolt/client/simplejson/jsonfilter.pyo
/usr/lib/xulrunner-1.9/components/dom_json.xpt
/usr/lib/php/modules/json.so
/etc/php.d/json.ini


[[email protected]]# cat /etc/php.d/json.ini
; Enable json extension module
extension=json.so


what is the resolution to this???

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

#12 Post by divagater » Tue Jun 23, 2009 12:04 pm

schweet wrote:The way I compiled json is using "pear install json.gz"
Exactly how I compiled on other systems.

Thanks
Ali.
Ah, that is the problem. Pear's vs. of json has a completely different api from the standard php version. Uninstall the pear json and install the json library that became part of php. The docs on how to build and install json support for rpm based systems below php 5.2.x can be found in the NPC quick start guide here: http://trac2.assembla.com/npc/wiki/QuickStartGuide

Cheers,
Billy
[url=http://forums.cacti.net/viewtopic.php?t=26540][b]NPC 2.0.4[/b][/url]
[url=http://trac2.assembla.com/npc][size=75]Trac[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=defect][size=75]Bugs[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=enhancement][size=75]Requests[/size][/url]

linebacker2
Posts: 28
Joined: Fri May 08, 2009 11:34 am

#13 Post by linebacker2 » Tue Jun 23, 2009 2:49 pm

divagater thanks!

I am having a problem uninstalling it. I can't seem to find it when doing yum list pear* or json*

yum list pear*

Loading mirror speeds from cached hostfile
* updates: mirrors.med.harvard.edu
* rpmforge: apt.sw.be
* fedora: mirrors.med.harvard.edu
Error: No matching Packages to list


yum list json*

Available Packages
json.noarch 2-1.fc10 updates
json-glib.i386 0.6.2-1.fc10 fedora
json-glib-devel.i386 0.6.2-1.fc10 fedora
json-javadoc.noarch 2-1.fc10 updates

do you know what its called exactly? Also how would I install the json library that's part of php? The link that you are referring too is not that clear. I am running a Fedora10 system.

Thanks for your help once again!!

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

#14 Post by divagater » Tue Jun 23, 2009 6:14 pm

linebacker2 wrote:divagater thanks!

I am having a problem uninstalling it. I can't seem to find it when doing yum list pear* or json*
The other user clearly indicated that he had installed the pear json library. If you are running fc10 then you should have php 5.2 or higher installed which should come bundled with json support. Do you see a fatal error in your httpd error logs relating to json?

Show me the output of the following command:

rpm -qa | grep php


Also, here is a simple php script you can run from the command line to test your json support. Save this as json_test.php in any location and run from the command line with the following command: php json_test.php

Code: Select all


<?php

$array = array('fish' => 'trout', 'fruit' => 'apple', 'mammal' => 'dog');

$a = json_encode($array);

echo "\nTesting json_encode():\n $a \n\n";

echo "Testing json_decode():\n";
print_r(json_decode($a));

?>
You can show me the output from that test but do look at your http error logs while loading NPC and look for an errors that say fatal.

Cheers,
Billy
[url=http://forums.cacti.net/viewtopic.php?t=26540][b]NPC 2.0.4[/b][/url]
[url=http://trac2.assembla.com/npc][size=75]Trac[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=defect][size=75]Bugs[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=enhancement][size=75]Requests[/size][/url]

schweet
Posts: 13
Joined: Thu Jun 04, 2009 11:12 am

#15 Post by schweet » Wed Jun 24, 2009 5:47 am

To uninstall json with pear (only if you have installed it with pear in the first plac):

#pear uninstall json


Thanks
Ali.

Post Reply