Nagios Plugin for Cacti (NPC) 2.0.4

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
Dag
Posts: 4
Joined: Sun Mar 09, 2008 9:00 am
Location: Stockholm, Sweden

Post by Dag »

I'm wondering if it's possible to select multiple services to add
Data Input Method for all of them at once? Like you do for the hosts. It's kind of annoying to add Data Input Methods for 280 services manually.
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

Dag wrote:I'm wondering if it's possible to select multiple services to add
Data Input Method for all of them at once? Like you do for the hosts. It's kind of annoying to add Data Input Methods for 280 services manually.
That is annoying. The add data input mechanism was not meant to be a mass import and it was sort of added last minute as a "hey, this may be cool." I was never really sure how much people used or liked it. Ideally I wanted an import/export mechanism i.e. cacti <-> nagios so folks could move in either direction. That would be complicated and I didn't want to put the time into it unless it would be usefull for many.

I just started working on a new release (no dates yet). There are a few performance issues in the current version I need to fix for folks monitoring thousands of devices and I have a few new feature ideas. I may start another post to solicit input on features people are looking for but for now I people can feel free to post comments in this thread.

Cheers,
Billy
shadhin71
Posts: 1
Joined: Fri Nov 07, 2008 3:12 pm

Newbie question

Post by shadhin71 »

First excuse my ignorance. I am just trying to understand this. As far as I know cacti is built upon RRD not traditional database. However ndo2db is a traditional database concept. So are we able to achieve functionality of traditional database using NPC out of cacti? What I am trying to say ...using NPC can I look at a graph and then drill down for same service checks for last year some time frame. Please reply or request additional explanation of my question if needed.
jmain
Posts: 1
Joined: Fri Nov 28, 2008 9:15 pm
Location: Toronto, Canada

Using NPC and NagVis with the same Nagios instance

Post by jmain »

I was able to get NDOUtils to work with NPC or NagVis but with multiple broker_module lines enabled in the nagios.cfg only the first entry would update.

Having tried for a couple of days to get this working with no success, I decided to tackle it from the other direction. After some trial-and-error I discovered that I could configure NagVis to use the same tables in the Cacti database that NPC creates.

I started by configuring NDOUtils to work with NPC and update the Cacti database. After that was working reliably, I took a look at the nagvis.ini.php file and updated the NDO-Backend section as below:

Code: Select all

; options for the NDO-Backend
; in this example the ID of the Backend is "ndomy_1" you can define another ID.
[backend_ndomy_1]
; type of backend - MUST be set
backendtype="ndomy"
; hostname for NDO-db
dbhost="localhost"
; portname for NDO-db
dbport=3306
; database-name for NDO-db
dbname="cacti"
; username for NDO-db
;dbuser="root"
; password for NDO-db
;dbpass=""
; prefix for tables in NDO-db
dbprefix="npc_"
; instace-name for tables in NDO-db
dbinstancename="default"
; maximum delay of the NDO Database in Seconds
maxtimewithoutupdate=180
; path to the cgi-bin of this backend
htmlcgi="/nagios/cgi-bin"
Basically, I uncommented everything except for the dbuser and dbpass fields and updated the rest to point to the Cacti database using the npc_ prefix instead of nagios_ for the tables. The last step was to grant my nagios account select privilege on the cacti tables.

Code: Select all

mysql>  grant select on cacti.* to 'nagios'@'localhost' identified by 'password';
That's it. After a restarting NDOUtils and Nagios I was able to view my NagVis maps in Nagios and the NPC pages in Cacti.

This should be stable and reliable until an new version of NDOUtils is released since that is the only way the table structure would change. The NagVis documentation states that it only needs read access to these tables, so it shouldn't cause any conflicts with either Cacti or NPC. At least none that I have seen so far.

Hopefully this will help prevent somebody else from banging their head against the wall for as long as I did. :)

System Configuration:
  • Fedora Core 9
    Nagios 3.0.5
    • Nagios Plug-ins 1.4.13
      NDOUtil 1.4b7
      NagVis 1.2.3
      PNP4Nagios 0.4.12
    Cacti 0.8.7b
    • Plug-In Arch 2.1
      NPC 2.0.0b166
      Weathermap 0.95b
      Thold 0.3.9
Good Luck,
Jim
stevetuk31
Posts: 10
Joined: Mon Jul 16, 2007 10:57 am

Error: Save Failed.

Post by stevetuk31 »

Hi,

NPC is working just great. However, in order to add a new device in Cacti I need to disable the NPC plugin. I get the following error, if i dont disable the plugin:

Error: Save Failed.

Can anyone shed any light?

Thanks
Steve
vietcgi
Posts: 1
Joined: Sat Nov 08, 2008 5:27 am

