1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
|
<packagegui>
|
3
|
<name>zabbixagent</name>
|
4
|
<title>Services: Zabbix Agent</title>
|
5
|
<category>Monitoring</category>
|
6
|
<version>1.0</version>
|
7
|
<addedit_string>Zabbix Agent has been created/modified.</addedit_string>
|
8
|
<delete_string>Zabbix Agent has been deleted.</delete_string>
|
9
|
<restart_command>/usr/local/etc/rc.d/zabbix_agentd.sh restart</restart_command>
|
10
|
<menu>
|
11
|
<name>Zabbix Agent</name>
|
12
|
<tooltiptext>Setup Zabbix Agent specific settings</tooltiptext>
|
13
|
<section>Services</section>
|
14
|
<url>/pkg_edit.php?xml=zabbix-agent.xml&id=0</url>
|
15
|
</menu>
|
16
|
<service>
|
17
|
<name>zabbix-agent</name>
|
18
|
<rcfile>zabbix-agentd.sh</rcfile>
|
19
|
<executable>zabbix_agentd</executable>
|
20
|
</service>
|
21
|
<tabs>
|
22
|
<tab>
|
23
|
<text>Settings</text>
|
24
|
<url>/pkg_edit.php?xml=zabbix-agent.xml&id=0</url>
|
25
|
<active />
|
26
|
</tab>
|
27
|
</tabs>
|
28
|
<fields>
|
29
|
<field>
|
30
|
<fielddescr>Server</fielddescr>
|
31
|
<fieldname>server</fieldname>
|
32
|
<description>List of comma delimited IP addresses (or hostnames) of ZABBIX servers</description>
|
33
|
<value>127.0.0.1</value>
|
34
|
<type>input</type>
|
35
|
<size>60</size>
|
36
|
<required>true</required>
|
37
|
</field>
|
38
|
<field>
|
39
|
<fielddescr>Server Port</fielddescr>
|
40
|
<fieldname>serverport</fieldname>
|
41
|
<description>Server port for sending active check (generally 10051)</description>
|
42
|
<value>10051</value>
|
43
|
<type>input</type>
|
44
|
<size>60</size>
|
45
|
<required>true</required>
|
46
|
</field>
|
47
|
<field>
|
48
|
<fielddescr>Hostname</fielddescr>
|
49
|
<fieldname>hostname</fieldname>
|
50
|
<description>Unique hostname. Required for active checks.</description>
|
51
|
<value>localhost</value>
|
52
|
<type>input</type>
|
53
|
<size>60</size>
|
54
|
<required>true</required>
|
55
|
</field>
|
56
|
<field>
|
57
|
<fielddescr>Listen Port</fielddescr>
|
58
|
<fieldname>listenport</fieldname>
|
59
|
<value>10050</value>
|
60
|
<type>input</type>
|
61
|
<size>60</size>
|
62
|
<required>true</required>
|
63
|
<description>Listen port for sending active check (generally 10050)</description>
|
64
|
</field>
|
65
|
<field>
|
66
|
<fielddescr>Refresh Active Checks</fielddescr>
|
67
|
<fieldname>refreshactchecks</fieldname>
|
68
|
<value>120</value>
|
69
|
<type>input</type>
|
70
|
<size>60</size>
|
71
|
<required>false</required>
|
72
|
<description>The agent will refresh list of active checks once per 120 (default) seconds.</description>
|
73
|
</field>
|
74
|
<field>
|
75
|
<fielddescr>Timeout</fielddescr>
|
76
|
<fieldname>timeout</fieldname>
|
77
|
<value>3</value>
|
78
|
<type>input</type>
|
79
|
<size>60</size>
|
80
|
<required>true</required>
|
81
|
<description>Timeout (default 3). Do not spend more that Timeout seconds on getting requested value (1-255). The agent does not kill timeouted User Parameters processes!</description>
|
82
|
</field>
|
83
|
<field>
|
84
|
<fielddescr>User Parameters</fielddescr>
|
85
|
<fieldname>userparams</fieldname>
|
86
|
<value></value>
|
87
|
<type>textarea</type>
|
88
|
<rows>5</rows>
|
89
|
<cols>50</cols>
|
90
|
<required>false</required>
|
91
|
<description>User-defined parameter to monitor. There can be several user-defined parameters. Value has form, example: UserParameter=users,who|wc -l</description>
|
92
|
</field>
|
93
|
</fields>
|
94
|
<custom_php_install_command>
|
95
|
<![CDATA[
|
96
|
global $config, $g;
|
97
|
|
98
|
mwexec("mkdir -p /var/log/zabbix/");
|
99
|
mwexec("mkdir -p /var/run/zabbix/");
|
100
|
|
101
|
conf_mount_rw();
|
102
|
|
103
|
/* create a few directories and ensure the sample files are in place */
|
104
|
exec("/bin/mkdir -p /usr/local/etc/zabbix");
|
105
|
exec("/bin/mkdir -p /var/log/zabbix");
|
106
|
exec("/bin/mkdir -p /var/run/zabbix");
|
107
|
|
108
|
exec("/bin/rm -f /usr/local/etc/rc.d/zabbix_agentd");
|
109
|
|
110
|
$start = "/bin/mkdir -p /var/log/zabbix\n";
|
111
|
$start .= "/usr/sbin/chown -R zabbix:zabbix /var/log/zabbix\n";
|
112
|
|
113
|
$start .= "/bin/mkdir -p /var/run/zabbix\n";
|
114
|
$start .= "/usr/sbin/chown -R zabbix:zabbix /var/run/zabbix\n";
|
115
|
|
116
|
$start .= "echo \"Starting Zabbix Agent\"...\n";
|
117
|
|
118
|
/* start zabbix agent */
|
119
|
$start .= "/usr/local/bin/zabbix_agentd\n";
|
120
|
|
121
|
$stop = "echo \"Stopping Zabbix Agent\"\n";
|
122
|
$stop .= "/usr/bin/killall zabbix_agentd\n";
|
123
|
/* write out rc.d start/stop file */
|
124
|
write_rcfile(array(
|
125
|
"file" => "zabbix_agentd.sh",
|
126
|
"start" => "{$start}",
|
127
|
"restart" => "$stop\n" . "sleep 5\n" . "{$start}",
|
128
|
"stop" => "$stop"
|
129
|
)
|
130
|
);
|
131
|
|
132
|
conf_mount_ro();
|
133
|
]]>
|
134
|
</custom_php_install_command>
|
135
|
<custom_php_command_before_form></custom_php_command_before_form>
|
136
|
<custom_php_after_head_command></custom_php_after_head_command>
|
137
|
<custom_php_after_form_command></custom_php_after_form_command>
|
138
|
<custom_php_validation_command>
|
139
|
<![CDATA[
|
140
|
global $_POST;
|
141
|
|
142
|
$ListenPort=$_POST['listenport'];
|
143
|
if (!preg_match("/^\d+$/", $ListenPort)) {
|
144
|
$input_errors[]='Listen Port is not numeric.';
|
145
|
}
|
146
|
|
147
|
$ServerPort=$_POST['serverport'];
|
148
|
if (!preg_match("/^\d+$/", $ServerPort)) {
|
149
|
$input_errors[]='Server Port is not numeric.';
|
150
|
}
|
151
|
|
152
|
$RefreshActiveChecks=$_POST['refreshactchecks'];
|
153
|
if (!preg_match("/^\d+$/", $RefreshActiveChecks)) {
|
154
|
$input_errors[]='Refresh Active Checks is not numeric.';
|
155
|
}
|
156
|
|
157
|
$Timeout=$_POST['timeout'];
|
158
|
if (!preg_match("/^\d+$/", $Timeout)) {
|
159
|
$input_errors[]='Timeout is not numeric.';
|
160
|
}
|
161
|
]]>
|
162
|
</custom_php_validation_command>
|
163
|
<custom_add_php_command></custom_add_php_command>
|
164
|
<custom_php_resync_config_command>
|
165
|
<![CDATA[
|
166
|
conf_mount_rw();
|
167
|
global $config;
|
168
|
global $g;
|
169
|
|
170
|
$Server=$config['installedpackages']['zabbixagent']['config'][0]['server'];
|
171
|
$ServerPort=$config['installedpackages']['zabbixagent']['config'][0]['serverport'];
|
172
|
$Hostname=$config['installedpackages']['zabbixagent']['config'][0]['hostname'];
|
173
|
$ListenPort=$config['installedpackages']['zabbixagent']['config'][0]['listenport'];
|
174
|
$RefreshActChecks=$config['installedpackages']['zabbixagent']['config'][0]['refreshactchecks'];
|
175
|
$Timeout=$config['installedpackages']['zabbixagent']['config'][0]['timeout'];
|
176
|
$UserParams=$config['installedpackages']['zabbixagent']['config'][0]['userparams'];
|
177
|
|
178
|
$conf = "Server=$Server\n";
|
179
|
$conf .= "ServerPort=$ServerPort\n";
|
180
|
$conf .= "Hostname=$Hostname\n";
|
181
|
$conf .= "ListenIP=0.0.0.0\n";
|
182
|
$conf .= "ListenPort=$ListenPort\n";
|
183
|
$conf .= "StartAgents=5\n";
|
184
|
$conf .= "RefreshActiveChecks=$RefreshActChecks\n";
|
185
|
$conf .= "DebugLevel=3\n";
|
186
|
$conf .= "PidFile=/var/run/zabbix/zabbix_agentd.pid\n";
|
187
|
$conf .= "LogFile=/var/log/zabbix/zabbix_agentd.log\n";
|
188
|
$conf .= "LogFileSize=1\n";
|
189
|
$conf .= "Timeout=$Timeout\n";
|
190
|
$conf .= "$UserParams\n";
|
191
|
|
192
|
file_put_contents("/usr/local/etc/zabbix/zabbix_agentd.conf", $conf);
|
193
|
conf_mount_ro();
|
194
|
|
195
|
]]>
|
196
|
</custom_php_resync_config_command>
|
197
|
<custom_php_deinstall_command>
|
198
|
<![CDATA[
|
199
|
exec("/usr/bin/killall zabbix_agentd");
|
200
|
|
201
|
exec("/bin/rm /usr/local/etc/rc.d/zabbix_agentd.sh");
|
202
|
|
203
|
exec("/bin/rm -r /var/log/zabbix/");
|
204
|
exec("/bin/rm -r /var/run/zabbix/");
|
205
|
]]>
|
206
|
</custom_php_deinstall_command>
|
207
|
</packagegui>
|
208
|
|