- patch for extinfo
authorMichał 'Wolvverine' Panasiewicz <wolvverine@pld-linux.org>
Tue, 25 Dec 2007 05:49:32 +0000 (05:49 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    cacti-plugin-npc-extinfo.patch -> 1.1

cacti-plugin-npc-extinfo.patch [new file with mode: 0644]

diff --git a/cacti-plugin-npc-extinfo.patch b/cacti-plugin-npc-extinfo.patch
new file mode 100644 (file)
index 0000000..4f59a67
--- /dev/null
@@ -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@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>&nbsp;[ <?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>&nbsp;</td><td>&nbsp;</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>";
+-                              }
+-                              echo "</tr>";
+-                              break;
+-                      case "Next Check":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>" . $key . ":</td>";
+-                              echo "<td>" . $value . "</td>";
+-                              echo "</tr>";
+-                              break;
+-                      case "Check Latency":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>" . $key . ":</td>";
+-                              echo "<td>" . $value . "</td>";
+-                              echo "</tr>";
+-                              break;
+-                      case "Check Duration":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>" . $key . ":</td>";
+-                              echo "<td>" . $value . "</td>";
+-                              echo "</tr>";
+-                              break;
+-                      case "flapping":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>Flapping:</td>";
+-                              if ($service_detail["flapping"]) {
+-                                      echo "<td>Yes</td>";
+-                              } else {
+-                                      echo "<td>No</td>";
+-                              }
+-                              echo "</tr>";
+-                              break;
+-                }
+-
+-              if($rowColor == $background1) {
+-                        $rowColor = $background2;
+-                } else {
+-                        $rowColor = $background1;
+-                }
+-
+-              if ($key == "flapping") {
+-                      echo "<tr bgcolor='" . $rowColor . "'>";
+-                      echo "<td>Event Handler:</td>";
+-                      if (!$service_config["event_handler"]) {
+-                              echo "<td>N/A</td>";
+-                        } else {
+-                              echo "<td>" . $service_config["event_handler"] . "</td>";
+-                        }
+-                      echo "</tr>";
+-              }
+-
+-
+-      }
+-
+-
+-?>
+-
+-      </tbody>
+-      </table>
+-
+-      </td>
+-      </tr>
+-      </tbody>
+-      </table>
+-
+-   </td>
+-
+-   <td valign="top">
+-      <table width="70%" border="0" align="right">
+-      <thead>
+-      <tr class="textHeaderDark" bgcolor='#00438C'>
+-      <td align="center"><strong>Service Monitoring Options</strong></td>
+-      </tr>
+-      </thead>
+-      <tbody>
+-      <tr>
+-      <td width="70%" 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
+-       $rowColor = $background1;
+-         echo "<tr bgcolor='" . $rowColor . "'>";
+-
+-
+-      foreach ($service_config as $key => $value) {
+-
+-              if ($key == "event_handler") { continue; }
+-
+-              echo "<tr bgcolor='" . $rowColor . "'>";
+-
+-                switch($key)
+-                {
+-                        case "active_checks_enabled":
+-                                echo "<td>Active Checks:</td>";
+-                                break;
+-                        case "passive_checks_enabled":
+-                                echo "<td>Passive Checks:</td>";
+-                                break;
+-                        case "event_handler_enabled":
+-                                echo "<td>Event Handler:</td>";
+-                                break;
+-                        case "flap_detection_enabled":
+-                                echo "<td>Flap Detection:</td>";
+-                                break;
+-                        case "notifications_enabled":
+-                                echo "<td>Notifications:</td>";
+-                                break;
+-                        case "failure_prediction_enabled":
+-                                echo "<td>Failure Prediction:</td>";
+-                                break;
+-                        case "process_performance_data":
+-                                echo "<td>Process Performance Data:</td>";
+-                                break;
+-                        case "obsess_over_service":
+-                                echo "<td>Obsess Over Service:</td>";
+-                                break;
+-                }
+-
+-              if ($value == 0) {
+-                      echo "<td class='optionDISABLED'>Disabled</td></tr>";
+-              } else {
+-                      echo "<td class='optionENABLED'>Enabled</td></tr>";
+-              }
+-
+-              if($rowColor == $background1) {
+-                        $rowColor = $background2;
+-                } else {
+-                        $rowColor = $background1;
+-                }
+-
+-
+-      }
+-
+-?>
+-            </tbody>
+-            </table>
+-         </td>
+-         </tr>
+-         </table>
+-
+-   </td>
+-
+-
+-
+-<?php
+-
+-
+-
+-
+-   echo "</tr>";
+-   echo "<tr>";
+-
+-?>
+-   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+-   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+-   <td valign="top" colspan='2'>
+-      <table width="60%" border="0" align="center">
+-         <thead>
+-          <tr class="textHeaderDark" bgcolor='#00438C'>
+-               <td align="center"><strong>Service Comments</strong></td>
+-            </tr>
+-         </thead>
+-         <tbody>
+-            <tr>
+-               <td width="60%" valign="top">
+-                  <table width="100%" align="center" cellpadding="3">
+-                   <thead>
+-                      <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
+-                         <td>Entry Time</td>
+-                         <td>Author</td>
+-                         <td>Comment</td>
+-                         <td>Persistent</td>
+-                         <td>Type</td>
+-                         <td>Delete</td>
+-                     <tbody>
+-<?php
+-      for($i = 0; $i < $row_count; $i++) {
+-              
+-              echo "<tr bgcolor='" . $rowColor . "'>";
+-              echo "<td nowrap>" . $comments[$i]["timestamp"] . "</td>";
+-              echo "<td>" . $comments[$i]["author"] . "</td>";
+-              echo "<td>" . $comments[$i]["comment"] . "</td>";
+-              echo "<td>";
+-              if ($comments[$i]["persist"]) {
+-                      echo "Yes";
+-              } else {
+-                      echo "No"; 
+-              }
+-              echo "</td>";
+-              echo "<td>";
+-              if ($comments[$i]["type"] == 2) {
+-                      echo "Comment";
+-              } elseif ($comments[$i]["type"] == 4) {
+-                      echo "Acknowledgment";
+-              }
+-              echo "</td>";
+-              echo "<td>";
+-              if ($comments[$i]["type"] == 2) {
+-                      echo "<a href='command.php?cmd=DEL_SVC_COMMENT&id=" . $comments[$i]["id"] . "&host=" . $hostname . "&hostid=" . $hostid . "&service=" . $_REQUEST["service"] . "&serviceid=" . $serviceid . "'><img src='images/delete.gif' alt='delete' title='Delete comment' border=0></a>";
+-              } elseif ($comments[$i]["type"] == 4) {
+-                      echo "<a href='command.php?cmd=REMOVE_SVC_ACKNOWLEDGEMENT&host=" . $hostname . "&hostid=" . $hostid . "&service=" . $_REQUEST["service"] . "&serviceid=" . $serviceid . "'><img src='images/delete.gif' alt='Remove' title='Remove problem acknowledgment' border=0></a>";
+-              }
+-              echo "</td>";
+-
+-
+-              if($rowColor == $background1) {
+-                      $rowColor = $background2;
+-              } else {
+-                      $rowColor = $background1;
+-              }
+-      }
+-
+-
+-
+-
+-
+-
+-
+-?>
+-                   </tbody>
+-                </table>
+-             </td>
+-          </tr>
+-          <tr>
+-             <td>
+-                <?php 
+-                      echo "<a href='command.php?cmd=ADD_SVC_COMMENT&host=" . $hostname . "&hostid=" . $hostid . "&service=" . $_REQUEST["service"] . "&serviceid=" . $serviceid . "'><img src='images/comment.gif' alt='Add a comment' title='Add a comment' border=0></a>"; 
+-                      echo "<a href='command.php?cmd=DEL_ALL_SVC_COMMENTS&host=" . $hostname . "&hostid=" . $hostid . "&service=" . $_REQUEST["service"] . "&serviceid=" . $serviceid . "'><img src='images/delete.gif' alt='Delete all comments' title='Delete all comments' border=0></a>"; 
+-                ?>
+-               </td>
+-            </tr>
+-      </tbody>
+-      </table>
+-   </td>
+-   <td></td>
+-   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+-   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+-   <tr>
+-
+-
+-
+-
+-
+-   <td valign="top" colspan='2'>
+-      <table width="60%" border="0" align="center">
+-      <thead>
+-      <tr align="center" class="textHeaderDark" bgcolor='#00438C'>
+-      <td align="center"><strong>Graph Mapping</strong></td>
+-      </tr>
+-      </thead>
+-      <tbody>
+-      <tr>
+-      <td width="60%" valign="top">
+-         <table width="100%" align="center" cellpadding="3">
+-            <tbody>
+-
+-<?php
+-
+-$cacti_graphs = db_fetch_assoc("
+-select
+-                graph_templates_graph.id,
+-                graph_templates_graph.local_graph_id,
+-                graph_templates_graph.height,
+-                graph_templates_graph.width,
+-                graph_templates_graph.title_cache as title,
+-                graph_templates.name,
+-                graph_local.host_id
+-                from graph_local,graph_templates_graph
+-                left join graph_templates on graph_local.graph_template_id=graph_templates.id
+-                where graph_local.id=graph_templates_graph.local_graph_id
+-                and graph_templates_graph.title_cache like '%'
+-                order by graph_templates_graph.title_cache,graph_local.host_id");
+-
+-              $row_count = count($cacti_graphs);
+-/* http://logindev/cacti/graph_image.php?local_graph_id=6&rra_id=0 */
+-?>
+-
+-                   <FORM NAME="gm" ACTION="" method="post">
+-                   <tr bgcolor='<?php echo $background1; ?>'>
+-                        <td>Associated graph:</td>
+-                        <td>
+-                         <select name="local_graph_id" size="1">
+-                            <?php
+-                              echo "<OPTION VALUE='NULL'>None</option>";
+-                              for($i = 0; $i < $row_count; $i++) {
+-                                      echo "<OPTION VALUE='" . $cacti_graphs[$i]["local_graph_id"] . "'>" . $cacti_graphs[$i]["title"] . "</option>";
+-                              }
+-                            ?> 
+-
+-
+-                         </select>
+-                      </td>
+-                        <td><INPUT TYPE="submit" VALUE="Map"></td>
+-                   </tr>
+-                   </FORM>
+-
+-
+-            </tbody>
+-         </table>
+-              <?php 
+-                      if ($service_detail["cacti_graph_id"]) {
+-                              echo "<table align='center'>";
+-                              echo "<tr><td width='100%'>";
+-                              echo "<img src='../../graph_image.php?local_graph_id=" . $service_detail["cacti_graph_id"] . "&rra_id=0'>";
+-                              echo "</td></tr>";
+-                      }
+-              ?>
+-      </td>
+-      </tr>
+-   </tbody>
+-   </table>
+-
+-   </td>
+-
+-   </tr>
+-   </table>
+-
+-<?php
+-
+-
+-}
+-
+-
+-function hostInfo() {
+-
+-      $hostid = $_REQUEST["hostid"];
+-      $hostname = $_REQUEST["hostname"];
+-
+-      if (isset($_POST["local_graph_id"])) {
+-              db_execute("update npc_host set cacti_graph_id = " . $_POST["local_graph_id"] . " where id = " . $hostid);
+-              header("Location: extinfo.php?type=1&hostid=" . $hostid . "&hostname=" . $hostname);
+-      }
+-
+-      include_once("top_npc_header.php");
+-
+-        $background1 = "#F5F5F5";
+-        $background2 = "#E7E9F2";
+-        $rowColor = $background1;
+-
+-      $host_flapping["flapping"] = db_fetch_cell("select id from npc_flapping_host where id = $hostid");
+-
+-      $host_history = db_fetch_row("select started, soft_state, hard_state, current_attempt, plugin_output from npc_host_history where hostid = $hostid order by started desc;");
+-
+-      $host_check = db_fetch_row("select check_command, check_execute_time, check_latency, from_unixtime(last_check) as last_check, from_unixtime(next_check) as next_check, max_attempts, last_notification, next_notification, no_more_notifications, check_type, performance_data from npc_host_check where hostid = $hostid;");
+-
+-      $host_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_host, event_handler, cacti_graph_id from npc_host where id = $hostid");
+-
+-      $comments = db_fetch_assoc("select id,serviceid,timestamp,author,comment,persist,type from npc_comment where hostid = $hostid");
+-
+-      $graphView = db_fetch_cell("select id from graph_tree_items where host_id = (select id from host where npc_host_id = $hostid)");
+-
+-      $row_count = count($comments);
+-
+-      $duration =  date("U") - $host_history["started"];
+-
+-?>
+-
+-
+-
+-
+-   <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
+-   <tr class="textSubHeaderDark" bgcolor='#6d88ad'>
+-      <td>
+-              <h2>&nbsp;<strong><?php echo $hostname; ?></strong></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 $hostid; ?>'>
+-                      <select name="command" size="1">
+-
+-<?php 
+-                      if (read_config_option("nagios_commands")) {
+-
+-                              echo "<OPTION VALUE='NULL'>Execute a command</option>";
+-
+-                              if ($host_config["active_checks_enabled"]) {
+-                                      echo "<OPTION VALUE='DISABLE_HOST_CHECK'>Disable active checks</option>";
+-                                      echo "<OPTION VALUE='SCHEDULE_HOST_CHECK'>Re-schedule the next check</option>";
+-                                      echo "<OPTION VALUE='SCHEDULE_HOST_SVC_CHECKS'>Schedule a check of all services</option>";
+-                              } else {
+-                                      echo "<OPTION VALUE='ENABLE_HOST_CHECK'>Enable Active Checks</option>";
+-                              }
+-                              echo "<OPTION VALUE='DISABLE_HOST_SVC_CHECKS'>Disable checks of all services</option>";
+-                              echo "<OPTION VALUE='ENABLE_HOST_SVC_CHECKS'>Enabble checks of all services</option>";
+-                              if ($host_config["passive_checks_enabled"]) {
+-                                      echo "<OPTION VALUE='PROCESS_HOST_CHECK_RESULT'>Submit passive check result</option>";
+-                                      echo "<OPTION VALUE='DISABLE_PASSIVE_HOST_CHECKS'>Stop accepting passive checks</option>";
+-                              } else {
+-                                      echo "<OPTION VALUE='ENABLE_PASSIVE_HOST_CHECKS'>Start accepting passive checks</option>";
+-                              }
+-                              if ($host_config["obsess_over_service"]) {
+-                                      echo "<OPTION VALUE='STOP_OBSESSING_OVER_HOST'>Stop obsessing</option>";
+-                              } else {
+-                                      echo "<OPTION VALUE='START_OBSESSING_OVER_HOST'>Start obsessing</option>";
+-                              }
+-                              if ($host_history["soft_state"] == 1 || $host_history["soft_state"] == 2 && $host_history["soft_state"] == $host_history["hard_state"]) {
+-                                      if (!db_fetch_cell("select * from npc_comment where hostid = $hostid and type = 4;")) {
+-                                              echo "<OPTION VALUE='ACKNOWLEDGE_HOST_PROBLEM'>Acknowledge This Host Problem</option>";
+-                                      } elseif (db_fetch_cell("select * from npc_comment where hostid = $hostid and type = 4;")) {
+-                                              echo "<OPTION VALUE='REMOVE_HOST_ACKNOWLEDGEMENT'>Remove Problem Acknowledgement</option>";
+-                                      }
+-                              }
+-                              if ($host_config["notifications_enabled"]) {
+-                                      echo "<OPTION VALUE='DISABLE_HOST_NOTIFICATIONS'>Disable Notifications</option>";
+-                                      if ($host_history["soft_state"] != 0) {
+-                                              echo "<OPTION VALUE='DELAY_HOST_NOTIFICATION'>Delay Next Service Notification</option>";
+-                                      }
+-                              } else {
+-                                      echo "<OPTION VALUE='ENABLE_HOST_NOTIFICATIONS'>Enable Notifications</option>";
+-                              }
+-                              echo "<OPTION VALUE='SCHEDULE_HOST_DOWNTIME'>Schedule Downtime</option>";
+-                              if ($host_config["event_handler_enabled"]) {
+-                                      echo "<OPTION VALUE='DISABLE_HOST_EVENT_HANDLER'>Disable Event Handler</option>";
+-                              } else {
+-                                      echo "<OPTION VALUE='ENABLE_HOST_EVENT_HANDLER'>Enable Event Handler</option>";
+-                              }
+-                              if ($host_config["flap_detection_enabled"]) {
+-                                      echo "<OPTION VALUE='DISABLE_HOST_FLAP_DETECTION'>Disable Flap Detection</option>";
+-                              } else {
+-                                      echo "<OPTION VALUE='ENABLE_HOST_FLAP_DETECTION'>Enable Flap Detection</option>";
+-                              }
+-                              echo "<OPTION VALUE='ADD_HOST_COMMENT'>Add Host Comment</option>";
+-                              echo "<OPTION VALUE='DEL_ALL_HOST_COMMENTS'>Delete All Host Comments</option>";
+-                      } else {
+-                              echo "<OPTION VALUE='NULL'>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 bgcolor='#a9b7cb'>
+-      <td><a href='statusDetail.php?filter=showHost&name=<?php echo $hostname; ?>'>View Services</a> | <?php if ($graphView) { ?><a href='<?php echo $config['url_path']?>graph_view.php?action=tree&tree_id=1&leaf_id=<?php echo $graphView; ?>'>View Graphs</a> | <?php } ?><a href='hostConfig.php?name=<?php echo $hostname; ?>&hostid=<?php echo $hostid; ?>'>Configure</a></td>
+-      <td>&nbsp;</td></tr>
+-   </tr>
+-
+-   <tr><td>&nbsp;</td><td>&nbsp;</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>Host 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
+-
+-
+-      $host_detail = array(
+-              'Current Status'   => $host_history["soft_state"],
+-              'State Duration'   => formatTime($duration),
+-              'Check Command'    => $host_check["check_command"],
+-              'Plugin Output'    => $host_history["plugin_output"],
+-              'Performance Data' => $host_check["performance_data"],
+-              'Current Attempt'  => $host_history["current_attempt"],
+-              'Last Check'       => $host_check["last_check"],
+-              'Next Check'       => $host_check["next_check"],
+-              'Check Latency'    => $host_check["check_latency"],
+-              'Check Duration'   => $host_check["check_execute_time"],
+-              'flapping'         => $host_flapping["flapping"],
+-              'Event Handler'    => $host_config["event_handler"],
+-      );
+-
+-      foreach ($host_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='statusHOSTUP'><strong>UP</strong></td>";
+-                                              break;
+-                                      case "1":
+-                                              echo "<td class='statusHOSTDOWN'><strong>DOWN</strong></td>";
+-                                              break;
+-                                      case "2":
+-                                              echo "<td class='statusHOSTUNREACHABLE'><strong>UNREACHABLE</strong></td>";
+-                                              break;
+-                              }
+-                              echo "</tr>";
+-                              break;
+-                      case "State Duration":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>" . $key . ":</td>";
+-                              echo "<td>" . $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 . "/" . $host_check["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>";
+-                              }
+-                              echo "</tr>";
+-                              break;
+-                      case "Next 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>";
+-                              }
+-                              echo "</tr>";
+-                              break;
+-                      case "Check Latency":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>" . $key . ":</td>";
+-                              echo "<td>" . $value . "</td>";
+-                              echo "</tr>";
+-                              break;
+-                      case "Check Duration":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>" . $key . ":</td>";
+-                              echo "<td>" . $value . "</td>";
+-                              echo "</tr>";
+-                              break;
+-                      case "flapping":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>Flapping:</td>";
+-                              if ($host_detail["flapping"]) {
+-                                      echo "<td>Yes</td>";
+-                              } else {
+-                                      echo "<td>No</td>";
+-                              }
+-                              echo "</tr>";
+-                              break;
+-                      case "Event Handler":
+-                              echo "<tr bgcolor='" . $rowColor . "'>";
+-                              echo "<td>" . $key . ":</td>";
+-                              if (!$value) {
+-                                      echo "<td>N/A</td>";
+-                              } else {
+-                                      echo "<td>" . $value . "</td>";
+-                              }
+-                              echo "</tr>";
+-                              break;
+-                }
+-
+-              if($rowColor == $background1) {
+-                        $rowColor = $background2;
+-                } else {
+-                        $rowColor = $background1;
+-                }
+-
+-      }
+-
+-
+-?>
+-
+-      </tbody>
+-      </table>
+-
+-      </td>
+-      </tr>
+-      </tbody>
+-      </table>
+-
+-   </td>
+-
+-   <td valign="top">
+-      <table width="70%" border="0" align="right">
+-      <thead>
+-      <tr class="textHeaderDark" bgcolor='#00438C'>
+-      <td align="center"><strong>Host Monitoring Options</strong></td>
+-      </tr>
+-      </thead>
+-      <tbody>
+-      <tr>
+-      <td width="70%" 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
+-       $rowColor = $background1;
+-         echo "<tr bgcolor='" . $rowColor . "'>";
+-
+-
+-      foreach ($host_config as $key => $value) {
+-
+-              if ($key == "event_handler") { continue; }
+-              if ($key == "cacti_graph_id") { continue; }
+-
+-              echo "<tr bgcolor='" . $rowColor . "'>";
+-
+-                switch($key)
+-                {
+-                        case "active_checks_enabled":
+-                                echo "<td>Active Checks:</td>";
+-                                break;
+-                        case "passive_checks_enabled":
+-                                echo "<td>Passive Checks:</td>";
+-                                break;
+-                        case "event_handler_enabled":
+-                                echo "<td>Event Handler:</td>";
+-                                break;
+-                        case "flap_detection_enabled":
+-                                echo "<td>Flap Detection:</td>";
+-                                break;
+-                        case "notifications_enabled":
+-                                echo "<td>Notifications:</td>";
+-                                break;
+-                        case "failure_prediction_enabled":
+-                                echo "<td>Failure Prediction:</td>";
+-                                break;
+-                        case "process_performance_data":
+-                                echo "<td>Process Performance Data:</td>";
+-                                break;
+-                        case "obsess_over_host":
+-                                echo "<td>Obsess Over Host:</td>";
+-                                break;
+-                }
+-
+-              if ($value == 0) {
+-                      echo "<td class='optionDISABLED'>Disabled</td></tr>";
+-              } else {
+-                      echo "<td class='optionENABLED'>Enabled</td></tr>";
+-              }
+-
+-              if($rowColor == $background1) {
+-                        $rowColor = $background2;
+-                } else {
+-                        $rowColor = $background1;
+-                }
+-
+-
+-      }
+-
+-?>
+-            </tbody>
+-            </table>
+-         </td>
+-         </tr>
+-         </table>
+-
+-   </td>
+-
+-
+-
+-<?php
+-
+-
+-
+-
+-   echo "</tr>";
+-   echo "<tr>";
+-
+-?>
+-   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+-   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+-   <td valign="top" colspan='2'>
+-      <table width="60%" border="0" align="center">
+-         <thead>
+-          <tr class="textHeaderDark" bgcolor='#00438C'>
+-               <td align="center"><strong>Host Comments</strong></td>
+-            </tr>
+-         </thead>
+-         <tbody>
+-            <tr>
+-               <td width="60%" valign="top">
+-                  <table width="100%" align="center" cellpadding="3">
+-                   <thead>
+-                      <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
+-                         <td>Entry Time</td>
+-                         <td>Author</td>
+-                         <td>Comment</td>
+-                         <td>Persistent</td>
+-                         <td>Type</td>
+-                         <td>Delete</td>
+-                     <tbody>
+-<?php
+-      for($i = 0; $i < $row_count; $i++) {
+-              
+-              echo "<tr bgcolor='" . $rowColor . "'>";
+-              echo "<td nowrap>" . $comments[$i]["timestamp"] . "</td>";
+-              echo "<td>" . $comments[$i]["author"] . "</td>";
+-              echo "<td>" . $comments[$i]["comment"] . "</td>";
+-              echo "<td>";
+-              if ($comments[$i]["persist"]) {
+-                      echo "Yes";
+-              } else {
+-                      echo "No"; 
+-              }
+-              echo "</td>";
+-              echo "<td>";
+-              if ($comments[$i]["type"] == 1) {
+-                      echo "Comment";
+-              } elseif ($comments[$i]["type"] == 3) {
+-                      echo "Acknowledgment";
+-              }
+-              echo "</td>";
+-              echo "<td>";
+-              if ($comments[$i]["type"] == 1) {
+-                      echo "<a href='command.php?cmd=DEL_HOST_COMMENT&id=" . $comments[$i]["id"] . "&host=" . $hostname . "&hostid=" . $hostid . "'><img src='images/delete.gif' alt='delete' title='Delete comment' border=0></a>";
+-              } elseif ($comments[$i]["type"] == 3) {
+-                      echo "<a href='command.php?cmd=REMOVE_HOST_ACKNOWLEDGEMENT&host=" . $hostname . "&hostid=" . $hostid . "'><img src='images/delete.gif' alt='Remove' title='Remove problem acknowledgment' border=0></a>";
+-              }
+-              echo "</td>";
+-
+-
+-              if($rowColor == $background1) {
+-                      $rowColor = $background2;
+-              } else {
+-                      $rowColor = $background1;
+-              }
+-      }
+-
+-
+-
+-
+-
+-
+-
+-?>
+-                   </tbody>
+-                </table>
+-             </td>
+-          </tr>
+-          <tr>
+-             <td>
+-                <?php 
+-                      echo "<a href='command.php?cmd=ADD_HOST_COMMENT&host=" . $hostname . "&hostid=" . $hostid . "'><img src='images/comment.gif' alt='Add a comment' title='Add a comment' border=0></a>"; 
+-                      echo "<a href='command.php?cmd=DEL_ALL_HOST_COMMENTS&host=" . $hostname . "&hostid=" . $hostid . "'><img src='images/delete.gif' alt='Delete all comments' title='Delete all comments' border=0></a>"; 
+-                ?>
+-               </td>
+-            </tr>
+-      </tbody>
+-      </table>
+-   </td>
+-   <td></td>
+-   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+-   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+-   <tr>
+-
+-
+-
+-
+-
+-   <td valign="top" colspan='2'>
+-      <table width="60%" border="0" align="center">
+-      <thead>
+-      <tr align="center" class="textHeaderDark" bgcolor='#00438C'>
+-      <td align="center"><strong>Graph Mapping</strong></td>
+-      </tr>
+-      </thead>
+-      <tbody>
+-      <tr>
+-      <td width="60%" valign="top">
+-         <table width="100%" align="center" cellpadding="3">
+-            <tbody>
+-
+-<?php
+-
+-$cacti_graphs = db_fetch_assoc("
+-select
+-                graph_templates_graph.id,
+-                graph_templates_graph.local_graph_id,
+-                graph_templates_graph.height,
+-                graph_templates_graph.width,
+-                graph_templates_graph.title_cache as title,
+-                graph_templates.name,
+-                graph_local.host_id
+-                from graph_local,graph_templates_graph
+-                left join graph_templates on graph_local.graph_template_id=graph_templates.id
+-                where graph_local.id=graph_templates_graph.local_graph_id
+-                and graph_templates_graph.title_cache like '%'
+-                order by graph_templates_graph.title_cache,graph_local.host_id");
+-
+-              $row_count = count($cacti_graphs);
+-/* http://logindev/cacti/graph_image.php?local_graph_id=6&rra_id=0 */
+-?>
+-
+-                   <FORM NAME="gm" ACTION="" method="post">
+-                   <tr bgcolor='<?php echo $background1; ?>'>
+-                        <td>Associated graph:</td>
+-                        <td>
+-                         <select name="local_graph_id" size="1">
+-                            <?php
+-                              echo "<OPTION VALUE='NULL'>None</option>";
+-                              for($i = 0; $i < $row_count; $i++) {
+-                                      echo "<OPTION VALUE='" . $cacti_graphs[$i]["local_graph_id"] . "'>" . $cacti_graphs[$i]["title"] . "</option>";
+-                              }
+-                            ?> 
+-
+-
+-                         </select>
+-                      </td>
+-                        <td><INPUT TYPE="submit" VALUE="Map"></td>
+-                   </tr>
+-                   </FORM>
+-
+-
+-            </tbody>
+-         </table>
+-              <?php 
+-                      if ($host_config["cacti_graph_id"]) {
+-                              echo "<table align='center'>";
+-                              echo "<tr><td width='100%'>";
+-                              echo "<img src='../../graph_image.php?local_graph_id=" . $host_config["cacti_graph_id"] . "&rra_id=0'>";
+-                              echo "</td></tr>";
+-                      }
+-              ?>
+-      </td>
+-      </tr>
+-   </tbody>
+-   </table>
+-
+-   </td>
+-
+-   </tr>
+-   </table>
+-
+-<?php
+-
+-
+-}
+-
+-
+-
+-
+-?>
++<?php\r
++/*\r
++ +-------------------------------------------------------------------------+\r
++ | Nagios Plugin 0.1a for cacti 0.8.6f                                     |\r
++ | Copyright (C) 2005 Billy Gunn (billy@gunn.org)                          |\r
++ |                                                                         |\r
++ | This program is free software; you can redistribute it and/or           |\r
++ | modify it under the terms of the GNU General Public License             |\r
++ | as published by the Free Software Foundation; either version 2          |\r
++ | of the License, or (at your option) any later version.                  |\r
++ |                                                                         |\r
++ | This program is distributed in the hope that it will be useful,         |\r
++ | but WITHOUT ANY WARRANTY; without even the implied warranty of          |\r
++ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |\r
++ | GNU General Public License for more details.                            |\r
++ +-------------------------------------------------------------------------+\r
++ | Cacti and Nagios are the copyright of their respective owners.          |\r
++ +-------------------------------------------------------------------------+\r
++*/\r
++\r
++chdir('../../');\r
++include_once("./include/auth.php");\r
++include_once("./include/config.php");\r
++\r
++// Refresh the page at a user supplied interval\r
++header("Refresh: " . read_config_option("npc_refresh") . "; URL=" . $_SERVER["REQUEST_URI"]);\r
++\r
++/* set default action */\r
++if (!isset($_REQUEST["type"])) { $_REQUEST["type"] = ""; }\r
++\r
++switch ($_REQUEST["type"]) {\r
++        case '1':\r
++\r
++                hostInfo();\r
++                include_once("./include/bottom_footer.php");\r
++                break;\r
++\r
++        case '2':\r
++\r
++                serviceInfo();\r
++                include_once("./include/bottom_footer.php");\r
++                break;\r
++\r
++        default:\r
++\r
++                hostInfo();\r
++                include_once("./include/bottom_footer.php");\r
++                break;\r
++}\r
++\r
++\r
++function formatTime($time) {\r
++\r
++        $days = floor($time/60/60/24);\r
++        $time -= $days*60*60*24;\r
++        $hours = floor($time/60/60);\r
++        $time -= $hours*60*60;\r
++        $minutes = floor($time/60);\r
++        $time -= $minutes*60;\r
++        $seconds = $time;\r
++\r
++        return ($days . "d " . $hours . "h " . $minutes . "m " . $seconds . "s");\r
++}\r
++\r
++\r
++function serviceInfo() {\r
++\r
++      $hostid = $_REQUEST["hostid"];\r
++      $serviceid = $_REQUEST["serviceid"];\r
++      $hostname = $_REQUEST["hostname"];\r
++      $serviceName = ereg_replace("\+", " ", $_REQUEST["service"]);\r
++\r
++\r
++      if (isset($_POST["local_graph_id"])) {\r
++              db_execute("update npc_service set cacti_graph_id = " . $_POST["local_graph_id"] . " where id = " . $serviceid);\r
++              header("Location: extinfo.php?type=2&hostid=" . $hostid . "&hostname=" . $hostname . "&serviceid=" . $serviceid . "&service=" . $_REQUEST["service"]);\r
++      }\r
++\r
++      include_once("top_npc_header.php");\r
++\r
++        $background1 = "#F5F5F5";\r
++        $background2 = "#E7E9F2";\r
++        $rowColor = $background1;\r
++\r
++        $service_detail = db_fetch_row("\r
++select distinct\r
++        service_soft_state as 'Current Status',\r
++        duration as 'State Duration',\r
++        check_command as 'Check Command',\r
++        plugin_output as 'Plugin Output',\r
++        performance_data as 'Performance Data',\r
++        current_attempt as 'Current Attempt',\r
++        from_unixtime(last_check) as 'Last Check',\r
++        from_unixtime(next_check) as 'Next Check',\r
++        check_latency as 'Check Latency',\r
++        check_execute_time as 'Check Duration',\r
++        hostid,\r
++        name,\r
++        host_soft_state as 'Host Soft State',\r
++        host_notifications as 'Host Notifications',\r
++        service as 'Service',\r
++        cacti_graph_id,\r
++        serviceid,\r
++      service_hard_state,\r
++        service_notifications as 'Service Notifications',\r
++        max_attempts as 'Max Attempts'\r
++from\r
++        (\r
++                select\r
++                        npc_host.id as hostid,\r
++                        npc_host.name,\r
++                        npc_hostgroup_membership.groupid as hostgroup,\r
++                        npc_host_history.soft_state as host_soft_state,\r
++                        npc_host.notifications_enabled as host_notifications,\r
++                        npc_service.id as serviceid,\r
++                        npc_service.cacti_graph_id,\r
++                        npc_service.service_description as service,\r
++                        npc_service_history.soft_state as service_soft_state,\r
++                        npc_service_history.hard_state as service_hard_state,\r
++                        npc_service.notifications_enabled as service_notifications,\r
++                        npc_service_check.last_check,\r
++                        npc_service_check.next_check,\r
++                        npc_service_check.check_execute_time,\r
++                        npc_service_check.check_latency,\r
++                        npc_service_check.check_command,\r
++                        npc_service_check.performance_data,\r
++                        unix_timestamp() - npc_service_history.started as duration,\r
++                        npc_service_history.current_attempt,\r
++                        npc_service_check.max_attempts,\r
++                        npc_service_history.plugin_output\r
++                from\r
++                        npc_host,\r
++                        npc_host_history,\r
++                        npc_hostgroup_membership,\r
++                        npc_service,\r
++                        npc_service_check,\r
++                        npc_service_history\r
++                where\r
++                        npc_host.id = npc_hostgroup_membership.hostid and\r
++                        npc_host.id = npc_service.hostid and\r
++                        npc_host.id = npc_host_history.hostid and\r
++                        npc_service.id = npc_service_check.serviceid and\r
++                        npc_service.id = npc_service_history.serviceid and\r
++                        npc_service_history.lasted is null and\r
++                        npc_host_history.lasted is null and\r
++                        npc_service.configured = TRUE and\r
++                        npc_service.has_been_checked = TRUE and\r
++                        npc_host.has_been_checked = TRUE\r
++                union\r
++                select\r
++                        npc_host.id as hostid,\r
++                        npc_host.name,\r
++                        0 as hostgroup,\r
++                        npc_host_history.soft_state as host_soft_state,\r
++                        npc_host.notifications_enabled as host_notifications,\r
++                        npc_service.id as serviceid,\r
++                        npc_service.cacti_graph_id,\r
++                        npc_service.service_description as service,\r
++                        npc_service_history.soft_state as service_soft_state,\r
++                        npc_service_history.hard_state as service_hard_state,\r
++                        npc_service.notifications_enabled as service_notifications,\r
++                        npc_service_check.last_check,\r
++                        npc_service_check.next_check,\r
++                        npc_service_check.check_execute_time,\r
++                        npc_service_check.check_latency,\r
++                        npc_service_check.check_command,\r
++                        npc_service_check.performance_data,\r
++                        unix_timestamp() - npc_service_history.started as duration,\r
++                        npc_service_history.current_attempt,\r
++                        npc_service_check.max_attempts,\r
++                        npc_service_history.plugin_output\r
++                from\r
++                        npc_host,\r
++                        npc_host_history,\r
++                        npc_service,\r
++                        npc_service_check,\r
++                        npc_service_history\r
++                where\r
++                        npc_host.id not in (select hostid from npc_hostgroup_membership) and\r
++                        npc_host.id = npc_service.hostid and\r
++                        npc_host.id = npc_host_history.hostid and\r
++                        npc_service.id = npc_service_check.serviceid and\r
++                        npc_service.id = npc_service_history.serviceid and\r
++                        npc_service_history.lasted is null and\r
++                        npc_host_history.lasted is null and\r
++                        npc_service.configured = TRUE and\r
++                        npc_service.has_been_checked = TRUE and\r
++                        npc_host.has_been_checked = TRUE\r
++                union\r
++                select\r
++                        npc_host.id as hostid,\r
++                        npc_host.name,\r
++                        npc_hostgroup_membership.groupid as hostgroup,\r
++                        -1 as host_soft_state,\r
++                        npc_host.notifications_enabled as host_notifications,\r
++                        npc_service.id as serviceid,\r
++                        npc_service.cacti_graph_id,\r
++                        npc_service.service_description as service,\r
++                        npc_service_history.soft_state as service_soft_state,\r
++                        npc_service_history.hard_state as service_hard_state,\r
++                        npc_service.notifications_enabled as service_notifications,\r
++                        npc_service_check.last_check,\r
++                        npc_service_check.next_check,\r
++                        npc_service_check.check_execute_time,\r
++                        npc_service_check.check_latency,\r
++                        npc_service_check.check_command,\r
++                        npc_service_check.performance_data,\r
++                        unix_timestamp() - npc_service_history.started as duration,\r
++                        npc_service_history.current_attempt,\r
++                        npc_service_check.max_attempts,\r
++                        npc_service_history.plugin_output\r
++                from\r
++                        npc_host,\r
++                        npc_hostgroup_membership,\r
++                        npc_service,\r
++                        npc_service_check,\r
++                        npc_service_history\r
++                where\r
++                        npc_host.id = npc_hostgroup_membership.hostid and\r
++                        npc_host.id = npc_service.hostid and\r
++                        npc_service.id = npc_service_check.serviceid and\r
++                        npc_service.id = npc_service_history.serviceid and\r
++                        npc_service_history.lasted is null and\r
++                        npc_service.configured = TRUE and\r
++                        npc_service.has_been_checked = TRUE and\r
++                        npc_host.has_been_checked = FALSE\r
++                union\r
++                select\r
++                        npc_host.id as hostid,\r
++                        npc_host.name,\r
++                        0 as hostgroup,\r
++                        -1 as host_soft_state,\r
++                        npc_host.notifications_enabled as host_notifications,\r
++                        npc_service.id as serviceid,\r
++                        npc_service.cacti_graph_id,\r
++                        npc_service.service_description as service,\r
++                        npc_service_history.soft_state as service_soft_state,\r
++                        npc_service_history.hard_state as service_hard_state,\r
++                        npc_service.notifications_enabled as service_notifications,\r
++                        npc_service_check.last_check,\r
++                        npc_service_check.next_check,\r
++                        npc_service_check.check_execute_time,\r
++                        npc_service_check.check_latency,\r
++                        npc_service_check.check_command,\r
++                        npc_service_check.performance_data,\r
++                        unix_timestamp() - npc_service_history.started as duration,\r
++                        npc_service_history.current_attempt,\r
++                        npc_service_check.max_attempts,\r
++                        npc_service_history.plugin_output\r
++                from\r
++                        npc_host,\r
++                        npc_service,\r
++                        npc_service_check,\r
++                        npc_service_history\r
++                where\r
++                        npc_host.id not in (select hostid from npc_hostgroup_membership) and\r
++                        npc_host.id = npc_service.hostid and\r
++                        npc_service.id = npc_service_check.serviceid and\r
++                        npc_service.id = npc_service_history.serviceid and\r
++                        npc_service_history.lasted is null and\r
++                        npc_service.configured = TRUE and\r
++                        npc_service.has_been_checked = TRUE and\r
++                        npc_host.has_been_checked = FALSE\r
++                union\r
++                select\r
++                        npc_host.id as hostid,\r
++                        npc_host.name,\r
++                        npc_hostgroup_membership.groupid as hostgroup,\r
++                        npc_host_history.soft_state as host_soft_state,\r
++                        npc_host.notifications_enabled as host_notifications,\r
++                        npc_service.id as serviceid,\r
++                        npc_service.cacti_graph_id,\r
++                        npc_service.service_description as service,\r
++                        -1 as service_soft_state,\r
++                        -1 as service_hard_state,\r
++                        npc_service.notifications_enabled as service_notifications,\r
++                        npc_service_check.last_check,\r
++                        npc_service_check.next_check,\r
++                        npc_service_check.check_execute_time,\r
++                        npc_service_check.check_latency,\r
++                        npc_service_check.check_command,\r
++                        npc_service_check.performance_data,\r
++                        0 as duration,\r
++                        0 as current_attempt,\r
++                        npc_service_check.max_attempts,\r
++                        null as plugin_output\r
++                from\r
++                        npc_host,\r
++                        npc_host_history,\r
++                        npc_hostgroup_membership,\r
++                        npc_service,\r
++                        npc_service_check\r
++                where\r
++                        npc_host.id = npc_hostgroup_membership.hostid and\r
++                        npc_host.id = npc_service.hostid and\r
++                        npc_host.id = npc_host_history.hostid and\r
++                        npc_service.id = npc_service_check.serviceid and\r
++                        npc_host_history.lasted is null and\r
++                        npc_service.configured = TRUE and\r
++                        npc_service.has_been_checked = FALSE and\r
++                        npc_host.has_been_checked = TRUE\r
++                union\r
++                select\r
++                        npc_host.id as hostid,\r
++                        npc_host.name,\r
++                        0 as hostgroup,\r
++                        npc_host_history.soft_state as host_soft_state,\r
++                        npc_host.notifications_enabled as host_notifications,\r
++                        npc_service.id as serviceid,\r
++                        npc_service.cacti_graph_id,\r
++                        npc_service.service_description as service,\r
++                        -1 as service_soft_state,\r
++                        -1 as service_hard_state,\r
++                        npc_service.notifications_enabled as service_notifications,\r
++                        npc_service_check.last_check,\r
++                        npc_service_check.next_check,\r
++                        npc_service_check.check_execute_time,\r
++                        npc_service_check.check_latency,\r
++                        npc_service_check.check_command,\r
++                        npc_service_check.performance_data,\r
++                        0 as duration,\r
++                        0 as current_attempt,\r
++                        npc_service_check.max_attempts,\r
++                        null as plugin_output\r
++                from\r
++                        npc_host,\r
++                        npc_host_history,\r
++                        npc_service,\r
++                        npc_service_check\r
++                where\r
++                        npc_host.id not in (select hostid from npc_hostgroup_membership) and\r
++                        npc_host.id = npc_service.hostid and\r
++                        npc_host.id = npc_host_history.hostid and\r
++                        npc_service.id = npc_service_check.serviceid and\r
++                        npc_host_history.lasted is null and\r
++                        npc_service.configured = TRUE and\r
++                        npc_service.has_been_checked = FALSE and\r
++                        npc_host.has_been_checked = TRUE\r
++                union\r
++                select\r
++                        npc_host.id as hostid,\r
++                        npc_host.name,\r
++                        npc_hostgroup_membership.groupid as hostgroup,\r
++                        -1 as host_soft_state,\r
++                        npc_host.notifications_enabled as host_notifications,\r
++                        npc_service.id as serviceid,\r
++                        npc_service.cacti_graph_id,\r
++                        npc_service.service_description as service,\r
++                        -1 as service_soft_state,\r
++                        -1 as service_hard_state,\r
++                        npc_service.notifications_enabled as service_notifications,\r
++                        npc_service_check.last_check,\r
++                        npc_service_check.next_check,\r
++                        npc_service_check.check_execute_time,\r
++                        npc_service_check.check_latency,\r
++                        npc_service_check.check_command,\r
++                        npc_service_check.performance_data,\r
++                        0 as duration,\r
++                        0 as current_attempt,\r
++                        npc_service_check.max_attempts,\r
++                        null as plugin_output\r
++                from\r
++                        npc_host,\r
++                        npc_hostgroup_membership,\r
++                        npc_service,\r
++                        npc_service_check\r
++                where\r
++                        npc_host.id = npc_hostgroup_membership.hostid and\r
++                        npc_host.id = npc_service.hostid and\r
++                        npc_service.id = npc_service_check.serviceid and\r
++                        npc_service.configured = TRUE and\r
++                        npc_service.has_been_checked = FALSE and\r
++                        npc_host.has_been_checked = FALSE\r
++                union\r
++                select\r
++                        npc_host.id as hostid,\r
++                        npc_host.name,\r
++                        0 as hostgroup,\r
++                        -1 as host_soft_state,\r
++                        npc_host.notifications_enabled as host_notifications,\r
++                        npc_service.id as serviceid,\r
++                        npc_service.cacti_graph_id,\r
++                        npc_service.service_description as service,\r
++                        -1 as service_soft_state,\r
++                        -1 as service_hard_state,\r
++                        npc_service.notifications_enabled as service_notifications,\r
++                        npc_service_check.last_check,\r
++                        npc_service_check.next_check,\r
++                        npc_service_check.check_execute_time,\r
++                        npc_service_check.check_latency,\r
++                        npc_service_check.check_command,\r
++                        npc_service_check.performance_data,\r
++                        0 as duration,\r
++                        0 as current_attempt,\r
++                        npc_service_check.max_attempts,\r
++                        null as plugin_output\r
++                from\r
++                        npc_host,\r
++                        npc_service,\r
++                        npc_service_check\r
++                where\r
++                        npc_host.id not in (select hostid from npc_hostgroup_membership) and\r
++                        npc_host.id = npc_service.hostid and\r
++                        npc_service.id = npc_service_check.serviceid and\r
++                        npc_service.configured = TRUE and\r
++                        npc_service.has_been_checked = FALSE and\r
++                        npc_host.has_been_checked = FALSE\r
++                order by\r
++                        name\r
++        ) as host_details where hostid = $hostid and service = '$serviceName'");\r
++\r
++      $service_detail["flapping"] = db_fetch_cell("select id from npc_flapping_service where id = $serviceid");\r
++      $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'");\r
++      $comments = db_fetch_assoc("select id,serviceid,timestamp,author,comment,persist,type from npc_comment where serviceid = '$serviceid'");\r
++      $row_count = count($comments);\r
++\r
++?>\r
++\r
++\r
++\r
++\r
++   <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">\r
++   <tr class="textSubHeaderDark" bgcolor='#6d88ad'>\r
++      <td>\r
++              <h2>&nbsp;[ <?php echo $serviceName; ?> ] on \r
++              <a href="extinfo.php?type=1&hostid=<?php echo $hostid; ?>&hostname=<?php echo $hostname; ?>"><?php echo $hostname; ?></a></h2>\r
++      </td>\r
++      <td align='right' nowrap>\r
++              <FORM NAME="cl" ACTION="command.php" method="POST">Command: \r
++                      <INPUT TYPE='hidden' NAME='host' VALUE='<?php echo $hostname; ?>'>\r
++                      <INPUT TYPE='hidden' NAME='hostid' VALUE='<?php echo $service_detail["hostid"]; ?>'>\r
++                      <INPUT TYPE='hidden' NAME='service' VALUE='<?php echo $serviceName; ?>'>\r
++                      <INPUT TYPE='hidden' NAME='serviceid' VALUE='<?php echo $service_detail["serviceid"]; ?>'>\r
++                      <select name="command" size="1">\r
++\r
++<?php \r
++                      if (read_config_option("nagios_commands")) {\r
++\r
++                              echo "<OPTION VALUE='NULL'>Execute a command</option>";\r
++\r
++                              if ($service_config["active_checks_enabled"]) {\r
++                                      echo "<strong><OPTION VALUE='DISABLE_SVC_CHECK'>Disable active checks</option></strong>";\r
++                                      echo "<OPTION VALUE='SCHEDULE_SVC_CHECK'>Re-schedule the next check</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_SVC_CHECK'>Enable Active Checks</option>";\r
++                              }\r
++                              if ($service_config["passive_checks_enabled"]) {\r
++                                      echo "<OPTION VALUE='PROCESS_SVC_CHECK_RESULT'>Submit passive check result</option>";\r
++                                      echo "<OPTION VALUE='DISABLE_PASSIVE_SVC_CHECKS'>Stop accepting passive checks</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_PASSIVE_SVC_CHECKS'>Start accepting passive checks</option>";\r
++                              }\r
++                              if ($service_config["obsess_over_service"]) {\r
++                                      echo "<OPTION VALUE='STOP_OBSESSING_OVER_SVC'>Stop obsessing</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='START_OBSESSING_OVER_SVC'>Start obsessing</option>";\r
++                              }\r
++                              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"]) {\r
++                                      if (!db_fetch_cell("select * from npc_comment where serviceid = $serviceid and type = 4;")) {\r
++                                              echo "<OPTION VALUE='ACKNOWLEDGE_SVC_PROBLEM'>Acknowledge This Service Problem</option>";\r
++                                      } elseif (db_fetch_cell("select * from npc_comment where serviceid = $serviceid and type = 4;")) {\r
++                                              echo "<OPTION VALUE='REMOVE_SVC_ACKNOWLEDGEMENT'>Remove Problem Acknowledgement</option>";\r
++                                      }\r
++                              }\r
++                              if ($service_config["notifications_enabled"]) {\r
++                                      echo "<OPTION VALUE='DISABLE_SVC_NOTIFICATIONS'>Disable Notifications</option>";\r
++                                      if ($service_detail["Current Status"] != 0) {\r
++                                              echo "<OPTION VALUE='DELAY_SVC_NOTIFICATION'>Delay Next Service Notification</option>";\r
++                                      }\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_SVC_NOTIFICATIONS'>Enable Notifications</option>";\r
++                              }\r
++                              echo "<OPTION VALUE='SCHEDULE_SVC_DOWNTIME'>Schedule Downtime</option>";\r
++                              if ($service_config["event_handler_enabled"]) {\r
++                                      echo "<OPTION VALUE='DISABLE_SVC_EVENT_HANDLER'>Disable Event Handler</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_SVC_EVENT_HANDLER'>Enable Event Handler</option>";\r
++                              }\r
++                              if ($service_config["flap_detection_enabled"]) {\r
++                                      echo "<OPTION VALUE='DISABLE_SVC_FLAP_DETECTION'>Disable Flap Detection</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_SVC_FLAP_DETECTION'>Enable Flap Detection</option>";\r
++                              }\r
++                              echo "<OPTION VALUE='ADD_SVC_COMMENT'>Add Service Comment</option>";\r
++                              echo "<OPTION VALUE='DEL_ALL_SVC_COMMENTS'>Delete All Service Comments</option>";\r
++                      } else {\r
++                              echo "<OPTION VALUE=''>Command execution disabled</option>";\r
++                      }\r
++?>\r
++\r
++                      </select>\r
++                      <input type='image' src='../../images/button_go.gif' alt='Go' value='Execute' align='absmiddle'>\r
++              </form>\r
++\r
++\r
++      </td>\r
++   </tr>\r
++\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <tr>\r
++   <td valign="top">\r
++      <table width="100%" border="0" align="left" valign="top">\r
++      <thead>\r
++      <tr class="textHeaderDark" bgcolor='#00438C'>\r
++      <td align="center"><strong>Service State Information</strong></td>\r
++      </tr>\r
++      </thead>\r
++      <tbody>\r
++      <tr>\r
++      <td width="100%" valign="top">\r
++         <table width="100%" align="center" cellpadding="3">\r
++         <thead>\r
++         <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
++         <td>Parameter</td>\r
++         <td>Value</td>\r
++         </tr>\r
++         </thead>\r
++         <tbody>\r
++\r
++\r
++<?php\r
++\r
++\r
++      foreach ($service_detail as $key => $value) {\r
++\r
++\r
++              switch($key) \r
++              {\r
++                      case "Current Status":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              switch($value)\r
++                              {\r
++                                      case "-1":\r
++                                              echo "<td class='statusPENDING'><strong>PENDING</strong></td>";\r
++                                              break;\r
++                                      case "0":\r
++                                              echo "<td class='statusOK'><strong>OK</strong></td>";\r
++                                              break;\r
++                                      case "1":\r
++                                              echo "<td class='statusWARNING'><strong>WARNING</strong></td>";\r
++                                              break;\r
++                                      case "2":\r
++                                              echo "<td class='statusCRITICAL'><strong>CRITICAL</strong></td>";\r
++                                              break;\r
++                                      case "3":\r
++                                              echo "<td class='statusUNKNOWN'><strong>UNKNOWN</strong></td>";\r
++                                              break;\r
++                              }\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "State Duration":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . formatTime($value) . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Check Command":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Plugin Output":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Performance Data":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Current Attempt":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "/" . $service_detail["Max Attempts"] . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Last Check":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              if (preg_match('/1969-12-31/', $value)) {\r
++                                      echo "<td>N/A</td>";\r
++                              } else {\r
++                                      echo "<td>" . $value . "</td>";\r
++                              }\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Next Check":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Check Latency":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Check Duration":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "flapping":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>Flapping:</td>";\r
++                              if ($service_detail["flapping"]) {\r
++                                      echo "<td>Yes</td>";\r
++                              } else {\r
++                                      echo "<td>No</td>";\r
++                              }\r
++                              echo "</tr>";\r
++                              break;\r
++                }\r
++\r
++              if($rowColor == $background1) {\r
++                        $rowColor = $background2;\r
++                } else {\r
++                        $rowColor = $background1;\r
++                }\r
++\r
++              if ($key == "flapping") {\r
++                      echo "<tr bgcolor='" . $rowColor . "'>";\r
++                      echo "<td>Event Handler:</td>";\r
++                      if (!$service_config["event_handler"]) {\r
++                              echo "<td>N/A</td>";\r
++                        } else {\r
++                              echo "<td>" . $service_config["event_handler"] . "</td>";\r
++                        }\r
++                      echo "</tr>";\r
++              }\r
++\r
++\r
++      }\r
++\r
++\r
++?>\r
++\r
++      </tbody>\r
++      </table>\r
++\r
++      </td>\r
++      </tr>\r
++      </tbody>\r
++      </table>\r
++\r
++   </td>\r
++\r
++   <td valign="top">\r
++      <table width="70%" border="0" align="right">\r
++      <thead>\r
++      <tr class="textHeaderDark" bgcolor='#00438C'>\r
++      <td align="center"><strong>Service Monitoring Options</strong></td>\r
++      </tr>\r
++      </thead>\r
++      <tbody>\r
++      <tr>\r
++      <td width="70%" valign="top">\r
++         <table width="100%" align="center" cellpadding="3">\r
++         <thead>\r
++         <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
++         <td>Parameter</td>\r
++         <td>Value</td>\r
++         </tr>\r
++         </thead>\r
++         <tbody>\r
++\r
++<?php\r
++       $rowColor = $background1;\r
++         echo "<tr bgcolor='" . $rowColor . "'>";\r
++\r
++\r
++      foreach ($service_config as $key => $value) {\r
++\r
++              if ($key == "event_handler") { continue; }\r
++\r
++              echo "<tr bgcolor='" . $rowColor . "'>";\r
++\r
++                switch($key)\r
++                {\r
++                        case "active_checks_enabled":\r
++                                echo "<td>Active Checks:</td>";\r
++                                break;\r
++                        case "passive_checks_enabled":\r
++                                echo "<td>Passive Checks:</td>";\r
++                                break;\r
++                        case "event_handler_enabled":\r
++                                echo "<td>Event Handler:</td>";\r
++                                break;\r
++                        case "flap_detection_enabled":\r
++                                echo "<td>Flap Detection:</td>";\r
++                                break;\r
++                        case "notifications_enabled":\r
++                                echo "<td>Notifications:</td>";\r
++                                break;\r
++                        case "failure_prediction_enabled":\r
++                                echo "<td>Failure Prediction:</td>";\r
++                                break;\r
++                        case "process_performance_data":\r
++                                echo "<td>Process Performance Data:</td>";\r
++                                break;\r
++                        case "obsess_over_service":\r
++                                echo "<td>Obsess Over Service:</td>";\r
++                                break;\r
++                }\r
++\r
++              if ($value == 0) {\r
++                      echo "<td class='optionDISABLED'>Disabled</td></tr>";\r
++              } else {\r
++                      echo "<td class='optionENABLED'>Enabled</td></tr>";\r
++              }\r
++\r
++              if($rowColor == $background1) {\r
++                        $rowColor = $background2;\r
++                } else {\r
++                        $rowColor = $background1;\r
++                }\r
++\r
++\r
++      }\r
++\r
++?>\r
++            </tbody>\r
++            </table>\r
++         </td>\r
++         </tr>\r
++         </table>\r
++\r
++   </td>\r
++\r
++\r
++\r
++<?php\r
++\r
++\r
++\r
++\r
++   echo "</tr>";\r
++   echo "<tr>";\r
++\r
++?>\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <td valign="top" colspan='2'>\r
++      <table width="60%" border="0" align="center">\r
++         <thead>\r
++          <tr class="textHeaderDark" bgcolor='#00438C'>\r
++               <td align="center"><strong>Service Comments</strong></td>\r
++            </tr>\r
++         </thead>\r
++         <tbody>\r
++            <tr>\r
++               <td width="60%" valign="top">\r
++                  <table width="100%" align="center" cellpadding="3">\r
++                   <thead>\r
++                      <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
++                         <td>Entry Time</td>\r
++                         <td>Author</td>\r
++                         <td>Comment</td>\r
++                         <td>Persistent</td>\r
++                         <td>Type</td>\r
++                         <td>Delete</td>\r
++                     <tbody>\r
++<?php\r
++      for($i = 0; $i < $row_count; $i++) {\r
++              \r
++              echo "<tr bgcolor='" . $rowColor . "'>";\r
++              echo "<td nowrap>" . $comments[$i]["timestamp"] . "</td>";\r
++              echo "<td>" . $comments[$i]["author"] . "</td>";\r
++              echo "<td>" . $comments[$i]["comment"] . "</td>";\r
++              echo "<td>";\r
++              if ($comments[$i]["persist"]) {\r
++                      echo "Yes";\r
++              } else {\r
++                      echo "No"; \r
++              }\r
++              echo "</td>";\r
++              echo "<td>";\r
++              if ($comments[$i]["type"] == 2) {\r
++                      echo "Comment";\r
++              } elseif ($comments[$i]["type"] == 4) {\r
++                      echo "Acknowledgment";\r
++              }\r
++              echo "</td>";\r
++              echo "<td>";\r
++              if ($comments[$i]["type"] == 2) {\r
++                      echo "<a href='command.php?cmd=DEL_SVC_COMMENT&id=" . $comments[$i]["id"] . "&host=" . $hostname . "&hostid=" . $hostid . "&service=" . $_REQUEST["service"] . "&serviceid=" . $serviceid . "'><img src='images/delete.gif' alt='delete' title='Delete comment' border=0></a>";\r
++              } elseif ($comments[$i]["type"] == 4) {\r
++                      echo "<a href='command.php?cmd=REMOVE_SVC_ACKNOWLEDGEMENT&host=" . $hostname . "&hostid=" . $hostid . "&service=" . $_REQUEST["service"] . "&serviceid=" . $serviceid . "'><img src='images/delete.gif' alt='Remove' title='Remove problem acknowledgment' border=0></a>";\r
++              }\r
++              echo "</td>";\r
++\r
++\r
++              if($rowColor == $background1) {\r
++                      $rowColor = $background2;\r
++              } else {\r
++                      $rowColor = $background1;\r
++              }\r
++      }\r
++\r
++\r
++\r
++\r
++\r
++\r
++\r
++?>\r
++                   </tbody>\r
++                </table>\r
++             </td>\r
++          </tr>\r
++          <tr>\r
++             <td>\r
++                <?php \r
++                      echo "<a href='command.php?cmd=ADD_SVC_COMMENT&host=" . $hostname . "&hostid=" . $hostid . "&service=" . $_REQUEST["service"] . "&serviceid=" . $serviceid . "'><img src='images/comment.gif' alt='Add a comment' title='Add a comment' border=0></a>"; \r
++                      echo "<a href='command.php?cmd=DEL_ALL_SVC_COMMENTS&host=" . $hostname . "&hostid=" . $hostid . "&service=" . $_REQUEST["service"] . "&serviceid=" . $serviceid . "'><img src='images/delete.gif' alt='Delete all comments' title='Delete all comments' border=0></a>"; \r
++                ?>\r
++               </td>\r
++            </tr>\r
++      </tbody>\r
++      </table>\r
++   </td>\r
++   <td></td>\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <tr>\r
++\r
++\r
++\r
++\r
++\r
++   <td valign="top" colspan='2'>\r
++      <table width="60%" border="0" align="center">\r
++      <thead>\r
++      <tr align="center" class="textHeaderDark" bgcolor='#00438C'>\r
++      <td align="center"><strong>Graph Mapping</strong></td>\r
++      </tr>\r
++      </thead>\r
++      <tbody>\r
++      <tr>\r
++      <td width="60%" valign="top">\r
++         <table width="100%" align="center" cellpadding="3">\r
++            <tbody>\r
++\r
++<?php\r
++\r
++$cacti_graphs = db_fetch_assoc("\r
++select\r
++                graph_templates_graph.id,\r
++                graph_templates_graph.local_graph_id,\r
++                graph_templates_graph.height,\r
++                graph_templates_graph.width,\r
++                graph_templates_graph.title_cache as title,\r
++                graph_templates.name,\r
++                graph_local.host_id\r
++                from graph_local,graph_templates_graph\r
++                left join graph_templates on graph_template_id=graph_templates.id\r
++                where graph_local.id=graph_templates_graph.local_graph_id\r
++                and graph_templates_graph.title_cache like '%'\r
++                order by graph_templates_graph.title_cache,graph_local.host_id");\r
++\r
++              $row_count = count($cacti_graphs);\r
++/* http://logindev/cacti/graph_image.php?local_graph_id=6&rra_id=0 */\r
++?>\r
++\r
++                   <FORM NAME="gm" ACTION="" method="post">\r
++                   <tr bgcolor='<?php echo $background1; ?>'>\r
++                        <td>Associated graph:</td>\r
++                        <td>\r
++                         <select name="local_graph_id" size="1">\r
++                            <?php\r
++                              echo "<OPTION VALUE='NULL'>None</option>";\r
++                              for($i = 0; $i < $row_count; $i++) {\r
++                                      echo "<OPTION VALUE='" . $cacti_graphs[$i]["local_graph_id"] . "'>" . $cacti_graphs[$i]["title"] . "</option>";\r
++                              }\r
++                            ?> \r
++\r
++\r
++                         </select>\r
++                      </td>\r
++                        <td><INPUT TYPE="submit" VALUE="Map"></td>\r
++                   </tr>\r
++                   </FORM>\r
++\r
++\r
++            </tbody>\r
++         </table>\r
++              <?php \r
++                      if ($service_detail["cacti_graph_id"]) {\r
++                              echo "<table align='center'>";\r
++                              echo "<tr><td width='100%'>";\r
++                              echo "<img src='../../graph_image.php?local_graph_id=" . $service_detail["cacti_graph_id"] . "&rra_id=0'>";\r
++                              echo "</td></tr>";\r
++                      }\r
++              ?>\r
++      </td>\r
++      </tr>\r
++   </tbody>\r
++   </table>\r
++\r
++   </td>\r
++\r
++   </tr>\r
++   </table>\r
++\r
++<?php\r
++\r
++\r
++}\r
++\r
++\r
++function hostInfo() {\r
++\r
++      $hostid = $_REQUEST["hostid"];\r
++      $hostname = $_REQUEST["hostname"];\r
++\r
++      if (isset($_POST["local_graph_id"])) {\r
++              db_execute("update npc_host set cacti_graph_id = " . $_POST["local_graph_id"] . " where id = " . $hostid);\r
++              header("Location: extinfo.php?type=1&hostid=" . $hostid . "&hostname=" . $hostname);\r
++      }\r
++\r
++      include_once("top_npc_header.php");\r
++\r
++        $background1 = "#F5F5F5";\r
++        $background2 = "#E7E9F2";\r
++        $rowColor = $background1;\r
++\r
++      $host_flapping["flapping"] = db_fetch_cell("select id from npc_flapping_host where id = $hostid");\r
++\r
++      $host_history = db_fetch_row("select started, soft_state, hard_state, current_attempt, plugin_output from npc_host_history where hostid = $hostid order by started desc;");\r
++\r
++      $host_check = db_fetch_row("select check_command, check_execute_time, check_latency, from_unixtime(last_check) as last_check, from_unixtime(next_check) as next_check, max_attempts, last_notification, next_notification, no_more_notifications, check_type, performance_data from npc_host_check where hostid = $hostid;");\r
++\r
++      $host_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_host, event_handler, cacti_graph_id from npc_host where id = $hostid");\r
++\r
++      $comments = db_fetch_assoc("select id,serviceid,timestamp,author,comment,persist,type from npc_comment where hostid = $hostid");\r
++\r
++      $graphView = db_fetch_cell("select id from graph_tree_items where host_id = (select id from host where npc_host_id = $hostid)");\r
++\r
++      $row_count = count($comments);\r
++\r
++      $duration =  date("U") - $host_history["started"];\r
++\r
++?>\r
++\r
++\r
++\r
++\r
++   <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">\r
++   <tr class="textSubHeaderDark" bgcolor='#6d88ad'>\r
++      <td>\r
++              <h2>&nbsp;<strong><?php echo $hostname; ?></strong></h2>\r
++      </td>\r
++      <td align='right' nowrap>\r
++              <FORM NAME="cl" ACTION="command.php" method="POST">Command: \r
++                      <INPUT TYPE='hidden' NAME='host' VALUE='<?php echo $hostname; ?>'>\r
++                      <INPUT TYPE='hidden' NAME='hostid' VALUE='<?php echo $hostid; ?>'>\r
++                      <select name="command" size="1">\r
++\r
++<?php \r
++                      if (read_config_option("nagios_commands")) {\r
++\r
++                              echo "<OPTION VALUE='NULL'>Execute a command</option>";\r
++\r
++                              if ($host_config["active_checks_enabled"]) {\r
++                                      echo "<OPTION VALUE='DISABLE_HOST_CHECK'>Disable active checks</option>";\r
++                                      echo "<OPTION VALUE='SCHEDULE_HOST_CHECK'>Re-schedule the next check</option>";\r
++                                      echo "<OPTION VALUE='SCHEDULE_HOST_SVC_CHECKS'>Schedule a check of all services</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_HOST_CHECK'>Enable Active Checks</option>";\r
++                              }\r
++                              echo "<OPTION VALUE='DISABLE_HOST_SVC_CHECKS'>Disable checks of all services</option>";\r
++                              echo "<OPTION VALUE='ENABLE_HOST_SVC_CHECKS'>Enabble checks of all services</option>";\r
++                              if ($host_config["passive_checks_enabled"]) {\r
++                                      echo "<OPTION VALUE='PROCESS_HOST_CHECK_RESULT'>Submit passive check result</option>";\r
++                                      echo "<OPTION VALUE='DISABLE_PASSIVE_HOST_CHECKS'>Stop accepting passive checks</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_PASSIVE_HOST_CHECKS'>Start accepting passive checks</option>";\r
++                              }\r
++                              if ($host_config["obsess_over_service"]) {\r
++                                      echo "<OPTION VALUE='STOP_OBSESSING_OVER_HOST'>Stop obsessing</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='START_OBSESSING_OVER_HOST'>Start obsessing</option>";\r
++                              }\r
++                              if ($host_history["soft_state"] == 1 || $host_history["soft_state"] == 2 && $host_history["soft_state"] == $host_history["hard_state"]) {\r
++                                      if (!db_fetch_cell("select * from npc_comment where hostid = $hostid and type = 4;")) {\r
++                                              echo "<OPTION VALUE='ACKNOWLEDGE_HOST_PROBLEM'>Acknowledge This Host Problem</option>";\r
++                                      } elseif (db_fetch_cell("select * from npc_comment where hostid = $hostid and type = 4;")) {\r
++                                              echo "<OPTION VALUE='REMOVE_HOST_ACKNOWLEDGEMENT'>Remove Problem Acknowledgement</option>";\r
++                                      }\r
++                              }\r
++                              if ($host_config["notifications_enabled"]) {\r
++                                      echo "<OPTION VALUE='DISABLE_HOST_NOTIFICATIONS'>Disable Notifications</option>";\r
++                                      if ($host_history["soft_state"] != 0) {\r
++                                              echo "<OPTION VALUE='DELAY_HOST_NOTIFICATION'>Delay Next Service Notification</option>";\r
++                                      }\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_HOST_NOTIFICATIONS'>Enable Notifications</option>";\r
++                              }\r
++                              echo "<OPTION VALUE='SCHEDULE_HOST_DOWNTIME'>Schedule Downtime</option>";\r
++                              if ($host_config["event_handler_enabled"]) {\r
++                                      echo "<OPTION VALUE='DISABLE_HOST_EVENT_HANDLER'>Disable Event Handler</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_HOST_EVENT_HANDLER'>Enable Event Handler</option>";\r
++                              }\r
++                              if ($host_config["flap_detection_enabled"]) {\r
++                                      echo "<OPTION VALUE='DISABLE_HOST_FLAP_DETECTION'>Disable Flap Detection</option>";\r
++                              } else {\r
++                                      echo "<OPTION VALUE='ENABLE_HOST_FLAP_DETECTION'>Enable Flap Detection</option>";\r
++                              }\r
++                              echo "<OPTION VALUE='ADD_HOST_COMMENT'>Add Host Comment</option>";\r
++                              echo "<OPTION VALUE='DEL_ALL_HOST_COMMENTS'>Delete All Host Comments</option>";\r
++                      } else {\r
++                              echo "<OPTION VALUE='NULL'>Command execution disabled</option>";\r
++                      }\r
++?>\r
++\r
++                      </select>\r
++                      <input type='image' src='../../images/button_go.gif' alt='Go' value='Execute' align='absmiddle'>\r
++              </form>\r
++\r
++\r
++      </td>\r
++   </tr>\r
++   <tr><td></td><td></td></tr>\r
++   <tr bgcolor='#a9b7cb'>\r
++      <td><a href='statusDetail.php?filter=showHost&name=<?php echo $hostname; ?>'>View Services</a> | <?php if ($graphView) { ?><a href='<?php echo $config['url_path']?>graph_view.php?action=tree&tree_id=1&leaf_id=<?php echo $graphView; ?>'>View Graphs</a> | <?php } ?><a href='hostConfig.php?name=<?php echo $hostname; ?>&hostid=<?php echo $hostid; ?>'>Configure</a></td>\r
++      <td>&nbsp;</td></tr>\r
++   </tr>\r
++\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <tr>\r
++   <td valign="top">\r
++      <table width="100%" border="0" align="left" valign="top">\r
++      <thead>\r
++      <tr class="textHeaderDark" bgcolor='#00438C'>\r
++      <td align="center"><strong>Host State Information</strong></td>\r
++      </tr>\r
++      </thead>\r
++      <tbody>\r
++      <tr>\r
++      <td width="100%" valign="top">\r
++         <table width="100%" align="center" cellpadding="3">\r
++         <thead>\r
++         <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
++         <td>Parameter</td>\r
++         <td>Value</td>\r
++         </tr>\r
++         </thead>\r
++         <tbody>\r
++\r
++\r
++<?php\r
++\r
++\r
++      $host_detail = array(\r
++              'Current Status'   => $host_history["soft_state"],\r
++              'State Duration'   => formatTime($duration),\r
++              'Check Command'    => $host_check["check_command"],\r
++              'Plugin Output'    => $host_history["plugin_output"],\r
++              'Performance Data' => $host_check["performance_data"],\r
++              'Current Attempt'  => $host_history["current_attempt"],\r
++              'Last Check'       => $host_check["last_check"],\r
++              'Next Check'       => $host_check["next_check"],\r
++              'Check Latency'    => $host_check["check_latency"],\r
++              'Check Duration'   => $host_check["check_execute_time"],\r
++              'flapping'         => $host_flapping["flapping"],\r
++              'Event Handler'    => $host_config["event_handler"],\r
++      );\r
++\r
++      foreach ($host_detail as $key => $value) {\r
++\r
++\r
++              switch($key) \r
++              {\r
++                      case "Current Status":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              switch($value)\r
++                              {\r
++                                      case "-1":\r
++                                              echo "<td class='statusPENDING'><strong>PENDING</strong></td>";\r
++                                              break;\r
++                                      case "0":\r
++                                              echo "<td class='statusHOSTUP'><strong>UP</strong></td>";\r
++                                              break;\r
++                                      case "1":\r
++                                              echo "<td class='statusHOSTDOWN'><strong>DOWN</strong></td>";\r
++                                              break;\r
++                                      case "2":\r
++                                              echo "<td class='statusHOSTUNREACHABLE'><strong>UNREACHABLE</strong></td>";\r
++                                              break;\r
++                              }\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "State Duration":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Check Command":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Plugin Output":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Performance Data":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Current Attempt":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "/" . $host_check["max_attempts"] . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Last Check":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              if (preg_match('/1969-12-31/', $value)) {\r
++                                      echo "<td>N/A</td>";\r
++                              } else {\r
++                                      echo "<td>" . $value . "</td>";\r
++                              }\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Next Check":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              if (preg_match('/1969-12-31/', $value)) {\r
++                                      echo "<td>N/A</td>";\r
++                              } else {\r
++                                      echo "<td>" . $value . "</td>";\r
++                              }\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Check Latency":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Check Duration":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              echo "<td>" . $value . "</td>";\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "flapping":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>Flapping:</td>";\r
++                              if ($host_detail["flapping"]) {\r
++                                      echo "<td>Yes</td>";\r
++                              } else {\r
++                                      echo "<td>No</td>";\r
++                              }\r
++                              echo "</tr>";\r
++                              break;\r
++                      case "Event Handler":\r
++                              echo "<tr bgcolor='" . $rowColor . "'>";\r
++                              echo "<td>" . $key . ":</td>";\r
++                              if (!$value) {\r
++                                      echo "<td>N/A</td>";\r
++                              } else {\r
++                                      echo "<td>" . $value . "</td>";\r
++                              }\r
++                              echo "</tr>";\r
++                              break;\r
++                }\r
++\r
++              if($rowColor == $background1) {\r
++                        $rowColor = $background2;\r
++                } else {\r
++                        $rowColor = $background1;\r
++                }\r
++\r
++      }\r
++\r
++\r
++?>\r
++\r
++      </tbody>\r
++      </table>\r
++\r
++      </td>\r
++      </tr>\r
++      </tbody>\r
++      </table>\r
++\r
++   </td>\r
++\r
++   <td valign="top">\r
++      <table width="70%" border="0" align="right">\r
++      <thead>\r
++      <tr class="textHeaderDark" bgcolor='#00438C'>\r
++      <td align="center"><strong>Host Monitoring Options</strong></td>\r
++      </tr>\r
++      </thead>\r
++      <tbody>\r
++      <tr>\r
++      <td width="70%" valign="top">\r
++         <table width="100%" align="center" cellpadding="3">\r
++         <thead>\r
++         <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
++         <td>Parameter</td>\r
++         <td>Value</td>\r
++         </tr>\r
++         </thead>\r
++         <tbody>\r
++\r
++<?php\r
++       $rowColor = $background1;\r
++         echo "<tr bgcolor='" . $rowColor . "'>";\r
++\r
++\r
++      foreach ($host_config as $key => $value) {\r
++\r
++              if ($key == "event_handler") { continue; }\r
++              if ($key == "cacti_graph_id") { continue; }\r
++\r
++              echo "<tr bgcolor='" . $rowColor . "'>";\r
++\r
++                switch($key)\r
++                {\r
++                        case "active_checks_enabled":\r
++                                echo "<td>Active Checks:</td>";\r
++                                break;\r
++                        case "passive_checks_enabled":\r
++                                echo "<td>Passive Checks:</td>";\r
++                                break;\r
++                        case "event_handler_enabled":\r
++                                echo "<td>Event Handler:</td>";\r
++                                break;\r
++                        case "flap_detection_enabled":\r
++                                echo "<td>Flap Detection:</td>";\r
++                                break;\r
++                        case "notifications_enabled":\r
++                                echo "<td>Notifications:</td>";\r
++                                break;\r
++                        case "failure_prediction_enabled":\r
++                                echo "<td>Failure Prediction:</td>";\r
++                                break;\r
++                        case "process_performance_data":\r
++                                echo "<td>Process Performance Data:</td>";\r
++                                break;\r
++                        case "obsess_over_host":\r
++                                echo "<td>Obsess Over Host:</td>";\r
++                                break;\r
++                }\r
++\r
++              if ($value == 0) {\r
++                      echo "<td class='optionDISABLED'>Disabled</td></tr>";\r
++              } else {\r
++                      echo "<td class='optionENABLED'>Enabled</td></tr>";\r
++              }\r
++\r
++              if($rowColor == $background1) {\r
++                        $rowColor = $background2;\r
++                } else {\r
++                        $rowColor = $background1;\r
++                }\r
++\r
++\r
++      }\r
++\r
++?>\r
++            </tbody>\r
++            </table>\r
++         </td>\r
++         </tr>\r
++         </table>\r
++\r
++   </td>\r
++\r
++\r
++\r
++<?php\r
++\r
++\r
++\r
++\r
++   echo "</tr>";\r
++   echo "<tr>";\r
++\r
++?>\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <td valign="top" colspan='2'>\r
++      <table width="60%" border="0" align="center">\r
++         <thead>\r
++          <tr class="textHeaderDark" bgcolor='#00438C'>\r
++               <td align="center"><strong>Host Comments</strong></td>\r
++            </tr>\r
++         </thead>\r
++         <tbody>\r
++            <tr>\r
++               <td width="60%" valign="top">\r
++                  <table width="100%" align="center" cellpadding="3">\r
++                   <thead>\r
++                      <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
++                         <td>Entry Time</td>\r
++                         <td>Author</td>\r
++                         <td>Comment</td>\r
++                         <td>Persistent</td>\r
++                         <td>Type</td>\r
++                         <td>Delete</td>\r
++                     <tbody>\r
++<?php\r
++      for($i = 0; $i < $row_count; $i++) {\r
++              \r
++              echo "<tr bgcolor='" . $rowColor . "'>";\r
++              echo "<td nowrap>" . $comments[$i]["timestamp"] . "</td>";\r
++              echo "<td>" . $comments[$i]["author"] . "</td>";\r
++              echo "<td>" . $comments[$i]["comment"] . "</td>";\r
++              echo "<td>";\r
++              if ($comments[$i]["persist"]) {\r
++                      echo "Yes";\r
++              } else {\r
++                      echo "No"; \r
++              }\r
++              echo "</td>";\r
++              echo "<td>";\r
++              if ($comments[$i]["type"] == 1) {\r
++                      echo "Comment";\r
++              } elseif ($comments[$i]["type"] == 3) {\r
++                      echo "Acknowledgment";\r
++              }\r
++              echo "</td>";\r
++              echo "<td>";\r
++              if ($comments[$i]["type"] == 1) {\r
++                      echo "<a href='command.php?cmd=DEL_HOST_COMMENT&id=" . $comments[$i]["id"] . "&host=" . $hostname . "&hostid=" . $hostid . "'><img src='images/delete.gif' alt='delete' title='Delete comment' border=0></a>";\r
++              } elseif ($comments[$i]["type"] == 3) {\r
++                      echo "<a href='command.php?cmd=REMOVE_HOST_ACKNOWLEDGEMENT&host=" . $hostname . "&hostid=" . $hostid . "'><img src='images/delete.gif' alt='Remove' title='Remove problem acknowledgment' border=0></a>";\r
++              }\r
++              echo "</td>";\r
++\r
++\r
++              if($rowColor == $background1) {\r
++                      $rowColor = $background2;\r
++              } else {\r
++                      $rowColor = $background1;\r
++              }\r
++      }\r
++\r
++\r
++\r
++\r
++\r
++\r
++\r
++?>\r
++                   </tbody>\r
++                </table>\r
++             </td>\r
++          </tr>\r
++          <tr>\r
++             <td>\r
++                <?php \r
++                      echo "<a href='command.php?cmd=ADD_HOST_COMMENT&host=" . $hostname . "&hostid=" . $hostid . "'><img src='images/comment.gif' alt='Add a comment' title='Add a comment' border=0></a>"; \r
++                      echo "<a href='command.php?cmd=DEL_ALL_HOST_COMMENTS&host=" . $hostname . "&hostid=" . $hostid . "'><img src='images/delete.gif' alt='Delete all comments' title='Delete all comments' border=0></a>"; \r
++                ?>\r
++               </td>\r
++            </tr>\r
++      </tbody>\r
++      </table>\r
++   </td>\r
++   <td></td>\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
++   <tr>\r
++\r
++\r
++\r
++\r
++\r
++   <td valign="top" colspan='2'>\r
++      <table width="60%" border="0" align="center">\r
++      <thead>\r
++      <tr align="center" class="textHeaderDark" bgcolor='#00438C'>\r
++      <td align="center"><strong>Graph Mapping</strong></td>\r
++      </tr>\r
++      </thead>\r
++      <tbody>\r
++      <tr>\r
++      <td width="60%" valign="top">\r
++         <table width="100%" align="center" cellpadding="3">\r
++            <tbody>\r
++\r
++<?php\r
++\r
++$cacti_graphs = db_fetch_assoc("\r
++select\r
++                graph_templates_graph.id,\r
++                graph_templates_graph.local_graph_id,\r
++                graph_templates_graph.height,\r
++                graph_templates_graph.width,\r
++                graph_templates_graph.title_cache as title,\r
++                graph_templates.name,\r
++                graph_local.host_id\r
++                from graph_local,graph_templates_graph\r
++                left join graph_templates on graph_template_id=graph_templates.id\r
++                where graph_local.id=graph_templates_graph.local_graph_id\r
++                and graph_templates_graph.title_cache like '%'\r
++                order by graph_templates_graph.title_cache,graph_local.host_id");\r
++\r
++              $row_count = count($cacti_graphs);\r
++/* http://logindev/cacti/graph_image.php?local_graph_id=6&rra_id=0 */\r
++?>\r
++\r
++                   <FORM NAME="gm" ACTION="" method="post">\r
++                   <tr bgcolor='<?php echo $background1; ?>'>\r
++                        <td>Associated graph:</td>\r
++                        <td>\r
++                         <select name="local_graph_id" size="1">\r
++                            <?php\r
++                              echo "<OPTION VALUE='NULL'>None</option>";\r
++                              for($i = 0; $i < $row_count; $i++) {\r
++                                      echo "<OPTION VALUE='" . $cacti_graphs[$i]["local_graph_id"] . "'>" . $cacti_graphs[$i]["title"] . "</option>";\r
++                              }\r
++                            ?> \r
++\r
++\r
++                         </select>\r
++                      </td>\r
++                        <td><INPUT TYPE="submit" VALUE="Map"></td>\r
++                   </tr>\r
++                   </FORM>\r
++\r
++\r
++            </tbody>\r
++         </table>\r
++              <?php \r
++                      if ($host_config["cacti_graph_id"]) {\r
++                              echo "<table align='center'>";\r
++                              echo "<tr><td width='100%'>";\r
++                              echo "<img src='../../graph_image.php?local_graph_id=" . $host_config["cacti_graph_id"] . "&rra_id=0'>";\r
++                              echo "</td></tr>";\r
++                      }\r
++              ?>\r
++      </td>\r
++      </tr>\r
++   </tbody>\r
++   </table>\r
++\r
++   </td>\r
++\r
++   </tr>\r
++   </table>\r
++\r
++<?php\r
++\r
++\r
++}\r
++\r
++\r
++\r
++\r
++?>\r
This page took 0.43622 seconds and 4 git commands to generate.