[Plug-In] SNMP


Recommended Posts

18 hours ago, kubed_zero said:

In essence, this update modifies the SNMP installer script to look on the /boot drive for an SNMP config file to use, preferring that over the bundled config if it exists. This means that even without using the UI, you can get a custom SNMP file to load up without any adjustments to the go file or anything else.

 

I'm having issues updating due to failing at this point even though I don't have a custom SNMP config.  SNMP seems to be working fine, I'm even monitoring free diskspace on /boot via snmp so very curious about this

snmpwalk -v 2c localhost -c public hrFSMountPoint
snmpwalk failureCouldn't find /boot mount point. SNMP output:
Timeout: No Response from localhost
plugin: run failed: /bin/bash retval: 1

 

Link to comment
2 hours ago, PacMain said:

I'm having issues updating due to failing at this point even though I don't have a custom SNMP config.  SNMP seems to be working fine, I'm even monitoring free diskspace on /boot via snmp so very curious about this

snmpwalk -v 2c localhost -c public hrFSMountPoint
snmpwalk failureCouldn't find /boot mount point. SNMP output:
Timeout: No Response from localhost
plugin: run failed: /bin/bash retval: 1

 

Huh, I didn't edit anything related to this bit. Specifically, what it's failing on is that it's trying to call snmpwalk after SNMP is started, and it's getting back "No Response from localhost" instead of a valid SNMP response. That sounds to me though as if SNMP failed to start up.

- If you reboot and try to update again, does it work?

- An alternative would be to uninstall SNMP, reboot, and then reinstall with the newest version.

 

I'm not sure what version of SNMP/Unraid you're currently on, but there have been some adjustments in more recent versions to make updating safer. 

Edited by kubed_zero
Clarified the nature of the failure
Link to comment

Just updated my server with the new version. Was a bit more work because I manually editted the existing plugin so I could test my changes so it did not allow me to update :) Simply removed it, rebooted just to be sure, downloaded the new version and pasted my config. Works like a charm :D

 

Fantastic that now everybody can do it like this simply through the UI!

  • Thanks 1
Link to comment
  • 3 weeks later...
2 hours ago, Kacper said:

I am trying to find disk temperature with snmpwalk, but I cannot. What oid it suppose to be or what string should i search for to find disk temperature?

NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".2 = STRING: WDC_WD100EMAZ-00WJTA0_JEGKPT5N: 30

Here's an example of how it will look.

 

Here's one way of calling SNMP to get just the custom stuff: snmpwalk -v 2c -c public localhost nsExtendOutLine

 

You can also uninstall and reinstall the plugin and the installation logs will give you an example of how to call SNMP, along with what your system's output currently is. 

Link to comment

I've noticed a problem related to the changes I've made regarding saving the config file. Last night my server went down due to a lightning strike killing the power. And I've notices it remained offline on my monitoring. So: I checked the config but hey there are no "snmp" settings anymore how strange. Went to reinstall/download the plugin and then I saw:

 

Executing install script for unraid-snmp-2021.05.21-x86_64-1.txz.
Set permissions and move into dir /usr/local/emhttp/plugins/snmp
Set shell script executable permissions
Set read only permissions for other files
Checking if /etc/rc.d/rc.snmpd exists before editing
Stop SNMP daemon if it is currently running
Shutting down snmpd: DONE
Using the user-defined config /boot/config/plugins/snmp/snmpd.conf, backing up the original
Editing SNMP startup options in rc.snmpd to be [-LF 0-5 /var/log/snmpd.log -A -p /var/run/snmpd -a]
Restart SNMP daemon now that we've adjusted how rc.snmpd starts it
Starting snmpd: /usr/sbin/snmpd -LF 0-5 /var/log/snmpd.log -A -p /var/run/snmpd -a -c /etc/snmp/snmpd.conf
PID of started SNMP daemon is 20036
Package unraid-snmp-2021.05.21-x86_64-1.txz installed.

+==============================================================================
| Testing SNMP by listing mounts, /boot should be present
+==============================================================================

snmpwalk -v 2c localhost -c public hrFSMountPoint
snmpwalk failureCouldn't find /boot mount point. SNMP output:
Timeout: No Response from localhost
plugin: run failed: /bin/bash retval: 1

Updating Support Links



Finished Installing. If the DONE button did not appear, then you will need to click the red X in the top right corner

 

So yeah! If it uses my config then accessing localhost with public as a community does not work! When rebooting it "reinstalls" the plugin and that seem to fail. No idea why this did not happen to me when testing it....

 

