Project

General

Profile

Download (15.4 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php 
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
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 3805bfdd John Fleming
	$config['snmpd']['pollport'] = "161";
38 5b237745 Scott Ullrich
}
39
40 3805bfdd John Fleming
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 95fb49e8 Seth Mos
	$config['snmpd']['modules']['hostres'] = true;
46
	$config['snmpd']['modules']['bridge'] = true;
47 3805bfdd John Fleming
}
48 4f4d63d8 John Fleming
$pconfig['enable'] = isset($config['snmpd']['enable']);
49 3805bfdd John Fleming
$pconfig['pollport'] = $config['snmpd']['pollport'];
50 5b237745 Scott Ullrich
$pconfig['syslocation'] = $config['snmpd']['syslocation'];
51
$pconfig['syscontact'] = $config['snmpd']['syscontact'];
52
$pconfig['rocommunity'] = $config['snmpd']['rocommunity'];
53 4f4d63d8 John Fleming
/* 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 8c3c9dc2 John Fleming
$pconfig['trapstring'] = $config['snmpd']['trapstring'];
61 5b237745 Scott Ullrich
62 3805bfdd John Fleming
$pconfig['mibii'] = isset($config['snmpd']['modules']['mibii']);
63
$pconfig['netgraph'] = isset($config['snmpd']['modules']['netgraph']);
64
$pconfig['pf'] = isset($config['snmpd']['modules']['pf']);
65 95fb49e8 Seth Mos
$pconfig['hostres'] = isset($config['snmpd']['modules']['hostres']);
66
$pconfig['bridge'] = isset($config['snmpd']['modules']['bridge']);
67 7cbad422 Scott Ullrich
$pconfig['bindlan'] = isset($config['snmpd']['bindlan']);
68 3805bfdd John Fleming
69 5b237745 Scott Ullrich
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 3805bfdd John Fleming
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
79
80
		$reqdfields = explode(" ", "pollport");
81
		$reqdfieldsn = explode(",", "Polling Port");
82 5b237745 Scott Ullrich
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
83 a42bf8cd Scott Ullrich
		
84 72b5583c Scott Ullrich
	
85 5b237745 Scott Ullrich
	}
86
87 4f4d63d8 John Fleming
	if ($_POST['trapenable']) {
88
		$reqdfields = explode(" ", "trapserver");
89
		$reqdfieldsn = explode(",", "Trap server");
90
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
91 3805bfdd John Fleming
92 4f4d63d8 John Fleming
		$reqdfields = explode(" ", "trapserverport");
93
		$reqdfieldsn = explode(",", "Trap server port");
94
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
95 3805bfdd John Fleming
96 8c3c9dc2 John Fleming
		$reqdfields = explode(" ", "trapstring");
97
		$reqdfieldsn = explode(",", "Trap string");
98
		do_input_validation($_POST, $reqdfields, $reqdfields, $reqdfieldsn, &$input_errors);
99 4f4d63d8 John Fleming
	}
100
101 8c3c9dc2 John Fleming
102 4f4d63d8 John Fleming
/* 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 5b237745 Scott Ullrich
	if (!$input_errors) {
113 4f4d63d8 John Fleming
		$config['snmpd']['enable'] = $_POST['enable'] ? true : false;
114 3805bfdd John Fleming
		$config['snmpd']['pollport'] = $_POST['pollport'];
115 3184f4e7 Scott Ullrich
		$config['snmpd']['syslocation'] = $_POST['syslocation'];	
116 5b237745 Scott Ullrich
		$config['snmpd']['syscontact'] = $_POST['syscontact'];
117
		$config['snmpd']['rocommunity'] = $_POST['rocommunity'];
118 4f4d63d8 John Fleming
		/* 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 8c3c9dc2 John Fleming
		$config['snmpd']['trapstring'] = $_POST['trapstring'];
126 4f4d63d8 John Fleming
		
127 3805bfdd John Fleming
		$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 95fb49e8 Seth Mos
		$config['snmpd']['modules']['hostres'] = $_POST['hostres'] ? true : false;
131
		$config['snmpd']['modules']['bridge'] = $_POST['bridge'] ? true : false;
132 7cbad422 Scott Ullrich
		$config['snmpd']['bindlan'] = $_POST['bindlan'] ? true : false;
133 5b237745 Scott Ullrich
			
134
		write_config();
135
		
136
		$retval = 0;
137 920b3bb0 Scott Ullrich
138
		config_lock();
139
		$retval = services_snmpd_configure();
140
		config_unlock();
141
142 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
143
	}
144
}
145 4df96eff Scott Ullrich
146
$pgtitle = "Services: SNMP";
147
include("head.inc");
148
149 5b237745 Scott Ullrich
?>
150
<script language="JavaScript">
151
<!--
152 4f4d63d8 John Fleming
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 8c3c9dc2 John Fleming
	        document.iform.trapstring.disabled = false;
161 4f4d63d8 John Fleming
	    }
162
	    else
163
	    {
164
                document.iform.trapserver.disabled = true;
165
                document.iform.trapserverport.disabled = true;
166 8c3c9dc2 John Fleming
                document.iform.trapstring.disabled = true;
167 4f4d63d8 John Fleming
	    }
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 3805bfdd John Fleming
	    document.iform.pollport.disabled = false;
187 4f4d63d8 John Fleming
	    document.iform.syslocation.disabled = false;
188
	    document.iform.syscontact.disabled = false;
189
	    document.iform.rocommunity.disabled = false;
190
	    document.iform.trapenable.disabled = false;
191 7cbad422 Scott Ullrich
	    document.iform.bindlan.disabled = false;
192 4f4d63d8 John Fleming
	    /* 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 8c3c9dc2 John Fleming
                document.iform.trapstring.disabled = false;
208 4f4d63d8 John Fleming
	    }
209
	    else
210
	    {
211
                document.iform.trapserver.disabled = true;
212 a21b1cad John Fleming
                document.iform.trapserverport.disabled = true;
213 8c3c9dc2 John Fleming
                document.iform.trapstring.disabled = true;
214 4f4d63d8 John Fleming
	    }
215 3805bfdd John Fleming
	    document.iform.mibii.disabled = false;
216
	    document.iform.netgraph.disabled = false;
217
	    document.iform.pf.disabled = false;
218 95fb49e8 Seth Mos
	    document.iform.hostres.disabled = false;
219
	    document.iform.bridge.disabled = false;
220 4f4d63d8 John Fleming
	}
221
	else
222
	{
223 3805bfdd John Fleming
            document.iform.pollport.disabled = true;
224 4f4d63d8 John Fleming
            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 8c3c9dc2 John Fleming
            document.iform.trapstring.disabled = true;
235 3805bfdd John Fleming
236
            document.iform.mibii.disabled = true;
237
            document.iform.netgraph.disabled = true;
238
            document.iform.pf.disabled = true;
239 95fb49e8 Seth Mos
            document.iform.hostres.disabled = true;
240
            document.iform.bridge.disabled = true;
241 7cbad422 Scott Ullrich
	    
242
	    document.iform.bindlan.disabled = true;
243 4f4d63d8 John Fleming
	}
244 5b237745 Scott Ullrich
}
245
//-->
246
</script>
247
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
248
<?php include("fbegin.inc"); ?>
249 74f446e8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
250 5b237745 Scott Ullrich
<?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 4f4d63d8 John Fleming
255 5b237745 Scott Ullrich
                <tr> 
256 4f4d63d8 John Fleming
  		  <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 5b237745 Scott Ullrich
                </tr>
262 3805bfdd John Fleming
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 5b237745 Scott Ullrich
                <tr> 
272 b8093370 Scott Ullrich
                  <td width="22%" valign="top" class="vncell">System location</td>
273 5b237745 Scott Ullrich
                  <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 3805bfdd John Fleming
278 5b237745 Scott Ullrich
                <tr> 
279 b8093370 Scott Ullrich
                  <td width="22%" valign="top" class="vncell">System contact</td>
280 5b237745 Scott Ullrich
                  <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 3805bfdd John Fleming
285 5b237745 Scott Ullrich
                <tr> 
286 4f4d63d8 John Fleming
                  <td width="22%" valign="top" class="vncellreq">Read Community String</td>
287 5b237745 Scott Ullrich
                  <td width="78%" class="vtable"> 
288
                    <input name="rocommunity" type="text" class="formfld" id="rocommunity" size="40" value="<?=htmlspecialchars($pconfig['rocommunity']);?>"> 
289 3805bfdd John Fleming
                    <br>In most cases, &quot;public&quot; is used here</br>
290
		  </td>
291 5b237745 Scott Ullrich
                </tr>
292 4f4d63d8 John Fleming
293
<?php 
294
			/* disabled until some docs show up on what this does.
295
                <tr>
296
                  <td width="22%" valign="top" class="vtable">&nbsp;</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 3805bfdd John Fleming
                    <strong>Enable Write Community String</strong>
300
		  </td>
301 4f4d63d8 John Fleming
                </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 3805bfdd John Fleming
		    <br>Please use something other then &quot;private&quot; here</br>
308
		  </td>
309 4f4d63d8 John Fleming
                </tr>
310
		    	*/ 
