Nagios Plugin for Cacti (NPC) 2.0.4

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
jgoldschrafe
Posts: 1
Joined: Thu Aug 21, 2008 4:19 pm
Location: Cold Spring Harbor, NY

Post by jgoldschrafe »

This plugin seems really cool. Has anyone gotten it to scale? I'm running it in an environment with around 2400 service checks on 450 hosts and paging through results is absolutely unbearable. Half the time, it never even finishes when I try to switch pages, because it hits the specified PHP max execution time of 30 seconds.

I'm not sure if the queries are terribly unoptimized or if I'm doing something wrong with my PHP configuration. The server's no dog, it's a quad Xeon with 4 GB of RAM and a rather fast RAID 0+1 DB volume.

Edit: Neat, it looks like something is actually making PHP segfault:

Code: Select all

[Thu Aug 21 17:25:01 2008] [error] [client 143.48.3.13] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /usr/share/cacti/plugins/npc/lib/Doctrine/Table.php on line 1645, referer: http://monitor1/cacti/plugins/npc/npc.php?module=layoutDev&action=drawLayout
[Thu Aug 21 17:25:02 2008] [notice] child pid 19025 exit signal Segmentation fault (11)
I've turned on MySQL slow query logging and I want to see what it turns up.

Edit 2: I keep getting this:

Code: Select all

SELECT n.hostgroup_id AS n__hostgroup_id, n.instance_id AS n__instance_id, n.config_type AS n__config_type, n.hostgroup_object_id AS n__hostgroup_object_id, n.alias AS n__alias, n3.hoststatus_id AS n3__hoststatus_id, n3.host_object_id AS n3__host_object_id, n3.current_state AS n3__current_state, n3.output AS n3__output, n7.instance_id AS n7__instance_id, n7.instance_name AS n7__instance_name, n5.name1 AS n5__0, n6.name1 AS n6__1 FROM npc_hostgroups n INNER JOIN npc_hostgroup_members n2 ON n.hostgroup_id = n2.hostgroup_id INNER JOIN npc_hostgroup_members n4 ON n.hostgroup_id = n4.hostgroup_id INNER JOIN npc_hoststatus n3 ON n2.host_object_id = n3.host_object_id INNER JOIN npc_objects n5 ON n.hostgroup_object_id = n5.object_id INNER JOIN npc_objects n6 ON n3.host_object_id = n6.object_id INNER JOIN npc_instances n7 ON n.instance_id = n7.instance_id ORDER BY n5__0 ASC, n6__1 ASC;
Does anyone know where this query is being executed from? It's returning an absolutely obscene number of rows, in the order of hundreds of thousands. Debugging and profiling PHP is absolutely not my forte.
sfxdana
Posts: 2
Joined: Wed Aug 20, 2008 11:34 am

Problems with NPC

Post by sfxdana »

We currently have about 844+ hosts and 6500+ services running in Nagios3.

But we have the following problems with the NPC plugin (166):

1. We get PHP Fatal errors until setting php.ini mem option to 256MB.

2. After that we get PHP Fatal errors about execution time exceeding 30 secs.
Changing that to 60 seconds gets us back to nr. 1

3. With more than a 100+ performance counters, it's a pain to add the data input into cacti.
N2C doesn't look like it's does this. Would be nice to have an option to add data input via a list as with N2C.

We are using a distributed enviroment so using cacti to get that data is not possible.

Sfxdana
User avatar
proc
Posts: 4
Joined: Wed Aug 27, 2008 1:35 pm

Minor sort patch

Post by proc »

I am not sure if this has been posted before, but I wasn't able to find any references to it so I thought I would submit it.

I noticed on the page when setting up hosts that the "Nagios Host Mapping" pull down was seemingly randomly sorted. I had a heck of a time finding one of our 400+ hosts in there. This small patch simply adds the "ORDER BY name" line to the sql query which returns the results sorted. :)

Code: Select all

--- setup.php.orig      2008-08-28 11:52:19.000000000 -0400
+++ setup.php   2008-08-28 11:51:47.000000000 -0400
@@ -248,7 +248,8 @@
                                 "default" => "0",
                                 "sql" => "SELECT npc_hosts.host_object_id as id, concat(npc_instances.instance_name, ': ', obj1.name1) "
                                        . "AS name FROM `npc_hosts` LEFT JOIN npc_objects as obj1 ON npc_hosts.host_object_id=obj1.object_id "
