Nagios Plugin for Cacti (NPC) 2.0.4

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
juangose
Posts: 12
Joined: Thu Jul 07, 2005 2:15 pm

Post by juangose »

I use your installer for windows, the last version and I installed the NCP and I have the NCP tab but i cant add the host to the plugins. I have the following in the attachment
Attachments
host.JPG
host.JPG (162.47 KiB) Viewed 8583 times
Nagios.JPG
Nagios.JPG (121.99 KiB) Viewed 8583 times
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

juangose wrote:I use your installer for windows, the last version and I installed the NCP and I have the NCP tab but i cant add the host to the plugins. I have the following in the attachment
Please install the latest NPC 2.0.4. What you have there is an earlier version.

Being on windows does not change the requirements. There is a bunch of back and forth with another windows user on this thread: http://forums.cacti.net/about33082-15.html

Look for the posts from linebacker2. Essentially, his issue and probably your issue is that you do not have php-pdo and php-json support installed. Read through that thread, verify you have the correct modules installed, verify you have data in the npc_* tables etc.

Cheers,
Billy
Last edited by divagater on Wed Jul 15, 2009 1:44 pm, edited 1 time in total.
[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]
MickeeRascal
Posts: 13
Joined: Tue Apr 21, 2009 8:43 am

Post by MickeeRascal »

Platform: Centos OS
PHP 5.2.9
json version 1.2.1
PDO
Apache

I had a working version of NPC (2.0.0b) on Cacti 0.8.7d.

Today I upgraded to Cacti 0.8.7e and NPC (2.0.4).

I assume I need to run the command to upgrade the current database schema - which gives me this error:
ERROR 1061 (42000) at line 2: Duplicate key name 'idx1'

However, I assume that is a red herring.

Im not getting any hosts/services etc on the NPC plugin screen (just empty data) although the ndo2db.debug file is showing that the DB is being updated.

The httpd error log doesn't show a lot although the following line appears frequently:
[Wed Jul 15 12:34:18 2009] [error] [client x.x.x.x] PHP Notice: Undefined offset: 0 in /var/www/cacti/plugins/npc/controllers/nagios.php on line 111, referer: /cacti/plugins/npc/npc.php?module=layout&action=drawLayout
Which relates to:
Line 111:
$results[0]['program_version'] = $version[0]['program_version'];
Any ideas how to troubleshoot?
Last edited by MickeeRascal on Wed Jul 15, 2009 9:24 am, edited 3 times in total.
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

Chrysalis wrote:cacti database has npc_ tables which seem to be filled with data correctly.

Now when I view the npc tab in cacti I get the spinning circles whilst it tries to fetch data, the nagios status in the top left has all green boxes.

The 2 hostgroup boxes bottom right host status and service status show correct stats.

However the first 4 boxes are all 0s and and my host status summary and service status summary at the top are all 0s.
Coud you send a screenshot? Also, while tailing your apache error logs (not the access logs) click the npc tab and what for any errors especially of the fatal type. Notices can be ignored.

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]
MickeeRascal
Posts: 13
Joined: Tue Apr 21, 2009 8:43 am

Post by MickeeRascal »

MickeeRascal wrote:Platform: Centos OS
PHP 5.2.9
json version 1.2.1
PDO
Apache

I had a working version of NPC (2.0.0b) on Cacti 0.8.7d.

Today I upgraded to Cacti 0.8.7e and NPC (2.0.4).

I assume I need to run the command to upgrade the current database schema - which gives me this error:
ERROR 1061 (42000) at line 2: Duplicate key name 'idx1'

However, I assume that is a red herring.

Im not getting any hosts/services etc on the NPC plugin screen (just empty data) although the ndo2db.debug file is showing that the DB is being updated.

The httpd error log doesn't show a lot although the following line appears frequently:
[Wed Jul 15 12:34:18 2009] [error] [client x.x.x.x] PHP Notice: Undefined offset: 0 in /var/www/cacti/plugins/npc/controllers/nagios.php on line 111, referer: /cacti/plugins/npc/npc.php?module=layout&action=drawLayout
Which relates to:
Line 111:
$results[0]['program_version'] = $version[0]['program_version'];
Any ideas how to troubleshoot?
Problem solved.

