Skip to content

Instantly share code, notes, and snippets.

@dlangille
Last active September 30, 2019 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/f4428a70f8a03d54fbf61bb9ddb682d0 to your computer and use it in GitHub Desktop.
Save dlangille/f4428a70f8a03d54fbf61bb9ddb682d0 to your computer and use it in GitHub Desktop.
I upgraded just now (upgraded: 5.7.3_20 -> 5.8) and it fails to start. mibII/mta_sendmail.c:open_sendmailst: could not guess version of statistics file "/var/log/sendmail.st" - & 'Error opening specified endpoint "udp:10.55.0.39:161"'I went so far as to follow "the recipe" again: https://dan.langille.org/2015/09/07/installing-net-mgmtnet-snmpd-a…
[dan@dev-nginx01:~] $ grep snmp /etc/rc.conf
snmpd_flags="-a -r"
snmpd_conffile="/usr/local/etc/snmpd.conf"
snmpd_enable="YES"
[dan@dev-nginx01:~] $ diff -ruN /usr/local/share/snmp/snmpd.conf.example /usr/local/etc/snmpd.conf
--- /usr/local/share/snmp/snmpd.conf.example 2019-09-30 13:09:19.788339000 +0000
+++ /usr/local/etc/snmpd.conf 2019-09-30 12:29:05.687513000 +0000
@@ -12,7 +12,7 @@
#
# Listen for connections from the local system only
-agentAddress udp:127.0.0.1:161
+agentAddress udp:10.55.0.39:161
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
#agentAddress udp:161,udp6:[::1]:161
@@ -74,8 +74,8 @@
# Note that setting these values here, results in the corresponding MIB objects being 'read-only'
# See snmpd.conf(5) for more details
-sysLocation Sitting on the Dock of the Bay
-sysContact Me <me@example.org>
+sysLocation BSD Cabal HQ
+sysContact dan@langille.org
# Application + End-to-End layers
sysServices 72
@@ -191,3 +191,6 @@
# Listen for network connections (from localhost)
# rather than the default named socket /var/agentx/master
#agentXSocket tcp:localhost:705
+
+extend nginx /usr/local/etc/snmp/nginx-stats
+extend phpfpmsp /usr/local/etc/snmp/phpfpm-sp
[dan@dev-nginx01:~] $
[dan@dev-nginx01:~] $ tail /var/log/snmpd.log
mibII/mta_sendmail.c:open_sendmailst: could not guess version of statistics file "/var/log/sendmail.st"
Turning on AgentX master support.
Error opening specified endpoint "udp:10.55.0.39:161"
Server Exiting with code 1
[dan@dev-nginx01:~] $
[dan@dev-nginx01:~] $ ifconfig -a
ix0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=e53fbb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,WOL_UCAST,WOL_MCAST,WOL_MAGIC,VLAN_HWFILTER,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
ether 00:25:90:fa:0f:10
media: Ethernet autoselect
status: no carrier
ix1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=e53fbb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,WOL_UCAST,WOL_MCAST,WOL_MAGIC,VLAN_HWFILTER,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
ether 00:25:90:fa:0f:11
media: Ethernet autoselect
status: no carrier
ix2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=e53fbb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,WOL_UCAST,WOL_MCAST,WOL_MAGIC,VLAN_HWFILTER,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
ether 00:1b:21:39:a9:c5
inet 10.55.0.39 netmask 0xffffffff broadcast 10.55.0.39
media: Ethernet autoselect (10Gbase-SR <full-duplex,rxpause,txpause>)
status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
groups: lo
pflog0: flags=141<UP,RUNNING,PROMISC> metric 0 mtu 33160
groups: pflog
[dan@dev-nginx01:~] $
[dan@dev-nginx01:~] $ pkg info net-snmp
net-snmp-5.8
Name : net-snmp
Version : 5.8
Installed on : Mon Sep 30 15:50:18 2019 UTC
Origin : net-mgmt/net-snmp
Architecture : FreeBSD:12:amd64
Prefix : /usr/local
Categories : net-mgmt ipv6
Licenses : BSD3CLAUSE
Maintainer : zi@FreeBSD.org
WWW : http://net-snmp.sourceforge.net/
Comment : Extendable SNMP implementation
Options :
AX_DISABLE_TRAP: off
AX_SOCKONLY : off
DOCS : on
DUMMY : on
JAIL : on
MFD_REWRITES : off
MYSQL : off
NEWSYSLOG : on
PERL : on
PERL_EMBEDDED : on
PYTHON : off
SMUX : off
TKMIB : off
TLS : off
UNPRIVILEGED : off
Shared Libs required:
libpkg.so.4
libperl.so.5.30
libpcre.so.1
Shared Libs provided:
libnetsnmpmibs.so.35
libnetsnmp.so.35
libnetsnmphelpers.so.35
libnetsnmpagent.so.35
libnetsnmptrapd.so.35
Annotations :
FreeBSD_version: 1200086
cpe : cpe:2.3:a:net-snmp:snmp:5.8:::::freebsd12:x64
repo_type : binary
repository : local
Flat size : 12.2MiB
Description :
This is Net-SNMP (previously known as "ucd-snmp").
Various tools relating to the Simple Network Management Protocol including:
An extensible agent
An SNMP library
tools to request or set information from SNMP agents
tools to generate and handle SNMP traps
a version of the Unix 'netstat' command using SNMP
a graphical Perl/Tk/SNMP based mib browser
WWW: http://net-snmp.sourceforge.net/
[dan@dev-nginx01:~] $
@jurajlutter
Copy link

root@jfbsd12:/usr/local/etc # ifconfig lo1
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet 172.31.5.12 netmask 0xffffffff
        groups: lo

root@jfbsd12:/usr/local/etc # netstat -anf inet | grep 161
udp4       0      0 172.31.5.12.161        *.*

root@jfbsd12:/usr/local/etc # ps ax | grep snmp
97935  -  SJ   0:00.02 /usr/local/sbin/snmpd -p /var/run/net_snmpd.pid

root@jfbsd12:/usr/local/etc # diff -u /usr/local/share/snmp/snmpd.conf.example snmpd.conf
--- /usr/local/share/snmp/snmpd.conf.example    2019-09-30 13:55:40.640371000 +0000
+++ snmpd.conf  2019-09-30 13:59:17.761955000 +0000
@@ -12,7 +12,7 @@
 #

 #  Listen for connections from the local system only
-agentAddress  udp:127.0.0.1:161
+agentAddress  udp:172.31.5.12:161
 #  Listen for connections on all interfaces (both IPv4 *and* IPv6)
 #agentAddress udp:161,udp6:[::1]:161

@opsec
Copy link

opsec commented Sep 30, 2019

Tested with generic snmpd.conf, changed

agentAddress udp:127.0.0.1:161

to

agentAddress udp:193.105.105.132:161

Result: snmpd starts.

So something with lo0 ?

@dlangille
Copy link
Author

In my case, this is a jail without lo0 having 127.0.0.1

This worked before. No configuration file changes.

@dlangille
Copy link
Author

if I comment out this in /etc/rc.conf:

#snmpd_conffile="/usr/local/etc/snmpd.conf"

It runs:

[dan@dev-nginx01:~] $ sockstat -l | grep 161
root     snmpd      72144 6  udp4   10.55.0.39:161        *:*
[dan@dev-nginx01:~] $ 

@opsec
Copy link

opsec commented Sep 30, 2019

tested with 127.0.0.2 as alias on lo0, works.

Tested with 127.0.0.1, does not work. Interesting.

@dlangille
Copy link
Author

Interesting.

[dan@dev-nginx01:~] $ sudo service snmpd restart
snmpd not running? (check /var/run/net_snmpd.pid).
Starting snmpd.
[dan@dev-nginx01:~] $ ': sockstat -l | grep 161
root     snmpd      66557 8  udp4   127.0.10.1:161        *:*
root     snmpd      66557 9  udp4   10.55.0.39:161        *:*
[dan@dev-nginx01:~] $ ps auwwx | grep snmp
root       66557  1.5  0.0  29700 16612  -  SJ   16:56   0:00.01 /usr/local/sbin/snmpd -p /var/run/net_snmpd.pid -c /usr/local/etc/snmpd.conf -a -r
dan        67550  0.0  0.0  11292  2612  0  S+J  16:57   0:00.00 grep snmp
[dan@dev-nginx01:~] $ grep Address /usr/local/etc/snmpd.conf
agentAddress  udp:127.0.10.1:161
#agentAddress  udp:10.55.0.39:161
#agentAddress udp:161,udp6:[::1]:161
                                                 #     and check the 'agentAddress' setting above
[dan@dev-nginx01:~] $ 

I added lo1 at 127.0.10.1

So why does this start now and listen on 10.55.0.39?

@opsec
Copy link

opsec commented Sep 30, 2019

It's because for whatever reason, if you give it udp:127.0.0.1:161, it tries to open this twice and fails/aborts.

If you give udp:127.0.0.1:162, it opens both :161 and :162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment