Nagios Plugin for Cacti (NPC) 2.0.4

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
colejv
Posts: 46
Joined: Wed Mar 19, 2008 10:50 am

Post by colejv »

I can confirm in mysql that the npc_hosts table is populated with 159 rows.
I had the same results initially, it was because freebsd does not add pdo_mysql by default. To check for pdo_mysql create a phpinfo() file like phpinfo.php

Code: Select all

<?php
phpinfo();
?>
Then either navigate to it in the browser and look for PDO drivers or from the cli

Code: Select all

nagios1# php phpinfo.php | grep mysql
PDO drivers => sqlite, mysql
pdo_mysql
** output edited for clarity

The hostinfo plugin works pretty well too
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.8 (FreeBSD) mod_ssl/2.2.8 OpenSSL/0.9.7e-p1 DAV/2 PHP/5.2.5 with Suhosin-Patch
PHP - 5.2.5
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, gd
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)
    SuperLinks (superlinks - v0.72)
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

sonartribe wrote:I've updated php to 5.2.5 and it's fixed the original problem in controller.php, but still having problems with the hosts and service grids not showing anything, even though the hostgroups grids are showing data.

I can confirm in mysql that the npc_hosts table is populated with 159 rows.
sonartribe, I am grabbing suse 10.2 now so I can setup a vm to test with. I will verify compatibility and if it goes well then I can focus on exactly what might be causing you trouble.

One thing you could try is to tail the apache error log and then click Hosts link in the left tree menu. This will open a paging grid of your hosts. Watch the logs for any errors. There should not be any errors or warnings.

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

Post by divagater »

sonartribe, I am grabbing suse 10.2 now so I can setup a vm to test with. I will verify compatibility and if it goes well then I can focus on exactly what might be causing you trouble.
I verified that NPC works just fine with Suse 10.2 once upgrading to the latest available PHP version. The json module that ships with the defaul php-5.2.0 is bugged and will not work. I installed a minimal Suse 10.2 and addded yum. From there I did a yum update php5 and ended up with the following php components installed:

php5-json-5.2.5-18.1
apache2-mod_php5-5.2.5-18.1
php5-5.2.5-18.1
php5-tokenizer-5.2.5-18.1
php5-iconv-5.2.5-18.1
php5-dom-5.2.5-18.1
php5-ctype-5.2.5-18.1
php5-pdo-5.2.5-18.1
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

Post by sonartribe »

Thanks for your efforts in trying to resolve this.

I've checked that I have the necessary pdo_mysql running

PDO support => enabled
PDO drivers => mysql, sqlite, sqlite2
pdo_mysql
PDO Driver for MySQL, client library version => 5.0.26
pdo_sqlite
PDO Driver for SQLite 3.x => enabled
PECL Module version => 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6.2.2 2007/03/23 14:30:00 wez Exp $

Also I have tried tailing the apache error log when clicking the hosts, and nothing appears.

The only thing I can think of is some kind of permissions problem on mysql. I know it can read some bits from the db because the hostgroup bits work.

Does the php write a temporary file somewhere in the filesystem which migh be failing?

Is there any easy way to have some debug running either on php or on the queries entering the db?

One other bug I have found is when I try double clicking on a hostgroup in the hostgroup: host status portlet. Firefox shows the error "npc.hostGroupGrid is not a function".

Regards
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

another update

Post by sonartribe »

Okay, I think the ndo2db or ndomod isn't working properly.

When I set config_output_options=3 in ndomod.cfg I get stuff populated in the db and my hostgroups etc work. When I set this to 2, nothing gets populated in the npc_hosts, npc_groups, npc_hostgroups etc but I can see from the ndo2db.debug file that its updating npc_hostatus, npc_hostchecks, npc_timedevents, npc_timedevenqueue etc.

I have snooped on the tcp port for the ndomod and I can see it's flushing things all the time into the socket, and the ndo2db.debug files show that its dumping loads of data into teh db, but not all the tables.

Recompiling ndomod and ndo2db didnt seem to help things.

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

Post by divagater »

Also I have tried tailing the apache error log when clicking the hosts, and nothing appears.
So we know there is not a PHP issue.
Does the php write a temporary file somewhere in the filesystem which migh be failing?
The only temp file that gets written is when using the host importer (N2C). It writes a cache of ip address to cacti device id's in /tmp
Is there any easy way to have some debug running either on php or on the queries entering the db?
There are a couple things we can do and check.

You indicated that you have firebug installed. Open firebug and click 'Options -> Show XMLHttpRequests'. Now click the Hosts menu item. On the bottom toolbar just left of the search is a circle icon. That is a refresh button. In firebug click clear to clean up the window. Then click the refresh icon. Now disable Show XMLHttpRequests. Click the request in firebug and it will expand. Copy and paste the post and response in a reply. I am mostly interested in response.

To observer what queries are being executed you can enable query logging in mysql. I always have this enabled while developing. edit /etc/my.cnf and add the following line under the [mysqld] section:

log=/var/lib/mysql/queries.log

Restart mysql and all queries will be logged. ndo2db causes a lot of traffic so don't leave this enabled permanently.
One other bug I have found is when I try double clicking on a hostgroup in the hostgroup: host status portlet. Firefox shows the error "npc.hostGroupGrid is not a function".
Thanks, this a real bug and I will have a fix in the next alpha release coming soon.

~Billy
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

here you go

Post by sonartribe »

Here's the output from post and response attached.

I'll try the mysql debug.