Post by vietcgi »

never mind
sterpstra
Posts: 45
Joined: Tue May 27, 2008 11:48 pm
Location: So Cal
Contact:

Post by sterpstra »

I'm revisiting this issue in hopes I can get it resolved once and for all... I have NPC [partially] working. The database appears to be updating and staying in sync without issue. Problem is, when I try to use the actual plugin, I get really weird results, including a huge resource spike...

- Service problems show up on the dashboard but hostgroups do not.
- I click on any of the navigation options and nothing comes up. There are also no queries being executed. ex. I click on "Hosts" and, after about 15 seconds, the following query appears:
2979954 | cacti | localhost | cacti | Query | 15 | Sending data | SELECT COUNT(DISTINCT n.logentry_id) AS num_results FROM npc_logentries n LEFT JOIN npc_instances n2

These are a few other long processes I've captured running on MYSQL.
2979631 | cacti | localhost | cacti | Query | 97 | Sorting result | SELECT n.servicegroup_id AS n__servicegroup_id, n.instance_id AS n__instance_id, n.config_type AS n_


2979801 | cacti | localhost | cacti | Query | 24 | Copying to tmp table on disk | SELECT n.servicegroup_id AS n__servicegroup_id, n.instance_id AS n__instance_id, n.config_type AS n_

HELP!!! I LOVE this plugin but can't get it working correctly...
Cacti Version - 0.8.7b
Plugin Architecture - 2.1
Poller Type - CMD.php
Server Info - Linux 2.6.24-16-server
Web Server - Apache
PHP - 5.2.4-2ubuntu5.3
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, imap, ADOdb, gd, mssql, mysql, mysqli, pdo_dblib, snmp, Zend Optimizer
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)
    Host Info (hostinfo - v0.2)
    Device Tracking (mactrack - v1.1)
    NTop Viewer (ntop - v0.1)
    Router Configs (routerconfigs - v0.1)
    Login Page Mod (loginmod - v1.0)
ashaugh
Posts: 1
Joined: Wed Jan 07, 2009 3:52 pm

Post by ashaugh »

sterpstra wrote:I'm revisiting this issue in hopes I can get it resolved once and for all... I have NPC [partially] working. The database appears to be updating and staying in sync without issue. Problem is, when I try to use the actual plugin, I get really weird results, including a huge resource spike...

- Service problems show up on the dashboard but hostgroups do not.
- I click on any of the navigation options and nothing comes up. There are also no queries being executed. ex. I click on "Hosts" and, after about 15 seconds, the following query appears:
2979954 | cacti | localhost | cacti | Query | 15 | Sending data | SELECT COUNT(DISTINCT n.logentry_id) AS num_results FROM npc_logentries n LEFT JOIN npc_instances n2

These are a few other long processes I've captured running on MYSQL.
2979631 | cacti | localhost | cacti | Query | 97 | Sorting result | SELECT n.servicegroup_id AS n__servicegroup_id, n.instance_id AS n__instance_id, n.config_type AS n_


2979801 | cacti | localhost | cacti | Query | 24 | Copying to tmp table on disk | SELECT n.servicegroup_id AS n__servicegroup_id, n.instance_id AS n__instance_id, n.config_type AS n_

HELP!!! I LOVE this plugin but can't get it working correctly...
Aside from the strange errors, this is my exact situation. I had NPC running like a clock before I updated to Ubuntu 8.10, but now I only have a partially filled Dashboard with absolutely nothing in my Hosts, Host Problems, Services, or Service Problems.

On the bright side, my Hostgroup Overview and Grid work perfectly, as does my Status Map.

Anything you can offer would make me happy.


EDIT - SOLVED - I adjusted my memory_limit in /etc/php5/apache2/php.ini to 64MB. Afterwards I changed my config_output_options in my NDOMOD.cfg file back to 2. Then I reloaded both NDO2db and Nagios and VIOLA it worked.

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

Post by divagater »

I will be tackling some performance issue in the next few releases. If you have a large Nagios installation please help test some of the updates. There is a link to the latest code in the first post.

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

Build 182 is available

Post by divagater »

Details are in the first post.

Cheers,
Billy
dhink
Posts: 3
Joined: Tue Mar 03, 2009 6:46 pm

NPC displaying an Empty Page

Post by dhink »

Hi,
I'm running into an issue with NPC. It is currently displaying a blank page when I click on the npc Tab.

It then generates an error inside /var/log/httpd/error.log

PHP Fatal error: Uncaught exception 'Doctrine_Manager_Exception' with message 'Empty data source name' in /var/www/cacti/plugins/npc/lib/Doctrine/Manager.php:383\nStack trace:\n#0 /var/www/cacti/plugins/npc/lib/Doctrine/Manager.php(277): Doctrine_Manager->parseDsn('mysql://'cactiu...')\n#1 /var/www/cacti/plugins/npc/lib/Doctrine/Manager.php(237): Doctrine_Manager->openConnection('mysql://'cactiu...', NULL)\n#2 /var/www/cacti/plugins/npc/config.php(14): Doctrine_Manager::connection('mysql://'cactiu...')\n#3 /var/www/cacti/plugins/npc/npc.php(23): include('/var/www/cacti/...')\n#4 {main}\n thrown in /var/www/cacti/plugins/npc/lib/Doctrine/Manager.php on line 383

I'm currently running:
Centos 5x (x86_64)
Cacti 0.8.7d
Nagios 3.0.6
npc-2.0.0b.166
ndoutils-1.4b7
cacti-plugin-0.8.7d-PA-v2.4

Installed Packages PHP packages:

php-mysql-5.1.6-20.el5_2.1
php-common-5.1.6-20.el5_2.1
php-5.1.6-20.el5_2.1
php-cli-5.1.6-20.el5_2.1
php-pear-1.4.9-4.el5.1
php-ldap-5.1.6-20.el5_2.1
php-devel-5.1.6-20.el5_2.1
php-json-5.1.6_1.2.1-1.aurore
php-snmp-5.1.6-20.el5_2.1
php-pdo-5.1.6-20.el5_2.1
php-gd-5.1.6-20.el5_2.1

Installed mysql packages

php-mysql-5.1.6-20.el5_2.1
libdbi-dbd-mysql-0.8.1a-1.2.2
mysql-5.0.45-7.el5
MySQL-python-1.2.1-1
mysql-devel-5.0.45-7.el5
mysql-connector-odbc-3.51.12-2.2
mysql-server-5.0.45-7.el5
mysql-devel-5.0.45-7.el5
perl-DBD-MySQL-3.0007-1.fc6
mysql-5.0.45-7.el5

I have 2 other plugins installed and they are working correctly. My cacti database is being populated. I'm showing 102 lines in npc_hosts.

ND02DB:

ndo2db_user=nagios
ndo2db_group=nagios
socket_type=unix
#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=cactiuser
db_pass=*********
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=/var/log/ndo2db.debug
max_debug_file_size=1000000