-                                       . "LEFT JOIN npc_instances ON npc_hosts.instance_id=npc_instances.instance_id",
+                                       . "LEFT JOIN npc_instances ON npc_hosts.instance_id=npc_instances.instance_id "
+                                       . "ORDER BY name",
                                 "form_id" => false
                         );
                 }
Attachments
sort.patch
(872 Bytes) Downloaded 316 times
driden91
Cacti User
Posts: 52
Joined: Fri Jan 20, 2006 10:38 am

Post by driden91 »

hello,

Is it possible to add a machine in easily with your Nagios plugin?

for example at the same time that adding the machine in cacti


thank in advance
econ
Posts: 11
Joined: Fri Nov 16, 2007 7:20 pm

Refresh

Post by econ »

TheWitness wrote:I suggest you create your own top_graph_header.php, instead call it top_npc_header.php and remove the refresh bit.

TheWitness

If I copy top_graph_header.php what else would i need to modify once the file is copied into the plugin directory?

or

Has anyone else found a better way to deal with the refresh rate of NPC without it affecting the rest of cacti?

Thanks!
blugger
Cacti User
Posts: 50
Joined: Wed May 07, 2008 10:23 am

Problem with rights ...

Post by blugger »

Do you have any idea on that?
Attachments
Picture 1
Picture 1
npc-1.jpg (124.16 KiB) Viewed 14641 times
Picture 2
Picture 2
npc-2.jpg (113.49 KiB) Viewed 14641 times
Picture 3 (Problem)
Picture 3 (Problem)
npc-3.jpg (108.16 KiB) Viewed 14641 times
econ
Posts: 11
Joined: Fri Nov 16, 2007 7:20 pm

Re: Problem with rights ...

Post by econ »

blugger wrote:Do you have any idea on that?
Blugger you are getting that error cause you have not specified the full path to the nagios.cmd. Under Settings | NPC put "/usr/local/nagios/var/rw/nagios.cmd" and see if that resolves your issue.
blugger
Cacti User
Posts: 50
Joined: Wed May 07, 2008 10:23 am

Thx ...

Post by blugger »

Hi again!

Thanks, that fixed my problem.

Now there is the question how to get my cacti devices into nagios (npc)?

There is a "N2C" but no "C2N" :-) ...

I hope nagios (npc) will bring me some advantages here ...
econ
Posts: 11
Joined: Fri Nov 16, 2007 7:20 pm

Re: Refresh

Post by econ »

econ wrote:
TheWitness wrote:I suggest you create your own top_graph_header.php, instead call it top_npc_header.php and remove the refresh bit.

TheWitness
Does anyone have any suggestions on how to fix the refresh rate for NPC? When you enable NPC it changes the refresh for all of cacti. I have remarked out the piece in npc for refresh but then it adopts cacti's refresh rate and causes lots of tax on cacti.

Thanks!
Palermo
Cacti User
Posts: 87
Joined: Thu Sep 11, 2008 11:48 pm

Post by Palermo »

Hi,
I have a question.
I sucssefully installed nagios according the quick manual, but on installing ndoutils-1.4b7 i ran into some problems. hopefully you can help me.
Let me show you what i did....

For CactiEZ
I did the folowing.

Code: Select all

#Removed the nagios folder (Older version) in /usr/local/nagios/
#Made a new folder in the same directory and dit the following steps

yum install httpd
yum install gcc
yum install glibc glibc-common
yum install gd gd-devel

#It starded to download all kinds of things. :-)

su -l 
#To become a root user

/usr/sbin/useradd -m nagios
passwd nagios
#For creating a user + pass

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd apache
#Creating a usergroup

cd ~/downloads
tar xzf nagios-3.0.3.tar.gz
cd nagios-3.0.3
./configure --with-command-group=nagcmd

make all

make install
make install-init
make install-config
make install-commandmode

#to Compile the Nagios source code.


cd ~/downloads
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
#To Compile and install the plugins.

chkconfig --add nagios
chkconfig nagios on

Verify the sample Nagios configuration files.

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

#No errors has been found

service nagios start

#When is go to the http://localhost/nagios/ link
#it prompt with a login screen an version 3.0.3 works


#Next i need to install ndoutils-1.4b7 to get NPC working

