]> git.pld-linux.org Git - packages/cacti-plugin-npc.git/blame - cacti-plugin-npc-extinfo.patch
- BR: pkgconfig
[packages/cacti-plugin-npc.git] / cacti-plugin-npc-extinfo.patch
CommitLineData
adf72a57
MWP
1--- npc/extinfo.php.orig 2005-10-10 14:17:15.000000000 +0000
2+++ npc/extinfo.php 2006-12-26 16:32:52.000000000 +0000
3@@ -1,1473 +1,1473 @@
4-<?php
5-/*
6- +-------------------------------------------------------------------------+
7- | Nagios Plugin 0.1a for cacti 0.8.6f |
8- | Copyright (C) 2005 Billy Gunn (billy@gunn.org) |
9- | |
10- | This program is free software; you can redistribute it and/or |
11- | modify it under the terms of the GNU General Public License |
12- | as published by the Free Software Foundation; either version 2 |
13- | of the License, or (at your option) any later version. |
14- | |
15- | This program is distributed in the hope that it will be useful, |
16- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18- | GNU General Public License for more details. |
19- +-------------------------------------------------------------------------+
20- | Cacti and Nagios are the copyright of their respective owners. |
21- +-------------------------------------------------------------------------+
22-*/
23-
24-chdir('../../');
25-include_once("./include/auth.php");
26-include_once("./include/config.php");
27-
28-// Refresh the page at a user supplied interval
29-header("Refresh: " . read_config_option("npc_refresh") . "; URL=" . $_SERVER["REQUEST_URI"]);
30-
31-/* set default action */
32-if (!isset($_REQUEST["type"])) { $_REQUEST["type"] = ""; }
33-
34-switch ($_REQUEST["type"]) {
35- case '1':
36-
37- hostInfo();
38- include_once("./include/bottom_footer.php");
39- break;
40-
41- case '2':
42-
43- serviceInfo();
44- include_once("./include/bottom_footer.php");
45- break;
46-
47- default:
48-
49- hostInfo();
50- include_once("./include/bottom_footer.php");
51- break;
52-}
53-
54-
55-function formatTime($time) {
56-
57- $days = floor($time/60/60/24);
58- $time -= $days*60*60*24;
59- $hours = floor($time/60/60);
60- $time -= $hours*60*60;
61- $minutes = floor($time/60);
62- $time -= $minutes*60;
63- $seconds = $time;
64-
65- return ($days . "d " . $hours . "h " . $minutes . "m " . $seconds . "s");
66-}
67-
68-
69-function serviceInfo() {
70-
71- $hostid = $_REQUEST["hostid"];
72- $serviceid = $_REQUEST["serviceid"];
73- $hostname = $_REQUEST["hostname"];
74- $serviceName = ereg_replace("\+", " ", $_REQUEST["service"]);
75-
76-
77- if (isset($_POST["local_graph_id"])) {
78- db_execute("update npc_service set cacti_graph_id = " . $_POST["local_graph_id"] . " where id = " . $serviceid);
79- header("Location: extinfo.php?type=2&hostid=" . $hostid . "&hostname=" . $hostname . "&serviceid=" . $serviceid . "&service=" . $_REQUEST["service"]);
80- }
81-
82- include_once("top_npc_header.php");
83-
84- $background1 = "#F5F5F5";
85- $background2 = "#E7E9F2";
86- $rowColor = $background1;
87-
88- $service_detail = db_fetch_row("
89-select distinct
90- service_soft_state as 'Current Status',
91- duration as 'State Duration',
92- check_command as 'Check Command',
93- plugin_output as 'Plugin Output',
94- performance_data as 'Performance Data',
95- current_attempt as 'Current Attempt',
96- from_unixtime(last_check) as 'Last Check',
97- from_unixtime(next_check) as 'Next Check',
98- check_latency as 'Check Latency',
99- check_execute_time as 'Check Duration',
100- hostid,
101- name,
102- host_soft_state as 'Host Soft State',
103- host_notifications as 'Host Notifications',
104- service as 'Service',
105- cacti_graph_id,
106- serviceid,
107- service_hard_state,
108- service_notifications as 'Service Notifications',
109- max_attempts as 'Max Attempts'
110-from
111- (
112- select
113- npc_host.id as hostid,
114- npc_host.name,
115- npc_hostgroup_membership.groupid as hostgroup,
116- npc_host_history.soft_state as host_soft_state,
117- npc_host.notifications_enabled as host_notifications,
118- npc_service.id as serviceid,
119- npc_service.cacti_graph_id,
120- npc_service.service_description as service,
121- npc_service_history.soft_state as service_soft_state,
122- npc_service_history.hard_state as service_hard_state,
123- npc_service.notifications_enabled as service_notifications,
124- npc_service_check.last_check,
125- npc_service_check.next_check,
126- npc_service_check.check_execute_time,
127- npc_service_check.check_latency,
128- npc_service_check.check_command,
129- npc_service_check.performance_data,
130- unix_timestamp() - npc_service_history.started as duration,
131- npc_service_history.current_attempt,
132- npc_service_check.max_attempts,
133- npc_service_history.plugin_output
134- from
135- npc_host,
136- npc_host_history,
137- npc_hostgroup_membership,
138- npc_service,
139- npc_service_check,
140- npc_service_history
141- where
142- npc_host.id = npc_hostgroup_membership.hostid and
143- npc_host.id = npc_service.hostid and
144- npc_host.id = npc_host_history.hostid and
145- npc_service.id = npc_service_check.serviceid and
146- npc_service.id = npc_service_history.serviceid and
147- npc_service_history.lasted is null and
148- npc_host_history.lasted is null and
149- npc_service.configured = TRUE and
150- npc_service.has_been_checked = TRUE and
151- npc_host.has_been_checked = TRUE
152- union
153- select
154- npc_host.id as hostid,
155- npc_host.name,
156- 0 as hostgroup,
157- npc_host_history.soft_state as host_soft_state,
158- npc_host.notifications_enabled as host_notifications,
159- npc_service.id as serviceid,
160- npc_service.cacti_graph_id,
161- npc_service.service_description as service,
162- npc_service_history.soft_state as service_soft_state,
163- npc_service_history.hard_state as service_hard_state,
164- npc_service.notifications_enabled as service_notifications,
165- npc_service_check.last_check,
166- npc_service_check.next_check,
167- npc_service_check.check_execute_time,
168- npc_service_check.check_latency,
169- npc_service_check.check_command,
170- npc_service_check.performance_data,
171- unix_timestamp() - npc_service_history.started as duration,
172- npc_service_history.current_attempt,
173- npc_service_check.max_attempts,
174- npc_service_history.plugin_output
175- from
176- npc_host,
177- npc_host_history,
178- npc_service,
179- npc_service_check,
180- npc_service_history
181- where
182- npc_host.id not in (select hostid from npc_hostgroup_membership) and
183- npc_host.id = npc_service.hostid and
184- npc_host.id = npc_host_history.hostid and
185- npc_service.id = npc_service_check.serviceid and
186- npc_service.id = npc_service_history.serviceid and
187- npc_service_history.lasted is null and
188- npc_host_history.lasted is null and
189- npc_service.configured = TRUE and
190- npc_service.has_been_checked = TRUE and
191- npc_host.has_been_checked = TRUE
192- union
193- select
194- npc_host.id as hostid,
195- npc_host.name,
196- npc_hostgroup_membership.groupid as hostgroup,
197- -1 as host_soft_state,
198- npc_host.notifications_enabled as host_notifications,
199- npc_service.id as serviceid,
200- npc_service.cacti_graph_id,
201- npc_service.service_description as service,
202- npc_service_history.soft_state as service_soft_state,
203- npc_service_history.hard_state as service_hard_state,
204- npc_service.notifications_enabled as service_notifications,
205- npc_service_check.last_check,
206- npc_service_check.next_check,
207- npc_service_check.check_execute_time,
208- npc_service_check.check_latency,
209- npc_service_check.check_command,
210- npc_service_check.performance_data,
211- unix_timestamp() - npc_service_history.started as duration,
212- npc_service_history.current_attempt,
213- npc_service_check.max_attempts,
214- npc_service_history.plugin_output
215- from
216- npc_host,
217- npc_hostgroup_membership,
218- npc_service,
219- npc_service_check,
220- npc_service_history
221- where
222- npc_host.id = npc_hostgroup_membership.hostid and
223- npc_host.id = npc_service.hostid and
224- npc_service.id = npc_service_check.serviceid and
225- npc_service.id = npc_service_history.serviceid and
226- npc_service_history.lasted is null and
227- npc_service.configured = TRUE and
228- npc_service.has_been_checked = TRUE and
229- npc_host.has_been_checked = FALSE
230- union
231- select
232- npc_host.id as hostid,
233- npc_host.name,
234- 0 as hostgroup,
235- -1 as host_soft_state,
236- npc_host.notifications_enabled as host_notifications,
237- npc_service.id as serviceid,
238- npc_service.cacti_graph_id,
239- npc_service.service_description as service,
240- npc_service_history.soft_state as service_soft_state,
241- npc_service_history.hard_state as service_hard_state,
242- npc_service.notifications_enabled as service_notifications,
243- npc_service_check.last_check,
244- npc_service_check.next_check,
245- npc_service_check.check_execute_time,
246- npc_service_check.check_latency,
247- npc_service_check.check_command,
248- npc_service_check.performance_data,
249- unix_timestamp() - npc_service_history.started as duration,
250- npc_service_history.current_attempt,
251- npc_service_check.max_attempts,
252- npc_service_history.plugin_output
253- from
254- npc_host,
255- npc_service,
256- npc_service_check,
257- npc_service_history
258- where
259- npc_host.id not in (select hostid from npc_hostgroup_membership) and
260- npc_host.id = npc_service.hostid and
261- npc_service.id = npc_service_check.serviceid and
262- npc_service.id = npc_service_history.serviceid and
263- npc_service_history.lasted is null and
264- npc_service.configured = TRUE and
265- npc_service.has_been_checked = TRUE and
266- npc_host.has_been_checked = FALSE
267- union
268- select
269- npc_host.id as hostid,
270- npc_host.name,
271- npc_hostgroup_membership.groupid as hostgroup,
272- npc_host_history.soft_state as host_soft_state,
273- npc_host.notifications_enabled as host_notifications,
274- npc_service.id as serviceid,
275- npc_service.cacti_graph_id,
276- npc_service.service_description as service,
277- -1 as service_soft_state,
278- -1 as service_hard_state,
279- npc_service.notifications_enabled as service_notifications,
280- npc_service_check.last_check,
281- npc_service_check.next_check,
282- npc_service_check.check_execute_time,
283- npc_service_check.check_latency,
284- npc_service_check.check_command,
285- npc_service_check.performance_data,
286- 0 as duration,
287- 0 as current_attempt,
288- npc_service_check.max_attempts,
289- null as plugin_output
290- from
291- npc_host,
292- npc_host_history,
293- npc_hostgroup_membership,
294- npc_service,
295- npc_service_check
296- where
297- npc_host.id = npc_hostgroup_membership.hostid and
298- npc_host.id = npc_service.hostid and
299- npc_host.id = npc_host_history.hostid and
300- npc_service.id = npc_service_check.serviceid and
301- npc_host_history.lasted is null and
302- npc_service.configured = TRUE and
303- npc_service.has_been_checked = FALSE and
304- npc_host.has_been_checked = TRUE
305- union
306- select
307- npc_host.id as hostid,
308- npc_host.name,
309- 0 as hostgroup,
310- npc_host_history.soft_state as host_soft_state,
311- npc_host.notifications_enabled as host_notifications,
312- npc_service.id as serviceid,
313- npc_service.cacti_graph_id,
314- npc_service.service_description as service,
315- -1 as service_soft_state,
316- -1 as service_hard_state,
317- npc_service.notifications_enabled as service_notifications,
318- npc_service_check.last_check,
319- npc_service_check.next_check,
320- npc_service_check.check_execute_time,
321- npc_service_check.check_latency,
322- npc_service_check.check_command,
323- npc_service_check.performance_data,
324- 0 as duration,
325- 0 as current_attempt,
326- npc_service_check.max_attempts,
327- null as plugin_output
328- from
329- npc_host,
330- npc_host_history,
331- npc_service,
332- npc_service_check
333- where
334- npc_host.id not in (select hostid from npc_hostgroup_membership) and
335- npc_host.id = npc_service.hostid and
336- npc_host.id = npc_host_history.hostid and
337- npc_service.id = npc_service_check.serviceid and
338- npc_host_history.lasted is null and
339- npc_service.configured = TRUE and
340- npc_service.has_been_checked = FALSE and
341- npc_host.has_been_checked = TRUE
342- union
343- select
344- npc_host.id as hostid,
345- npc_host.name,
346- npc_hostgroup_membership.groupid as hostgroup,
347- -1 as host_soft_state,
348- npc_host.notifications_enabled as host_notifications,
349- npc_service.id as serviceid,
350- npc_service.cacti_graph_id,
351- npc_service.service_description as service,
352- -1 as service_soft_state,
353- -1 as service_hard_state,
354- npc_service.notifications_enabled as service_notifications,
355- npc_service_check.last_check,
356- npc_service_check.next_check,
357- npc_service_check.check_execute_time,
358- npc_service_check.check_latency,
359- npc_service_check.check_command,
360- npc_service_check.performance_data,
361- 0 as duration,
362- 0 as current_attempt,
363- npc_service_check.max_attempts,
364- null as plugin_output
365- from
366- npc_host,
367- npc_hostgroup_membership,
368- npc_service,
369- npc_service_check
370- where
371- npc_host.id = npc_hostgroup_membership.hostid and
372- npc_host.id = npc_service.hostid and
373- npc_service.id = npc_service_check.serviceid and
374- npc_service.configured = TRUE and
375- npc_service.has_been_checked = FALSE and
376- npc_host.has_been_checked = FALSE
377- union
378- select
379- npc_host.id as hostid,
380- npc_host.name,
381- 0 as hostgroup,
382- -1 as host_soft_state,
383- npc_host.notifications_enabled as host_notifications,
384- npc_service.id as serviceid,
385- npc_service.cacti_graph_id,
386- npc_service.service_description as service,
387- -1 as service_soft_state,
388- -1 as service_hard_state,
389- npc_service.notifications_enabled as service_notifications,
390- npc_service_check.last_check,
391- npc_service_check.next_check,
392- npc_service_check.check_execute_time,
393- npc_service_check.check_latency,
394- npc_service_check.check_command,
395- npc_service_check.performance_data,
396- 0 as duration,
397- 0 as current_attempt,
398- npc_service_check.max_attempts,
399- null as plugin_output
400- from
401- npc_host,
402- npc_service,
403- npc_service_check
404- where
405- npc_host.id not in (select hostid from npc_hostgroup_membership) and
406- npc_host.id = npc_service.hostid and
407- npc_service.id = npc_service_check.serviceid and
408- npc_service.configured = TRUE and
409- npc_service.has_been_checked = FALSE and
410- npc_host.has_been_checked = FALSE
411- order by
412- name
413- ) as host_details where hostid = $hostid and service = '$serviceName'");
414-
415- $service_detail["flapping"] = db_fetch_cell("select id from npc_flapping_service where id = $serviceid");
416- $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'");
417- $comments = db_fetch_assoc("select id,serviceid,timestamp,author,comment,persist,type from npc_comment where serviceid = '$serviceid'");
418- $row_count = count($comments);
419-
420-?>
421-
422-
423-
424-
425- <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
426- <tr class="textSubHeaderDark" bgcolor='#6d88ad'>
427- <td>
428- <h2>&nbsp;[ <?php echo $serviceName; ?> ] on
429- <a href="extinfo.php?type=1&hostid=<?php echo $hostid; ?>&hostname=<?php echo $hostname; ?>"><?php echo $hostname; ?></a></h2>
430- </td>
431- <td align='right' nowrap>
432- <FORM NAME="cl" ACTION="command.php" method="POST">Command:
433- <INPUT TYPE='hidden' NAME='host' VALUE='<?php echo $hostname; ?>'>
434- <INPUT TYPE='hidden' NAME='hostid' VALUE='<?php echo $service_detail["hostid"]; ?>'>
435- <INPUT TYPE='hidden' NAME='service' VALUE='<?php echo $serviceName; ?>'>
436- <INPUT TYPE='hidden' NAME='serviceid' VALUE='<?php echo $service_detail["serviceid"]; ?>'>
437- <select name="command" size="1">
438-
439-<?php
440- if (read_config_option("nagios_commands")) {
441-
442- echo "<OPTION VALUE='NULL'>Execute a command</option>";
443-
444- if ($service_config["active_checks_enabled"]) {
445- echo "<strong><OPTION VALUE='DISABLE_SVC_CHECK'>Disable active checks</option></strong>";
446- echo "<OPTION VALUE='SCHEDULE_SVC_CHECK'>Re-schedule the next check</option>";
447- } else {
448- echo "<OPTION VALUE='ENABLE_SVC_CHECK'>Enable Active Checks</option>";
449- }
450- if ($service_config["passive_checks_enabled"]) {
451- echo "<OPTION VALUE='PROCESS_SVC_CHECK_RESULT'>Submit passive check result</option>";
452- echo "<OPTION VALUE='DISABLE_PASSIVE_SVC_CHECKS'>Stop accepting passive checks</option>";
453- } else {
454- echo "<OPTION VALUE='ENABLE_PASSIVE_SVC_CHECKS'>Start accepting passive checks</option>";
455- }
456- if ($service_config["obsess_over_service"]) {
457- echo "<OPTION VALUE='STOP_OBSESSING_OVER_SVC'>Stop obsessing</option>";
458- } else {
459- echo "<OPTION VALUE='START_OBSESSING_OVER_SVC'>Start obsessing</option>";
460- }
461- 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"]) {
462- if (!db_fetch_cell("select * from npc_comment where serviceid = $serviceid and type = 4;")) {
463- echo "<OPTION VALUE='ACKNOWLEDGE_SVC_PROBLEM'>Acknowledge This Service Problem</option>";
464- } elseif (db_fetch_cell("select * from npc_comment where serviceid = $serviceid and type = 4;")) {
465- echo "<OPTION VALUE='REMOVE_SVC_ACKNOWLEDGEMENT'>Remove Problem Acknowledgement</option>";
466- }
467- }
468- if ($service_config["notifications_enabled"]) {
469- echo "<OPTION VALUE='DISABLE_SVC_NOTIFICATIONS'>Disable Notifications</option>";
470- if ($service_detail["Current Status"] != 0) {
471- echo "<OPTION VALUE='DELAY_SVC_NOTIFICATION'>Delay Next Service Notification</option>";
472- }
473- } else {
474- echo "<OPTION VALUE='ENABLE_SVC_NOTIFICATIONS'>Enable Notifications</option>";
475- }
476- echo "<OPTION VALUE='SCHEDULE_SVC_DOWNTIME'>Schedule Downtime</option>";
477- if ($service_config["event_handler_enabled"]) {
478- echo "<OPTION VALUE='DISABLE_SVC_EVENT_HANDLER'>Disable Event Handler</option>";
479- } else {
480- echo "<OPTION VALUE='ENABLE_SVC_EVENT_HANDLER'>Enable Event Handler</option>";
481- }
482- if ($service_config["flap_detection_enabled"]) {
483- echo "<OPTION VALUE='DISABLE_SVC_FLAP_DETECTION'>Disable Flap Detection</option>";
484- } else {
485- echo "<OPTION VALUE='ENABLE_SVC_FLAP_DETECTION'>Enable Flap Detection</option>";
486- }
487- echo "<OPTION VALUE='ADD_SVC_COMMENT'>Add Service Comment</option>";
488- echo "<OPTION VALUE='DEL_ALL_SVC_COMMENTS'>Delete All Service Comments</option>";
489- } else {
490- echo "<OPTION VALUE=''>Command execution disabled</option>";
491- }
492-?>
493-
494- </select>
495- <input type='image' src='../../images/button_go.gif' alt='Go' value='Execute' align='absmiddle'>
496- </form>
497-
498-
499- </td>
500- </tr>
501-
502- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
503- <tr>
504- <td valign="top">
505- <table width="100%" border="0" align="left" valign="top">
506- <thead>
507- <tr class="textHeaderDark" bgcolor='#00438C'>
508- <td align="center"><strong>Service State Information</strong></td>
509- </tr>
510- </thead>
511- <tbody>
512- <tr>
513- <td width="100%" valign="top">
514- <table width="100%" align="center" cellpadding="3">
515- <thead>
516- <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
517- <td>Parameter</td>
518- <td>Value</td>
519- </tr>
520- </thead>
521- <tbody>
522-
523-
524-<?php
525-
526-
527- foreach ($service_detail as $key => $value) {
528-
529-
530- switch($key)
531- {
532- case "Current Status":
533- echo "<tr bgcolor='" . $rowColor . "'>";
534- echo "<td>" . $key . ":</td>";
535- switch($value)
536- {
537- case "-1":
538- echo "<td class='statusPENDING'><strong>PENDING</strong></td>";
539- break;
540- case "0":
541- echo "<td class='statusOK'><strong>OK</strong></td>";
542- break;
543- case "1":
544- echo "<td class='statusWARNING'><strong>WARNING</strong></td>";
545- break;
546- case "2":
547- echo "<td class='statusCRITICAL'><strong>CRITICAL</strong></td>";
548- break;
549- case "3":
550- echo "<td class='statusUNKNOWN'><strong>UNKNOWN</strong></td>";
551- break;
552- }
553- echo "</tr>";
554- break;
555- case "State Duration":
556- echo "<tr bgcolor='" . $rowColor . "'>";
557- echo "<td>" . $key . ":</td>";
558- echo "<td>" . formatTime($value) . "</td>";
559- echo "</tr>";
560- break;
561- case "Check Command":
562- echo "<tr bgcolor='" . $rowColor . "'>";
563- echo "<td>" . $key . ":</td>";
564- echo "<td>" . $value . "</td>";
565- echo "</tr>";
566- break;
567- case "Plugin Output":
568- echo "<tr bgcolor='" . $rowColor . "'>";
569- echo "<td>" . $key . ":</td>";
570- echo "<td>" . $value . "</td>";
571- echo "</tr>";
572- break;
573- case "Performance Data":
574- echo "<tr bgcolor='" . $rowColor . "'>";
575- echo "<td>" . $key . ":</td>";
576- echo "<td>" . $value . "</td>";
577- echo "</tr>";
578- break;
579- case "Current Attempt":
580- echo "<tr bgcolor='" . $rowColor . "'>";
581- echo "<td>" . $key . ":</td>";
582- echo "<td>" . $value . "/" . $service_detail["Max Attempts"] . "</td>";
583- echo "</tr>";
584- break;
585- case "Last Check":
586- echo "<tr bgcolor='" . $rowColor . "'>";
587- echo "<td>" . $key . ":</td>";
588- if (preg_match('/1969-12-31/', $value)) {
589- echo "<td>N/A</td>";
590- } else {
591- echo "<td>" . $value . "</td>";
592- }
593- echo "</tr>";
594- break;
595- case "Next Check":
596- echo "<tr bgcolor='" . $rowColor . "'>";
597- echo "<td>" . $key . ":</td>";
598- echo "<td>" . $value . "</td>";
599- echo "</tr>";
600- break;
601- case "Check Latency":
602- echo "<tr bgcolor='" . $rowColor . "'>";
603- echo "<td>" . $key . ":</td>";
604- echo "<td>" . $value . "</td>";
605- echo "</tr>";
606- break;
607- case "Check Duration":
608- echo "<tr bgcolor='" . $rowColor . "'>";
609- echo "<td>" . $key . ":</td>";
610- echo "<td>" . $value . "</td>";
611- echo "</tr>";
612- break;
613- case "flapping":
614- echo "<tr bgcolor='" . $rowColor . "'>";
615- echo "<td>Flapping:</td>";
616- if ($service_detail["flapping"]) {
617- echo "<td>Yes</td>";
618- } else {
619- echo "<td>No</td>";
620- }
621- echo "</tr>";
622- break;
623- }
624-
625- if($rowColor == $background1) {
626- $rowColor = $background2;
627- } else {
628- $rowColor = $background1;
629- }
630-
631- if ($key == "flapping") {
632- echo "<tr bgcolor='" . $rowColor . "'>";
633- echo "<td>Event Handler:</td>";
634- if (!$service_config["event_handler"]) {
635- echo "<td>N/A</td>";
636- } else {
637- echo "<td>" . $service_config["event_handler"] . "</td>";
638- }
639- echo "</tr>";
640- }
641-
642-
643- }
644-
645-
646-?>
647-
648- </tbody>
649- </table>
650-
651- </td>
652- </tr>
653- </tbody>
654- </table>
655-
656- </td>
657-
658- <td valign="top">
659- <table width="70%" border="0" align="right">
660- <thead>
661- <tr class="textHeaderDark" bgcolor='#00438C'>
662- <td align="center"><strong>Service Monitoring Options</strong></td>
663- </tr>
664- </thead>
665- <tbody>
666- <tr>
667- <td width="70%" valign="top">
668- <table width="100%" align="center" cellpadding="3">
669- <thead>
670- <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
671- <td>Parameter</td>
672- <td>Value</td>
673- </tr>
674- </thead>
675- <tbody>
676-
677-<?php
678- $rowColor = $background1;
679- echo "<tr bgcolor='" . $rowColor . "'>";
680-
681-
682- foreach ($service_config as $key => $value) {
683-
684- if ($key == "event_handler") { continue; }
685-
686- echo "<tr bgcolor='" . $rowColor . "'>";
687-
688- switch($key)
689- {
690- case "active_checks_enabled":
691- echo "<td>Active Checks:</td>";
692- break;
693- case "passive_checks_enabled":
694- echo "<td>Passive Checks:</td>";
695- break;
696- case "event_handler_enabled":
697- echo "<td>Event Handler:</td>";
698- break;
699- case "flap_detection_enabled":
700- echo "<td>Flap Detection:</td>";
701- break;
702- case "notifications_enabled":
703- echo "<td>Notifications:</td>";
704- break;
705- case "failure_prediction_enabled":
706- echo "<td>Failure Prediction:</td>";
707- break;
708- case "process_performance_data":
709- echo "<td>Process Performance Data:</td>";
710- break;
711- case "obsess_over_service":
712- echo "<td>Obsess Over Service:</td>";
713- break;
714- }
715-
716- if ($value == 0) {
717- echo "<td class='optionDISABLED'>Disabled</td></tr>";
718- } else {
719- echo "<td class='optionENABLED'>Enabled</td></tr>";
720- }
721-
722- if($rowColor == $background1) {
723- $rowColor = $background2;
724- } else {
725- $rowColor = $background1;
726- }
727-
728-
729- }
730-
731-?>
732- </tbody>
733- </table>
734- </td>
735- </tr>
736- </table>
737-
738- </td>
739-
740-
741-
742-<?php
743-
744-
745-
746-
747- echo "</tr>";
748- echo "<tr>";
749-
750-?>
751- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
752- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
753- <td valign="top" colspan='2'>
754- <table width="60%" border="0" align="center">
755- <thead>
756- <tr class="textHeaderDark" bgcolor='#00438C'>
757- <td align="center"><strong>Service Comments</strong></td>
758- </tr>
759- </thead>
760- <tbody>
761- <tr>
762- <td width="60%" valign="top">
763- <table width="100%" align="center" cellpadding="3">
764- <thead>
765- <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
766- <td>Entry Time</td>
767- <td>Author</td>
768- <td>Comment</td>
769- <td>Persistent</td>
770- <td>Type</td>
771- <td>Delete</td>
772- <tbody>
773-<?php
774- for($i = 0; $i < $row_count; $i++) {
775-
776- echo "<tr bgcolor='" . $rowColor . "'>";
777- echo "<td nowrap>" . $comments[$i]["timestamp"] . "</td>";
778- echo "<td>" . $comments[$i]["author"] . "</td>";
779- echo "<td>" . $comments[$i]["comment"] . "</td>";
780- echo "<td>";
781- if ($comments[$i]["persist"]) {
782- echo "Yes";
783- } else {
784- echo "No";
785- }
786- echo "</td>";
787- echo "<td>";
788- if ($comments[$i]["type"] == 2) {
789- echo "Comment";
790- } elseif ($comments[$i]["type"] == 4) {
791- echo "Acknowledgment";
792- }
793- echo "</td>";
794- echo "<td>";
795- if ($comments[$i]["type"] == 2) {
796- 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>";
797- } elseif ($comments[$i]["type"] == 4) {
798- 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>";
799- }
800- echo "</td>";
801-
802-
803- if($rowColor == $background1) {
804- $rowColor = $background2;
805- } else {
806- $rowColor = $background1;
807- }
808- }
809-
810-
811-
812-
813-
814-
815-
816-?>
817- </tbody>
818- </table>
819- </td>
820- </tr>
821- <tr>
822- <td>
823- <?php
824- 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>";
825- 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>";
826- ?>
827- </td>
828- </tr>
829- </tbody>
830- </table>
831- </td>
832- <td></td>
833- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
834- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
835- <tr>
836-
837-
838-
839-
840-
841- <td valign="top" colspan='2'>
842- <table width="60%" border="0" align="center">
843- <thead>
844- <tr align="center" class="textHeaderDark" bgcolor='#00438C'>
845- <td align="center"><strong>Graph Mapping</strong></td>
846- </tr>
847- </thead>
848- <tbody>
849- <tr>
850- <td width="60%" valign="top">
851- <table width="100%" align="center" cellpadding="3">
852- <tbody>
853-
854-<?php
855-
856-$cacti_graphs = db_fetch_assoc("
857-select
858- graph_templates_graph.id,
859- graph_templates_graph.local_graph_id,
860- graph_templates_graph.height,
861- graph_templates_graph.width,
862- graph_templates_graph.title_cache as title,
863- graph_templates.name,
864- graph_local.host_id
865- from graph_local,graph_templates_graph
866- left join graph_templates on graph_local.graph_template_id=graph_templates.id
867- where graph_local.id=graph_templates_graph.local_graph_id
868- and graph_templates_graph.title_cache like '%'
869- order by graph_templates_graph.title_cache,graph_local.host_id");
870-
871- $row_count = count($cacti_graphs);
872-/* http://logindev/cacti/graph_image.php?local_graph_id=6&rra_id=0 */
873-?>
874-
875- <FORM NAME="gm" ACTION="" method="post">
876- <tr bgcolor='<?php echo $background1; ?>'>
877- <td>Associated graph:</td>
878- <td>
879- <select name="local_graph_id" size="1">
880- <?php
881- echo "<OPTION VALUE='NULL'>None</option>";
882- for($i = 0; $i < $row_count; $i++) {
883- echo "<OPTION VALUE='" . $cacti_graphs[$i]["local_graph_id"] . "'>" . $cacti_graphs[$i]["title"] . "</option>";
884- }
885- ?>
886-
887-
888- </select>
889- </td>
890- <td><INPUT TYPE="submit" VALUE="Map"></td>
891- </tr>
892- </FORM>
893-
894-
895- </tbody>
896- </table>
897- <?php
898- if ($service_detail["cacti_graph_id"]) {
899- echo "<table align='center'>";
900- echo "<tr><td width='100%'>";
901- echo "<img src='../../graph_image.php?local_graph_id=" . $service_detail["cacti_graph_id"] . "&rra_id=0'>";
902- echo "</td></tr>";
903- }
904- ?>
905- </td>
906- </tr>
907- </tbody>
908- </table>
909-
910- </td>
911-
912- </tr>
913- </table>
914-
915-<?php
916-
917-
918-}
919-
920-
921-function hostInfo() {
922-
923- $hostid = $_REQUEST["hostid"];
924- $hostname = $_REQUEST["hostname"];
925-
926- if (isset($_POST["local_graph_id"])) {
927- db_execute("update npc_host set cacti_graph_id = " . $_POST["local_graph_id"] . " where id = " . $hostid);
928- header("Location: extinfo.php?type=1&hostid=" . $hostid . "&hostname=" . $hostname);
929- }
930-
931- include_once("top_npc_header.php");
932-
933- $background1 = "#F5F5F5";
934- $background2 = "#E7E9F2";
935- $rowColor = $background1;
936-
937- $host_flapping["flapping"] = db_fetch_cell("select id from npc_flapping_host where id = $hostid");
938-
939- $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;");
940-
941- $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;");
942-
943- $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");
944-
945- $comments = db_fetch_assoc("select id,serviceid,timestamp,author,comment,persist,type from npc_comment where hostid = $hostid");
946-
947- $graphView = db_fetch_cell("select id from graph_tree_items where host_id = (select id from host where npc_host_id = $hostid)");
948-
949- $row_count = count($comments);
950-
951- $duration = date("U") - $host_history["started"];
952-
953-?>
954-
955-
956-
957-
958- <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
959- <tr class="textSubHeaderDark" bgcolor='#6d88ad'>
960- <td>
961- <h2>&nbsp;<strong><?php echo $hostname; ?></strong></h2>
962- </td>
963- <td align='right' nowrap>
964- <FORM NAME="cl" ACTION="command.php" method="POST">Command:
965- <INPUT TYPE='hidden' NAME='host' VALUE='<?php echo $hostname; ?>'>
966- <INPUT TYPE='hidden' NAME='hostid' VALUE='<?php echo $hostid; ?>'>
967- <select name="command" size="1">
968-
969-<?php
970- if (read_config_option("nagios_commands")) {
971-
972- echo "<OPTION VALUE='NULL'>Execute a command</option>";
973-
974- if ($host_config["active_checks_enabled"]) {
975- echo "<OPTION VALUE='DISABLE_HOST_CHECK'>Disable active checks</option>";
976- echo "<OPTION VALUE='SCHEDULE_HOST_CHECK'>Re-schedule the next check</option>";
977- echo "<OPTION VALUE='SCHEDULE_HOST_SVC_CHECKS'>Schedule a check of all services</option>";
978- } else {
979- echo "<OPTION VALUE='ENABLE_HOST_CHECK'>Enable Active Checks</option>";
980- }
981- echo "<OPTION VALUE='DISABLE_HOST_SVC_CHECKS'>Disable checks of all services</option>";
982- echo "<OPTION VALUE='ENABLE_HOST_SVC_CHECKS'>Enabble checks of all services</option>";
983- if ($host_config["passive_checks_enabled"]) {
984- echo "<OPTION VALUE='PROCESS_HOST_CHECK_RESULT'>Submit passive check result</option>";
985- echo "<OPTION VALUE='DISABLE_PASSIVE_HOST_CHECKS'>Stop accepting passive checks</option>";
986- } else {
987- echo "<OPTION VALUE='ENABLE_PASSIVE_HOST_CHECKS'>Start accepting passive checks</option>";
988- }
989- if ($host_config["obsess_over_service"]) {
990- echo "<OPTION VALUE='STOP_OBSESSING_OVER_HOST'>Stop obsessing</option>";
991- } else {
992- echo "<OPTION VALUE='START_OBSESSING_OVER_HOST'>Start obsessing</option>";
993- }
994- if ($host_history["soft_state"] == 1 || $host_history["soft_state"] == 2 && $host_history["soft_state"] == $host_history["hard_state"]) {
995- if (!db_fetch_cell("select * from npc_comment where hostid = $hostid and type = 4;")) {
996- echo "<OPTION VALUE='ACKNOWLEDGE_HOST_PROBLEM'>Acknowledge This Host Problem</option>";
997- } elseif (db_fetch_cell("select * from npc_comment where hostid = $hostid and type = 4;")) {
998- echo "<OPTION VALUE='REMOVE_HOST_ACKNOWLEDGEMENT'>Remove Problem Acknowledgement</option>";
999- }
1000- }
1001- if ($host_config["notifications_enabled"]) {
1002- echo "<OPTION VALUE='DISABLE_HOST_NOTIFICATIONS'>Disable Notifications</option>";
1003- if ($host_history["soft_state"] != 0) {
1004- echo "<OPTION VALUE='DELAY_HOST_NOTIFICATION'>Delay Next Service Notification</option>";
1005- }
1006- } else {
1007- echo "<OPTION VALUE='ENABLE_HOST_NOTIFICATIONS'>Enable Notifications</option>";
1008- }
1009- echo "<OPTION VALUE='SCHEDULE_HOST_DOWNTIME'>Schedule Downtime</option>";
1010- if ($host_config["event_handler_enabled"]) {
1011- echo "<OPTION VALUE='DISABLE_HOST_EVENT_HANDLER'>Disable Event Handler</option>";
1012- } else {
1013- echo "<OPTION VALUE='ENABLE_HOST_EVENT_HANDLER'>Enable Event Handler</option>";
1014- }
1015- if ($host_config["flap_detection_enabled"]) {
1016- echo "<OPTION VALUE='DISABLE_HOST_FLAP_DETECTION'>Disable Flap Detection</option>";
1017- } else {
1018- echo "<OPTION VALUE='ENABLE_HOST_FLAP_DETECTION'>Enable Flap Detection</option>";
1019- }
1020- echo "<OPTION VALUE='ADD_HOST_COMMENT'>Add Host Comment</option>";
1021- echo "<OPTION VALUE='DEL_ALL_HOST_COMMENTS'>Delete All Host Comments</option>";
1022- } else {
1023- echo "<OPTION VALUE='NULL'>Command execution disabled</option>";
1024- }
1025-?>
1026-
1027- </select>
1028- <input type='image' src='../../images/button_go.gif' alt='Go' value='Execute' align='absmiddle'>
1029- </form>
1030-
1031-
1032- </td>
1033- </tr>
1034- <tr><td></td><td></td></tr>
1035- <tr bgcolor='#a9b7cb'>
1036- <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>
1037- <td>&nbsp;</td></tr>
1038- </tr>
1039-
1040- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
1041- <tr>
1042- <td valign="top">
1043- <table width="100%" border="0" align="left" valign="top">
1044- <thead>
1045- <tr class="textHeaderDark" bgcolor='#00438C'>
1046- <td align="center"><strong>Host State Information</strong></td>
1047- </tr>
1048- </thead>
1049- <tbody>
1050- <tr>
1051- <td width="100%" valign="top">
1052- <table width="100%" align="center" cellpadding="3">
1053- <thead>
1054- <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
1055- <td>Parameter</td>
1056- <td>Value</td>
1057- </tr>
1058- </thead>
1059- <tbody>
1060-
1061-
1062-<?php
1063-
1064-
1065- $host_detail = array(
1066- 'Current Status' => $host_history["soft_state"],
1067- 'State Duration' => formatTime($duration),
1068- 'Check Command' => $host_check["check_command"],
1069- 'Plugin Output' => $host_history["plugin_output"],
1070- 'Performance Data' => $host_check["performance_data"],
1071- 'Current Attempt' => $host_history["current_attempt"],
1072- 'Last Check' => $host_check["last_check"],
1073- 'Next Check' => $host_check["next_check"],
1074- 'Check Latency' => $host_check["check_latency"],
1075- 'Check Duration' => $host_check["check_execute_time"],
1076- 'flapping' => $host_flapping["flapping"],
1077- 'Event Handler' => $host_config["event_handler"],
1078- );
1079-
1080- foreach ($host_detail as $key => $value) {
1081-
1082-
1083- switch($key)
1084- {
1085- case "Current Status":
1086- echo "<tr bgcolor='" . $rowColor . "'>";
1087- echo "<td>" . $key . ":</td>";
1088- switch($value)
1089- {
1090- case "-1":
1091- echo "<td class='statusPENDING'><strong>PENDING</strong></td>";
1092- break;
1093- case "0":
1094- echo "<td class='statusHOSTUP'><strong>UP</strong></td>";
1095- break;
1096- case "1":
1097- echo "<td class='statusHOSTDOWN'><strong>DOWN</strong></td>";
1098- break;
1099- case "2":
1100- echo "<td class='statusHOSTUNREACHABLE'><strong>UNREACHABLE</strong></td>";
1101- break;
1102- }
1103- echo "</tr>";
1104- break;
1105- case "State Duration":
1106- echo "<tr bgcolor='" . $rowColor . "'>";
1107- echo "<td>" . $key . ":</td>";
1108- echo "<td>" . $value . "</td>";
1109- echo "</tr>";
1110- break;
1111- case "Check Command":
1112- echo "<tr bgcolor='" . $rowColor . "'>";
1113- echo "<td>" . $key . ":</td>";
1114- echo "<td>" . $value . "</td>";
1115- echo "</tr>";
1116- break;
1117- case "Plugin Output":
1118- echo "<tr bgcolor='" . $rowColor . "'>";
1119- echo "<td>" . $key . ":</td>";
1120- echo "<td>" . $value . "</td>";
1121- echo "</tr>";
1122- break;
1123- case "Performance Data":
1124- echo "<tr bgcolor='" . $rowColor . "'>";
1125- echo "<td>" . $key . ":</td>";
1126- echo "<td>" . $value . "</td>";
1127- echo "</tr>";
1128- break;
1129- case "Current Attempt":
1130- echo "<tr bgcolor='" . $rowColor . "'>";
1131- echo "<td>" . $key . ":</td>";
1132- echo "<td>" . $value . "/" . $host_check["max_attempts"] . "</td>";
1133- echo "</tr>";
1134- break;
1135- case "Last Check":
1136- echo "<tr bgcolor='" . $rowColor . "'>";
1137- echo "<td>" . $key . ":</td>";
1138- if (preg_match('/1969-12-31/', $value)) {
1139- echo "<td>N/A</td>";
1140- } else {
1141- echo "<td>" . $value . "</td>";
1142- }
1143- echo "</tr>";
1144- break;
1145- case "Next Check":
1146- echo "<tr bgcolor='" . $rowColor . "'>";
1147- echo "<td>" . $key . ":</td>";
1148- if (preg_match('/1969-12-31/', $value)) {
1149- echo "<td>N/A</td>";
1150- } else {
1151- echo "<td>" . $value . "</td>";
1152- }
1153- echo "</tr>";
1154- break;
1155- case "Check Latency":
1156- echo "<tr bgcolor='" . $rowColor . "'>";
1157- echo "<td>" . $key . ":</td>";
1158- echo "<td>" . $value . "</td>";
1159- echo "</tr>";
1160- break;
1161- case "Check Duration":
1162- echo "<tr bgcolor='" . $rowColor . "'>";
1163- echo "<td>" . $key . ":</td>";
1164- echo "<td>" . $value . "</td>";
1165- echo "</tr>";
1166- break;
1167- case "flapping":
1168- echo "<tr bgcolor='" . $rowColor . "'>";
1169- echo "<td>Flapping:</td>";
1170- if ($host_detail["flapping"]) {
1171- echo "<td>Yes</td>";
1172- } else {
1173- echo "<td>No</td>";
1174- }
1175- echo "</tr>";
1176- break;
1177- case "Event Handler":
1178- echo "<tr bgcolor='" . $rowColor . "'>";
1179- echo "<td>" . $key . ":</td>";
1180- if (!$value) {
1181- echo "<td>N/A</td>";
1182- } else {
1183- echo "<td>" . $value . "</td>";
1184- }
1185- echo "</tr>";
1186- break;
1187- }
1188-
1189- if($rowColor == $background1) {
1190- $rowColor = $background2;
1191- } else {
1192- $rowColor = $background1;
1193- }
1194-
1195- }
1196-
1197-
1198-?>
1199-
1200- </tbody>
1201- </table>
1202-
1203- </td>
1204- </tr>
1205- </tbody>
1206- </table>
1207-
1208- </td>
1209-
1210- <td valign="top">
1211- <table width="70%" border="0" align="right">
1212- <thead>
1213- <tr class="textHeaderDark" bgcolor='#00438C'>
1214- <td align="center"><strong>Host Monitoring Options</strong></td>
1215- </tr>
1216- </thead>
1217- <tbody>
1218- <tr>
1219- <td width="70%" valign="top">
1220- <table width="100%" align="center" cellpadding="3">
1221- <thead>
1222- <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
1223- <td>Parameter</td>
1224- <td>Value</td>
1225- </tr>
1226- </thead>
1227- <tbody>
1228-
1229-<?php
1230- $rowColor = $background1;
1231- echo "<tr bgcolor='" . $rowColor . "'>";
1232-
1233-
1234- foreach ($host_config as $key => $value) {
1235-
1236- if ($key == "event_handler") { continue; }
1237- if ($key == "cacti_graph_id") { continue; }
1238-
1239- echo "<tr bgcolor='" . $rowColor . "'>";
1240-
1241- switch($key)
1242- {
1243- case "active_checks_enabled":
1244- echo "<td>Active Checks:</td>";
1245- break;
1246- case "passive_checks_enabled":
1247- echo "<td>Passive Checks:</td>";
1248- break;
1249- case "event_handler_enabled":
1250- echo "<td>Event Handler:</td>";
1251- break;
1252- case "flap_detection_enabled":
1253- echo "<td>Flap Detection:</td>";
1254- break;
1255- case "notifications_enabled":
1256- echo "<td>Notifications:</td>";
1257- break;
1258- case "failure_prediction_enabled":
1259- echo "<td>Failure Prediction:</td>";
1260- break;
1261- case "process_performance_data":
1262- echo "<td>Process Performance Data:</td>";
1263- break;
1264- case "obsess_over_host":
1265- echo "<td>Obsess Over Host:</td>";
1266- break;
1267- }
1268-
1269- if ($value == 0) {
1270- echo "<td class='optionDISABLED'>Disabled</td></tr>";
1271- } else {
1272- echo "<td class='optionENABLED'>Enabled</td></tr>";
1273- }
1274-
1275- if($rowColor == $background1) {
1276- $rowColor = $background2;
1277- } else {
1278- $rowColor = $background1;
1279- }
1280-
1281-
1282- }
1283-
1284-?>
1285- </tbody>
1286- </table>
1287- </td>
1288- </tr>
1289- </table>
1290-
1291- </td>
1292-
1293-
1294-
1295-<?php
1296-
1297-
1298-
1299-
1300- echo "</tr>";
1301- echo "<tr>";
1302-
1303-?>
1304- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
1305- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
1306- <td valign="top" colspan='2'>
1307- <table width="60%" border="0" align="center">
1308- <thead>
1309- <tr class="textHeaderDark" bgcolor='#00438C'>
1310- <td align="center"><strong>Host Comments</strong></td>
1311- </tr>
1312- </thead>
1313- <tbody>
1314- <tr>
1315- <td width="60%" valign="top">
1316- <table width="100%" align="center" cellpadding="3">
1317- <thead>
1318- <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>
1319- <td>Entry Time</td>
1320- <td>Author</td>
1321- <td>Comment</td>
1322- <td>Persistent</td>
1323- <td>Type</td>
1324- <td>Delete</td>
1325- <tbody>
1326-<?php
1327- for($i = 0; $i < $row_count; $i++) {
1328-
1329- echo "<tr bgcolor='" . $rowColor . "'>";
1330- echo "<td nowrap>" . $comments[$i]["timestamp"] . "</td>";
1331- echo "<td>" . $comments[$i]["author"] . "</td>";
1332- echo "<td>" . $comments[$i]["comment"] . "</td>";
1333- echo "<td>";
1334- if ($comments[$i]["persist"]) {
1335- echo "Yes";
1336- } else {
1337- echo "No";
1338- }
1339- echo "</td>";
1340- echo "<td>";
1341- if ($comments[$i]["type"] == 1) {
1342- echo "Comment";
1343- } elseif ($comments[$i]["type"] == 3) {
1344- echo "Acknowledgment";
1345- }
1346- echo "</td>";
1347- echo "<td>";
1348- if ($comments[$i]["type"] == 1) {
1349- 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>";
1350- } elseif ($comments[$i]["type"] == 3) {
1351- 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>";
1352- }
1353- echo "</td>";
1354-
1355-
1356- if($rowColor == $background1) {
1357- $rowColor = $background2;
1358- } else {
1359- $rowColor = $background1;
1360- }
1361- }
1362-
1363-
1364-
1365-
1366-
1367-
1368-
1369-?>
1370- </tbody>
1371- </table>
1372- </td>
1373- </tr>
1374- <tr>
1375- <td>
1376- <?php
1377- 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>";
1378- 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>";
1379- ?>
1380- </td>
1381- </tr>
1382- </tbody>
1383- </table>
1384- </td>
1385- <td></td>
1386- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
1387- <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
1388- <tr>
1389-
1390-
1391-
1392-
1393-
1394- <td valign="top" colspan='2'>
1395- <table width="60%" border="0" align="center">
1396- <thead>
1397- <tr align="center" class="textHeaderDark" bgcolor='#00438C'>
1398- <td align="center"><strong>Graph Mapping</strong></td>
1399- </tr>
1400- </thead>
1401- <tbody>
1402- <tr>
1403- <td width="60%" valign="top">
1404- <table width="100%" align="center" cellpadding="3">
1405- <tbody>
1406-
1407-<?php
1408-
1409-$cacti_graphs = db_fetch_assoc("
1410-select
1411- graph_templates_graph.id,
1412- graph_templates_graph.local_graph_id,
1413- graph_templates_graph.height,
1414- graph_templates_graph.width,
1415- graph_templates_graph.title_cache as title,
1416- graph_templates.name,
1417- graph_local.host_id
1418- from graph_local,graph_templates_graph
1419- left join graph_templates on graph_local.graph_template_id=graph_templates.id
1420- where graph_local.id=graph_templates_graph.local_graph_id
1421- and graph_templates_graph.title_cache like '%'
1422- order by graph_templates_graph.title_cache,graph_local.host_id");
1423-
1424- $row_count = count($cacti_graphs);
1425-/* http://logindev/cacti/graph_image.php?local_graph_id=6&rra_id=0 */
1426-?>
1427-
1428- <FORM NAME="gm" ACTION="" method="post">
1429- <tr bgcolor='<?php echo $background1; ?>'>
1430- <td>Associated graph:</td>
1431- <td>
1432- <select name="local_graph_id" size="1">
1433- <?php
1434- echo "<OPTION VALUE='NULL'>None</option>";
1435- for($i = 0; $i < $row_count; $i++) {
1436- echo "<OPTION VALUE='" . $cacti_graphs[$i]["local_graph_id"] . "'>" . $cacti_graphs[$i]["title"] . "</option>";
1437- }
1438- ?>
1439-
1440-
1441- </select>
1442- </td>
1443- <td><INPUT TYPE="submit" VALUE="Map"></td>
1444- </tr>
1445- </FORM>
1446-
1447-
1448- </tbody>
1449- </table>
1450- <?php
1451- if ($host_config["cacti_graph_id"]) {
1452- echo "<table align='center'>";
1453- echo "<tr><td width='100%'>";
1454- echo "<img src='../../graph_image.php?local_graph_id=" . $host_config["cacti_graph_id"] . "&rra_id=0'>";
1455- echo "</td></tr>";
1456- }
1457- ?>
1458- </td>
1459- </tr>
1460- </tbody>
1461- </table>
1462-
1463- </td>
1464-
1465- </tr>
1466- </table>
1467-
1468-<?php
1469-
1470-
1471-}
1472-
1473-
1474-
1475-
1476-?>
1477+<?php\r
1478+/*\r
1479+ +-------------------------------------------------------------------------+\r
1480+ | Nagios Plugin 0.1a for cacti 0.8.6f |\r
1481+ | Copyright (C) 2005 Billy Gunn (billy@gunn.org) |\r
1482+ | |\r
1483+ | This program is free software; you can redistribute it and/or |\r
1484+ | modify it under the terms of the GNU General Public License |\r
1485+ | as published by the Free Software Foundation; either version 2 |\r
1486+ | of the License, or (at your option) any later version. |\r
1487+ | |\r
1488+ | This program is distributed in the hope that it will be useful, |\r
1489+ | but WITHOUT ANY WARRANTY; without even the implied warranty of |\r
1490+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\r
1491+ | GNU General Public License for more details. |\r
1492+ +-------------------------------------------------------------------------+\r
1493+ | Cacti and Nagios are the copyright of their respective owners. |\r
1494+ +-------------------------------------------------------------------------+\r
1495+*/\r
1496+\r
1497+chdir('../../');\r
1498+include_once("./include/auth.php");\r
1499+include_once("./include/config.php");\r
1500+\r
1501+// Refresh the page at a user supplied interval\r
1502+header("Refresh: " . read_config_option("npc_refresh") . "; URL=" . $_SERVER["REQUEST_URI"]);\r
1503+\r
1504+/* set default action */\r
1505+if (!isset($_REQUEST["type"])) { $_REQUEST["type"] = ""; }\r
1506+\r
1507+switch ($_REQUEST["type"]) {\r
1508+ case '1':\r
1509+\r
1510+ hostInfo();\r
1511+ include_once("./include/bottom_footer.php");\r
1512+ break;\r
1513+\r
1514+ case '2':\r
1515+\r
1516+ serviceInfo();\r
1517+ include_once("./include/bottom_footer.php");\r
1518+ break;\r
1519+\r
1520+ default:\r
1521+\r
1522+ hostInfo();\r
1523+ include_once("./include/bottom_footer.php");\r
1524+ break;\r
1525+}\r
1526+\r
1527+\r
1528+function formatTime($time) {\r
1529+\r
1530+ $days = floor($time/60/60/24);\r
1531+ $time -= $days*60*60*24;\r
1532+ $hours = floor($time/60/60);\r
1533+ $time -= $hours*60*60;\r
1534+ $minutes = floor($time/60);\r
1535+ $time -= $minutes*60;\r
1536+ $seconds = $time;\r
1537+\r
1538+ return ($days . "d " . $hours . "h " . $minutes . "m " . $seconds . "s");\r
1539+}\r
1540+\r
1541+\r
1542+function serviceInfo() {\r
1543+\r
1544+ $hostid = $_REQUEST["hostid"];\r
1545+ $serviceid = $_REQUEST["serviceid"];\r
1546+ $hostname = $_REQUEST["hostname"];\r
1547+ $serviceName = ereg_replace("\+", " ", $_REQUEST["service"]);\r
1548+\r
1549+\r
1550+ if (isset($_POST["local_graph_id"])) {\r
1551+ db_execute("update npc_service set cacti_graph_id = " . $_POST["local_graph_id"] . " where id = " . $serviceid);\r
1552+ header("Location: extinfo.php?type=2&hostid=" . $hostid . "&hostname=" . $hostname . "&serviceid=" . $serviceid . "&service=" . $_REQUEST["service"]);\r
1553+ }\r
1554+\r
1555+ include_once("top_npc_header.php");\r
1556+\r
1557+ $background1 = "#F5F5F5";\r
1558+ $background2 = "#E7E9F2";\r
1559+ $rowColor = $background1;\r
1560+\r
1561+ $service_detail = db_fetch_row("\r
1562+select distinct\r
1563+ service_soft_state as 'Current Status',\r
1564+ duration as 'State Duration',\r
1565+ check_command as 'Check Command',\r
1566+ plugin_output as 'Plugin Output',\r
1567+ performance_data as 'Performance Data',\r
1568+ current_attempt as 'Current Attempt',\r
1569+ from_unixtime(last_check) as 'Last Check',\r
1570+ from_unixtime(next_check) as 'Next Check',\r
1571+ check_latency as 'Check Latency',\r
1572+ check_execute_time as 'Check Duration',\r
1573+ hostid,\r
1574+ name,\r
1575+ host_soft_state as 'Host Soft State',\r
1576+ host_notifications as 'Host Notifications',\r
1577+ service as 'Service',\r
1578+ cacti_graph_id,\r
1579+ serviceid,\r
1580+ service_hard_state,\r
1581+ service_notifications as 'Service Notifications',\r
1582+ max_attempts as 'Max Attempts'\r
1583+from\r
1584+ (\r
1585+ select\r
1586+ npc_host.id as hostid,\r
1587+ npc_host.name,\r
1588+ npc_hostgroup_membership.groupid as hostgroup,\r
1589+ npc_host_history.soft_state as host_soft_state,\r
1590+ npc_host.notifications_enabled as host_notifications,\r
1591+ npc_service.id as serviceid,\r
1592+ npc_service.cacti_graph_id,\r
1593+ npc_service.service_description as service,\r
1594+ npc_service_history.soft_state as service_soft_state,\r
1595+ npc_service_history.hard_state as service_hard_state,\r
1596+ npc_service.notifications_enabled as service_notifications,\r
1597+ npc_service_check.last_check,\r
1598+ npc_service_check.next_check,\r
1599+ npc_service_check.check_execute_time,\r
1600+ npc_service_check.check_latency,\r
1601+ npc_service_check.check_command,\r
1602+ npc_service_check.performance_data,\r
1603+ unix_timestamp() - npc_service_history.started as duration,\r
1604+ npc_service_history.current_attempt,\r
1605+ npc_service_check.max_attempts,\r
1606+ npc_service_history.plugin_output\r
1607+ from\r
1608+ npc_host,\r
1609+ npc_host_history,\r
1610+ npc_hostgroup_membership,\r
1611+ npc_service,\r
1612+ npc_service_check,\r
1613+ npc_service_history\r
1614+ where\r
1615+ npc_host.id = npc_hostgroup_membership.hostid and\r
1616+ npc_host.id = npc_service.hostid and\r
1617+ npc_host.id = npc_host_history.hostid and\r
1618+ npc_service.id = npc_service_check.serviceid and\r
1619+ npc_service.id = npc_service_history.serviceid and\r
1620+ npc_service_history.lasted is null and\r
1621+ npc_host_history.lasted is null and\r
1622+ npc_service.configured = TRUE and\r
1623+ npc_service.has_been_checked = TRUE and\r
1624+ npc_host.has_been_checked = TRUE\r
1625+ union\r
1626+ select\r
1627+ npc_host.id as hostid,\r
1628+ npc_host.name,\r
1629+ 0 as hostgroup,\r
1630+ npc_host_history.soft_state as host_soft_state,\r
1631+ npc_host.notifications_enabled as host_notifications,\r
1632+ npc_service.id as serviceid,\r
1633+ npc_service.cacti_graph_id,\r
1634+ npc_service.service_description as service,\r
1635+ npc_service_history.soft_state as service_soft_state,\r
1636+ npc_service_history.hard_state as service_hard_state,\r
1637+ npc_service.notifications_enabled as service_notifications,\r
1638+ npc_service_check.last_check,\r
1639+ npc_service_check.next_check,\r
1640+ npc_service_check.check_execute_time,\r
1641+ npc_service_check.check_latency,\r
1642+ npc_service_check.check_command,\r
1643+ npc_service_check.performance_data,\r
1644+ unix_timestamp() - npc_service_history.started as duration,\r
1645+ npc_service_history.current_attempt,\r
1646+ npc_service_check.max_attempts,\r
1647+ npc_service_history.plugin_output\r
1648+ from\r
1649+ npc_host,\r
1650+ npc_host_history,\r
1651+ npc_service,\r
1652+ npc_service_check,\r
1653+ npc_service_history\r
1654+ where\r
1655+ npc_host.id not in (select hostid from npc_hostgroup_membership) and\r
1656+ npc_host.id = npc_service.hostid and\r
1657+ npc_host.id = npc_host_history.hostid and\r
1658+ npc_service.id = npc_service_check.serviceid and\r
1659+ npc_service.id = npc_service_history.serviceid and\r
1660+ npc_service_history.lasted is null and\r
1661+ npc_host_history.lasted is null and\r
1662+ npc_service.configured = TRUE and\r
1663+ npc_service.has_been_checked = TRUE and\r
1664+ npc_host.has_been_checked = TRUE\r
1665+ union\r
1666+ select\r
1667+ npc_host.id as hostid,\r
1668+ npc_host.name,\r
1669+ npc_hostgroup_membership.groupid as hostgroup,\r
1670+ -1 as host_soft_state,\r
1671+ npc_host.notifications_enabled as host_notifications,\r
1672+ npc_service.id as serviceid,\r
1673+ npc_service.cacti_graph_id,\r
1674+ npc_service.service_description as service,\r
1675+ npc_service_history.soft_state as service_soft_state,\r
1676+ npc_service_history.hard_state as service_hard_state,\r
1677+ npc_service.notifications_enabled as service_notifications,\r
1678+ npc_service_check.last_check,\r
1679+ npc_service_check.next_check,\r
1680+ npc_service_check.check_execute_time,\r
1681+ npc_service_check.check_latency,\r
1682+ npc_service_check.check_command,\r
1683+ npc_service_check.performance_data,\r
1684+ unix_timestamp() - npc_service_history.started as duration,\r
1685+ npc_service_history.current_attempt,\r
1686+ npc_service_check.max_attempts,\r
1687+ npc_service_history.plugin_output\r
1688+ from\r
1689+ npc_host,\r
1690+ npc_hostgroup_membership,\r
1691+ npc_service,\r
1692+ npc_service_check,\r
1693+ npc_service_history\r
1694+ where\r
1695+ npc_host.id = npc_hostgroup_membership.hostid and\r
1696+ npc_host.id = npc_service.hostid and\r
1697+ npc_service.id = npc_service_check.serviceid and\r
1698+ npc_service.id = npc_service_history.serviceid and\r
1699+ npc_service_history.lasted is null and\r
1700+ npc_service.configured = TRUE and\r
1701+ npc_service.has_been_checked = TRUE and\r
1702+ npc_host.has_been_checked = FALSE\r
1703+ union\r
1704+ select\r
1705+ npc_host.id as hostid,\r
1706+ npc_host.name,\r
1707+ 0 as hostgroup,\r
1708+ -1 as host_soft_state,\r
1709+ npc_host.notifications_enabled as host_notifications,\r
1710+ npc_service.id as serviceid,\r
1711+ npc_service.cacti_graph_id,\r
1712+ npc_service.service_description as service,\r
1713+ npc_service_history.soft_state as service_soft_state,\r
1714+ npc_service_history.hard_state as service_hard_state,\r
1715+ npc_service.notifications_enabled as service_notifications,\r
1716+ npc_service_check.last_check,\r
1717+ npc_service_check.next_check,\r
1718+ npc_service_check.check_execute_time,\r
1719+ npc_service_check.check_latency,\r
1720+ npc_service_check.check_command,\r
1721+ npc_service_check.performance_data,\r
1722+ unix_timestamp() - npc_service_history.started as duration,\r
1723+ npc_service_history.current_attempt,\r
1724+ npc_service_check.max_attempts,\r
1725+ npc_service_history.plugin_output\r
1726+ from\r
1727+ npc_host,\r
1728+ npc_service,\r
1729+ npc_service_check,\r
1730+ npc_service_history\r
1731+ where\r
1732+ npc_host.id not in (select hostid from npc_hostgroup_membership) and\r
1733+ npc_host.id = npc_service.hostid and\r
1734+ npc_service.id = npc_service_check.serviceid and\r
1735+ npc_service.id = npc_service_history.serviceid and\r
1736+ npc_service_history.lasted is null and\r
1737+ npc_service.configured = TRUE and\r
1738+ npc_service.has_been_checked = TRUE and\r
1739+ npc_host.has_been_checked = FALSE\r
1740+ union\r
1741+ select\r
1742+ npc_host.id as hostid,\r
1743+ npc_host.name,\r
1744+ npc_hostgroup_membership.groupid as hostgroup,\r
1745+ npc_host_history.soft_state as host_soft_state,\r
1746+ npc_host.notifications_enabled as host_notifications,\r
1747+ npc_service.id as serviceid,\r
1748+ npc_service.cacti_graph_id,\r
1749+ npc_service.service_description as service,\r
1750+ -1 as service_soft_state,\r
1751+ -1 as service_hard_state,\r
1752+ npc_service.notifications_enabled as service_notifications,\r
1753+ npc_service_check.last_check,\r
1754+ npc_service_check.next_check,\r
1755+ npc_service_check.check_execute_time,\r
1756+ npc_service_check.check_latency,\r
1757+ npc_service_check.check_command,\r
1758+ npc_service_check.performance_data,\r
1759+ 0 as duration,\r
1760+ 0 as current_attempt,\r
1761+ npc_service_check.max_attempts,\r
1762+ null as plugin_output\r
1763+ from\r
1764+ npc_host,\r
1765+ npc_host_history,\r
1766+ npc_hostgroup_membership,\r
1767+ npc_service,\r
1768+ npc_service_check\r
1769+ where\r
1770+ npc_host.id = npc_hostgroup_membership.hostid and\r
1771+ npc_host.id = npc_service.hostid and\r
1772+ npc_host.id = npc_host_history.hostid and\r
1773+ npc_service.id = npc_service_check.serviceid and\r
1774+ npc_host_history.lasted is null and\r
1775+ npc_service.configured = TRUE and\r
1776+ npc_service.has_been_checked = FALSE and\r
1777+ npc_host.has_been_checked = TRUE\r
1778+ union\r
1779+ select\r
1780+ npc_host.id as hostid,\r
1781+ npc_host.name,\r
1782+ 0 as hostgroup,\r
1783+ npc_host_history.soft_state as host_soft_state,\r
1784+ npc_host.notifications_enabled as host_notifications,\r
1785+ npc_service.id as serviceid,\r
1786+ npc_service.cacti_graph_id,\r
1787+ npc_service.service_description as service,\r
1788+ -1 as service_soft_state,\r
1789+ -1 as service_hard_state,\r
1790+ npc_service.notifications_enabled as service_notifications,\r
1791+ npc_service_check.last_check,\r
1792+ npc_service_check.next_check,\r
1793+ npc_service_check.check_execute_time,\r
1794+ npc_service_check.check_latency,\r
1795+ npc_service_check.check_command,\r
1796+ npc_service_check.performance_data,\r
1797+ 0 as duration,\r
1798+ 0 as current_attempt,\r
1799+ npc_service_check.max_attempts,\r
1800+ null as plugin_output\r
1801+ from\r
1802+ npc_host,\r
1803+ npc_host_history,\r
1804+ npc_service,\r
1805+ npc_service_check\r
1806+ where\r
1807+ npc_host.id not in (select hostid from npc_hostgroup_membership) and\r
1808+ npc_host.id = npc_service.hostid and\r
1809+ npc_host.id = npc_host_history.hostid and\r
1810+ npc_service.id = npc_service_check.serviceid and\r
1811+ npc_host_history.lasted is null and\r
1812+ npc_service.configured = TRUE and\r
1813+ npc_service.has_been_checked = FALSE and\r
1814+ npc_host.has_been_checked = TRUE\r
1815+ union\r
1816+ select\r
1817+ npc_host.id as hostid,\r
1818+ npc_host.name,\r
1819+ npc_hostgroup_membership.groupid as hostgroup,\r
1820+ -1 as host_soft_state,\r
1821+ npc_host.notifications_enabled as host_notifications,\r
1822+ npc_service.id as serviceid,\r
1823+ npc_service.cacti_graph_id,\r
1824+ npc_service.service_description as service,\r
1825+ -1 as service_soft_state,\r
1826+ -1 as service_hard_state,\r
1827+ npc_service.notifications_enabled as service_notifications,\r
1828+ npc_service_check.last_check,\r
1829+ npc_service_check.next_check,\r
1830+ npc_service_check.check_execute_time,\r
1831+ npc_service_check.check_latency,\r
1832+ npc_service_check.check_command,\r
1833+ npc_service_check.performance_data,\r
1834+ 0 as duration,\r
1835+ 0 as current_attempt,\r
1836+ npc_service_check.max_attempts,\r
1837+ null as plugin_output\r
1838+ from\r
1839+ npc_host,\r
1840+ npc_hostgroup_membership,\r
1841+ npc_service,\r
1842+ npc_service_check\r
1843+ where\r
1844+ npc_host.id = npc_hostgroup_membership.hostid and\r
1845+ npc_host.id = npc_service.hostid and\r
1846+ npc_service.id = npc_service_check.serviceid and\r
1847+ npc_service.configured = TRUE and\r
1848+ npc_service.has_been_checked = FALSE and\r
1849+ npc_host.has_been_checked = FALSE\r
1850+ union\r
1851+ select\r
1852+ npc_host.id as hostid,\r
1853+ npc_host.name,\r
1854+ 0 as hostgroup,\r
1855+ -1 as host_soft_state,\r
1856+ npc_host.notifications_enabled as host_notifications,\r
1857+ npc_service.id as serviceid,\r
1858+ npc_service.cacti_graph_id,\r
1859+ npc_service.service_description as service,\r
1860+ -1 as service_soft_state,\r
1861+ -1 as service_hard_state,\r
1862+ npc_service.notifications_enabled as service_notifications,\r
1863+ npc_service_check.last_check,\r
1864+ npc_service_check.next_check,\r
1865+ npc_service_check.check_execute_time,\r
1866+ npc_service_check.check_latency,\r
1867+ npc_service_check.check_command,\r
1868+ npc_service_check.performance_data,\r
1869+ 0 as duration,\r
1870+ 0 as current_attempt,\r
1871+ npc_service_check.max_attempts,\r
1872+ null as plugin_output\r
1873+ from\r
1874+ npc_host,\r
1875+ npc_service,\r
1876+ npc_service_check\r
1877+ where\r
1878+ npc_host.id not in (select hostid from npc_hostgroup_membership) and\r
1879+ npc_host.id = npc_service.hostid and\r
1880+ npc_service.id = npc_service_check.serviceid and\r
1881+ npc_service.configured = TRUE and\r
1882+ npc_service.has_been_checked = FALSE and\r
1883+ npc_host.has_been_checked = FALSE\r
1884+ order by\r
1885+ name\r
1886+ ) as host_details where hostid = $hostid and service = '$serviceName'");\r
1887+\r
1888+ $service_detail["flapping"] = db_fetch_cell("select id from npc_flapping_service where id = $serviceid");\r
1889+ $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
1890+ $comments = db_fetch_assoc("select id,serviceid,timestamp,author,comment,persist,type from npc_comment where serviceid = '$serviceid'");\r
1891+ $row_count = count($comments);\r
1892+\r
1893+?>\r
1894+\r
1895+\r
1896+\r
1897+\r
1898+ <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">\r
1899+ <tr class="textSubHeaderDark" bgcolor='#6d88ad'>\r
1900+ <td>\r
1901+ <h2>&nbsp;[ <?php echo $serviceName; ?> ] on \r
1902+ <a href="extinfo.php?type=1&hostid=<?php echo $hostid; ?>&hostname=<?php echo $hostname; ?>"><?php echo $hostname; ?></a></h2>\r
1903+ </td>\r
1904+ <td align='right' nowrap>\r
1905+ <FORM NAME="cl" ACTION="command.php" method="POST">Command: \r
1906+ <INPUT TYPE='hidden' NAME='host' VALUE='<?php echo $hostname; ?>'>\r
1907+ <INPUT TYPE='hidden' NAME='hostid' VALUE='<?php echo $service_detail["hostid"]; ?>'>\r
1908+ <INPUT TYPE='hidden' NAME='service' VALUE='<?php echo $serviceName; ?>'>\r
1909+ <INPUT TYPE='hidden' NAME='serviceid' VALUE='<?php echo $service_detail["serviceid"]; ?>'>\r
1910+ <select name="command" size="1">\r
1911+\r
1912+<?php \r
1913+ if (read_config_option("nagios_commands")) {\r
1914+\r
1915+ echo "<OPTION VALUE='NULL'>Execute a command</option>";\r
1916+\r
1917+ if ($service_config["active_checks_enabled"]) {\r
1918+ echo "<strong><OPTION VALUE='DISABLE_SVC_CHECK'>Disable active checks</option></strong>";\r
1919+ echo "<OPTION VALUE='SCHEDULE_SVC_CHECK'>Re-schedule the next check</option>";\r
1920+ } else {\r
1921+ echo "<OPTION VALUE='ENABLE_SVC_CHECK'>Enable Active Checks</option>";\r
1922+ }\r
1923+ if ($service_config["passive_checks_enabled"]) {\r
1924+ echo "<OPTION VALUE='PROCESS_SVC_CHECK_RESULT'>Submit passive check result</option>";\r
1925+ echo "<OPTION VALUE='DISABLE_PASSIVE_SVC_CHECKS'>Stop accepting passive checks</option>";\r
1926+ } else {\r
1927+ echo "<OPTION VALUE='ENABLE_PASSIVE_SVC_CHECKS'>Start accepting passive checks</option>";\r
1928+ }\r
1929+ if ($service_config["obsess_over_service"]) {\r
1930+ echo "<OPTION VALUE='STOP_OBSESSING_OVER_SVC'>Stop obsessing</option>";\r
1931+ } else {\r
1932+ echo "<OPTION VALUE='START_OBSESSING_OVER_SVC'>Start obsessing</option>";\r
1933+ }\r
1934+ 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
1935+ if (!db_fetch_cell("select * from npc_comment where serviceid = $serviceid and type = 4;")) {\r
1936+ echo "<OPTION VALUE='ACKNOWLEDGE_SVC_PROBLEM'>Acknowledge This Service Problem</option>";\r
1937+ } elseif (db_fetch_cell("select * from npc_comment where serviceid = $serviceid and type = 4;")) {\r
1938+ echo "<OPTION VALUE='REMOVE_SVC_ACKNOWLEDGEMENT'>Remove Problem Acknowledgement</option>";\r
1939+ }\r
1940+ }\r
1941+ if ($service_config["notifications_enabled"]) {\r
1942+ echo "<OPTION VALUE='DISABLE_SVC_NOTIFICATIONS'>Disable Notifications</option>";\r
1943+ if ($service_detail["Current Status"] != 0) {\r
1944+ echo "<OPTION VALUE='DELAY_SVC_NOTIFICATION'>Delay Next Service Notification</option>";\r
1945+ }\r
1946+ } else {\r
1947+ echo "<OPTION VALUE='ENABLE_SVC_NOTIFICATIONS'>Enable Notifications</option>";\r
1948+ }\r
1949+ echo "<OPTION VALUE='SCHEDULE_SVC_DOWNTIME'>Schedule Downtime</option>";\r
1950+ if ($service_config["event_handler_enabled"]) {\r
1951+ echo "<OPTION VALUE='DISABLE_SVC_EVENT_HANDLER'>Disable Event Handler</option>";\r
1952+ } else {\r
1953+ echo "<OPTION VALUE='ENABLE_SVC_EVENT_HANDLER'>Enable Event Handler</option>";\r
1954+ }\r
1955+ if ($service_config["flap_detection_enabled"]) {\r
1956+ echo "<OPTION VALUE='DISABLE_SVC_FLAP_DETECTION'>Disable Flap Detection</option>";\r
1957+ } else {\r
1958+ echo "<OPTION VALUE='ENABLE_SVC_FLAP_DETECTION'>Enable Flap Detection</option>";\r
1959+ }\r
1960+ echo "<OPTION VALUE='ADD_SVC_COMMENT'>Add Service Comment</option>";\r
1961+ echo "<OPTION VALUE='DEL_ALL_SVC_COMMENTS'>Delete All Service Comments</option>";\r
1962+ } else {\r
1963+ echo "<OPTION VALUE=''>Command execution disabled</option>";\r
1964+ }\r
1965+?>\r
1966+\r
1967+ </select>\r
1968+ <input type='image' src='../../images/button_go.gif' alt='Go' value='Execute' align='absmiddle'>\r
1969+ </form>\r
1970+\r
1971+\r
1972+ </td>\r
1973+ </tr>\r
1974+\r
1975+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
1976+ <tr>\r
1977+ <td valign="top">\r
1978+ <table width="100%" border="0" align="left" valign="top">\r
1979+ <thead>\r
1980+ <tr class="textHeaderDark" bgcolor='#00438C'>\r
1981+ <td align="center"><strong>Service State Information</strong></td>\r
1982+ </tr>\r
1983+ </thead>\r
1984+ <tbody>\r
1985+ <tr>\r
1986+ <td width="100%" valign="top">\r
1987+ <table width="100%" align="center" cellpadding="3">\r
1988+ <thead>\r
1989+ <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
1990+ <td>Parameter</td>\r
1991+ <td>Value</td>\r
1992+ </tr>\r
1993+ </thead>\r
1994+ <tbody>\r
1995+\r
1996+\r
1997+<?php\r
1998+\r
1999+\r
2000+ foreach ($service_detail as $key => $value) {\r
2001+\r
2002+\r
2003+ switch($key) \r
2004+ {\r
2005+ case "Current Status":\r
2006+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2007+ echo "<td>" . $key . ":</td>";\r
2008+ switch($value)\r
2009+ {\r
2010+ case "-1":\r
2011+ echo "<td class='statusPENDING'><strong>PENDING</strong></td>";\r
2012+ break;\r
2013+ case "0":\r
2014+ echo "<td class='statusOK'><strong>OK</strong></td>";\r
2015+ break;\r
2016+ case "1":\r
2017+ echo "<td class='statusWARNING'><strong>WARNING</strong></td>";\r
2018+ break;\r
2019+ case "2":\r
2020+ echo "<td class='statusCRITICAL'><strong>CRITICAL</strong></td>";\r
2021+ break;\r
2022+ case "3":\r
2023+ echo "<td class='statusUNKNOWN'><strong>UNKNOWN</strong></td>";\r
2024+ break;\r
2025+ }\r
2026+ echo "</tr>";\r
2027+ break;\r
2028+ case "State Duration":\r
2029+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2030+ echo "<td>" . $key . ":</td>";\r
2031+ echo "<td>" . formatTime($value) . "</td>";\r
2032+ echo "</tr>";\r
2033+ break;\r
2034+ case "Check Command":\r
2035+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2036+ echo "<td>" . $key . ":</td>";\r
2037+ echo "<td>" . $value . "</td>";\r
2038+ echo "</tr>";\r
2039+ break;\r
2040+ case "Plugin Output":\r
2041+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2042+ echo "<td>" . $key . ":</td>";\r
2043+ echo "<td>" . $value . "</td>";\r
2044+ echo "</tr>";\r
2045+ break;\r
2046+ case "Performance Data":\r
2047+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2048+ echo "<td>" . $key . ":</td>";\r
2049+ echo "<td>" . $value . "</td>";\r
2050+ echo "</tr>";\r
2051+ break;\r
2052+ case "Current Attempt":\r
2053+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2054+ echo "<td>" . $key . ":</td>";\r
2055+ echo "<td>" . $value . "/" . $service_detail["Max Attempts"] . "</td>";\r
2056+ echo "</tr>";\r
2057+ break;\r
2058+ case "Last Check":\r
2059+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2060+ echo "<td>" . $key . ":</td>";\r
2061+ if (preg_match('/1969-12-31/', $value)) {\r
2062+ echo "<td>N/A</td>";\r
2063+ } else {\r
2064+ echo "<td>" . $value . "</td>";\r
2065+ }\r
2066+ echo "</tr>";\r
2067+ break;\r
2068+ case "Next Check":\r
2069+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2070+ echo "<td>" . $key . ":</td>";\r
2071+ echo "<td>" . $value . "</td>";\r
2072+ echo "</tr>";\r
2073+ break;\r
2074+ case "Check Latency":\r
2075+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2076+ echo "<td>" . $key . ":</td>";\r
2077+ echo "<td>" . $value . "</td>";\r
2078+ echo "</tr>";\r
2079+ break;\r
2080+ case "Check Duration":\r
2081+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2082+ echo "<td>" . $key . ":</td>";\r
2083+ echo "<td>" . $value . "</td>";\r
2084+ echo "</tr>";\r
2085+ break;\r
2086+ case "flapping":\r
2087+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2088+ echo "<td>Flapping:</td>";\r
2089+ if ($service_detail["flapping"]) {\r
2090+ echo "<td>Yes</td>";\r
2091+ } else {\r
2092+ echo "<td>No</td>";\r
2093+ }\r
2094+ echo "</tr>";\r
2095+ break;\r
2096+ }\r
2097+\r
2098+ if($rowColor == $background1) {\r
2099+ $rowColor = $background2;\r
2100+ } else {\r
2101+ $rowColor = $background1;\r
2102+ }\r
2103+\r
2104+ if ($key == "flapping") {\r
2105+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2106+ echo "<td>Event Handler:</td>";\r
2107+ if (!$service_config["event_handler"]) {\r
2108+ echo "<td>N/A</td>";\r
2109+ } else {\r
2110+ echo "<td>" . $service_config["event_handler"] . "</td>";\r
2111+ }\r
2112+ echo "</tr>";\r
2113+ }\r
2114+\r
2115+\r
2116+ }\r
2117+\r
2118+\r
2119+?>\r
2120+\r
2121+ </tbody>\r
2122+ </table>\r
2123+\r
2124+ </td>\r
2125+ </tr>\r
2126+ </tbody>\r
2127+ </table>\r
2128+\r
2129+ </td>\r
2130+\r
2131+ <td valign="top">\r
2132+ <table width="70%" border="0" align="right">\r
2133+ <thead>\r
2134+ <tr class="textHeaderDark" bgcolor='#00438C'>\r
2135+ <td align="center"><strong>Service Monitoring Options</strong></td>\r
2136+ </tr>\r
2137+ </thead>\r
2138+ <tbody>\r
2139+ <tr>\r
2140+ <td width="70%" valign="top">\r
2141+ <table width="100%" align="center" cellpadding="3">\r
2142+ <thead>\r
2143+ <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
2144+ <td>Parameter</td>\r
2145+ <td>Value</td>\r
2146+ </tr>\r
2147+ </thead>\r
2148+ <tbody>\r
2149+\r
2150+<?php\r
2151+ $rowColor = $background1;\r
2152+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2153+\r
2154+\r
2155+ foreach ($service_config as $key => $value) {\r
2156+\r
2157+ if ($key == "event_handler") { continue; }\r
2158+\r
2159+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2160+\r
2161+ switch($key)\r
2162+ {\r
2163+ case "active_checks_enabled":\r
2164+ echo "<td>Active Checks:</td>";\r
2165+ break;\r
2166+ case "passive_checks_enabled":\r
2167+ echo "<td>Passive Checks:</td>";\r
2168+ break;\r
2169+ case "event_handler_enabled":\r
2170+ echo "<td>Event Handler:</td>";\r
2171+ break;\r
2172+ case "flap_detection_enabled":\r
2173+ echo "<td>Flap Detection:</td>";\r
2174+ break;\r
2175+ case "notifications_enabled":\r
2176+ echo "<td>Notifications:</td>";\r
2177+ break;\r
2178+ case "failure_prediction_enabled":\r
2179+ echo "<td>Failure Prediction:</td>";\r
2180+ break;\r
2181+ case "process_performance_data":\r
2182+ echo "<td>Process Performance Data:</td>";\r
2183+ break;\r
2184+ case "obsess_over_service":\r
2185+ echo "<td>Obsess Over Service:</td>";\r
2186+ break;\r
2187+ }\r
2188+\r
2189+ if ($value == 0) {\r
2190+ echo "<td class='optionDISABLED'>Disabled</td></tr>";\r
2191+ } else {\r
2192+ echo "<td class='optionENABLED'>Enabled</td></tr>";\r
2193+ }\r
2194+\r
2195+ if($rowColor == $background1) {\r
2196+ $rowColor = $background2;\r
2197+ } else {\r
2198+ $rowColor = $background1;\r
2199+ }\r
2200+\r
2201+\r
2202+ }\r
2203+\r
2204+?>\r
2205+ </tbody>\r
2206+ </table>\r
2207+ </td>\r
2208+ </tr>\r
2209+ </table>\r
2210+\r
2211+ </td>\r
2212+\r
2213+\r
2214+\r
2215+<?php\r
2216+\r
2217+\r
2218+\r
2219+\r
2220+ echo "</tr>";\r
2221+ echo "<tr>";\r
2222+\r
2223+?>\r
2224+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2225+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2226+ <td valign="top" colspan='2'>\r
2227+ <table width="60%" border="0" align="center">\r
2228+ <thead>\r
2229+ <tr class="textHeaderDark" bgcolor='#00438C'>\r
2230+ <td align="center"><strong>Service Comments</strong></td>\r
2231+ </tr>\r
2232+ </thead>\r
2233+ <tbody>\r
2234+ <tr>\r
2235+ <td width="60%" valign="top">\r
2236+ <table width="100%" align="center" cellpadding="3">\r
2237+ <thead>\r
2238+ <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
2239+ <td>Entry Time</td>\r
2240+ <td>Author</td>\r
2241+ <td>Comment</td>\r
2242+ <td>Persistent</td>\r
2243+ <td>Type</td>\r
2244+ <td>Delete</td>\r
2245+ <tbody>\r
2246+<?php\r
2247+ for($i = 0; $i < $row_count; $i++) {\r
2248+ \r
2249+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2250+ echo "<td nowrap>" . $comments[$i]["timestamp"] . "</td>";\r
2251+ echo "<td>" . $comments[$i]["author"] . "</td>";\r
2252+ echo "<td>" . $comments[$i]["comment"] . "</td>";\r
2253+ echo "<td>";\r
2254+ if ($comments[$i]["persist"]) {\r
2255+ echo "Yes";\r
2256+ } else {\r
2257+ echo "No"; \r
2258+ }\r
2259+ echo "</td>";\r
2260+ echo "<td>";\r
2261+ if ($comments[$i]["type"] == 2) {\r
2262+ echo "Comment";\r
2263+ } elseif ($comments[$i]["type"] == 4) {\r
2264+ echo "Acknowledgment";\r
2265+ }\r
2266+ echo "</td>";\r
2267+ echo "<td>";\r
2268+ if ($comments[$i]["type"] == 2) {\r
2269+ 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
2270+ } elseif ($comments[$i]["type"] == 4) {\r
2271+ 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
2272+ }\r
2273+ echo "</td>";\r
2274+\r
2275+\r
2276+ if($rowColor == $background1) {\r
2277+ $rowColor = $background2;\r
2278+ } else {\r
2279+ $rowColor = $background1;\r
2280+ }\r
2281+ }\r
2282+\r
2283+\r
2284+\r
2285+\r
2286+\r
2287+\r
2288+\r
2289+?>\r
2290+ </tbody>\r
2291+ </table>\r
2292+ </td>\r
2293+ </tr>\r
2294+ <tr>\r
2295+ <td>\r
2296+ <?php \r
2297+ 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
2298+ 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
2299+ ?>\r
2300+ </td>\r
2301+ </tr>\r
2302+ </tbody>\r
2303+ </table>\r
2304+ </td>\r
2305+ <td></td>\r
2306+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2307+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2308+ <tr>\r
2309+\r
2310+\r
2311+\r
2312+\r
2313+\r
2314+ <td valign="top" colspan='2'>\r
2315+ <table width="60%" border="0" align="center">\r
2316+ <thead>\r
2317+ <tr align="center" class="textHeaderDark" bgcolor='#00438C'>\r
2318+ <td align="center"><strong>Graph Mapping</strong></td>\r
2319+ </tr>\r
2320+ </thead>\r
2321+ <tbody>\r
2322+ <tr>\r
2323+ <td width="60%" valign="top">\r
2324+ <table width="100%" align="center" cellpadding="3">\r
2325+ <tbody>\r
2326+\r
2327+<?php\r
2328+\r
2329+$cacti_graphs = db_fetch_assoc("\r
2330+select\r
2331+ graph_templates_graph.id,\r
2332+ graph_templates_graph.local_graph_id,\r
2333+ graph_templates_graph.height,\r
2334+ graph_templates_graph.width,\r
2335+ graph_templates_graph.title_cache as title,\r
2336+ graph_templates.name,\r
2337+ graph_local.host_id\r
2338+ from graph_local,graph_templates_graph\r
2339+ left join graph_templates on graph_template_id=graph_templates.id\r
2340+ where graph_local.id=graph_templates_graph.local_graph_id\r
2341+ and graph_templates_graph.title_cache like '%'\r
2342+ order by graph_templates_graph.title_cache,graph_local.host_id");\r
2343+\r
2344+ $row_count = count($cacti_graphs);\r
2345+/* http://logindev/cacti/graph_image.php?local_graph_id=6&rra_id=0 */\r
2346+?>\r
2347+\r
2348+ <FORM NAME="gm" ACTION="" method="post">\r
2349+ <tr bgcolor='<?php echo $background1; ?>'>\r
2350+ <td>Associated graph:</td>\r
2351+ <td>\r
2352+ <select name="local_graph_id" size="1">\r
2353+ <?php\r
2354+ echo "<OPTION VALUE='NULL'>None</option>";\r
2355+ for($i = 0; $i < $row_count; $i++) {\r
2356+ echo "<OPTION VALUE='" . $cacti_graphs[$i]["local_graph_id"] . "'>" . $cacti_graphs[$i]["title"] . "</option>";\r
2357+ }\r
2358+ ?> \r
2359+\r
2360+\r
2361+ </select>\r
2362+ </td>\r
2363+ <td><INPUT TYPE="submit" VALUE="Map"></td>\r
2364+ </tr>\r
2365+ </FORM>\r
2366+\r
2367+\r
2368+ </tbody>\r
2369+ </table>\r
2370+ <?php \r
2371+ if ($service_detail["cacti_graph_id"]) {\r
2372+ echo "<table align='center'>";\r
2373+ echo "<tr><td width='100%'>";\r
2374+ echo "<img src='../../graph_image.php?local_graph_id=" . $service_detail["cacti_graph_id"] . "&rra_id=0'>";\r
2375+ echo "</td></tr>";\r
2376+ }\r
2377+ ?>\r
2378+ </td>\r
2379+ </tr>\r
2380+ </tbody>\r
2381+ </table>\r
2382+\r
2383+ </td>\r
2384+\r
2385+ </tr>\r
2386+ </table>\r
2387+\r
2388+<?php\r
2389+\r
2390+\r
2391+}\r
2392+\r
2393+\r
2394+function hostInfo() {\r
2395+\r
2396+ $hostid = $_REQUEST["hostid"];\r
2397+ $hostname = $_REQUEST["hostname"];\r
2398+\r
2399+ if (isset($_POST["local_graph_id"])) {\r
2400+ db_execute("update npc_host set cacti_graph_id = " . $_POST["local_graph_id"] . " where id = " . $hostid);\r
2401+ header("Location: extinfo.php?type=1&hostid=" . $hostid . "&hostname=" . $hostname);\r
2402+ }\r
2403+\r
2404+ include_once("top_npc_header.php");\r
2405+\r
2406+ $background1 = "#F5F5F5";\r
2407+ $background2 = "#E7E9F2";\r
2408+ $rowColor = $background1;\r
2409+\r
2410+ $host_flapping["flapping"] = db_fetch_cell("select id from npc_flapping_host where id = $hostid");\r
2411+\r
2412+ $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
2413+\r
2414+ $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
2415+\r
2416+ $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
2417+\r
2418+ $comments = db_fetch_assoc("select id,serviceid,timestamp,author,comment,persist,type from npc_comment where hostid = $hostid");\r
2419+\r
2420+ $graphView = db_fetch_cell("select id from graph_tree_items where host_id = (select id from host where npc_host_id = $hostid)");\r
2421+\r
2422+ $row_count = count($comments);\r
2423+\r
2424+ $duration = date("U") - $host_history["started"];\r
2425+\r
2426+?>\r
2427+\r
2428+\r
2429+\r
2430+\r
2431+ <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">\r
2432+ <tr class="textSubHeaderDark" bgcolor='#6d88ad'>\r
2433+ <td>\r
2434+ <h2>&nbsp;<strong><?php echo $hostname; ?></strong></h2>\r
2435+ </td>\r
2436+ <td align='right' nowrap>\r
2437+ <FORM NAME="cl" ACTION="command.php" method="POST">Command: \r
2438+ <INPUT TYPE='hidden' NAME='host' VALUE='<?php echo $hostname; ?>'>\r
2439+ <INPUT TYPE='hidden' NAME='hostid' VALUE='<?php echo $hostid; ?>'>\r
2440+ <select name="command" size="1">\r
2441+\r
2442+<?php \r
2443+ if (read_config_option("nagios_commands")) {\r
2444+\r
2445+ echo "<OPTION VALUE='NULL'>Execute a command</option>";\r
2446+\r
2447+ if ($host_config["active_checks_enabled"]) {\r
2448+ echo "<OPTION VALUE='DISABLE_HOST_CHECK'>Disable active checks</option>";\r
2449+ echo "<OPTION VALUE='SCHEDULE_HOST_CHECK'>Re-schedule the next check</option>";\r
2450+ echo "<OPTION VALUE='SCHEDULE_HOST_SVC_CHECKS'>Schedule a check of all services</option>";\r
2451+ } else {\r
2452+ echo "<OPTION VALUE='ENABLE_HOST_CHECK'>Enable Active Checks</option>";\r
2453+ }\r
2454+ echo "<OPTION VALUE='DISABLE_HOST_SVC_CHECKS'>Disable checks of all services</option>";\r
2455+ echo "<OPTION VALUE='ENABLE_HOST_SVC_CHECKS'>Enabble checks of all services</option>";\r
2456+ if ($host_config["passive_checks_enabled"]) {\r
2457+ echo "<OPTION VALUE='PROCESS_HOST_CHECK_RESULT'>Submit passive check result</option>";\r
2458+ echo "<OPTION VALUE='DISABLE_PASSIVE_HOST_CHECKS'>Stop accepting passive checks</option>";\r
2459+ } else {\r
2460+ echo "<OPTION VALUE='ENABLE_PASSIVE_HOST_CHECKS'>Start accepting passive checks</option>";\r
2461+ }\r
2462+ if ($host_config["obsess_over_service"]) {\r
2463+ echo "<OPTION VALUE='STOP_OBSESSING_OVER_HOST'>Stop obsessing</option>";\r
2464+ } else {\r
2465+ echo "<OPTION VALUE='START_OBSESSING_OVER_HOST'>Start obsessing</option>";\r
2466+ }\r
2467+ if ($host_history["soft_state"] == 1 || $host_history["soft_state"] == 2 && $host_history["soft_state"] == $host_history["hard_state"]) {\r
2468+ if (!db_fetch_cell("select * from npc_comment where hostid = $hostid and type = 4;")) {\r
2469+ echo "<OPTION VALUE='ACKNOWLEDGE_HOST_PROBLEM'>Acknowledge This Host Problem</option>";\r
2470+ } elseif (db_fetch_cell("select * from npc_comment where hostid = $hostid and type = 4;")) {\r
2471+ echo "<OPTION VALUE='REMOVE_HOST_ACKNOWLEDGEMENT'>Remove Problem Acknowledgement</option>";\r
2472+ }\r
2473+ }\r
2474+ if ($host_config["notifications_enabled"]) {\r
2475+ echo "<OPTION VALUE='DISABLE_HOST_NOTIFICATIONS'>Disable Notifications</option>";\r
2476+ if ($host_history["soft_state"] != 0) {\r
2477+ echo "<OPTION VALUE='DELAY_HOST_NOTIFICATION'>Delay Next Service Notification</option>";\r
2478+ }\r
2479+ } else {\r
2480+ echo "<OPTION VALUE='ENABLE_HOST_NOTIFICATIONS'>Enable Notifications</option>";\r
2481+ }\r
2482+ echo "<OPTION VALUE='SCHEDULE_HOST_DOWNTIME'>Schedule Downtime</option>";\r
2483+ if ($host_config["event_handler_enabled"]) {\r
2484+ echo "<OPTION VALUE='DISABLE_HOST_EVENT_HANDLER'>Disable Event Handler</option>";\r
2485+ } else {\r
2486+ echo "<OPTION VALUE='ENABLE_HOST_EVENT_HANDLER'>Enable Event Handler</option>";\r
2487+ }\r
2488+ if ($host_config["flap_detection_enabled"]) {\r
2489+ echo "<OPTION VALUE='DISABLE_HOST_FLAP_DETECTION'>Disable Flap Detection</option>";\r
2490+ } else {\r
2491+ echo "<OPTION VALUE='ENABLE_HOST_FLAP_DETECTION'>Enable Flap Detection</option>";\r
2492+ }\r
2493+ echo "<OPTION VALUE='ADD_HOST_COMMENT'>Add Host Comment</option>";\r
2494+ echo "<OPTION VALUE='DEL_ALL_HOST_COMMENTS'>Delete All Host Comments</option>";\r
2495+ } else {\r
2496+ echo "<OPTION VALUE='NULL'>Command execution disabled</option>";\r
2497+ }\r
2498+?>\r
2499+\r
2500+ </select>\r
2501+ <input type='image' src='../../images/button_go.gif' alt='Go' value='Execute' align='absmiddle'>\r
2502+ </form>\r
2503+\r
2504+\r
2505+ </td>\r
2506+ </tr>\r
2507+ <tr><td></td><td></td></tr>\r
2508+ <tr bgcolor='#a9b7cb'>\r
2509+ <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
2510+ <td>&nbsp;</td></tr>\r
2511+ </tr>\r
2512+\r
2513+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2514+ <tr>\r
2515+ <td valign="top">\r
2516+ <table width="100%" border="0" align="left" valign="top">\r
2517+ <thead>\r
2518+ <tr class="textHeaderDark" bgcolor='#00438C'>\r
2519+ <td align="center"><strong>Host State Information</strong></td>\r
2520+ </tr>\r
2521+ </thead>\r
2522+ <tbody>\r
2523+ <tr>\r
2524+ <td width="100%" valign="top">\r
2525+ <table width="100%" align="center" cellpadding="3">\r
2526+ <thead>\r
2527+ <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
2528+ <td>Parameter</td>\r
2529+ <td>Value</td>\r
2530+ </tr>\r
2531+ </thead>\r
2532+ <tbody>\r
2533+\r
2534+\r
2535+<?php\r
2536+\r
2537+\r
2538+ $host_detail = array(\r
2539+ 'Current Status' => $host_history["soft_state"],\r
2540+ 'State Duration' => formatTime($duration),\r
2541+ 'Check Command' => $host_check["check_command"],\r
2542+ 'Plugin Output' => $host_history["plugin_output"],\r
2543+ 'Performance Data' => $host_check["performance_data"],\r
2544+ 'Current Attempt' => $host_history["current_attempt"],\r
2545+ 'Last Check' => $host_check["last_check"],\r
2546+ 'Next Check' => $host_check["next_check"],\r
2547+ 'Check Latency' => $host_check["check_latency"],\r
2548+ 'Check Duration' => $host_check["check_execute_time"],\r
2549+ 'flapping' => $host_flapping["flapping"],\r
2550+ 'Event Handler' => $host_config["event_handler"],\r
2551+ );\r
2552+\r
2553+ foreach ($host_detail as $key => $value) {\r
2554+\r
2555+\r
2556+ switch($key) \r
2557+ {\r
2558+ case "Current Status":\r
2559+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2560+ echo "<td>" . $key . ":</td>";\r
2561+ switch($value)\r
2562+ {\r
2563+ case "-1":\r
2564+ echo "<td class='statusPENDING'><strong>PENDING</strong></td>";\r
2565+ break;\r
2566+ case "0":\r
2567+ echo "<td class='statusHOSTUP'><strong>UP</strong></td>";\r
2568+ break;\r
2569+ case "1":\r
2570+ echo "<td class='statusHOSTDOWN'><strong>DOWN</strong></td>";\r
2571+ break;\r
2572+ case "2":\r
2573+ echo "<td class='statusHOSTUNREACHABLE'><strong>UNREACHABLE</strong></td>";\r
2574+ break;\r
2575+ }\r
2576+ echo "</tr>";\r
2577+ break;\r
2578+ case "State Duration":\r
2579+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2580+ echo "<td>" . $key . ":</td>";\r
2581+ echo "<td>" . $value . "</td>";\r
2582+ echo "</tr>";\r
2583+ break;\r
2584+ case "Check Command":\r
2585+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2586+ echo "<td>" . $key . ":</td>";\r
2587+ echo "<td>" . $value . "</td>";\r
2588+ echo "</tr>";\r
2589+ break;\r
2590+ case "Plugin Output":\r
2591+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2592+ echo "<td>" . $key . ":</td>";\r
2593+ echo "<td>" . $value . "</td>";\r
2594+ echo "</tr>";\r
2595+ break;\r
2596+ case "Performance Data":\r
2597+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2598+ echo "<td>" . $key . ":</td>";\r
2599+ echo "<td>" . $value . "</td>";\r
2600+ echo "</tr>";\r
2601+ break;\r
2602+ case "Current Attempt":\r
2603+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2604+ echo "<td>" . $key . ":</td>";\r
2605+ echo "<td>" . $value . "/" . $host_check["max_attempts"] . "</td>";\r
2606+ echo "</tr>";\r
2607+ break;\r
2608+ case "Last Check":\r
2609+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2610+ echo "<td>" . $key . ":</td>";\r
2611+ if (preg_match('/1969-12-31/', $value)) {\r
2612+ echo "<td>N/A</td>";\r
2613+ } else {\r
2614+ echo "<td>" . $value . "</td>";\r
2615+ }\r
2616+ echo "</tr>";\r
2617+ break;\r
2618+ case "Next Check":\r
2619+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2620+ echo "<td>" . $key . ":</td>";\r
2621+ if (preg_match('/1969-12-31/', $value)) {\r
2622+ echo "<td>N/A</td>";\r
2623+ } else {\r
2624+ echo "<td>" . $value . "</td>";\r
2625+ }\r
2626+ echo "</tr>";\r
2627+ break;\r
2628+ case "Check Latency":\r
2629+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2630+ echo "<td>" . $key . ":</td>";\r
2631+ echo "<td>" . $value . "</td>";\r
2632+ echo "</tr>";\r
2633+ break;\r
2634+ case "Check Duration":\r
2635+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2636+ echo "<td>" . $key . ":</td>";\r
2637+ echo "<td>" . $value . "</td>";\r
2638+ echo "</tr>";\r
2639+ break;\r
2640+ case "flapping":\r
2641+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2642+ echo "<td>Flapping:</td>";\r
2643+ if ($host_detail["flapping"]) {\r
2644+ echo "<td>Yes</td>";\r
2645+ } else {\r
2646+ echo "<td>No</td>";\r
2647+ }\r
2648+ echo "</tr>";\r
2649+ break;\r
2650+ case "Event Handler":\r
2651+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2652+ echo "<td>" . $key . ":</td>";\r
2653+ if (!$value) {\r
2654+ echo "<td>N/A</td>";\r
2655+ } else {\r
2656+ echo "<td>" . $value . "</td>";\r
2657+ }\r
2658+ echo "</tr>";\r
2659+ break;\r
2660+ }\r
2661+\r
2662+ if($rowColor == $background1) {\r
2663+ $rowColor = $background2;\r
2664+ } else {\r
2665+ $rowColor = $background1;\r
2666+ }\r
2667+\r
2668+ }\r
2669+\r
2670+\r
2671+?>\r
2672+\r
2673+ </tbody>\r
2674+ </table>\r
2675+\r
2676+ </td>\r
2677+ </tr>\r
2678+ </tbody>\r
2679+ </table>\r
2680+\r
2681+ </td>\r
2682+\r
2683+ <td valign="top">\r
2684+ <table width="70%" border="0" align="right">\r
2685+ <thead>\r
2686+ <tr class="textHeaderDark" bgcolor='#00438C'>\r
2687+ <td align="center"><strong>Host Monitoring Options</strong></td>\r
2688+ </tr>\r
2689+ </thead>\r
2690+ <tbody>\r
2691+ <tr>\r
2692+ <td width="70%" valign="top">\r
2693+ <table width="100%" align="center" cellpadding="3">\r
2694+ <thead>\r
2695+ <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
2696+ <td>Parameter</td>\r
2697+ <td>Value</td>\r
2698+ </tr>\r
2699+ </thead>\r
2700+ <tbody>\r
2701+\r
2702+<?php\r
2703+ $rowColor = $background1;\r
2704+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2705+\r
2706+\r
2707+ foreach ($host_config as $key => $value) {\r
2708+\r
2709+ if ($key == "event_handler") { continue; }\r
2710+ if ($key == "cacti_graph_id") { continue; }\r
2711+\r
2712+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2713+\r
2714+ switch($key)\r
2715+ {\r
2716+ case "active_checks_enabled":\r
2717+ echo "<td>Active Checks:</td>";\r
2718+ break;\r
2719+ case "passive_checks_enabled":\r
2720+ echo "<td>Passive Checks:</td>";\r
2721+ break;\r
2722+ case "event_handler_enabled":\r
2723+ echo "<td>Event Handler:</td>";\r
2724+ break;\r
2725+ case "flap_detection_enabled":\r
2726+ echo "<td>Flap Detection:</td>";\r
2727+ break;\r
2728+ case "notifications_enabled":\r
2729+ echo "<td>Notifications:</td>";\r
2730+ break;\r
2731+ case "failure_prediction_enabled":\r
2732+ echo "<td>Failure Prediction:</td>";\r
2733+ break;\r
2734+ case "process_performance_data":\r
2735+ echo "<td>Process Performance Data:</td>";\r
2736+ break;\r
2737+ case "obsess_over_host":\r
2738+ echo "<td>Obsess Over Host:</td>";\r
2739+ break;\r
2740+ }\r
2741+\r
2742+ if ($value == 0) {\r
2743+ echo "<td class='optionDISABLED'>Disabled</td></tr>";\r
2744+ } else {\r
2745+ echo "<td class='optionENABLED'>Enabled</td></tr>";\r
2746+ }\r
2747+\r
2748+ if($rowColor == $background1) {\r
2749+ $rowColor = $background2;\r
2750+ } else {\r
2751+ $rowColor = $background1;\r
2752+ }\r
2753+\r
2754+\r
2755+ }\r
2756+\r
2757+?>\r
2758+ </tbody>\r
2759+ </table>\r
2760+ </td>\r
2761+ </tr>\r
2762+ </table>\r
2763+\r
2764+ </td>\r
2765+\r
2766+\r
2767+\r
2768+<?php\r
2769+\r
2770+\r
2771+\r
2772+\r
2773+ echo "</tr>";\r
2774+ echo "<tr>";\r
2775+\r
2776+?>\r
2777+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2778+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2779+ <td valign="top" colspan='2'>\r
2780+ <table width="60%" border="0" align="center">\r
2781+ <thead>\r
2782+ <tr class="textHeaderDark" bgcolor='#00438C'>\r
2783+ <td align="center"><strong>Host Comments</strong></td>\r
2784+ </tr>\r
2785+ </thead>\r
2786+ <tbody>\r
2787+ <tr>\r
2788+ <td width="60%" valign="top">\r
2789+ <table width="100%" align="center" cellpadding="3">\r
2790+ <thead>\r
2791+ <tr align="center" class="textSubHeaderDark" bgcolor='#6d88ad'>\r
2792+ <td>Entry Time</td>\r
2793+ <td>Author</td>\r
2794+ <td>Comment</td>\r
2795+ <td>Persistent</td>\r
2796+ <td>Type</td>\r
2797+ <td>Delete</td>\r
2798+ <tbody>\r
2799+<?php\r
2800+ for($i = 0; $i < $row_count; $i++) {\r
2801+ \r
2802+ echo "<tr bgcolor='" . $rowColor . "'>";\r
2803+ echo "<td nowrap>" . $comments[$i]["timestamp"] . "</td>";\r
2804+ echo "<td>" . $comments[$i]["author"] . "</td>";\r
2805+ echo "<td>" . $comments[$i]["comment"] . "</td>";\r
2806+ echo "<td>";\r
2807+ if ($comments[$i]["persist"]) {\r
2808+ echo "Yes";\r
2809+ } else {\r
2810+ echo "No"; \r
2811+ }\r
2812+ echo "</td>";\r
2813+ echo "<td>";\r
2814+ if ($comments[$i]["type"] == 1) {\r
2815+ echo "Comment";\r
2816+ } elseif ($comments[$i]["type"] == 3) {\r
2817+ echo "Acknowledgment";\r
2818+ }\r
2819+ echo "</td>";\r
2820+ echo "<td>";\r
2821+ if ($comments[$i]["type"] == 1) {\r
2822+ 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
2823+ } elseif ($comments[$i]["type"] == 3) {\r
2824+ 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
2825+ }\r
2826+ echo "</td>";\r
2827+\r
2828+\r
2829+ if($rowColor == $background1) {\r
2830+ $rowColor = $background2;\r
2831+ } else {\r
2832+ $rowColor = $background1;\r
2833+ }\r
2834+ }\r
2835+\r
2836+\r
2837+\r
2838+\r
2839+\r
2840+\r
2841+\r
2842+?>\r
2843+ </tbody>\r
2844+ </table>\r
2845+ </td>\r
2846+ </tr>\r
2847+ <tr>\r
2848+ <td>\r
2849+ <?php \r
2850+ 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
2851+ 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
2852+ ?>\r
2853+ </td>\r
2854+ </tr>\r
2855+ </tbody>\r
2856+ </table>\r
2857+ </td>\r
2858+ <td></td>\r
2859+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2860+ <tr><td>&nbsp;</td><td>&nbsp;</td></tr>\r
2861+ <tr>\r
2862+\r
2863+\r
2864+\r
2865+\r
2866+\r
2867+ <td valign="top" colspan='2'>\r
2868+ <table width="60%" border="0" align="center">\r
2869+ <thead>\r
2870+ <tr align="center" class="textHeaderDark" bgcolor='#00438C'>\r
2871+ <td align="center"><strong>Graph Mapping</strong></td>\r
2872+ </tr>\r
2873+ </thead>\r
2874+ <tbody>\r
2875+ <tr>\r
2876+ <td width="60%" valign="top">\r
2877+ <table width="100%" align="center" cellpadding="3">\r
2878+ <tbody>\r
2879+\r
2880+<?php\r
2881+\r
2882+$cacti_graphs = db_fetch_assoc("\r
2883+select\r
2884+ graph_templates_graph.id,\r
2885+ graph_templates_graph.local_graph_id,\r
2886+ graph_templates_graph.height,\r
2887+ graph_templates_graph.width,\r
2888+ graph_templates_graph.title_cache as title,\r
2889+ graph_templates.name,\r
2890+ graph_local.host_id\r
2891+ from graph_local,graph_templates_graph\r
2892+ left join graph_templates on graph_template_id=graph_templates.id\r
2893+ where graph_local.id=graph_templates_graph.local_graph_id\r
2894+ and graph_templates_graph.title_cache like '%'\r
2895+ order by graph_templates_graph.title_cache,graph_local.host_id");\r
2896+\r
2897+ $row_count = count($cacti_graphs);\r
2898+/* http://logindev/cacti/graph_image.php?local_graph_id=6&rra_id=0 */\r
2899+?>\r
2900+\r
2901+ <FORM NAME="gm" ACTION="" method="post">\r
2902+ <tr bgcolor='<?php echo $background1; ?>'>\r
2903+ <td>Associated graph:</td>\r
2904+ <td>\r
2905+ <select name="local_graph_id" size="1">\r
2906+ <?php\r
2907+ echo "<OPTION VALUE='NULL'>None</option>";\r
2908+ for($i = 0; $i < $row_count; $i++) {\r
2909+ echo "<OPTION VALUE='" . $cacti_graphs[$i]["local_graph_id"] . "'>" . $cacti_graphs[$i]["title"] . "</option>";\r
2910+ }\r
2911+ ?> \r
2912+\r
2913+\r
2914+ </select>\r
2915+ </td>\r
2916+ <td><INPUT TYPE="submit" VALUE="Map"></td>\r
2917+ </tr>\r
2918+ </FORM>\r
2919+\r
2920+\r
2921+ </tbody>\r
2922+ </table>\r
2923+ <?php \r
2924+ if ($host_config["cacti_graph_id"]) {\r
2925+ echo "<table align='center'>";\r
2926+ echo "<tr><td width='100%'>";\r
2927+ echo "<img src='../../graph_image.php?local_graph_id=" . $host_config["cacti_graph_id"] . "&rra_id=0'>";\r
2928+ echo "</td></tr>";\r
2929+ }\r
2930+ ?>\r
2931+ </td>\r
2932+ </tr>\r
2933+ </tbody>\r
2934+ </table>\r
2935+\r
2936+ </td>\r
2937+\r
2938+ </tr>\r
2939+ </table>\r
2940+\r
2941+<?php\r
2942+\r
2943+\r
2944+}\r
2945+\r
2946+\r
2947+\r
2948+\r
2949+?>\r
This page took 0.552036 seconds and 4 git commands to generate.