311
?>
312
313 3184f4e7 Scott Ullrich
		<tr><td>&nbsp;</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 ba73e2a3 Scott Ullrich
  			<tr><td class="optsect_s"><strong>SNMP Traps</strong></td>
319 3184f4e7 Scott Ullrich
			<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 4f4d63d8 John Fleming
                <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 3805bfdd John Fleming
                    <br>Enter trap server name</br>
329
		  </td>
330 4f4d63d8 John Fleming
                </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 3805bfdd John Fleming
                    <br>Enter the port to send the traps to (default 162)</br>
337
		  </td>
338 4f4d63d8 John Fleming
                </tr>
339 3805bfdd John Fleming
340 8c3c9dc2 John Fleming
                <tr>
341 ba73e2a3 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Enter the SNMP trap string</td>
342 8c3c9dc2 John Fleming
                  <td width="78%" class="vtable">
343
                    <input name="trapstring" type="text" class="formfld" id="trapstring" size="40" value="<?=htmlspecialchars($pconfig['trapstring']);?>">
344 3805bfdd John Fleming
                    <br>Trap string</br>
345
		  </td>
346 8c3c9dc2 John Fleming
                </tr>
347
348 ba73e2a3 Scott Ullrich
		<tr><td>&nbsp;</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">&nbsp;</td></tr>
355
  			</table></td>
356
                </tr>
357
358 3805bfdd John Fleming
		<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 95fb49e8 Seth Mos
		    <br />
363 3805bfdd John Fleming
		    <input name="netgraph" type="checkbox" id="netgraph" value="yes" <?php if ($pconfig['netgraph']) echo "checked"; ?> >Netgraph
364 95fb49e8 Seth Mos
		    <br />
365 3805bfdd John Fleming
		    <input name="pf" type="checkbox" id="pf" value="yes" <?php if ($pconfig['pf']) echo "checked"; ?> >PF
366 95fb49e8 Seth Mos
		    <br />
367
		    <input name="hostres" type="checkbox" id="hostres" value="yes" <?php if ($pconfig['hostres']) echo "checked"; ?> >Host Resources
368 3805bfdd John Fleming
		  </td>
369
		</tr>
370 7cbad422 Scott Ullrich
                <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 5b237745 Scott Ullrich
                <tr> 
379
                  <td width="22%" valign="top">&nbsp;</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 4f4d63d8 John Fleming
enable_change(this);
389 5b237745 Scott Ullrich
//-->
390
</script>
391
<?php include("fend.inc"); ?>
392
</body>
393
</html>