I ended up just rebooting the system as a last resort and that seemed to fix most of the problems.

The Hostgroup: Service Status and Hosgroup: Host Status etc seem to be populating now. However, the Host Status Summary and Service Status Summary at the top are just showing zeros.

Edit: In fact it is showing "no hosts" in the Hosts->Hosts tree but "hostgroup Overview" lists them correctly. Weird.

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

Post by divagater »

MickeeRascal wrote:Problem solved.

I ended up just rebooting the system as a last resort and that seemed to fix most of the problems.

The Hostgroup: Service Status and Hosgroup: Host Status etc seem to be populating now. However, the Host Status Summary and Service Status Summary at the top are just showing zeros.

Edit: In fact it is showing "no hosts" in the Hosts->Hosts tree but "hostgroup Overview" lists them correctly. Weird.

Any ideas?

Yeah, that is very strange. Typically I would expect all or nothing. Do this for me. First, do a 'SELECT count(*) from npc_hosts'. Verify you have at least 1. The hit this URL:

http://Your_cacti_site/plugins/npc/npc.php?module=hosts&action=getHosts&p_state=any

That should return what looks like a bunch of text. Its actually the json response that populates the hosts grid.

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]
MickeeRascal
Posts: 13
Joined: Tue Apr 21, 2009 8:43 am

Post by MickeeRascal »

divagater wrote:
MickeeRascal wrote:Problem solved.

I ended up just rebooting the system as a last resort and that seemed to fix most of the problems.

The Hostgroup: Service Status and Hosgroup: Host Status etc seem to be populating now. However, the Host Status Summary and Service Status Summary at the top are just showing zeros.

Edit: In fact it is showing "no hosts" in the Hosts->Hosts tree but "hostgroup Overview" lists them correctly. Weird.

Any ideas?

Yeah, that is very strange. Typically I would expect all or nothing. Do this for me. First, do a 'SELECT count(*) from npc_hosts'. Verify you have at least 1. The hit this URL:

http://Your_cacti_site/plugins/npc/npc.php?module=hosts&action=getHosts&p_state=any

That should return what looks like a bunch of text. Its actually the json response that populates the hosts grid.

Billy
Hi Billy,

Thanks for the quick response.
mysql> select count(*) from npc_hosts;
+----------+
| count(*) |
+----------+
| 89 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from npc_services;
+----------+
| count(*) |
+----------+
| 232 |
+----------+
1 row in set (0.00 sec)
http://Your_cacti_site/plugins/npc/npc.php?module=hosts&action=getHosts&p_state=any - Output:
{"response":{"value":{"items":[],"total_count":0,"version":1}}}
Thanks for your time.
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

MickeeRascal wrote:Hi Billy,

Thanks for the quick response.
mysql> select count(*) from npc_hosts;
+----------+
| count(*) |
+----------+
| 89 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from npc_services;
+----------+
| count(*) |
+----------+
| 232 |
+----------+
1 row in set (0.00 sec)
http://Your_cacti_site/plugins/npc/npc.php?module=hosts&action=getHosts&p_state=any - Output:
{"response":{"value":{"items":[],"total_count":0,"version":1}}}
Thanks for your time.
Run this query for me. You don't have to send the output just let me know if it returns anything.

Code: Select all