Regards[/img]
Attachments
Output from firebug
Output from firebug
post.JPG (50.81 KiB) Viewed 8294 times
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

Post by sonartribe »

And attached is the query I caught in the mysql log.

Regards

Ian
Attachments
query.txt
(3.99 KiB) Downloaded 306 times
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

Post by sonartribe »

Running the first query manually into mysql, I think I have found the problem. The query is looking for npc_hosts.config_type=1, but all my entries in npc_hosts, the config_type=0.

Regards

Ian
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

Post by sonartribe »

okay, I've worked around it. I can't find any documentation which explains what the config_type relates to, but I have got my NPC to work by modifying my controllers/hosts.php and controllers/services.php so that both searches in each which is looking for config_type=1 is now looking for config_type=0! I also found this in setup.php which I've also changed to be consistent.

:D

Thanks for your help on this divagater!

Regards

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

Post by divagater »

sonartribe wrote:okay, I've worked around it. I can't find any documentation which explains what the config_type relates to, but I have got my NPC to work by modifying my controllers/hosts.php and controllers/services.php so that both searches in each which is looking for config_type=1 is now looking for config_type=0! I also found this in setup.php which I've also changed to be consistent.
Hey Ian. good job tracking that down. Unfortunately I am not quite sure what config_type is actually for. Most of the queries that I use are modified versions that were provided with nodutils. All the queries provided with ndoutils have config_type=1.

I need to figure out in what cases config_type is something other than 1 and why. Don't want your install to break when you upgrade ;).

Cheers,
Billy
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

Post by sonartribe »

in ndo2db.h

/************* types of config data *************/
#define NDO2DB_CONFIGTYPE_ORIGINAL 0
#define NDO2DB_CONFIGTYPE_RETAINED 1

Which goes back to the earlier problem I had where I had to set
config_output_options to 1 or 3 in ndomod.cfg, ie I had to make sure that ndomod dumps the original, or original+retained into ndo, otherwise I wasn't getting any of the npc_hosts tables populated at all.

Regards

Ian
sonartribe
Posts: 25
Joined: Mon May 08, 2006 10:31 am

it's all about the nagios config

Post by sonartribe »

Divagater,

The config_type value is determined on whether you use the nagios option " retain_state_information=". I didn't....

My config had this set to 0, and ndomod.cfg config_output_options set to 1 to populate the db with the original host/service configs, and config_type gets set to 0, and had to modify the hosts.php and services.php to get it to work.

If however you set nagios to retain_state_information, then ndomod.cfg config_output_options set to 2, then ndomod populates the db with the retained data, and config_type gets set to 1.

A third option is to have ndomod.cfg config_output_options to 3, which updates both original and retained data, and have a mixture of config_types depending on whether the hosts/services are new, or were there before the last restart.

So looks like we'll either have to specify that the retain_state_information in nagios.cfg is set to 1, or modify the db queries not to be concerned about the config_type value.



Regards

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

Post by gimpel »

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.
divagater wrote:In Cacti to get a graph you need to complete 4 steps. A Data Input Method, a Data Template, a Graph Template, and lastly add the graph to a host. What I have done is automate the 1st step for you by auto creating a data input method with all the correct parameters required for Cacti to poll the perf data from NPC. The Data Template step could be automated as well but I would have to make some assumptions.
Do I understand correctly that there should be a NPC related entry in the list of Data Input Methods?

Here I got a list
Linux - Get Memory Usage Script/Command
Unix - Get Free Disk Space Script/Command
Unix - Get Load Average Script/Command
Unix - Get Logged In Users Script/Command
Unix - Get System Processes Script/Command
Unix - Get TCP Connections Script/Command
Unix - Get Web Hits Script/Command
Unix - Ping Host Script/Command
Is there something missing?
I somehow fail on seeing how to get performance data from NPC. Over to the graphs in Cacti
n2o_2k
Posts: 7
Joined: Tue Apr 08, 2008 10:18 am

Post by n2o_2k »

Thanks for the great plugin. I followed the quick start guide but I am getting this error

Code: Select all

Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in /var/www/html/plugins/npc/controllers/controller.php on line 363
There was a post earlier with the same problem and the solution was an upgrade to php 5.2.5 which I am trying to avoid unless there is no other way around.

Here is my environment:
OS: CentOS 4
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.59 (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, json, ldap, mysql, mysqli, PDO, pdo_mysql, pdo_sqlite, snmp, eAccelerator
MySQL - 5.0.58
RRDTool - 1.2.23
SNMP - 5.1.2
Plugins
  • Nagios plugin for Cacti (npc - v2.0.0a)
    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.941)
    Create Aggregate Graphs (aggregate - v0.63)
    Documents (docs - v0.1)
    report it! (report it! - v0.5.0)
# rpm -qa | grep php
php-common-5.1.6-3.el4s1.8
php-gd-5.1.6-3.el4s1.8
php-mysql-5.1.6-3.el4s1.8
php-eaccelerator-5.1.6_0.9.5-1.el4.centos
php-pear-1.4.11-1.el4s1.1
php-devel-5.1.6-3.el4s1.8
php-cli-5.1.6-3.el4s1.8
php-pdo-5.1.6-3.el4s1.8
php-5.1.6-3.el4s1.8
php-ldap-5.1.6-3.el4s1.8
php-snmp-5.1.6-3.el4s1.8
php-json-5.1.6_1.2.1-1.aurore
Any inputs on what can be wrong ?
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests