SOURCES: cacti-plugin-npc-extinfo.patch (NEW) - patch for extinfo
wolvverine
wolvverine at pld-linux.org
Tue Dec 25 06:49:37 CET 2007
Author: wolvverine Date: Tue Dec 25 05:49:37 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- patch for extinfo
---- Files affected:
SOURCES:
cacti-plugin-npc-extinfo.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/cacti-plugin-npc-extinfo.patch
diff -u /dev/null SOURCES/cacti-plugin-npc-extinfo.patch:1.1
--- /dev/null Tue Dec 25 06:49:37 2007
+++ SOURCES/cacti-plugin-npc-extinfo.patch Tue Dec 25 06:49:32 2007
@@ -0,0 +1,2949 @@
+--- npc/extinfo.php.orig 2005-10-10 14:17:15.000000000 +0000
++++ npc/extinfo.php 2006-12-26 16:32:52.000000000 +0000
+@@ -1,1473 +1,1473 @@
+-<?php
+-/*
+- +-------------------------------------------------------------------------+
+- | Nagios Plugin 0.1a for cacti 0.8.6f |
+- | Copyright (C) 2005 Billy Gunn (billy at gunn.org) |
+- | |
+- | This program is free software; you can redistribute it and/or |
+- | modify it under the terms of the GNU General Public License |
+- | as published by the Free Software Foundation; either version 2 |
+- | of the License, or (at your option) any later version. |
+- | |
+- | This program is distributed in the hope that it will be useful, |
+- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+- | GNU General Public License for more details. |
+- +-------------------------------------------------------------------------+
+- | Cacti and Nagios are the copyright of their respective owners. |
+- +-------------------------------------------------------------------------+
+-*/
+-
+-chdir('../../');
+-include_once("./include/auth.php");
+-include_once("./include/config.php");
+-
+-// Refresh the page at a user supplied interval
+-header("Refresh: " . read_config_option("npc_refresh") . "; URL=" . $_SERVER["REQUEST_URI"]);
+-
+-/* set default action */
+-if (!isset($_REQUEST["type"])) { $_REQUEST["type"] = ""; }
+-
+-switch ($_REQUEST["type"]) {
+- case '1':
+-
+- hostInfo();
+- include_once("./include/bottom_footer.php");
+- break;
+-
+- case '2':
+-
+- serviceInfo();
+- include_once("./include/bottom_footer.php");
+- break;
+-
+- default:
+-
+- hostInfo();
+- include_once("./include/bottom_footer.php");
+- break;
+-}
+-
+-
+-function formatTime($time) {
+-
+- $days = floor($time/60/60/24);
+- $time -= $days*60*60*24;
+- $hours = floor($time/60/60);
+- $time -= $hours*60*60;
+- $minutes = floor($time/60);
+- $time -= $minutes*60;
+- $seconds = $time;
+-
+- return ($days . "d " . $hours . "h " . $minutes . "m " . $seconds . "s");
+-}
+-
+-
+-function serviceInfo() {
+-
+- $hostid = $_REQUEST["hostid"];
+- $serviceid = $_REQUEST["serviceid"];
+- $hostname = $_REQUEST["hostname"];
+- $serviceName = ereg_replace("\+", " ", $_REQUEST["service"]);
+-
+-
+- if (isset($_POST["local_graph_id"])) {
+- db_execute("update npc_service set cacti_graph_id = " . $_POST["local_graph_id"] . " where id = " . $serviceid);
+- header("Location: extinfo.php?type=2&hostid=" . $hostid . "&hostname=" . $hostname . "&serviceid=" . $serviceid . "&service=" . $_REQUEST["service"]);
+- }
+-
+- include_once("top_npc_header.php");
+-
+- $background1 = "#F5F5F5";
+- $background2 = "#E7E9F2";
+- $rowColor = $background1;
+-
+- $service_detail = db_fetch_row("
+-select distinct
+- service_soft_state as 'Current Status',
+- duration as 'State Duration',
+- check_command as 'Check Command',
+- plugin_output as 'Plugin Output',
+- performance_data as 'Performance Data',
+- current_attempt as 'Current Attempt',
+- from_unixtime(last_check) as 'Last Check',
+- from_unixtime(next_check) as 'Next Check',
+- check_latency as 'Check Latency',
+- check_execute_time as 'Check Duration',
+- hostid,
+- name,
+- host_soft_state as 'Host Soft State',
+- host_notifications as 'Host Notifications',
+- service as 'Service',
+- cacti_graph_id,
+- serviceid,
+- service_hard_state,
+- service_notifications as 'Service Notifications',
+- max_attempts as 'Max Attempts'
+-from
+- (
+- select
+- npc_host.id as hostid,
+- npc_host.name,
+- npc_hostgroup_membership.groupid as hostgroup,
+- npc_host_history.soft_state as host_soft_state,
+- npc_host.notifications_enabled as host_notifications,
+- npc_service.id as serviceid,
+- npc_service.cacti_graph_id,
+- npc_service.service_description as service,
+- npc_service_history.soft_state as service_soft_state,
+- npc_service_history.hard_state as service_hard_state,
+- npc_service.notifications_enabled as service_notifications,
+- npc_service_check.last_check,
+- npc_service_check.next_check,
+- npc_service_check.check_execute_time,
+- npc_service_check.check_latency,
+- npc_service_check.check_command,
+- npc_service_check.performance_data,
+- unix_timestamp() - npc_service_history.started as duration,
+- npc_service_history.current_attempt,
+- npc_service_check.max_attempts,
+- npc_service_history.plugin_output
+- from
+- npc_host,
+- npc_host_history,
+- npc_hostgroup_membership,
+- npc_service,
+- npc_service_check,
+- npc_service_history
+- where
+- npc_host.id = npc_hostgroup_membership.hostid and
+- npc_host.id = npc_service.hostid and
+- npc_host.id = npc_host_history.hostid and
+- npc_service.id = npc_service_check.serviceid and
+- npc_service.id = npc_service_history.serviceid and
+- npc_service_history.lasted is null and
+- npc_host_history.lasted is null and
+- npc_service.configured = TRUE and
+- npc_service.has_been_checked = TRUE and
+- npc_host.has_been_checked = TRUE
+- union
+- select
+- npc_host.id as hostid,
+- npc_host.name,
+- 0 as hostgroup,
+- npc_host_history.soft_state as host_soft_state,
+- npc_host.notifications_enabled as host_notifications,
+- npc_service.id as serviceid,
+- npc_service.cacti_graph_id,
+- npc_service.service_description as service,
+- npc_service_history.soft_state as service_soft_state,
+- npc_service_history.hard_state as service_hard_state,
+- npc_service.notifications_enabled as service_notifications,
+- npc_service_check.last_check,
+- npc_service_check.next_check,
+- npc_service_check.check_execute_time,
+- npc_service_check.check_latency,
+- npc_service_check.check_command,
+- npc_service_check.performance_data,
+- unix_timestamp() - npc_service_history.started as duration,
+- npc_service_history.current_attempt,
+- npc_service_check.max_attempts,
+- npc_service_history.plugin_output
+- from
+- npc_host,
+- npc_host_history,
+- npc_service,
+- npc_service_check,
+- npc_service_history
+- where
+- npc_host.id not in (select hostid from npc_hostgroup_membership) and
+- npc_host.id = npc_service.hostid and
+- npc_host.id = npc_host_history.hostid and
+- npc_service.id = npc_service_check.serviceid and
+- npc_service.id = npc_service_history.serviceid and
+- npc_service_history.lasted is null and
+- npc_host_history.lasted is null and
+- npc_service.configured = TRUE and
+- npc_service.has_been_checked = TRUE and
+- npc_host.has_been_checked = TRUE
+- union
+- select
+- npc_host.id as hostid,
+- npc_host.name,
+- npc_hostgroup_membership.groupid as hostgroup,
+- -1 as host_soft_state,
+- npc_host.notifications_enabled as host_notifications,
+- npc_service.id as serviceid,
+- npc_service.cacti_graph_id,
+- npc_service.service_description as service,
+- npc_service_history.soft_state as service_soft_state,
+- npc_service_history.hard_state as service_hard_state,
+- npc_service.notifications_enabled as service_notifications,
+- npc_service_check.last_check,
+- npc_service_check.next_check,
+- npc_service_check.check_execute_time,
+- npc_service_check.check_latency,
+- npc_service_check.check_command,
+- npc_service_check.performance_data,
+- unix_timestamp() - npc_service_history.started as duration,
+- npc_service_history.current_attempt,
+- npc_service_check.max_attempts,
+- npc_service_history.plugin_output
+- from
+- npc_host,
+- npc_hostgroup_membership,
+- npc_service,
+- npc_service_check,
+- npc_service_history
+- where
+- npc_host.id = npc_hostgroup_membership.hostid and
+- npc_host.id = npc_service.hostid and
+- npc_service.id = npc_service_check.serviceid and
+- npc_service.id = npc_service_history.serviceid and
+- npc_service_history.lasted is null and
+- npc_service.configured = TRUE and
+- npc_service.has_been_checked = TRUE and
+- npc_host.has_been_checked = FALSE
+- union
+- select
+- npc_host.id as hostid,
+- npc_host.name,
+- 0 as hostgroup,
+- -1 as host_soft_state,
+- npc_host.notifications_enabled as host_notifications,
+- npc_service.id as serviceid,
+- npc_service.cacti_graph_id,
+- npc_service.service_description as service,
+- npc_service_history.soft_state as service_soft_state,
+- npc_service_history.hard_state as service_hard_state,
+- npc_service.notifications_enabled as service_notifications,
+- npc_service_check.last_check,
+- npc_service_check.next_check,
+- npc_service_check.check_execute_time,
+- npc_service_check.check_latency,
+- npc_service_check.check_command,
+- npc_service_check.performance_data,
+- unix_timestamp() - npc_service_history.started as duration,
+- npc_service_history.current_attempt,
+- npc_service_check.max_attempts,
+- npc_service_history.plugin_output
+- from
+- npc_host,
+- npc_service,
+- npc_service_check,
+- npc_service_history
+- where
+- npc_host.id not in (select hostid from npc_hostgroup_membership) and
+- npc_host.id = npc_service.hostid and
+- npc_service.id = npc_service_check.serviceid and
+- npc_service.id = npc_service_history.serviceid and
+- npc_service_history.lasted is null and
+- npc_service.configured = TRUE and
+- npc_service.has_been_checked = TRUE and
+- npc_host.has_been_checked = FALSE
+- union
+- select
+- npc_host.id as hostid,
+- npc_host.name,
+- npc_hostgroup_membership.groupid as hostgroup,
+- npc_host_history.soft_state as host_soft_state,
+- npc_host.notifications_enabled as host_notifications,
+- npc_service.id as serviceid,
+- npc_service.cacti_graph_id,
+- npc_service.service_description as service,
+- -1 as service_soft_state,
+- -1 as service_hard_state,
+- npc_service.notifications_enabled as service_notifications,
+- npc_service_check.last_check,
+- npc_service_check.next_check,
+- npc_service_check.check_execute_time,
+- npc_service_check.check_latency,
+- npc_service_check.check_command,
+- npc_service_check.performance_data,
+- 0 as duration,
+- 0 as current_attempt,
+- npc_service_check.max_attempts,
+- null as plugin_output
+- from
+- npc_host,
+- npc_host_history,
+- npc_hostgroup_membership,
+- npc_service,
+- npc_service_check
+- where
+- npc_host.id = npc_hostgroup_membership.hostid and
+- npc_host.id = npc_service.hostid and
+- npc_host.id = npc_host_history.hostid and
+- npc_service.id = npc_service_check.serviceid and
+- npc_host_history.lasted is null and
+- npc_service.configured = TRUE and
+- npc_service.has_been_checked = FALSE and
+- npc_host.has_been_checked = TRUE
+- union
+- select
+- npc_host.id as hostid,
+- npc_host.name,
+- 0 as hostgroup,
+- npc_host_history.soft_state as host_soft_state,
+- npc_host.notifications_enabled as host_notifications,
+- npc_service.id as serviceid,
+- npc_service.cacti_graph_id,
+- npc_service.service_description as service,
+- -1 as service_soft_state,
+- -1 as service_hard_state,
+- npc_service.notifications_enabled as service_notifications,
+- npc_service_check.last_check,
+- npc_service_check.next_check,
+- npc_service_check.check_execute_time,
+- npc_service_check.check_latency,
+- npc_service_check.check_command,
+- npc_service_check.performance_data,
+- 0 as duration,
+- 0 as current_attempt,
+- npc_service_check.max_attempts,
+- null as plugin_output
+- from
+- npc_host,
+- npc_host_history,
+- npc_service,
+- npc_service_check
+- where
+- npc_host.id not in (select hostid from npc_hostgroup_membership) and
+- npc_host.id = npc_service.hostid and
+- npc_host.id = npc_host_history.hostid and
+- npc_service.id = npc_service_check.serviceid and
+- npc_host_history.lasted is null and
+- npc_service.configured = TRUE and
+- npc_service.has_been_checked = FALSE and
+- npc_host.has_been_checked = TRUE
+- union
+- select
+- npc_host.id as hostid,
+- npc_host.name,
+- npc_hostgroup_membership.groupid as hostgroup,
+- -1 as host_soft_state,
+- npc_host.notifications_enabled as host_notifications,
+- npc_service.id as serviceid,
+- npc_service.cacti_graph_id,
+- npc_service.service_description as service,
+- -1 as service_soft_state,
+- -1 as service_hard_state,
+- npc_service.notifications_enabled as service_notifications,
+- npc_service_check.last_check,
+- npc_service_check.next_check,
+- npc_service_check.check_execute_time,
+- npc_service_check.check_latency,
+- npc_service_check.check_command,
+- npc_service_check.performance_data,
+- 0 as duration,
+- 0 as current_attempt,
+- npc_service_check.max_attempts,
+- null as plugin_output
+- from
+- npc_host,
+- npc_hostgroup_membership,
+- npc_service,
+- npc_service_check
+- where
+- npc_host.id = npc_hostgroup_membership.hostid and
+- npc_host.id = npc_service.hostid and
+- npc_service.id = npc_service_check.serviceid and
+- npc_service.configured = TRUE and
+- npc_service.has_been_checked = FALSE and
+- npc_host.has_been_checked = FALSE
+- union
+- select
+- npc_host.id as hostid,
+- npc_host.name,
+- 0 as hostgroup,
+- -1 as host_soft_state,
+- npc_host.notifications_enabled as host_notifications,
+- npc_service.id as serviceid,
+- npc_service.cacti_graph_id,
+- npc_service.service_description as service,
+- -1 as service_soft_state,
+- -1 as service_hard_state,
+- npc_service.notifications_enabled as service_notifications,
+- npc_service_check.last_check,
+- npc_service_check.next_check,
+- npc_service_check.check_execute_time,
+- npc_service_check.check_latency,
+- npc_service_check.check_command,
+- npc_service_check.performance_data,
+- 0 as duration,
+- 0 as current_attempt,
+- npc_service_check.max_attempts,
+- null as plugin_output
+- from
+- npc_host,
+- npc_service,
+- npc_service_check
+- where
+- npc_host.id not in (select hostid from npc_hostgroup_membership) and
+- npc_host.id = npc_service.hostid and
+- npc_service.id = npc_service_check.serviceid and
+- npc_service.configured = TRUE and
+- npc_service.has_been_checked = FALSE and
+- npc_host.has_been_checked = FALSE
+- order by
+- name
+- ) as host_details where hostid = $hostid and service = '$serviceName'");
+-
+- $service_detail["flapping"] = db_fetch_cell("select id from npc_flapping_service where id = $serviceid");
+- $service_config = db_fetch_row("select active_checks_enabled, passive_checks_enabled, event_handler_enabled, flap_detection_enabled, notifications_enabled, failure_prediction_enabled, process_performance_data, obsess_over_service, event_handler from npc_service where hostid = $hostid and service_description = '$serviceName'");
+- $comments = db_fetch_assoc("select id,serviceid,timestamp,author,comment,persist,type from npc_comment where serviceid = '$serviceid'");
+- $row_count = count($comments);
+-
+-?>
+-
+-
+-
+-
+- <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
+- <tr class="textSubHeaderDark" bgcolor='#6d88ad'>
+- <td>
+- <h2> [ <?php echo $serviceName; ?> ] on
+- <a href="extinfo.php?type=1&hostid=<?php echo $hostid; ?>&hostname=<?php echo $hostname; ?>"><?php echo $hostname; ?></a></h2>
+- </td>
+- <td align='right' nowrap>
+- <FORM NAME="cl" ACTION="command.php" method="POST">Command:
+- <INPUT TYPE='hidden' NAME='host' VALUE='<?php echo $hostname; ?>'>
+- <INPUT TYPE='hidden' NAME='hostid' VALUE='<?php echo $service_detail["hostid"]; ?>'>
+- <INPUT TYPE='hidden' NAME='service' VALUE='<?php echo $serviceName; ?>'>
+- <INPUT TYPE='hidden' NAME='serviceid' VALUE='<?php echo $service_detail["serviceid"]; ?>'>
+- <select name="command" size="1">
+-
+-<?php
+- if (read_config_option("nagios_commands")) {
+-
+- echo "<OPTION VALUE='NULL'>Execute a command</option>";
+-
+- if ($service_config["active_checks_enabled"]) {
+- echo "<strong><OPTION VALUE='DISABLE_SVC_CHECK'>Disable active checks</option></strong>";
+- echo "<OPTION VALUE='SCHEDULE_SVC_CHECK'>Re-schedule the next check</option>";
+- } else {
+- echo "<OPTION VALUE='ENABLE_SVC_CHECK'>Enable Active Checks</option>";
+- }
+- if ($service_config["passive_checks_enabled"]) {
+- echo "<OPTION VALUE='PROCESS_SVC_CHECK_RESULT'>Submit passive check result</option>";
+- echo "<OPTION VALUE='DISABLE_PASSIVE_SVC_CHECKS'>Stop accepting passive checks</option>";
+- } else {
+- echo "<OPTION VALUE='ENABLE_PASSIVE_SVC_CHECKS'>Start accepting passive checks</option>";
+- }
+- if ($service_config["obsess_over_service"]) {
+- echo "<OPTION VALUE='STOP_OBSESSING_OVER_SVC'>Stop obsessing</option>";
+- } else {
+- echo "<OPTION VALUE='START_OBSESSING_OVER_SVC'>Start obsessing</option>";
+- }
+- if ($service_detail["Current Status"] == 1 || $service_detail["Current Status"] == 2 || $service_detail["Current Status"] == 3 && $service_detail["Current Status"] == $service_detail["service_hard_state"]) {
+- if (!db_fetch_cell("select * from npc_comment where serviceid = $serviceid and type = 4;")) {
+- echo "<OPTION VALUE='ACKNOWLEDGE_SVC_PROBLEM'>Acknowledge This Service Problem</option>";
+- } elseif (db_fetch_cell("select * from npc_comment where serviceid = $serviceid and type = 4;")) {
+- echo "<OPTION VALUE='REMOVE_SVC_ACKNOWLEDGEMENT'>Remove Problem Acknowledgement</option>";
+- }
+- }
+- if ($service_config["notifications_enabled"]) {
+- echo "<OPTION VALUE='DISABLE_SVC_NOTIFICATIONS'>Disable Notifications</option>";
+- if ($service_detail["Current Status"] != 0) {
+- echo "<OPTION VALUE='DELAY_SVC_NOTIFICATION'>Delay Next Service Notification</option>";
+- }
+- } else {
+- echo "<OPTION VALUE='ENABLE_SVC_NOTIFICATIONS'>Enable Notifications</option>";
+- }
+- echo "<OPTION VALUE='SCHEDULE_SVC_DOWNTIME'>Schedule Downtime</option>";
+- if ($service_config["event_handler_enabled"]) {
+- echo "<OPTION VALUE='DISABLE_SVC_EVENT_HANDLER'>Disable Event Handler</option>";
+- } else {
+- echo "<OPTION VALUE='ENABLE_SVC_EVENT_HANDLER'>Enable Event Handler</option>";
+- }
+- if ($service_config["flap_detection_enabled"]) {
+- echo "<OPTION VALUE='DISABLE_SVC_FLAP_DETECTION'>Disable Flap Detection</option>";
+- } else {
+- echo "<OPTION VALUE='ENABLE_SVC_FLAP_DETECTION'>Enable Flap Detection</option>";
+- }
+- echo "<OPTION VALUE='ADD_SVC_COMMENT'>Add Service Comment</option>";
+- echo "<OPTION VALUE='DEL_ALL_SVC_COMMENTS'>Delete All Service Comments</option>";
+- } else {
+- echo "<OPTION VALUE=''>Command execution disabled</option>";
+- }
+-?>
+-
+- </select>
+- <input type='image' src='../../images/button_go.gif' alt='Go' value='Execute' align='absmiddle'>
+- </form>
+-
+-
+- </td>
+- </tr>
+-
+- <tr><td> </td><td> </td></tr>
+- <tr>
+- <td valign="top">
+- <table width="100%" border="0" align="left" valign="top">
+- <thead>
+- <tr class="textHeaderDark" bgcolor='#00438C'>
+- <td align="center"><strong>Service State Information</strong></td>
+- </tr>
+- </thead>
+- <tbody>
+- <tr>
+- <td width="100%" valign="top">
+- <table width="100%" align="center" cellpadding="3">
+- <thead>
+- <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
+- <td>Parameter</td>
+- <td>Value</td>
+- </tr>
+- </thead>
+- <tbody>
+-
+-
+-<?php
+-
+-
+- foreach ($service_detail as $key => $value) {
+-
+-
+- switch($key)
+- {
+- case "Current Status":
+- echo "<tr bgcolor='" . $rowColor . "'>";
+- echo "<td>" . $key . ":</td>";
+- switch($value)
+- {
+- case "-1":
+- echo "<td class='statusPENDING'><strong>PENDING</strong></td>";
+- break;
+- case "0":
+- echo "<td class='statusOK'><strong>OK</strong></td>";
+- break;
+- case "1":
+- echo "<td class='statusWARNING'><strong>WARNING</strong></td>";
+- break;
+- case "2":
+- echo "<td class='statusCRITICAL'><strong>CRITICAL</strong></td>";
+- break;
+- case "3":
+- echo "<td class='statusUNKNOWN'><strong>UNKNOWN</strong></td>";
+- break;
+- }
+- echo "</tr>";
+- break;
+- case "State Duration":
+- echo "<tr bgcolor='" . $rowColor . "'>";
+- echo "<td>" . $key . ":</td>";
+- echo "<td>" . formatTime($value) . "</td>";
+- echo "</tr>";
+- break;
+- case "Check Command":
+- echo "<tr bgcolor='" . $rowColor . "'>";
+- echo "<td>" . $key . ":</td>";
+- echo "<td>" . $value . "</td>";
+- echo "</tr>";
+- break;
+- case "Plugin Output":
+- echo "<tr bgcolor='" . $rowColor . "'>";
+- echo "<td>" . $key . ":</td>";
+- echo "<td>" . $value . "</td>";
+- echo "</tr>";
+- break;
+- case "Performance Data":
+- echo "<tr bgcolor='" . $rowColor . "'>";
+- echo "<td>" . $key . ":</td>";
+- echo "<td>" . $value . "</td>";
+- echo "</tr>";
+- break;
+- case "Current Attempt":
+- echo "<tr bgcolor='" . $rowColor . "'>";
+- echo "<td>" . $key . ":</td>";
+- echo "<td>" . $value . "/" . $service_detail["Max Attempts"] . "</td>";
+- echo "</tr>";
+- break;
+- case "Last Check":
+- echo "<tr bgcolor='" . $rowColor . "'>";
+- echo "<td>" . $key . ":</td>";
+- if (preg_match('/1969-12-31/', $value)) {
+- echo "<td>N/A</td>";
+- } else {
+- echo "<td>" . $value . "</td>";
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list