So @kubed_zero I think we can do a couple of things:

- First start the service with default config in order to test it, then restart it with the user config

- Always append a `rocommunity public 127.0.0.1` to allow this to happen

- Don't fail when the snmpwalk fails (when using custom config)

 

Do you have any preferences? For me I now have added option 2 as that was the quickest way to fix it.

 

It seems when manually installing it the plugin IS installed (I have the settings) but when I check the installed plugins it is not listed so that might be somekind of Unraid bug.

Link to comment
  • 1 month later...
  • 4 weeks later...

Hey Guys, maybe someone could help me.

 

I've got an  Problem when reading out the values for Free Disk Space / Used Space. Using the SNMP Plugin and in ioBroker also the SNMP Plugin to show me the values of my unraid machine in VIS.

 

I'm using this OID: .1.3.6.1.4.1.2021.9.1.13.1 to look up the disk free space for Disk 1 (also Disk7 and 8). Everything just fine. But if I try to get the values for disk 2, I'm getting some Values, but not the ones I see on my Dashboard in unraid ...

 

unraid:

unraid_disks.thumb.JPG.9cc4f53ea444a98982ed73ddb279b9d3.JPG

 

ioBroker:

iobroker_disks.thumb.JPG.33af9c3277c4f6cbd14ae154bb5ba617.JPG

 

Whats wrong here ?

Link to comment

Up until recently, I was able to get Observium to connect to the SNMP on the Unraid server. Now it cannot.

Observium is a docker on my Unraid and I am using the SNMP pluggin. I can do an snmpwalk to the Unraid server from several other machines. Observium can add multiple other devices.

Now here is the kicker I cannot fping from Observium console to Unraid, but I can to every other Docker. I have switched the conatiner from Custom: bond to bridge, same thing.

Any help on why the two cannot "see" each other.

Link to comment
  • 3 weeks later...
On 6/21/2021 at 8:31 AM, mattie112 said:

I've noticed a problem related to the changes I've made regarding saving the config file. Last night my server went down due to a lightning strike killing the power. And I've notices it remained offline on my monitoring. So: I checked the config but hey there are no "snmp" settings anymore how strange. Went to reinstall/download the plugin and then I saw:

 

Executing install script for unraid-snmp-2021.05.21-x86_64-1.txz.
Set permissions and move into dir /usr/local/emhttp/plugins/snmp
Set shell script executable permissions
Set read only permissions for other files
Checking if /etc/rc.d/rc.snmpd exists before editing
Stop SNMP daemon if it is currently running
Shutting down snmpd: DONE
Using the user-defined config /boot/config/plugins/snmp/snmpd.conf, backing up the original
Editing SNMP startup options in rc.snmpd to be [-LF 0-5 /var/log/snmpd.log -A -p /var/run/snmpd -a]
Restart SNMP daemon now that we've adjusted how rc.snmpd starts it
Starting snmpd: /usr/sbin/snmpd -LF 0-5 /var/log/snmpd.log -A -p /var/run/snmpd -a -c /etc/snmp/snmpd.conf
PID of started SNMP daemon is 20036
Package unraid-snmp-2021.05.21-x86_64-1.txz installed.

+==============================================================================
| Testing SNMP by listing mounts, /boot should be present
+==============================================================================

snmpwalk -v 2c localhost -c public hrFSMountPoint
snmpwalk failureCouldn't find /boot mount point. SNMP output:
Timeout: No Response from localhost
plugin: run failed: /bin/bash retval: 1

Updating Support Links



Finished Installing. If the DONE button did not appear, then you will need to click the red X in the top right corner

 

So yeah! If it uses my config then accessing localhost with public as a community does not work! When rebooting it "reinstalls" the plugin and that seem to fail. No idea why this did not happen to me when testing it....

 

So @kubed_zero I think we can do a couple of things:

- First start the service with default config in order to test it, then restart it with the user config

- Always append a `rocommunity public 127.0.0.1` to allow this to happen

- Don't fail when the snmpwalk fails (when using custom config)

 

Do you have any preferences? For me I now have added option 2 as that was the quickest way to fix it.

 

It seems when manually installing it the plugin IS installed (I have the settings) but when I check the installed plugins it is not listed so that might be somekind of Unraid bug.

 

1 seems a bit complicated for what is essentially a sanity test during installation. Honestly I'd rather remove the sanity test than have 1 in the installer script

2 seems fine, though I'd hope that if someone is messing with the SNMP config enough to bork the installation, they'd be able to just remove the sanity check from the PLG and call it a day. 

 

3 would be hard to differentiate between a custom config and the default I think, or similar to 1 would be extra complication to the install logic. 

 

Out of these, 2 vibes the most with me! 

Link to comment
  • 2 weeks later...

I get an error when i install the plugin:

 

Any ideas? 

Thanks a lot!

+==============================================================================
| Testing SNMP by listing mounts
+==============================================================================
Couldn't find /boot mount point in SNMP output. Output:
snmpwalk: symbol lookup error: /usr/lib64/libnetsnmp.so.30: undefined symbol: EVP_MD_CTX_create


plugin: run failed: /bin/bash retval: 1

 

Edited by Twix
Link to comment
  • 2 weeks later...

For anyone struggling to convert the MIB output to an OID, I found a way. I use PRTG to monitor snmp and it takes OIDs. It was able to auto-discover most things but not the NET-SNMP-EXTEND-MIB stuff. Not sure if the following has been noted in this thread previously but I couldn't find a coherent method among the posts.

 

snmpwalk on the NET-SNMP-EXTEND-MIB

root@BLOOTOO:~# snmpwalk -v 2c localhost -c public NET-SNMP-EXTEND-MIB::nsExtendOutLine
NET-SNMP-EXTEND-MIB::nsExtendOutLine."cpumhz".1 = STRING: 3713.766 MHz
NET-SNMP-EXTEND-MIB::nsExtendOutLine."meminfo".1 = STRING: MemTotal: 67461050368
NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree".1 = STRING: appdata: 286401884160
...

 

Convert prefix to OID format:

root@BLOOTOO:~# snmptranslate -Td NET-SNMP-EXTEND-MIB::nsExtendOutLine.
NET-SNMP-EXTEND-MIB::nsExtendOutLine.""
nsExtendOutLine OBJECT-TYPE
  -- FROM       NET-SNMP-EXTEND-MIB
  -- TEXTUAL CONVENTION DisplayString
  SYNTAX        OCTET STRING (0..255) 
  DISPLAY-HINT  "255a"
  MAX-ACCESS    read-only
  STATUS        current
  DESCRIPTION   "A single line of output from the extension command."
::= { iso(1) org(3) dod(6) internet(1) private(4) enterprises(1) netSnmp(8072) netSnmpObjects(1) nsExtensions(3) nsExtendObjects(2) nsExtendOutput2Table(4) nsExtendOutput2Entry(1) nsExtendOutLine(2) 0 }

 

Take note of the numbers at the end. 1.3.6.1.4.1.8072.1.3.2.4.1.2. is the OID way of saying NET-SNMP-EXTEND-MIB::nsExtendOutLine.

 

The OID for my appdata share is then:

1.3.6.1.4.1.8072.1.3.2.4.1.2."sharefree".1

 

PRTG accepts this as an snmpcustomstringsensor

image.png.1f47d87375dfbf13e26fafc7606e96f0.png

 

In PRTG use the following to extract the numerical portion of the string:

image.png.2f25bafb29d22928f3ad8373db484ffd.png

 

What the sensor looks like:

image.thumb.png.b85f6b29d05e33f72792fd85cce61d3d.png

  • Thanks 1
Link to comment
  • 1 month later...

does anyone know how to get the distribution to report back 'Unraid' instead of linux Unraid?

 

I have librenms discovering my unraid server, but it detects it as Linux 5.10.28-Unraid, and LibreNMS then gives it a basic Linux Penguin Icon, and apparently, I need it just to return unraid 

 

This is a script they give you to put into /usr/bin and call it distro

 

Ive done this, made it executable, but it returns Slackware 14.2

 

#!/usr/bin/env bash
# Detects which OS and if it is Linux then it will detect which Linux Distribution.

OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`

if [ "${OS}" = "SunOS" ] ; then
  OS=Solaris
  ARCH=`uname -p`
  OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"

elif [ "${OS}" = "AIX" ] ; then
  OSSTR="${OS} `oslevel` (`oslevel -r`)"

elif [ "${OS}" = "Linux" ] ; then
  KERNEL=`uname -r`

  if [ -f /etc/fedora-release ]; then
    DIST=$(cat /etc/fedora-release | awk '{print $1}')
    REV=`cat /etc/fedora-release | sed s/.*release\ // | sed s/\ .*//`
        
  elif [ -f /etc/redhat-release ] ; then
    DIST=$(cat /etc/redhat-release | awk '{print $1}')
    if [ "${DIST}" = "CentOS" ]; then
      DIST="CentOS"
    elif [ "${DIST}" = "Mandriva" ]; then
      DIST="Mandriva"
      PSEUDONAME=`cat /etc/mandriva-release | sed s/.*\(// | sed s/\)//`
      REV=`cat /etc/mandriva-release | sed s/.*release\ // | sed s/\ .*//`
    elif [ -f /etc/oracle-release ]; then
      DIST="Oracle"
    else
      DIST="RedHat"
    fi

    PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
    REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`

  elif [ -f /etc/mandrake-release ] ; then
    DIST='Mandrake'
    PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
    REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`

  elif [ -f /etc/devuan_version ] ; then
    DIST="Devuan `cat /etc/devuan_version`"
    REV=""

  elif [ -f /etc/debian_version ] ; then
    DIST="Debian `cat /etc/debian_version`"
    REV=""
    ID=`lsb_release -i | awk -F ':' '{print $2}' | sed 's/	//g'`
    if [ "${ID}" = "Raspbian" ] ; then
      DIST="Raspbian `cat /etc/debian_version`"
    fi

  elif [ -f /etc/gentoo-release ] ; then
    DIST="Gentoo"
    REV=$(tr -d '[[:alpha:]]' </etc/gentoo-release | tr -d " ")

  elif [ -f /etc/arch-release ] ; then
    DIST="Arch Linux"
    REV="" # Omit version since Arch Linux uses rolling releases
    IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling"

  elif [ -f /etc/os-release ] ; then
    DIST=$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '"')
    REV=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '"')

  elif [ -f /etc/openwrt_version ] ; then
    DIST="OpenWrt"
    REV=$(cat /etc/openwrt_version)

  elif [ -f /etc/pld-release ] ; then
    DIST=$(cat /etc/pld-release)
    REV=""

  elif [ -f /etc/SuSE-release ] ; then
    DIST=$(echo SLES $(grep VERSION /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
    REV=$(echo SP$(grep PATCHLEVEL /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
  fi

  if [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then
    LSB_DIST=$(lsb_release -si)
    LSB_REV=$(lsb_release -sr)
    if [ "$LSB_DIST" != "" ] ; then
      DIST=$LSB_DIST
    fi
    if [ "$LSB_REV" != "" ] ; then
      REV=$LSB_REV
    fi
  fi

  if [ "`uname -a | awk '{print $(NF)}'`" = "DD-WRT" ] ; then
    DIST="dd-wrt"
  fi

  if [ -n "${REV}" ]
  then
    OSSTR="${DIST} ${REV}"
  else
    OSSTR="${DIST}"
  fi

elif [ "${OS}" = "Darwin" ] ; then
  if [ -f /usr/bin/sw_vers ] ; then
    OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '`
  fi

elif [ "${OS}" = "FreeBSD" ] ; then
  OSSTR=`/usr/bin/uname -mior`
fi

echo ${OSSTR}

 

Edited by rorton
Link to comment

I've been using the SNMP plugin in conjunction with LibreSNMP to monitor my UnRAID server. On Tuesday this week I got an alert that the UnRAID server was offline, which it wasn't. Eventually realised that the SNMP plugin had stopped responding. The only way I could get it to respond again was to remove it and reinstall it. Unfortunately this has become a daily event now mainly because I can't figure out what's causing it.

As there aren't others complaining about this I assume it's just me. But I haven't added as much as a docker container for ~4 weeks so nothing has changed recently that I can pinpoint and say "It must be that". Any suggestion on how to diagnose this?

Link to comment
Just now, stetho said:

I've been using the SNMP plugin in conjunction with LibreSNMP to monitor my UnRAID server. On Tuesday this week I got an alert that the UnRAID server was offline, which it wasn't. Eventually realised that the SNMP plugin had stopped responding. The only way I could get it to respond again was to remove it and reinstall it. Unfortunately this has become a daily event now mainly because I can't figure out what's causing it.

As there aren't others complaining about this I assume it's just me. But I haven't added as much as a docker container for ~4 weeks so nothing has changed recently that I can pinpoint and say "It must be that". Any suggestion on how to diagnose this?

My suggestions would be checking the logs (of course), also trying rebooting, or removing any SNMP-related files from your boot USB. You can also see if the SNMP service is still running when it "stops responding" and one other suggestion might be to call SNMP from Unraid itself (the install script does this so you can reference it for syntax)

One final suggestion is to remove the custom script extensions from the SNMP config so it's not checking disk temps and just reporting basic Linux stuff. Maybe something there is causing an issue, not sure. 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.