NDOMOD
instance_name=default
output_type=unixsocket
output=/usr/local/nagios/var/ndo.sock
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=3 (i've tried this in setting 2 and 3)

Nagios Log:

[1236124540] Nagios 3.0.6 starting... (PID=23268)
[1236124540] Local time is Tue Mar 03 15:55:40 PST 2009
[1236124540] LOG VERSION: 2.0
[1236124540] ndomod: NDOMOD 1.4b7 (10-31-2007) Copyright (c) 2005-2007 Ethan Galstad (nagios@nagios.org)
[1236124540] ndomod: Successfully connected to data sink. 0 queued items to flush.

config.php

+-------------------------------------------------------------------------+
*/

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = *********;
$database_port = "3306";

/* Default session name - Session name must contain alpha characters */
#$cacti_session_name = "Cacti";

$config['url_path'] = '/cacti/';

?>

Global.php

!!! IMPORTANT !!!

The following defaults are not to be altered. Please refer to
include/config.php for user configurable database settings.

*/

/* Default database settings*/
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";

/* Default session name - Session name must contain alpha characters */
$cacti_session_name = "Cacti";

$plugins = array();
//$plugins[] = 'thold';
$plugins[] = 'loginmod';
$plugins[] = 'npc';
$plugins[] = 'weathermap';

/* Do not edit this line */
$config = array();

/*
Edit this to point to the default URL of your Cacti install
ex: if your cacti install as at http://serverip/cacti/ this
would be set to /cacti/
*/

$config['url_path'] = "/cacti/";

define('URL_PATH', $config['url_path']);

/* Include configuration */
include(dirname(__FILE__) . "/config.php");

if (isset($config["cacti_version"])) {
die("Invalid include/config.php file detected.");
exit;
}


Finally I'm able to manage the NPC plugin in the Plugin Management section. Any help would be greatly appreciated...

I've successfully gotten NPC to work on another box in Boston and host of other plugins with a bit of work, so I'm wondering what I did wrong..

Chris
dhink
Posts: 3
Joined: Tue Mar 03, 2009 6:46 pm

Post by dhink »

I solved my own problem and it had to do with my password. I used a password that had a "/" in it and I believe the manager.php parses the dsn line from npc/config.php, which in turn is built out of include/config.php. As a result NPC choked on my secure password.

Cause:
If you use a "/" in your password it will parse the line too early causing an error to be generated since it is dealing with it as one long string rather than the individual pieces. DO NOT USE a / in your cacti mysql password and expect NPC to work. Cacti will work correctly, but manager.php will fail every time it is called to make the connection to mysql. This is something that probably belongs in the quick start guide as a check. Or a simple checker when NPC is initializing for the first time that told you that you had a incompatible password would work also, but /shrug.

If you use a ' ' as suggested in an earlier post, it will still pass the / to the $dsn string and it would not be parsed correctly when called by manager.php. A reverse split would solve the problem, coming at it from the back-end of the string after splitting at @ It might require an extra line or two code to resolve, but would solve the problem and allow the pieces to be isolated easier without creating unnecessary parsing errors.

Good luck to everyone else, hope this helps some people save some time. BTW this is a great plugin...

Chris


:D
communIT
Posts: 1
Joined: Wed Mar 18, 2009 9:22 am

Hosts, Services, Service Problems - WORKING!

Post by communIT »

Tailing the apache2 error logs for days revealed that NPC was looking for three tables:

npc_host_graphs
npc_service_graphs
npc_settings

which for some reason didn't get created during the install process. I copied the SQL code from the "setup.php", and ran the following command to create the tables ($my_npc_database == ndo):

mysql -u nagios -p ndo < npc_tables_fix.sql

And *voila*!!! Hosts appear, Services too! Service Problems are populated, and all the rich, cacti + nagios goodness I've been craving is finally mine for the asking.

What an excellent plugin, built on two of the best Open Source tools available. If this helps anyone else, that just makes it better. In any case, it revealed for me the *true* power of Open Source - you not only can find something that does most of what you *need* it to do, but you can fix what doesn't work yourself, and make a contribution.
Attachments
npc_tables_fix.sql.zip
SQL code to add missing tables to NDO2DB database for Cacti plugin NPC
(436 Bytes) Downloaded 319 times
bigrat
Posts: 13
Joined: Wed Jun 11, 2008 3:12 am

Post by bigrat »

Hi divagater
Thanks for a great cacti plugin.
However, I just see "No hosts" and "No services" when I click hosts and services tab. In mysql database, I count 155 hosts and 17 services
mysql> npc_hosts;
+----------+
| count(*) |
+----------+
| 155 |
+----------+
1 row in set (0.00 sec)

mysql> npc_services;
+----------+
| count(*) |
+----------+
| 17 |
+----------+
1 row in set (0.00 sec)

I also find this errors in /etc/httpd/logs/ssl_error_log

[Fri Mar 27 10:17:54 2009] [error] [client xxx.xxx.xx.xxx] PHP Fatal error: Uncaught exception 'Doctrine_Connection_Exception' with message 'PDO Connection Error: SQLSTATE[28000] [1045] Access denied for user 'cactiuser'@'localhost' (using password: YES)' in /usr/local/cacti-0.8.7d/plugins/npc/lib/Doctrine/Connection.php:471\nStack trace:\n#0 /usr/local/cacti-0.8.7d/plugins/npc/lib/Doctrine/Connection/Mysql.php(101): Doctrine_Connection->connect()\n#1 /usr/local/cacti-0.8.7d/plugins/npc/lib/Doctrine/Connection.php(1009): Doctrine_Connection_Mysql->connect()\n#2 /usr/local/cacti-0.8.7d/plugins/npc/lib/Doctrine/Query/Abstract.php(986): Doctrine_Connection->execute('SELECT n.servic...', Array)\n#3 /usr/local/cacti-0.8.7d/plugins/npc/lib/Doctrine/Query/Abstract.php(1030): Doctrine_Query_Abstract->_execute(Array)\n#4 /usr/local/cacti-0.8.7d/plugins/npc/controllers/servicegroups.php(327): Doctrine_Query_Abstract->execute(Array, 3)\n#5 /usr/local/cacti-0.8.7d/plugins/npc/controllers/servicegroups.php(344): NpcServicegroupsController->getServicegroups()\n#6 /usr/local/cacti-0.8.7d/plugins/npc/contro in /usr/local/cacti-0.8.7d/plugins/npc/lib/Doctrine/Connection.php on line 471, referer: https://xxx.xxx.x.x/plugins/npc/npc.php ... drawLayout

My Cacti-Nagios
Fedora Core 10 - 2.6.27.12-170.2.5.fc10.i686.PAE
Cacti-0.8.7d
PIA 2.4
Spine-0.8.7c
MySQL 5.0.67
Nagios-3.1.0
NPC-2.0.0b.182
ndoutils-1.4b7

Please help me to fix this issue

Regards,
Bigrat :)
bigrat
Posts: 13
Joined: Wed Jun 11, 2008 3:12 am

Post by bigrat »

Oooh sorry, this issue is caused by complex mysql password. I just simplify my password. It's OK now.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests