net-mgmt/snmp: product info read and interface cleanup changes

This commit is contained in:
Franco Fichtner 2018-09-22 11:34:20 +02:00
parent becb3d644d
commit afd43c019e
3 changed files with 16 additions and 20 deletions

View file

@ -1,5 +1,6 @@
PLUGIN_NAME= snmp
PLUGIN_VERSION= 1.3
PLUGIN_REVISION= 2
PLUGIN_DEPENDS= bsnmp-regex bsnmp-ucd
PLUGIN_COMMENT= End of life, superseded by Net-SNMP plugin
PLUGIN_MAINTAINER= franco@opnsense.org

View file

@ -96,11 +96,14 @@ trap := "{$config['snmpd']['trapstring']}"
EOD;
}
$version = trim(file_get_contents('/usr/local/opnsense/version/opnsense'));
$platform = $g['product_name'];
$sysDescr = "{$g['product_name']} " . php_uname("n") .
" {$version} {$platform} " . php_uname("s") .
" " . php_uname("r") . " " . trim(shell_exec('uname -p'));
$sysDescr = join(' ', array(
$g['product_name'],
$g['product_version'],
php_uname('n'),
php_uname('s'),
php_uname('r'),
$g['product_arch']
));
$snmpdconf .= <<<EOD
system := 1
@ -128,14 +131,9 @@ EOD;
$bind_to_ip = '0.0.0.0';
if (!empty($config['snmpd']['bindip'])) {
if (is_ipaddr($config['snmpd']['bindip'])) {
$bind_to_ip = $config['snmpd']['bindip'];
} else {
$if = get_real_interface($config['snmpd']['bindip']);
$bind_to_ip_maybe = find_interface_ip($if);
if (is_ipaddr($bind_to_ip_maybe)) {
$bind_to_ip = $bind_to_ip_maybe;
}
$bind_to_ip_maybe = find_interface_ip(get_real_interface($config['snmpd']['bindip']));
if (is_ipaddr($bind_to_ip_maybe)) {
$bind_to_ip = $bind_to_ip_maybe;
}
}

View file

@ -327,14 +327,11 @@ include("head.inc");
<td>
<select name="bindip" class="selectpicker">
<option value=""><?= gettext('All') ?></option>
<?php
foreach (get_possible_listen_ips() as $lip):?>
<option value="<?=$lip['value'];?>" <?=$lip['value'] == $pconfig['bindip'] ? "selected=\"selected\"" : "";?>>
<?=htmlspecialchars($lip['name']);?>
<?php foreach (get_configured_interface_with_descr() as $ifname => $ifdescr): ?>
<option value="<?= html_safe($ifname) ?>" <?= $ifname == $pconfig['bindip'] ? 'selected="selected"' : '' ?>>
<?= htmlspecialchars($ifdescr) ?>
</option>
<?php
endforeach; ?>
<?php endforeach ?>
</select>
</td>
</tr>