cd ~/downloads
tar xzf ndoutils-1.4.tar.gz

#This error came 
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors

#i extracted the file in windows and copy'd all the files and directory's to #the download folder on the cacti system.
cd ndoutils-1.4b7

#i enterd the commando "make".  thats what the manual says.
[root@monitoring ndoutils-1.4b7]# make
make: *** No targets specified and no makefile found.  Stop.
Well what am i doing wrong?
The manual says that i need to do the "make" commando. but i gess no "make" file is in the directory.
What should i do now?

i hope you can help me.
If you need more info then let me know..

Thx in advanced
Cacti Version - 0.8.7b
Plugin Architecture - 2.0
Poller Type - Cactid v
Server Info - Linux 2.6.9-67.0.4.plus.c4smp
Web Server - Apache/2.0.63 (CentOS)
PHP - 5.1.6
PHP Extensions - libxml, xml, wddx, tokenizer, sysvshm, sysvsem, sysvmsg, standard, SimpleXML, sockets, SPL, shmop, session, Reflection, pspell, posix, mime_magic, iconv, hash, gmp, gettext, ftp, exif, date, curl, ctype, calendar, bz2, zlib, pcre, openssl, apache2handler, gd, ldap, mysql, mysqli, PDO, pdo_mysql, pdo_sqlite, snmp, eAccelerator
MySQL - 5.0.54
RRDTool - 1.2.23
SNMP - 5.1.2
Plugins
  • Global Plugin Settings (settings - v0.3)
    Thresholds (thold - v0.3.9)
    Large Site Performane Booster for Cacti (boost - v1.5)
    Device Monitoring (monitor - v0.8.2)
    Network Discovery (discovery - v0.8.4)
    Network Tools (tools - v0.2)
    Syslog Monitoring (syslog - v0.5.2)
    Device Tracking (mactrack - v1.1)
    RRD Cleaner (rrdclean - v1.1)
    Update Checker (update - v0.4)
    FlowView (flowview - v0.4)
    Host Info (hostinfo - v0.2)
    Error Images (errorimage - v0.1)
    PHP Network Weathermap (weathermap - v0.95b)
    Create Aggregate Graphs (aggregate - v0.63)
    Documents (docs - v0.1)
    report it! (report it! - v0.5.0)
Palermo
Cacti User
Posts: 87
Joined: Thu Sep 11, 2008 11:48 pm

Post by Palermo »

All progress goes with litle steps sometime ;-)

Somwhere on forums elswere i foud the commando show configure

Then when i use this commando again

./configure

It gave an permission problem

i had to change the permissions with this

Code: Select all

chmod +x configure
Then the ./configure workt.
The make commando also workt..

than is start creating a database

Code: Select all

mysql>create database nagios
Creating a user

Code: Select all

mysql>CREATE USER 'nagios'@'localhost' IDENTFIED BY '[i]password[/i]'
than is updated the user with all the permissions acording the manual

Code: Select all

mysql>GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'nagios'@'localhost';
I is try to login with the new user see if its woring

Code: Select all

[root@localhost ~]# mysql -u nagios -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 46226
Server version: 5.0.54 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> 
than my next wall came :( it all went well

Code: Select all

[root@localhost db]# ./upgradedb -u nagios -p [i]PASSWORD[/i] -d mysql.sql
DBI connect('database=mysql.sql;host=localhost','nagios',...) failed: Access denied for user 'nagios'@'localhost' (using password: YES) at ./upgradedb line 41
when i try to loging with the nagios username an password in mysql than is all ok no error. wy does it give an error?
econ
Posts: 11
Joined: Fri Nov 16, 2007 7:20 pm

Post by econ »

Palermo wrote:All progress goes with litle steps sometime ;-)

Code: Select all

[root@localhost db]# ./upgradedb -u nagios -p [i]PASSWORD[/i] -d mysql.sql
DBI connect('database=mysql.sql;host=localhost','nagios',...) failed: Access denied for user 'nagios'@'localhost' (using password: YES) at ./upgradedb line 41
when i try to loging with the nagios username an password in mysql than is all ok no error. wy does it give an error?
Does your mysql user nagios have SELECT, INSERT, UPDATE and DELETE permissions? All four will be needed.
Palermo
Cacti User
Posts: 87
Joined: Thu Sep 11, 2008 11:48 pm

