summaryrefslogtreecommitdiffstats
path: root/frontends/php/hosts.html
blob: 0e3ab7e133a7e7c5aaac10983f383be0aef1ffd4 (plain)
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
<?
	include "include/config.inc";
	$page["title"] = "Hosts";
	$page["file"] = "hosts.html";
	show_header($page["title"],0,0);
?>

<?
	show_table_header("CONFIGURATION OF HOSTS");
	echo "<br>";
?>

<?
	if(isset($register))
	{
		if($register=="add")
		{
			add_host($host,$port,$status,$template,$useip,$ip);
		}
		if($register=="changestatus")
		{
			update_host_status($hostid,$status);
		}
		if($register=="delete")
		{
			delete_host($hostid);
			unset($hostid);
		}
	}
?>

<?
	show_table_header("HOSTS");
	echo "<TABLE BORDER=0 COLS=4 WIDTH=\"100%\" BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
	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;
	for($i=0;$i<DBnum_rows($result);$i++)
	{
		if($col==1)
		{
			echo "<TR BGCOLOR=#EEEEEE>";
			$col=0;
		} else
		{
			echo "<TR BGCOLOR=#DDDDDD>";
			$col=1;
		}
	
		$hostid=DBget_field($result,$i,0);
		$host=DBget_field($result,$i,1);
		$port=DBget_field($result,$i,2);
		$status=DBget_field($result,$i,3);
		echo "<TD><a href=\"items.html?hostid=$hostid\">$host</a></TD>";
		echo "<TD>$port</TD>";
		echo "<TD>";
		if($status == 0)	
			echo "<a href=\"hosts.html?hostid=$hostid&register=changestatus&status=1\">Monitored</a>";
		else if($status == 1)
			echo "<a href=\"hosts.html?hostid=$hostid&register=changestatus&status=0\">Not monitored</a>";
		else
			echo "Unknown";
		echo "</TD>";
		echo "<TD><A HREF=\"hosts.html?register=delete&hostid=$hostid\">Delete</A></TD>";
		echo "</TR>";
	}
	echo "</TABLE>";
?>

<?
	echo "<br>";
	show_table2_header_begin();
	echo "New host";

	show_table2_v_delimiter();
	echo "<form method=\"post\" action=\"hosts.html\">";
	echo "Host";
	show_table2_h_delimiter();
	echo "<input name=\"host\" size=20>";

	show_table2_v_delimiter();
	echo "Use IP address";
	show_table2_h_delimiter();
	echo "<INPUT TYPE=\"CHECKBOX\"";
	echo " NAME=\"useip\"  VALUE=\"true\">";

	show_table2_v_delimiter();
	echo "IP address";
	show_table2_h_delimiter();
	echo "<input name=\"ip\" size=15>";

	show_table2_v_delimiter();
	echo "Port";
	show_table2_h_delimiter();
	echo "<input name=\"port\" size=5 value=\"10000\">";

	show_table2_v_delimiter();
	echo "Status";
	show_table2_h_delimiter();
	echo "<select name=\"status\" size=\"1\">";
	echo "<option value=\"0\" \"selected\">Monitored";
	echo "<option value=\"1\">Not monitored";
	echo "</select>";

	show_table2_v_delimiter();
	echo "Add parameters supported by zabbix_agent";
	show_table2_h_delimiter();
	echo "<INPUT TYPE=\"CHECKBOX\" CHECKED ";
	echo " NAME=\"template\"  VALUE=\"true\">";

	show_table2_v_delimiter2();
	echo "<input type=\"submit\" name=\"register\" value=\"add\">";

	show_table2_header_end();
?>

<?
	show_footer();
?>