SELECT   n.hoststatus_id                 AS n__hoststatus_id,
         n.instance_id                   AS n__instance_id,
         n.host_object_id                AS n__host_object_id,
         n.status_update_time            AS n__status_update_time,
         n.OUTPUT                        AS n__output,
         n.perfdata                      AS n__perfdata,
         n.current_state                 AS n__current_state,
         n.has_been_checked              AS n__has_been_checked,
         n.should_be_scheduled           AS n__should_be_scheduled,
         n.current_check_attempt         AS n__current_check_attempt,
         n.max_check_attempts            AS n__max_check_attempts,
         n.last_check                    AS n__last_check,
         n.next_check                    AS n__next_check,
         n.check_type                    AS n__check_type,
         n.last_state_change             AS n__last_state_change,
         n.last_hard_state_change        AS n__last_hard_state_change,
         n.last_hard_state               AS n__last_hard_state,
         n.last_time_up                  AS n__last_time_up,
         n.last_time_down                AS n__last_time_down,
         n.last_time_unreachable         AS n__last_time_unreachable,
         n.state_type                    AS n__state_type,
         n.last_notification             AS n__last_notification,
         n.next_notification             AS n__next_notification,
         n.no_more_notifications         AS n__no_more_notifications,
         n.notifications_enabled         AS n__notifications_enabled,
         n.problem_has_been_acknowledged AS n__problem_has_been_acknowledged,
         n.acknowledgement_type          AS n__acknowledgement_type,
         n.current_notification_number   AS n__current_notification_number,
         n.passive_checks_enabled        AS n__passive_checks_enabled,
         n.active_checks_enabled         AS n__active_checks_enabled,
         n.event_handler_enabled         AS n__event_handler_enabled,
         n.flap_detection_enabled        AS n__flap_detection_enabled,
         n.is_flapping                   AS n__is_flapping,
         n.percent_state_change          AS n__percent_state_change,
         n.latency                       AS n__latency,
         n.execution_time                AS n__execution_time,
         n.scheduled_downtime_depth      AS n__scheduled_downtime_depth,
         n.failure_prediction_enabled    AS n__failure_prediction_enabled,
         n.process_performance_data      AS n__process_performance_data,
         n.obsess_over_host              AS n__obsess_over_host,
         n.modified_host_attributes      AS n__modified_host_attributes,
         n.event_handler                 AS n__event_handler,
         n.check_command                 AS n__check_command,
         n.normal_check_interval         AS n__normal_check_interval,
         n.retry_check_interval          AS n__retry_check_interval,
         n.check_timeperiod_object_id    AS n__check_timeperiod_object_id,
         n3.host_id                      AS n3__host_id,
         n3.alias                        AS n3__alias,
         n3.address                      AS n3__address,
         n3.notes                        AS n3__notes,
         n3.notes_url                    AS n3__notes_url,
         n3.action_url                   AS n3__action_url,
         n3.icon_image                   AS n3__icon_image,
         n3.icon_image_alt               AS n3__icon_image_alt,
         n4.instance_id                  AS n4__instance_id,
         n4.instance_name                AS n4__instance_name,
         n5.service_id                   AS n5__service_id,
         n5.service_object_id            AS n5__service_object_id,
         n5.display_name                 AS n5__display_name,
         n6.host_graph_id                AS n6__host_graph_id,
         n6.local_graph_id               AS n6__local_graph_id,
         n2.name1                        AS n2__0
FROM     npc_hoststatus n
         LEFT JOIN npc_objects n2
           ON n.host_object_id = n2.object_id
         LEFT JOIN npc_hosts n3
           ON n.host_object_id = n3.host_object_id
         LEFT JOIN npc_instances n4
           ON n.instance_id = n4.instance_id
         LEFT JOIN npc_services n5
           ON n.host_object_id = n5.host_object_id
         LEFT JOIN npc_host_graphs n6
           ON n.host_object_id = n6.host_object_id
WHERE    (n.current_state IN (0,1,2,3,-1)
          AND n3.config_type = 1)
ORDER BY n4.instance_name ASC,
         n2__0 ASC
LIMIT 1 \G

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]
MickeeRascal
Posts: 13
Joined: Tue Apr 21, 2009 8:43 am

Post by MickeeRascal »

Billy,

Yes. It successfully returns a recordset.

1 row in set (0.01 sec)
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

MickeeRascal wrote:Billy,

Yes. It successfully returns a recordset.

1 row in set (0.01 sec)
Ok, so the query you ran is the query that gets generated by the ORM. But I generated the query you just ran by hand on my system. So either your query is not getting generated or the generated query has an error on your system and is not returning any results.