Post by Palermo »

Hi,

Yes the user has all the needed permissions

Code: Select all

mysql>GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'nagios'@'localhost'; 
I tested the accoud by logging in into mysql

Code: Select all

[root@localhost ~]# mysql -u nagios -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51480
Server version: 5.0.54 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> 
so the question is wy is the commando not acepting the user and password

Code: Select all

[root@localhost db]# ./upgradedb -u nagios -p [i]PASSWORD[/i] -d mysql.sql
DBI connect('database=mysql.sql;host=localhost','nagios',...) failed: Access denied for user 'nagios'@'localhost' (using password: YES) at ./upgradedb line 41 
sterpstra
Posts: 45
Joined: Tue May 27, 2008 11:48 pm
Location: So Cal
Contact:

Still have DB problems

Post by sterpstra »

I'm still having some problems getting my NPC to work. I have been following the thread for a bit and have only changed my php.ini to use 256M of memory. Other than that, everything is original configs... I get to the dashboard but it doesn't completely populate... And when I got to hosts, I get nothing. Anyone have any more ideas? Here's my config:
Cacti Version - 0.8.7b
Plugin Architecture - 2.1
Poller Type - CMD.php
Server Info - Linux 2.6.24-16-server
Web Server - Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.1 with Suhosin-Patch
PHP - 5.2.4-2ubuntu5.1
PHP Extensions - zip, xmlwriter, libxml, xml, wddx, tokenizer, sysvshm, sysvsem, sysvmsg, session, SimpleXML, sockets, soap, SPL, shmop, standard, Reflection, posix, mime_magic, mbstring, json, iconv, hash, gettext, ftp, filter, exif, dom, dba, date, ctype, calendar, bz2, bcmath, zlib, pcre, openssl, xmlreader, apache2handler, PDO, pdo_mysql, ADOdb, gd, mysql, mysqli, snmp
MySQL - 5.0.51a-3ubuntu5.1
RRDTool - 1.2.19
SNMP - 5.4.1
Plugins
  • Thresholds (thold - v0.3.9)
    SuperLinks (superlinks - v0.72)
    Network Tools (tools - v0.3)
    Network Discovery (discovery - v0.8.4)
    Device Monitoring (monitor - v0.8.2)
    PHP Network Weathermap (weathermap - v0.95b)
    Realtime for Cacti (realtime - v0.34)
    Cacti-ReportIt (reportit - v0.6.1)
    Global Plugin Settings (settings - v0.5)
    Nagios plugin for Cacti (npc - v2.0.0b)
    PHP Network Managing (PHP Network Managing - v0.6)
    Syslog Monitoring (syslog - v0.5.2)
    Host Info (hostinfo - v0.2)
    Device Tracking (mactrack - v1.1)
Palermo
Cacti User
Posts: 87
Joined: Thu Sep 11, 2008 11:48 pm

Post by Palermo »

@ econ
I got it working.
Again i flowed the NDOUTILS install.txt can be found in de default folder of ndoutils-1.4b7 an follow also i flowed the http://trac2.assembla.com/npc/wiki/QuickStartGuide that should work

however i have a deferent problem.
When i start nagios an look at the log

Code: Select all

[09-23-2008 15:00:42] ndomod: Error writing to data sink! Some output may get lost...
Informational Message[09-23-2008 15:00:42] ndomod: Successfully flushed 79 queued items to data sink.
Informational Message[09-23-2008 15:00:42] ndomod: Successfully reconnected to data sink! 0 items lost, 79 queued items to flush.
Informational Message[09-23-2008 15:00:26] ndomod: Error writing to data sink! Some output may get lost...
Informational Message[09-23-2008 15:00:26] ndomod: Successfully flushed 86 queued items to data sink.
the log is full of it.

Also i don't have nothing in the MySQL tables.
I check t the user name and password

Code: Select all

mysql> select * from npc_hosts;
Empty set (0.00 sec)

mysql> 
The user name has all permissions to do anything.

I check t an compared the files witch has been posted bij divagater
All seems to be good.

padawan had the same problem and had found a ndo.sock file witch i don't have..

Have any idea ???

attach the config files witch i use..

hope someone can help me
Attachments
ndo2db.txt
(3.93 KiB) Downloaded 305 times
ndomod.txt
(4.79 KiB) Downloaded 519 times
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests