File: services.php

package info (click to toggle)
nagat 1.0a2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 312 kB
  • ctags: 377
  • sloc: php: 2,604; sh: 78; makefile: 42
file content (120 lines) | stat: -rw-r--r-- 2,854 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
# $Id: services.php,v 1.8 2002/06/16 08:44:55 kemuri Exp $

/*
 * Copyright (c) 2002 Ypsilon.Net AG, Germany
 *
 * This file is part of Nagat.
 * 
 * Nagat is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * Nagat is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Nagat; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

# Page variables
define("PAGE_ID","services");
define("PAGE_TITLE","Services");
define("OBJECTTYPE","service");

require_once("local.inc");
include_once(NGT_LIB."head.inc");

$alter = '';
$rows = array();
$errmsg = '';
$message = '';
$objects = PluginGetObjects(OBJECTTYPE);

if( isset($objects) ) {
	uasort($objects,"NagiosUasortObjectService");
	foreach($objects as $key => $object) {

		$alter = ($alter != "alter1") ? "alter1" : "alter2";

		$name = !empty($object[OBJECTTYPE.'_description']) 
			? $object[OBJECTTYPE.'_description'] : $object['name'];

		# Is this a inheritable object?
		if( !empty($object['name']) ) {
			$cntinh = NagiosCountInherited(OBJECTTYPE,$name);
			if( $cntinh != 0 ) {
				$inheritance = 'used by '.$cntinh.' objects';
			} else {
			}
		} else if( !empty($object['use']) ) {
			$inheritance = 'uses '.$object['use'];
		} else {
			$inheritance = '';
		}

		if( !empty($object['host_name']) ) {
			$hosts = $object['host_name'];
		} else {
			$hosts = '';
		}
		
		if( isset($object['register']) && $object['register'] == 0) {
			$registered = 'no';
		} else {
			$registered = '';
		}

		$rows[] = <<<HTML
<tr class="$alter">
  <td><a href="serviceedit.php?objectid={$key}">Edit</a></td>
  <td>{$name}</td>
  <td>{$hosts}</td>
  <td>{$inheritance}</td>
  <td align="center">$registered</td>
</tr>
HTML;

        } # foreach
} else {
        $message = "No '".OBJECTTYPE."'-objects found.";
}


?>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
  <td colspan="6" align="left">
  <b><?=ErrorMsg($errmsg)?>
  <?=$message?>&nbsp;</b>
  </td>
</tr>
<tr>
  <td colspan="6">
  <form action="serviceedit.php">
  <input type="submit" value="New">
  </form>
  </td>
</tr>
<tr class="rowsep">
  <td>&nbsp;</td>
  <td>Name</td>
  <td>Host</td>
  <td>Inheritance</td>
  <td>Registered</td>
</tr>
<?=implode("\n",$rows)?>
</table>

<?
# Beautification
if( !is_array($objects) ) {
        print "<br><br><br><br><br><br><br><br>";
}
include_once(NGT_LIB."tail.inc");
?>