Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
a0b769e8
Commit
a0b769e8
authored
Nov 20, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bsnmpd: pluginify
parent
ec679740
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
185 deletions
+5
-185
services.inc
src/etc/inc/services.inc
+1
-176
rc.bootup
src/etc/rc.bootup
+0
-3
rc.newwanip
src/etc/rc.newwanip
+1
-1
interfaces.php
src/www/interfaces.php
+1
-1
services_snmp.php
src/www/services_snmp.php
+2
-4
No files found.
src/etc/inc/services.inc
View file @
a0b769e8
...
...
@@ -39,6 +39,7 @@
* files. Maybe eventually this will change...
*/
require_once
(
'dyndns.class'
);
require_once
(
'plugins.inc.d/bsnmpd.inc'
);
require_once
(
'plugins.inc.d/dnsmasq.inc'
);
require_once
(
'plugins.inc.d/relayd.inc'
);
require_once
(
'plugins.inc.d/unbound.inc'
);
...
...
@@ -1736,172 +1737,6 @@ function dyndnsCheckIP($int)
return
$ip_address
;
}
function
services_snmpd_configure
(
$verbose
=
false
)
{
global
$config
,
$g
;
killbypid
(
'/var/run/snmpd.pid'
,
'TERM'
,
true
);
if
(
!
isset
(
$config
[
'snmpd'
][
'enable'
]))
{
return
;
}
if
(
$verbose
)
{
echo
'Starting SNMP daemon....'
;
flush
();
}
/* generate snmpd.conf */
$fd
=
fopen
(
"/var/etc/snmpd.conf"
,
"w"
);
if
(
!
$fd
)
{
log_error
(
'Cannot open snmpd.conf in services_snmpd_configure()'
);
return
;
}
$snmpdconf
=
<<<EOD
location := "{$config['snmpd']['syslocation']}"
contact := "{$config['snmpd']['syscontact']}"
read := "{$config['snmpd']['rocommunity']}"
EOD;
if
(
isset
(
$config
[
'snmpd'
][
'trapenable'
])
&&
preg_match
(
'/^\S+$/'
,
$config
[
'snmpd'
][
'trapserver'
])){
$snmpdconf
.=
<<<EOD
# SNMP Trap support.
traphost := {$config['snmpd']['trapserver']}
trapport := {$config['snmpd']['trapserverport']}
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'
));
$snmpdconf
.=
<<<EOD
system := 1
%snmpd
sysDescr = "{$sysDescr}"
begemotSnmpdDebugDumpPdus = 2
begemotSnmpdDebugSyslogPri = 7
begemotSnmpdCommunityString.0.1 = $(read)
EOD;
if
(
isset
(
$config
[
'snmpd'
][
'trapenable'
])
&&
preg_match
(
'/^\S+$/'
,
$config
[
'snmpd'
][
'trapserver'
])){
$snmpdconf
.=
<<<EOD
begemotTrapSinkStatus.[$(traphost)].$(trapport) = 4
begemotTrapSinkVersion.[$(traphost)].$(trapport) = 2
begemotTrapSinkComm.[$(traphost)].$(trapport) = $(trap)
EOD;
}
$snmpdconf
.=
<<<EOD
begemotSnmpdCommunityDisable = 1
EOD;
$bind_to_ip
=
"0.0.0.0"
;
if
(
isset
(
$config
[
'snmpd'
][
'bindip'
]))
{
if
(
is_ipaddr
(
$config
[
'snmpd'
][
'bindip'
]))
{
$bind_to_ip
=
$config
[
'snmpd'
][
'bindip'
];
}
else
{
$if
=
get_real_interface
(
$config
[
'snmpd'
][
'bindip'
]);
if
(
does_interface_exist
(
$if
))
{
$bind_to_ip
=
find_interface_ip
(
$if
);
}
}
}
if
(
is_port
(
$config
[
'snmpd'
][
'pollport'
]
))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdPortStatus.{$bind_to_ip}.{$config['snmpd']['pollport']} = 1
EOD;
}
$snmpdconf
.=
<<<EOD
begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1
begemotSnmpdLocalPortType."/var/run/snmpd.sock" = 4
# These are bsnmp macros not php vars.
sysContact = $(contact)
sysLocation = $(location)
sysObjectId = 1.3.6.1.4.1.12325.1.1.2.1.$(system)
snmpEnableAuthenTraps = 2
EOD;
if
(
is_array
(
$config
[
'snmpd'
][
'modules'
]
))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'mibii'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'netgraph'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so"
%netgraph
begemotNgControlNodeName = "snmpd"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'pf'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'hostres'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'bridge'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so"
# config must end with blank line
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'ucd'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."ucd" = "/usr/local/lib/snmp_ucd.so"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'regex'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."regex" = "/usr/local/lib/snmp_regex.so"
EOD;
}
}
fwrite
(
$fd
,
$snmpdconf
);
fclose
(
$fd
);
unset
(
$snmpdconf
);
/* run bsnmpd */
mwexec
(
"/usr/sbin/bsnmpd -c /var/etc/snmpd.conf -p /var/run/snmpd.pid"
);
if
(
$verbose
)
{
echo
"done.
\n
"
;
}
}
function
services_dnsupdate_process
(
$int
=
''
,
$updatehost
=
''
,
$forced
=
false
)
{
global
$config
;
...
...
@@ -2149,16 +1984,6 @@ function services_get()
$services
[]
=
$pconfig
;
}
if
(
isset
(
$config
[
'snmpd'
][
'enable'
]))
{
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"bsnmpd"
;
$pconfig
[
'description'
]
=
gettext
(
"SNMP Service"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_snmpd_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_snmpd_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/snmpd.pid'
;
$services
[]
=
$pconfig
;
}
if
(
isset
(
$config
[
'igmpproxy'
][
'igmpentry'
])
&&
is_array
(
$config
[
'igmpproxy'
][
'igmpentry'
])
&&
(
count
(
$config
[
'igmpproxy'
][
'igmpentry'
])
>
0
))
{
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"igmpproxy"
;
...
...
src/etc/rc.bootup
View file @
a0b769e8
...
...
@@ -199,9 +199,6 @@ if (function_exists('plugins_configure')) {
/* start IPsec tunnels */
$ipsec_dynamic_hosts
=
ipsec_configure
();
/* start SNMP service */
services_snmpd_configure
(
true
);
/* load graphing functions */
enable_rrd_graphing
(
true
);
...
...
src/etc/rc.newwanip
View file @
a0b769e8
...
...
@@ -215,7 +215,7 @@ if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interface
services_igmpproxy_configure
();
/* restart snmp */
services_snmpd_configure
();
bsnmpd_configure_do
();
/* reconfigure ntpd */
system_ntp_configure
(
false
);
...
...
src/www/interfaces.php
View file @
a0b769e8
...
...
@@ -524,7 +524,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
/* restart snmp so that it binds to correct address */
services_snmpd_configure
();
bsnmpd_configure_do
();
/* sync filter configuration */
setup_gateways_monitor
();
filter_configure
();
...
...
src/www/services_snmp.php
View file @
a0b769e8
...
...
@@ -115,19 +115,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$config
[
'snmpd'
]
=
$snmp
;
// save and apply
write_config
();
services_snmpd_configure
();
get_std_save_message
();
bsnmpd_configure_do
();
header
(
url_safe
(
'Location: /services_snmp.php'
));
exit
;
}
}
$service_hook
=
'bsnmpd'
;
legacy_html_escape_form_data
(
$pconfig
);
include
(
"head.inc"
);
?>
?>
<body>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment