getting bsnmpd to talk to bsnmpget

dvl@

Developer
I'm going to give bnsmpd a go and see how it runs. I've got it running:

Code:
[16:49 empty dan ~] % ps auwwx | grep snmp    
root   24732  0.0  0.0 16620 5956  -  SsJ  16:49   0:00.00 /usr/sbin/bsnmpd -p /var/run/snmpd.pid
dan    24952  0.0  0.0 12812 2360  1  S+J  16:49   0:00.00 grep snmp

[16:44 empty dan ~] % sockstat -p 161 -4
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS    
root     bsnmpd     22635 6  udp4   10.55.0.21:161        *:*

But it won't talk to me:

Code:
[16:43 empty dan /etc] % bsnmpget  -s 10.55.0.21 sysUpTime.0
bsnmpget: Snmp dialog: Operation timed out

However, net-mgmt/net-snmp does answer.

Code:
[16:45 empty dan ~] % sudo service bsnmpd stop
Stopping bsnmpd.
Waiting for PIDS: 22635.

[16:46 empty dan ~] % sudo service snmpd onestart
Starting snmpd.

[16:46 empty dan ~] % sockstat -p 161 -4        
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS    
root     snmpd      23911 8  udp4   10.55.0.21:161        *:*

[16:46 empty dan ~] % bsnmpget  -s 10.55.0.21 sysUpTime.0
sysUpTime.0 = 1015

By far, the biggest impediment to getting users to use your code, is in the inability to find a working simple example. Getting started is always the first step. I've been searching and failing to find a working example so far. :/

Could you share your working /etc/snmpd.config with me/us please?
 
Hmm... It works fine with the default untouched /etc/snmpd.config.
Code:
ash in 🌐 ex21 in ~
❯ doas service bsnmpd onestart
Starting bsnmpd.

ash in 🌐 ex21 in ~
❯ bsnmpget -s localhost sysDescr sysContact sysUpTime
sysDescr.0 = ex21.domain.msk.ru 952319646 FreeBSD 13.2-STABLE
sysContact.0 = sysmeister@example.com
sysUpTime.0 = 2106
So I believe you have to check your config twice.
 
It does not work here, I don't know why.

Code:
[0:19 empty dan ~] % fetch -o snmpd.config "https://cgit.freebsd.org/src/plain/usr.sbin/bsnmpd/bsnmpd/snmpd.config?h=stable/13"
snmpd.config                                          9803  B  139 MBps    00s
[0:20 empty dan ~] % sudo mv snmpd.config /etc/ 
[0:20 empty dan ~] % sudo service bsnmpd restart
Stopping bsnmpd.
Waiting for PIDS: 49996.
Starting bsnmpd.
[0:20 empty dan ~] % bsnmpget -s localhost sysDescr sysContact sysUpTime
^C
[0:20 empty dan ~] % sockstat -p 161 -4                                 
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS     
root     bsnmpd     51464 6  udp4   10.55.0.21:161        *:*
[0:21 empty dan ~] % bsnmpget -s 10.55.0.21 sysDescr sysContact sysUpTime
bsnmpget: Snmp dialog: Operation timed out
[0:21 empty dan ~] %
 
It works over here, in this bhyve instance, but not in that jail above. Interesting. Why would bsnmpd fail but net/net-snmpd work on the same host?

Code:
root@testing:~ # uname -a
FreeBSD testing.int.unixathome.org 12.2-RELEASE-p7 FreeBSD 12.2-RELEASE-p7 GENERIC  amd64
root@testing:~ # service bsnmpd onestart
Starting bsnmpd.
root@testing:~ # bsnmpget -s localhost sysDescr sysContact sysUpTime
sysDescr.0 = testing.int.unixathome.org 1367750459 FreeBSD 12.2-RELEASE-p7
sysContact.0 = sysmeister@example.com
sysUpTime.0 = 828
root@testing:~ #
 
Code:
[0:21 empty dan ~] % sudo service bsnmpd stop                           
Stopping bsnmpd.
Waiting for PIDS: 51464.

directories (/usr/local/etc/rc.d), or is not executable
[0:27 empty dan ~] % sudo service snmpd onestart   
Starting snmpd.

[0:27 empty dan ~] % bsnmpget -s 10.55.0.21 sysDescr sysContact sysUpTime
sysDescr.0 = FreeBSD empty.int.unixathome.org 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64
sysContact.0 = Me <me@example.org>
sysUpTime.0 = 453
[0:27 empty dan ~] % sockstat -p 161 -4                                 
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     snmpd      54375 8  udp4   10.55.0.21:161        *:*
 
I know what it is. It's 127.0.0.1. More specifically, the lack thereof.

I added that to the jail configuration:

Code:
empty {
    persist;
    ip4.addr = "$NIC|10.55.0.21";
    ip4.addr += "127.0.0.1";
}

I restarted the jail. Now it works.

Code:
[0:33 empty dan ~] % sockstat -p 161 -4                                 
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS     
root     bsnmpd     57479 6  udp4   *:161                 *:*
[0:33 empty dan ~] % bsnmpget -s 10.55.0.21 sysDescr sysContact sysUpTime
sysDescr.0 = empty.int.unixathome.org 0 FreeBSD 13.2-RELEASE-p4
sysContact.0 = sysmeister@example.com
sysUpTime.0 = 699
[0:33 empty dan ~] %
 
My next goal, use https://github.com/trociny/bsnmp-ucd by adding this to the configuration:

Code:
begemotSnmpdModulePath."ucd" = "/usr/local/lib/snmp_ucd.so"

However, that gives this upon restart:

Code:
Oct 23 00:46:34 empty snmpd[61433]: creating UDP6 socket: Protocol not supported
Oct 23 00:46:34 empty snmpd[61433]: assignment to begemotSnmpdModulePath.3.117.99.100 returns 12
Oct 23 00:46:34 empty snmpd[61433]:   in file /etc/snmpd.config line 2
Oct 23 00:46:34 empty snmpd[61433]: error in config file
Oct 23 00:46:34 empty snmpd[61433]: assignment to begemotSnmpdModulePath.3.117.99.100 returns 12
Oct 23 00:46:34 empty snmpd[61433]:   in file /etc/snmpd.config line 2
Oct 23 00:46:34 empty snmpd[61433]: error in config file
Oct 23 00:46:34 empty snmpd[61433]: send: Connection refused

Where line 2 is blank and is right after the new configuration line. :)

EDIT: Adding an IPv6 address to the jail removes the UDP6, but the error persists.
 
Back
Top