Try this for me. Edit /plugins/npc/controllers/hosts.php and add the following lines starting at roughly line 212:

Here is the section of code I want you to edit:

Code: Select all

        $hosts = $q->execute(array(), Doctrine::HYDRATE_ARRAY);

        // Set the total number of records
        $this->numRecords = $q->getNumResults();

        return($hosts);
And here is the replacement code:

Code: Select all

        $hosts = $q->execute(array(), Doctrine::HYDRATE_ARRAY);
        print_r($q->getQuery());
        exit;

        // Set the total number of records
        $this->numRecords = $q->getNumResults();

        return($hosts);
So we just added 2 lines there. Now go back to:

http://Your_cacti_site/plugins/npc/npc.php?module=hosts&action=getHosts&p_state=any

There should be a ton of debug output on the screen. If you get the output the generated query is in there a few lines down from the top and starts with SELECT and ends with ASC.

I am positive there is an issue here because the json response you sent me ({"response":{"value":{"items":[],"total_count":0,"version":1}}}) populates the total_count value from the results of the query. Send me the generated query and run it manually or if you don't get any output let me know.

Remove the 2 lines we added after you are done. Now click on the NPC tab and grab a screen shot. Post that here.

Thanks,
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]
MickeeRascal
Posts: 13
Joined: Tue Apr 21, 2009 8:43 am

Post by MickeeRascal »

Billy,

The query is:

Code: Select all

SELECT n.hoststatus_id AS n__hoststatus_id, n.instance_id AS n__instance_id, n.host_object_id AS n__host_object_id, n.status_update_time AS n__status_update_time, n.output AS n__output, n.perfdata AS n__perfdata, n.current_state AS n__current_state, n.has_been_checked AS n__has_been_checked, n.should_be_scheduled AS n__should_be_scheduled, n.current_check_attempt AS n__current_check_attempt, n.max_check_attempts AS n__max_check_attempts, n.last_check AS n__last_check, n.next_check AS n__next_check, n.check_type AS n__check_type, n.last_state_change AS n__last_state_change, n.last_hard_state_change AS n__last_hard_state_change, n.last_hard_state AS n__last_hard_state, n.last_time_up AS n__last_time_up, n.last_time_down AS n__last_time_down, n.last_time_unreachable AS n__last_time_unreachable, n.state_type AS n__state_type, n.last_notification AS n__last_notification, n.next_notification AS n__next_notification, n.no_more_notifications AS n__no_more_notifications, n.notifications_enabled AS n__notifications_enabled, n.problem_has_been_acknowledged AS n__problem_has_been_acknowledged, n.acknowledgement_type AS n__acknowledgement_type, n.current_notification_number AS n__current_notification_number, n.passive_checks_enabled AS n__passive_checks_enabled, n.active_checks_enabled AS n__active_checks_enabled, n.event_handler_enabled AS n__event_handler_enabled, n.flap_detection_enabled AS n__flap_detection_enabled, n.is_flapping AS n__is_flapping, n.percent_state_change AS n__percent_state_change, n.latency AS n__latency, n.execution_time AS n__execution_time, n.scheduled_downtime_depth AS n__scheduled_downtime_depth, n.failure_prediction_enabled AS n__failure_prediction_enabled, n.process_performance_data AS n__process_performance_data, n.obsess_over_host AS n__obsess_over_host, n.modified_host_attributes AS n__modified_host_attributes, n.event_handler AS n__event_handler, n.check_command AS n__check_command, n.normal_check_interval AS n__normal_check_interval, n.retry_check_interval AS n__retry_check_interval, n.check_timeperiod_object_id AS n__check_timeperiod_object_id, n3.host_id AS n3__host_id, n3.alias AS n3__alias, n3.address AS n3__address, n3.notes AS n3__notes, n3.notes_url AS n3__notes_url, n3.action_url AS n3__action_url, n3.icon_image AS n3__icon_image, n3.icon_image_alt AS n3__icon_image_alt, n4.instance_id AS n4__instance_id, n4.instance_name AS n4__instance_name, n5.service_id AS n5__service_id, n5.service_object_id AS n5__service_object_id, n5.display_name AS n5__display_name, n6.host_graph_id AS n6__host_graph_id, n6.local_graph_id AS n6__local_graph_id, n2.name1 AS n2__0 FROM npc_hoststatus n LEFT JOIN npc_objects n2 ON n.host_object_id = n2.object_id LEFT JOIN npc_hosts n3 ON n.host_object_id = n3.host_object_id LEFT JOIN npc_instances n4 ON n.instance_id = n4.instance_id LEFT JOIN npc_services n5 ON n.host_object_id = n5.host_object_id LEFT JOIN npc_host_graphs n6 ON n.host_object_id = n6.host_object_id WHERE (n.current_state in (0, 1, 2, 3, -1) AND n3.config_type = 0) ORDER BY n4.instance_name ASC, n2__0 ASC
This returns:
Empty set (0.01 sec)
Let me know if you need any further info/screen shots.

