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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
<?
include "include/config.inc.php";
$page["title"] = "Hosts";
$page["file"] = "hosts.php";
show_header($page["title"],0,0);
?>
<?
if(!check_right("Host","R",0))
{
show_table_header("<font color=\"AA0000\">No permissions !</font
>");
show_footer();
exit;
}
?>
<?
if(isset($register))
{
if($register=="add")
{
$result=add_host($host,$port,$status,$template,$useip,$ip,$host_templateid);
show_messages($result,"Host added","Cannot add host");
}
if($register=="update")
{
$result=update_host($hostid,$host,$port,$status,$useip,$ip);
show_messages($result,"Host details updated","Cannot update host details");
}
if($register=="changestatus")
{
$result=update_host_status($hostid,$status);
show_messages($result,"Host status updated","Cannot update host status");
}
if($register=="delete")
{
$result=delete_host($hostid);
show_messages($result,"Host deleted","Cannot delete host");
unset($hostid);
}
}
?>
<?
show_table_header("CONFIGURATION OF HOSTS");
?>
<?
echo "<TABLE BORDER=0 COLS=4 WIDTH=\"100%\" BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
echo "<TR>";
echo "<TD WIDTH=\"3%\" NOSAVE><B>Id</B></TD>";
echo "<TD WIDTH=\"10%\" NOSAVE><B>Host</B></TD>";
echo "<TD WIDTH=\"10%\" NOSAVE><B>Port</B></TD>";
echo "<TD WIDTH=\"10%\" NOSAVE><B>Status</B></TD>";
echo "<TD WIDTH=\"10%\" NOSAVE><B>Actions</B></TD>";
echo "</TR>";
$result=DBselect("select h.hostid,h.host,h.port,h.status from hosts h order by h.host");
echo "<CENTER>";
$col=0;
while($row=DBfetch($result))
// for($i=0;$i<DBnum_rows($result);$i++)
{
if(!check_right("Host","R",$row["hostid"]))
{
continue;
}
if($col++%2==0) { echo "<TR BGCOLOR=#EEEEEE>"; }
else { echo "<TR BGCOLOR=#DDDDDD>"; }
echo "<TD>".$row["hostid"]."</TD>";
echo "<TD><a href=\"items.php?hostid=".$row["hostid"]."\">".$row["host"]."</a></TD>";
echo "<TD>".$row["port"]."</TD>";
echo "<TD>";
if(check_right("Host","U",$row["hostid"]))
{
if($row["status"] == 0)
echo "<a href=\"hosts.php?hostid=".$row["hostid"]."®ister=changestatus&status=1\">Monitored</a>";
else if($row["status"] == 1)
echo "<a href=\"hosts.php?hostid=".$row["hostid"]."®ister=changestatus&status=0\">Not monitored</a>";
else if($row["status"] == 2)
echo "Unreachable";
else
echo "Unknown";
}
else
{
if($row["status"] == 0)
echo "Monitored";
else if($row["status"] == 1)
echo "Not monitored";
else if($row["status"] == 2)
echo "Unreachable";
else
echo "Unknown";
}
echo "</TD>";
if(check_right("Host","U",$row["hostid"]))
{
echo "<TD><A HREF=\"hosts.php?register=change&hostid=".$row["hostid"]."#form\">Change</A></TD>";
}
else
{
echo "<TD>Change</TD>";
}
echo "</TR>";
}
echo "</TABLE>";
?>
<?
if(isset($register) && ($register == "change"))
{
$result=DBselect("select host,port,status,useip,ip from hosts where hostid=$hostid");
$host=DBget_field($result,0,0);
$port=DBget_field($result,0,1);
$status=DBget_field($result,0,2);
$useip=DBget_field($result,0,3);
$ip=DBget_field($result,0,4);
if($useip==0)
{
$useip="";
}
else
{
$useip="checked";
}
}
else
{
$host="";
$port=10000;
$status=0;
$useip="";
$ip="";
}
echo "<br>";
echo "<a name=\"form\"></a>";
show_table2_header_begin();
echo "Host details";
show_table2_v_delimiter();
echo "<form method=\"post\" action=\"hosts.php\">";
if(isset($hostid))
{
echo "<input name=\"hostid\" type=\"hidden\" value=$hostid>";
}
echo "Host";
show_table2_h_delimiter();
echo "<input name=\"host\" value=\"$host\" size=20>";
show_table2_v_delimiter();
echo "Use IP address";
show_table2_h_delimiter();
echo "<INPUT TYPE=\"CHECKBOX\" NAME=\"useip\" $useip>";
show_table2_v_delimiter();
echo "IP address";
show_table2_h_delimiter();
echo "<input name=\"ip\" value=\"$ip\" size=15>";
show_table2_v_delimiter();
echo "Port";
show_table2_h_delimiter();
echo "<input name=\"port\" size=5 value=\"$port\">";
show_table2_v_delimiter();
echo "Status";
show_table2_h_delimiter();
echo "<select name=\"status\" size=\"1\">";
if($status==0)
{
echo "<option value=\"0\" selected>Monitored";
echo "<option value=\"1\">Not monitored";
}
else
{
echo "<option value=\"0\">Monitored";
echo "<option value=\"1\" selected>Not monitored";
}
echo "</select>";
show_table2_v_delimiter();
echo "Add parameters supported by zabbix_agent";
show_table2_h_delimiter();
echo "<INPUT NAME=\"template\" TYPE=\"CHECKBOX\" VALUE=\"true\" CHECKED>";
show_table2_v_delimiter();
echo "Use the host as a template";
show_table2_h_delimiter();
echo "<select name=\"host_templateid\" size=\"1\">";
echo "<option value=\"0\" selected>...";
$result=DBselect("select host,hostid from hosts order by host");
while($row=DBfetch($result))
{
echo "<option value=\"".$row["hostid"]."\">".$row["host"];
}
echo "</select>";
show_table2_v_delimiter2();
echo "<input type=\"submit\" name=\"register\" value=\"add\">";
if(isset($hostid))
{
echo "<input type=\"submit\" name=\"register\" value=\"update\">";
echo "<input type=\"submit\" name=\"register\" value=\"delete\">";
}
show_table2_header_end();
?>
<?
show_footer();
?>
|