1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
services_snmp.php
|
5
|
part of m0n0wall (http://m0n0.ch/wall)
|
6
|
|
7
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
|
32
|
require("guiconfig.inc");
|
33
|
|
34
|
if (!is_array($config['snmpd'])) {
|
35
|
$config['snmpd'] = array();
|
36
|
$config['snmpd']['rocommunity'] = "public";
|
37
|
$config['snmpd']['pollport'] = "161";
|
38
|
}
|
39
|
|
40
|
if (!is_array($config['snmpd']['modules'])) {
|
41
|
$config['snmpd']['modules'] = array();
|
42
|
$config['snmpd']['modules']['mibii'] = true;
|
43
|
$config['snmpd']['modules']['netgraph'] = true;
|
44
|
$config['snmpd']['modules']['pf'] = true;
|
45
|
$config['snmpd']['modules']['hostres'] = true;
|
46
|
$config['snmpd']['modules']['bridge'] = true;
|
47
|
}
|
48
|
$pconfig['enable'] = isset($config['snmpd']['enable']);
|
49
|
$pconfig['pollport'] = $config['snmpd']['pollport'];
|
50
|
$pconfig['syslocation'] = $config['snmpd']['syslocation'];
|
51
|
$pconfig['syscontact'] = $config['snmpd']['syscontact'];
|
52
|
$pconfig['rocommunity'] = $config['snmpd']['rocommunity'];
|
53
|
/* disabled until some docs show up on what this does.
|
54
|
$pconfig['rwenable'] = isset($config['snmpd']['rwenable']);
|
55
|
$pconfig['rwcommunity'] = $config['snmpd']['rwcommunity'];
|
56
|
*/
|
57
|
$pconfig['trapenable'] = isset($config['snmpd']['trapenable']);
|
58
|
$pconfig['trapserver'] = $config['snmpd']['trapserver'];
|
59
|
$pconfig['trapserverport'] = $config['snmpd']['trapserverport'];
|
60
|
$pconfig['trapstring'] = $config['snmpd']['trapstring'];
|
61
|
|
62
|
$pconfig['mibii'] = isset($config['snmpd']['modules']['mibii']);
|
63
|
$pconfig['netgraph'] = isset($config['snmpd']['modules']['netgraph']);
|
64
|
$pconfig['pf'] = isset($config['snmpd']['modules']['pf']);
|
65
|
$pconfig['hostres'] = isset($config['snmpd']['modules']['hostres']);
|
66
|
$pconfig['bridge'] = isset($config['snmpd']['modules']['bridge']);
|
67
|
$pconfig['bindlan'] = isset($config['snmpd']['bindlan']);
|
68
|
|
69
|
if ($_POST) {
|
70
|
|
71
|
unset($input_errors);
|
72
|
$pconfig = $_POST;
|
73
|
|
74
|
/* input validation */
|
75
|
if ($_POST['enable']) {
|
76
|
$reqdfields = explode(" ", "rocommunity");
|
77
|
$reqdfieldsn = explode(",", "Community");
|
78
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
79
|
|
80
|
$reqdfields = explode(" ", "pollport");
|
81
|
$reqdfieldsn = explode(",", "Polling Port");
|
82
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
83
|
|
84
|
|
85
|
}
|
86
|
|
87
|
if ($_POST['trapenable']) {
|
88
|
$reqdfields = explode(" ", "trapserver");
|
89
|
$reqdfieldsn = explode(",", "Trap server");
|
90
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
91
|
|
92
|
$reqdfields = explode(" ", "trapserverport");
|
93
|
$reqdfieldsn = explode(",", "Trap server port");
|
94
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
95
|
|
96
|
$reqdfields = explode(" ", "trapstring");
|
97
|
$reqdfieldsn = explode(",", "Trap string");
|
98
|
do_input_validation($_POST, $reqdfields, $reqdfields, $reqdfieldsn, &$input_errors);
|
99
|
}
|
100
|
|
101
|
|
102
|
/* disabled until some docs show up on what this does.
|
103
|
if ($_POST['rwenable']) {
|
104
|
$reqdfields = explode(" ", "rwcommunity");
|
105
|
$reqdfieldsn = explode(",", "Write community string");
|
106
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
107
|
}
|
108
|
*/
|
109
|
|
110
|
|
111
|
|
112
|
if (!$input_errors) {
|
113
|
$config['snmpd']['enable'] = $_POST['enable'] ? true : false;
|
114
|
$config['snmpd']['pollport'] = $_POST['pollport'];
|
115
|
$config['snmpd']['syslocation'] = $_POST['syslocation'];
|
116
|
$config['snmpd']['syscontact'] = $_POST['syscontact'];
|
117
|
$config['snmpd']['rocommunity'] = $_POST['rocommunity'];
|
118
|
/* disabled until some docs show up on what this does.
|
119
|
$config['snmpd']['rwenable'] = $_POST['rwenable'] ? true : false;
|
120
|
$config['snmpd']['rwcommunity'] = $_POST['rwcommunity'];
|
121
|
*/
|
122
|
$config['snmpd']['trapenable'] = $_POST['trapenable'] ? true : false;
|
123
|
$config['snmpd']['trapserver'] = $_POST['trapserver'];
|
124
|
$config['snmpd']['trapserverport'] = $_POST['trapserverport'];
|
125
|
$config['snmpd']['trapstring'] = $_POST['trapstring'];
|
126
|
|
127
|
$config['snmpd']['modules']['mibii'] = $_POST['mibii'] ? true : false;
|
128
|
$config['snmpd']['modules']['netgraph'] = $_POST['netgraph'] ? true : false;
|
129
|
$config['snmpd']['modules']['pf'] = $_POST['pf'] ? true : false;
|
130
|
$config['snmpd']['modules']['hostres'] = $_POST['hostres'] ? true : false;
|
131
|
$config['snmpd']['modules']['bridge'] = $_POST['bridge'] ? true : false;
|
132
|
$config['snmpd']['bindlan'] = $_POST['bindlan'] ? true : false;
|
133
|
|
134
|
write_config();
|
135
|
|
136
|
$retval = 0;
|
137
|
|
138
|
config_lock();
|
139
|
$retval = services_snmpd_configure();
|
140
|
config_unlock();
|
141
|
|
142
|
$savemsg = get_std_save_message($retval);
|
143
|
}
|
144
|
}
|
145
|
|
146
|
$pgtitle = "Services: SNMP";
|
147
|
include("head.inc");
|
148
|
|
149
|
?>
|
150
|
<script language="JavaScript">
|
151
|
<!--
|
152
|
function enable_change(whichone) {
|
153
|
|
154
|
if( whichone.name == "trapenable" )
|
155
|
{
|
156
|
if( whichone.checked == true )
|
157
|
{
|
158
|
document.iform.trapserver.disabled = false;
|
159
|
document.iform.trapserverport.disabled = false;
|
160
|
document.iform.trapstring.disabled = false;
|
161
|
}
|
162
|
else
|
163
|
{
|
164
|
document.iform.trapserver.disabled = true;
|
165
|
document.iform.trapserverport.disabled = true;
|
166
|
document.iform.trapstring.disabled = true;
|
167
|
}
|
168
|
}
|
169
|
|
170
|
/* disabled until some docs show up on what this does.
|
171
|
if( whichone.name == "rwenable" )
|
172
|
{
|
173
|
if( whichone.checked == true )
|
174
|
{
|
175
|
document.iform.rwcommunity.disabled = false;
|
176
|
}
|
177
|
else
|
178
|
{
|
179
|
document.iform.rwcommunity.disabled = true;
|
180
|
}
|
181
|
}
|
182
|
*/
|
183
|
|
184
|
if( document.iform.enable.checked == true )
|
185
|
{
|
186
|
document.iform.pollport.disabled = false;
|
187
|
document.iform.syslocation.disabled = false;
|
188
|
document.iform.syscontact.disabled = false;
|
189
|
document.iform.rocommunity.disabled = false;
|
190
|
document.iform.trapenable.disabled = false;
|
191
|
document.iform.bindlan.disabled = false;
|
192
|
/* disabled until some docs show up on what this does.
|
193
|
document.iform.rwenable.disabled = false;
|
194
|
if( document.iform.rwenable.checked == true )
|
195
|
{
|
196
|
document.iform.rwcommunity.disabled = false;
|
197
|
}
|
198
|
else
|
199
|
{
|
200
|
document.iform.rwcommunity.disabled = true;
|
201
|
}
|
202
|
*/
|
203
|
if( document.iform.trapenable.checked == true )
|
204
|
{
|
205
|
document.iform.trapserver.disabled = false;
|
206
|
document.iform.trapserverport.disabled = false;
|
207
|
document.iform.trapstring.disabled = false;
|
208
|
}
|
209
|
else
|
210
|
{
|
211
|
document.iform.trapserver.disabled = true;
|
212
|
document.iform.trapserverport.disabled = true;
|
213
|
document.iform.trapstring.disabled = true;
|
214
|
}
|
215
|
document.iform.mibii.disabled = false;
|
216
|
document.iform.netgraph.disabled = false;
|
217
|
document.iform.pf.disabled = false;
|
218
|
document.iform.hostres.disabled = false;
|
219
|
document.iform.bridge.disabled = false;
|
220
|
}
|
221
|
else
|
222
|
{
|
223
|
document.iform.pollport.disabled = true;
|
224
|
document.iform.syslocation.disabled = true;
|
225
|
document.iform.syscontact.disabled = true;
|
226
|
document.iform.rocommunity.disabled = true;
|
227
|
/*
|
228
|
document.iform.rwenable.disabled = true;
|
229
|
document.iform.rwcommunity.disabled = true;
|
230
|
*/
|
231
|
document.iform.trapenable.disabled = true;
|
232
|
document.iform.trapserver.disabled = true;
|
233
|
document.iform.trapserverport.disabled = true;
|
234
|
document.iform.trapstring.disabled = true;
|
235
|
|
236
|
document.iform.mibii.disabled = true;
|
237
|
document.iform.netgraph.disabled = true;
|
238
|
document.iform.pf.disabled = true;
|
239
|
document.iform.hostres.disabled = true;
|
240
|
document.iform.bridge.disabled = true;
|
241
|
|
242
|
document.iform.bindlan.disabled = true;
|
243
|
}
|
244
|
}
|
245
|
//-->
|
246
|
</script>
|
247
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
248
|
<?php include("fbegin.inc"); ?>
|
249
|
<p class="pgtitle"><?=$pgtitle?></p>
|
250
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
251
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
252
|
<form action="services_snmp.php" method="post" name="iform" id="iform">
|
253
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
254
|
|
255
|
<tr>
|
256
|
<td colspan="2" valign="top" class="optsect_t">
|
257
|
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
258
|
<tr><td class="optsect_s"><strong>SNMP Daemon</strong></td>
|
259
|
<td align="right" class="optsect_s"><input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(this)"> <strong>Enable</strong></td></tr>
|
260
|
</table></td>
|
261
|
</tr>
|
262
|
|
263
|
<tr>
|
264
|
<td width="22%" valign="top" class="vncellreq">Polling Port </td>
|
265
|
<td width="78%" class="vtable">
|
266
|
<input name="pollport" type="text" class="formfld" id="pollport" size="40" value="<?=$pconfig['pollport'] ? htmlspecialchars($pconfig['pollport']) : htmlspecialchars(161);?>">
|
267
|
<br>Enter the port to accept polling events on (default 161)</br>
|
268
|
</td>
|
269
|
</tr>
|
270
|
|
271
|
<tr>
|
272
|
<td width="22%" valign="top" class="vncell">System location</td>
|
273
|
<td width="78%" class="vtable">
|
274
|
<input name="syslocation" type="text" class="formfld" id="syslocation" size="40" value="<?=htmlspecialchars($pconfig['syslocation']);?>">
|
275
|
</td>
|
276
|
</tr>
|
277
|
|
278
|
<tr>
|
279
|
<td width="22%" valign="top" class="vncell">System contact</td>
|
280
|
<td width="78%" class="vtable">
|
281
|
<input name="syscontact" type="text" class="formfld" id="syscontact" size="40" value="<?=htmlspecialchars($pconfig['syscontact']);?>">
|
282
|
</td>
|
283
|
</tr>
|
284
|
|
285
|
<tr>
|
286
|
<td width="22%" valign="top" class="vncellreq">Read Community String</td>
|
287
|
<td width="78%" class="vtable">
|
288
|
<input name="rocommunity" type="text" class="formfld" id="rocommunity" size="40" value="<?=htmlspecialchars($pconfig['rocommunity']);?>">
|
289
|
<br>In most cases, "public" is used here</br>
|
290
|
</td>
|
291
|
</tr>
|
292
|
|
293
|
<?php
|
294
|
/* disabled until some docs show up on what this does.
|
295
|
<tr>
|
296
|
<td width="22%" valign="top" class="vtable"> </td>
|
297
|
<td width="78%" class="vtable">
|
298
|
<input name="rwenable" type="checkbox" value="yes" <?php if ($pconfig['rwenable']) echo "checked"; ?> onClick="enable_change(this)">
|
299
|
<strong>Enable Write Community String</strong>
|
300
|
</td>
|
301
|
</tr>
|
302
|
|
303
|
<tr>
|
304
|
<td width="22%" valign="top" class="vncellreq">Write community string</td>
|
305
|
<td width="78%" class="vtable">
|
306
|
<input name="rwcommunity" type="text" class="formfld" id="rwcommunity" size="40" value="<?=htmlspecialchars($pconfig['rwcommunity']);?>">
|
307
|
<br>Please use something other then "private" here</br>
|
308
|
</td>
|
309
|
</tr>
|
310
|
*/
|
311
|
?>
|
312
|
|
313
|
<tr><td> </td></tr>
|
314
|
|
315
|
<tr>
|
316
|
<td colspan="2" valign="top" class="optsect_t">
|
317
|
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
318
|
<tr><td class="optsect_s"><strong>SNMP Traps</strong></td>
|
319
|
<td align="right" class="optsect_s"><input name="trapenable" type="checkbox" value="yes" <?php if ($pconfig['trapenable']) echo "checked"; ?> onClick="enable_change(this)"> <strong>Enable</strong></td></tr>
|
320
|
</table></td>
|
321
|
</tr>
|
322
|
|
323
|
|
324
|
<tr>
|
325
|
<td width="22%" valign="top" class="vncellreq">Trap server</td>
|
326
|
<td width="78%" class="vtable">
|
327
|
<input name="trapserver" type="text" class="formfld" id="trapserver" size="40" value="<?=htmlspecialchars($pconfig['trapserver']);?>">
|
328
|
<br>Enter trap server name</br>
|
329
|
</td>
|
330
|
</tr>
|
331
|
|
332
|
<tr>
|
333
|
<td width="22%" valign="top" class="vncellreq">Trap server port </td>
|
334
|
<td width="78%" class="vtable">
|
335
|
<input name="trapserverport" type="text" class="formfld" id="trapserverport" size="40" value="<?=$pconfig['trapserverport'] ? htmlspecialchars($pconfig['trapserverport']) : htmlspecialchars(162);?>">
|
336
|
<br>Enter the port to send the traps to (default 162)</br>
|
337
|
</td>
|
338
|
</tr>
|
339
|
|
340
|
<tr>
|
341
|
<td width="22%" valign="top" class="vncellreq">Enter the SNMP trap string</td>
|
342
|
<td width="78%" class="vtable">
|
343
|
<input name="trapstring" type="text" class="formfld" id="trapstring" size="40" value="<?=htmlspecialchars($pconfig['trapstring']);?>">
|
344
|
<br>Trap string</br>
|
345
|
</td>
|
346
|
</tr>
|
347
|
|
348
|
<tr><td> </td></tr>
|
349
|
|
350
|
<tr>
|
351
|
<td colspan="2" valign="top" class="optsect_t">
|
352
|
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
353
|
<tr><td class="optsect_s"><strong>Modules</strong></td>
|
354
|
<td align="right" class="optsect_s"> </td></tr>
|
355
|
</table></td>
|
356
|
</tr>
|
357
|
|
358
|
<tr>
|
359
|
<td width="22%" valign="top" class="vncellreq">SNMP Modules</td>
|
360
|
<td width="78%" class="vtable">
|
361
|
<input name="mibii" type="checkbox" id="mibii" value="yes" <?php if ($pconfig['mibii']) echo "checked"; ?> >MibII
|
362
|
<br />
|
363
|
<input name="netgraph" type="checkbox" id="netgraph" value="yes" <?php if ($pconfig['netgraph']) echo "checked"; ?> >Netgraph
|
364
|
<br />
|
365
|
<input name="pf" type="checkbox" id="pf" value="yes" <?php if ($pconfig['pf']) echo "checked"; ?> >PF
|
366
|
<br />
|
367
|
<input name="hostres" type="checkbox" id="hostres" value="yes" <?php if ($pconfig['hostres']) echo "checked"; ?> >Host Resources
|
368
|
</td>
|
369
|
</tr>
|
370
|
<tr>
|
371
|
<td width="22%" valign="top" class="vtable"></td>
|
372
|
<td width="78%" class="vtable">
|
373
|
<input name="bindlan" type="checkbox" value="yes" <?php if ($pconfig['bindlan']) echo "checked"; ?>> <strong>Bind to LAN interface only</strong>
|
374
|
<br>
|
375
|
This option can be useful when trying to access the SNMP agent
|
376
|
by the LAN interface's IP address through a VPN tunnel terminated on the WAN interface.</td>
|
377
|
</tr>
|
378
|
<tr>
|
379
|
<td width="22%" valign="top"> </td>
|
380
|
<td width="78%">
|
381
|
<input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
|
382
|
</td>
|
383
|
</tr>
|
384
|
</table>
|
385
|
</form>
|
386
|
<script language="JavaScript">
|
387
|
<!--
|
388
|
enable_change(this);
|
389
|
//-->
|
390
|
</script>
|
391
|
<?php include("fend.inc"); ?>
|
392
|
</body>
|
393
|
</html>
|