Thanks
Attachments
Picture 1.png
Picture 1.png (135.17 KiB) Viewed 8362 times
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

Goto Console -> Settings -> NPC. Look at the 'Host/Service Config Type' option. It exactly describes your problem. Mine is set to one and the query I sent you had config_type = 1 which worked for you. Your query has config_type = 0 which isn't working. Change that option to 1 and you will be all set.

Its been so long since I have seen the issue I forgot about it. Time to add a faq entry.

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]
MickeeRascal
Posts: 13
Joined: Tue Apr 21, 2009 8:43 am

Post by MickeeRascal »

Thanks Billy.

Top work. Great plugin.

Cheers
Bryant
Posts: 4
Joined: Wed May 30, 2007 12:02 pm

Post by Bryant »

Loving the plugin -- easy to set up, very clear instructions, and so on. Thanks!

I have two questions about fairly minor issues.

1. I'm also getting the PHP error: "PHP Notice: Undefined index: action in /var/www/cacti/plugins/npc/top_graph_header.php on line 95, referer: http://192.168.80.128/cacti/plugins/npc/npc.php"

Looking at the code, it's pretty clear that it's just expecting $_REQUEST['action'] to be set, and since it isn't always set we get errors. I'm just going to add isset($_REQUEST['action']) to the if clauses -- let me know if you want me to send you a patch, although it's a pretty trivial tweak. (I know the error doesn't hurt anything, I just hate cruft in my logs.)

2. I'm running Firefox 3.0.11. When I collapse a portlet, the uncollapse button fails to work until I reload the page. Once I reload the page, I can uncollapse and recollapse the portlet, but then it gets stuck again.

This is a very, very minor problem -- I don't tend to collapse portlets anyhow. Just thought you might like to know.

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

Post by divagater »

Bryant wrote:Loving the plugin -- easy to set up, very clear instructions, and so on. Thanks!

I have two questions about fairly minor issues.

1. I'm also getting the PHP error: "PHP Notice: Undefined index: action in /var/www/cacti/plugins/npc/top_graph_header.php on line 95, referer: http://192.168.80.128/cacti/plugins/npc/npc.php"

Looking at the code, it's pretty clear that it's just expecting $_REQUEST['action'] to be set, and since it isn't always set we get errors. I'm just going to add isset($_REQUEST['action']) to the if clauses -- let me know if you want me to send you a patch, although it's a pretty trivial tweak. (I know the error doesn't hurt anything, I just hate cruft in my logs.)

2. I'm running Firefox 3.0.11. When I collapse a portlet, the uncollapse button fails to work until I reload the page. Once I reload the page, I can uncollapse and recollapse the portlet, but then it gets stuck again.

This is a very, very minor problem -- I don't tend to collapse portlets anyhow. Just thought you might like to know.

Thanks again for this excellent work.
1. I can make sense of what you did so I will get it patched in 2.0.5.

2. I am able to reproduce this as well. Surprised I never noticed it before :) This "should" be a trivial fix as well and I will bug it to 2.0.5

Thanks a lot for the feed back.

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]
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests