[Plug-In] SNMP


Recommended Posts

Working backwards:

 

 

If that works, you can try restarting snmpd:

 

That seems to work fine:

 

root@OshTank:~# bash /etc/rc.d/rc.snmpd stop
Shutting down snmpd: . DONE
root@OshTank:~# bash /etc/rc.d/rc.snmpd start
Starting snmpd:  /usr/sbin/snmpd -LF w /var/log/snmpd.log -LF w /var/log/snmpd.log -A -p /var/run/snmpd -a -c /usr/local/emhttp/plugins/snmp/snmpd.conf
root@OshTank:~# 

 

It doesn't find the disk temp stuff if I run it manually:

 

root@OshTank:~# !snmpwalk
snmpwalk -v 2c localhost -c public 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp"'
NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp" = No Such Instance currently exists at this OID
root@OshTank:~# 

 

Well, is the config file updated properly?

 

It looks like you are trying to execute the whole statement below as a single command, but that didn't work for me:

 

root@OshTank:~# 
root@OshTank:~#  tail -n 1 /usr/local/emhttp/plugins/snmp/snmpd.conf extend disktemp /usr/local/emhttp/plugins/snmp/drive_temps.sh
==> /usr/local/emhttp/plugins/snmp/snmpd.conf <==
disk /mnt/cache
tail: cannot open ‘extend’ for reading: No such file or directory
tail: cannot open ‘disktemp’ for reading: No such file or directory

==> /usr/local/emhttp/plugins/snmp/drive_temps.sh <==
exit 0
root@OshTank:~# 

 

 

 

Here is some other stuff that might be useful:

 

root@OshTank:/usr/local/emhttp/plugins/snmp# more snmpd.conf 
rocommunity public
syslocation Here
syscontact root@tower
disk /mnt/disk1
disk /mnt/disk2
disk /mnt/disk3
disk /mnt/disk4
disk /mnt/disk5
disk /mnt/disk6
disk /mnt/disk7
disk /mnt/disk8
disk /mnt/disk9
disk /mnt/disk10
disk /mnt/disk11
disk /mnt/disk12
disk /mnt/disk13
disk /mnt/disk14
disk /mnt/disk15
disk /mnt/disk16
disk /mnt/disk17
disk /mnt/disk18
disk /mnt/disk19
disk /mnt/disk20
disk /mnt/cache
root@OshTank:/usr/local/emhttp/plugins/snmp# 

 

root@OshTank:/usr/local/emhttp/plugins/snmp# 
root@OshTank:/usr/local/emhttp/plugins/snmp# cat drive_temps.sh 
#!/usr/bin/bash

MDCMD=/root/mdcmd
AWK=/usr/bin/awk
CAT=/usr/bin/cat
FIND=/usr/bin/find
GREP=/usr/bin/grep
RM=/usr/bin/rm
SED=/usr/bin/sed
HDPARM=/usr/sbin/hdparm
SMARTCTL=/usr/sbin/smartctl

CACHE=/tmp/plugins/snmp/drive_temps.txt

mkdir -p $(dirname $CACHE)

# Cache the results for 5 minutes at a time, to speed up queries
if $FIND $(dirname $CACHE) -mmin -5 -name drive_temps.txt | $GREP -q drive_temps.txt
then
  $CAT $CACHE
  exit 0
fi

$RM -f $CACHE

$MDCMD status | $GREP '\(rdevId\|rdevName\).*=.' | while read -r device
do
  read -r name

  # Double-check the data to make sure it's in sync
  device_num=$(echo $device | $SED 's#.*\.\(.*\)=.*#\1#')
  name_num=$(echo $name | $SED 's#.*\.\(.*\)=.*#\1#')

  if [[ "$device_num" != "$name_num" ]]
  then
    echo 'ERROR! Couldn'"'"'t parse mdcmd output. Command was:'
    echo 'mdcmd status | $GREP '"'"'\(rdevId\|rdevName\).*=.'"'"' | while read -r device'
  fi

  device=$(echo $device | $SED 's#.*=#/dev/#')
  name=$(echo $name | $SED 's/.*=//')

  if ! $HDPARM -C $device 2>&1 | $GREP -cq standby
  then
    temp=$($SMARTCTL -A $device | $GREP -m 1 -i Temperature_Celsius | $AWK '{print $10}')
  fi

  # For debugging
#  echo "$name = $device, $temp"

  echo "$name: $temp" >> $CACHE
done

$CAT $CACHE
exit 0
root@OshTank:/usr/local/emhttp/plugins/snmp# 

 

Thanks for your help!

 

John

Link to comment

Hi coppit, thanks for working on this. May I also point you to the unraid changes fro upcoming 6.1 version:

http://lime-technology.com/forum/index.php?topic=42259.0;topicseen

So as a workaround, I could use, what was mentioned in the unmenu thread:

ln -s /usr/local/sbin/mdcmd /root

(otherwise, the scripts won't find mdcmd), but finally, the plugin should be adapted to use the new script locations.

when manually executing the drive_temps.sh script I also get a list of the drives with "<drive>:", but no temps - smartctrl does output them ok. When I change the temp grabbing to "unconditional", it works:

Instead of

  if ! $HDPARM -C $device 2>&1 | $GREP -cq standby
  then
    temp=$($SMARTCTL -A $device | $GREP -m 1 -i Temperature_Celsius | $AWK '{print $10}')
  fi

just using

   temp=$($SMARTCTL -A $device | $GREP -m 1 -i Temperature_Celsius | $AWK '{print $10}')

Nice thing is, that the temps are read even if hdparm -C reports the drive being in standby (without spinning up the drive).

 

Link to comment

Well, is the config file updated properly?

 

It looks like you are trying to execute the whole statement below as a single command

 

No, the "extend disktemp" was on the next line, and was the output of the "tail -n 1 /usr/local/emhttp/plugins/snmp/snmpd.conf" command. But you provided the content of the file later, which shows the problem:

 

root@OshTank:/usr/local/emhttp/plugins/snmp# more snmpd.conf 
rocommunity public
syslocation Here
syscontact root@tower
disk /mnt/disk1
disk /mnt/disk2
disk /mnt/disk3
disk /mnt/disk4
disk /mnt/disk5
disk /mnt/disk6
disk /mnt/disk7
disk /mnt/disk8
disk /mnt/disk9
disk /mnt/disk10
disk /mnt/disk11
disk /mnt/disk12
disk /mnt/disk13
disk /mnt/disk14
disk /mnt/disk15
disk /mnt/disk16
disk /mnt/disk17
disk /mnt/disk18
disk /mnt/disk19
disk /mnt/disk20
disk /mnt/cache
root@OshTank:/usr/local/emhttp/plugins/snmp# 

 

This is wrong. This file is not being overwritten like it should be. The last line should be:

 

extend disktemp /usr/local/emhttp/plugins/snmp/drive_temps.sh

 

The fix is to just delete the file and reinstall the plugin, or just reboot your server. I'm not sure why it's not working for you... On my system this file gets properly overwritten when I install the plugin.

 

You could check permissions:

 

ls -l /usr/local/emhttp/plugins/snmp/snmpd.conf

 

It should be "-rw-rw-rw".

Link to comment

no temps - smartctrl does output them ok. When I change the temp grabbing to "unconditional", it works

 

Thanks. It will be in the next release.

 

Is it possible to get it to report the user folder or even individual shares as a drive.

 

I guess you're looking for size? I suppose I could write a custom script like I did for the drive temps. Disk size is easy because query it is relatively fast.

 

Looking at the unraid GUI, there's a "free" column next to the shares. It looks like that data comes from /var/local/emhttp/shares.ini, perhaps updated every few minutes by unraid. That would be easy. Would that work for you? If so, I need some recommendation on where the data should end up. Can I just "extend" something like I did for disk temps?

 

Unfortunately computing the size is hard. That requires walking the whole tree, which for a big share could take several minutes.

 

The other complexity is that you'll probably want a UI to configure which folders to monitor. This is a part of plugin design that I haven't waded into yet.

 

Worse case scenario, I would be ok with all my disk's showing. right now its only tracking Log, boot and libvirt

Link to comment

Is it possible to get it to report the user folder or even individual shares as a drive.

 

I guess you're looking for size? I suppose I could write a custom script like I did for the drive temps. Disk size is easy because query it is relatively fast.

 

Looking at the unraid GUI, there's a "free" column next to the shares. It looks like that data comes from /var/local/emhttp/shares.ini, perhaps updated every few minutes by unraid. That would be easy. Would that work for you? If so, I need some recommendation on where the data should end up. Can I just "extend" something like I did for disk temps?

 

Unfortunately computing the size is hard. That requires walking the whole tree, which for a big share could take several minutes.

 

The other complexity is that you'll probably want a UI to configure which folders to monitor. This is a part of plugin design that I haven't waded into yet.

 

Worse case scenario, I would be ok with all my disk's showing. right now its only tracking Log, boot and libvirt

 

Thanks for the reply. The free space available from the shares.ini is just fine. I would love that.

Link to comment

Okay! Free space for shares is now reported by snmp:

 

$ snmpwalk -v 2c localhost -c public 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree"'
NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree".1 = STRING: Backups: 903213694976
NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree".2 = STRING: Media: 2453300314112
NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree".3 = STRING: Other: 3251798876160
NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree".4 = STRING: TimeMachine-old: 3251798876160
NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree".5 = STRING: temp: 104715132928

 

I still don't know how to get observium to display this data though. Help would be appreciated.

Link to comment

The fix is to just delete the file and reinstall the plugin, or just reboot your server. I'm not sure why it's not working for you... On my system this file gets properly overwritten when I install the plugin.

 

I tried just deleting and re-installing the plug-in, and behavior didn't change.  I did check permissions and they were set as you suggested.

 

I then deleted the SNMP plug-in, upgraded from 6.01 to 6.1, and re-installed the plug-in and now it works!

 

+==============================================================================
| Testing SNMP by listing mounts
+==============================================================================
Looks like snmpd is working... Output:
HOST-RESOURCES-MIB::hrFSMountPoint.22 = STRING: "/var/log"
HOST-RESOURCES-MIB::hrFSMountPoint.25 = STRING: "/boot"

Here's what drive temperatures look like:
snmpwalk -v 2c localhost -c public NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp"
NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".1 = STRING: WDC_WD20EFRX-68EUZN0_WD-WCC4M0927675: 28
NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".2 = STRING: WDC_WD20EFRX-68EUZN0_WD-WCC4M4PJF00N: 29
NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".3 = STRING: WDC_WD20EFRX-68EUZN0_WD-WCC4M3PHD4DE: 29
NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".4 = STRING: WDC_WD20EFRX-68EUZN0_WD-WCC4M0072449: 27

Here's what share free space looks like:
snmpwalk -v 2c localhost -c public NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree"
NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree".1 = STRING: 

 

 

Thanks,

 

John

 

Link to comment

Timeout: No Response from localhost

 

Yeah, I was worried about that. The removal of the "if" condition suggested by Guzzi has the side effect of the script taking too long to run.

 

I'll have to think about how to fix it.

That's probably caused by harddisks, that do not support reading temps when spun down !?

Maybe have a look at how it is solved in myMain - there I do get temps even when HDs are spun down, but seems, that those scripts do handle also other brands of disks that do not support temps when spun down ...

Link to comment

Hi,

 

Not sure if anyone else is having this issue. I am using librenms, which is apparently a fork of observium. The plugin works to get snmp installed and all stats seem to be okay with the exception of ram usage.

 

When looking at my ram usage it shows 99% used. From what I can tell, it is reporting the used ram + the cached ram, which in unRAID is essentially always maxed out. But the reality is that what I, and I assume most of us want to see is the used ram only.

 

Is anyone else experiencing this? Does anyone have a work around?

 

Thanks,

Ric

Link to comment
  • 1 month later...
The removal of the "if" condition suggested by Guzzi has the side effect of the script taking too long to run.

 

I'm now computing the temps in the background. So the initial call shouldn't time out. It won't have any data, but the next call should. Let me know how that works for you.

 

Maybe have a look at how it is solved in myMain - there I do get temps even when HDs are spun down, but seems, that those scripts do handle also other brands of disks that do not support temps when spun down ...

 

I assume you mean this implementation? It looks like the code computes the drive manufacturer and uses that along with a user-configurable setting to determine whether to get the temps or not.

 

I haven't seen my implementation spin up drives, so as long as the workaround above works, I think we're okay. But I concede that I may need to adapt the myMain code, before we can declare this done.

 

When looking at my ram usage it shows 99% used. From what I can tell, it is reporting the used ram + the cached ram, which in unRAID is essentially always maxed out.

 

Linux will use remaining space for file buffers and file cache. I don't think that's an unRAID behavior per se. Anyway, when I look in observium, it's reporting separately the used, buffers, cached, and free memory. Maybe it's a librenms problem?

Link to comment

Greetings,

 

Just downloaded the update.  It looks good except this error in your test display area:

 

Here's what share free space looks like:
snmpwalk -v 2c localhost -c public NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree"
NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree".1 = STRING: /usr/local/emhttp/plugins/snmp/share_free_space.sh: line 16: allocator=\"mostfree\" * 1024: syntax error: operand expected (error token is \"\"mostfree\" * 1024\")

 

Thanks!

Link to comment
  • 1 month later...

This might be unique to me but i found the installer installed everything but continually fails to properly start SNMP for me.

 

First thing i did was i modified the .plg package to put my unique community name, location and contact into in. The standard is public, here ,nobody or something like that.

 

Then i install the plugin pointing to the plg i just modified so i get my correct info i want into SNMP.

 

Next i found that RC.SNMP (/etc/rc.d) did not have the same permissions on it as other files. So i entered

chmod 755 rc.snmp

This now gave SNMP same permissions as other things running, which makes sense to me

from within rc.d i entered the below to start the service

./rc.snmp start

Now go into Observium and search for your IP of your unraid with the community string, i think it's v2 community from memory and it should come up.

 

This is what works from me. Either my unraid is broken some way (possibly) or there is something funky with the installer (Not throwing stones the plg is great) But yeah some stuff around to make it work :-)

 

 

Link to comment
  • 2 weeks later...

 

I still don't know how to get observium to display this data though. Help would be appreciated.

 

Hi. Just stumbled onto this plugin and got done reading this thread and have seen you ask for help on this a few times in it.  I've got an answer for you but I don't think you're going to like it...  I use other SNMP products in my day job so I'm not super familiar with Observium but I found all this in 20 minutes of googling.  I may have the particulars wrong but this is the basic gist.

 

The short answer is it'd take a hell of a lot.  http://postman.memetic.org/pipermail/observium/2015-January/009184.html is basically a statement on the "design ethos" of Observium.  What it boils down to is instead of being a buildable framework like other SNMP monitoring tools they'd rather have each monitorable node be a well defined package.  This means no throwing random OIDs at the software and having it graph a la MRTG, PRTG, Cactii, Solarwinds, whatever the kids are using these days.  It has to be a known, supported piece of hardware that's coded up specific for it.  Pretty brain dead in my opinion but whatever, it's their software. 

 

It can be done, http://www.maartenmoerman.nl/?p=649, tells you how to do custom OIDs in Observium... If you have the paid version.  So I guess they came around.  But only if you're paying for the software. 

 

The docker is the CE version which is basically the stripped down freeware version and for that, they only support modules that have been written by them and apparently it's an uphill battle to submit code that wasn't written by them.  I'll keep the bashing to a minimum but if you google a bit you'll see...  Yeah... I'll just leave it there.

 

It's really a shame because you guys have done AMAZING work getting things that matter to Unraid users into OIDs that we can monitor but I doubt they'll be added to Observium.  There are other options out there that may be more suited.  None of which appear to have a docker available at the moment.  Cactii or, even better, librenms(an Observium fork with an Observium migration script!) would probably be a better suited docker for our community.

Link to comment
  • 3 weeks later...

Is there a way to change the snmp community instead of the default "public"?

 

I'm guessing the only way is to edit the following line in the snmp.plg?

 

<!ENTITY community  "public">

<!ENTITY location    "Here">

<!ENTITY contact    "root@tower">

 

Solved: Followed instructions on a previous post. Thanks!

Link to comment

You need a DNS somewhere in your network to resolve "tower" to corresponding IP address.

There is usually a simple DNS in a router provided by ISP.

 

From my experience with Docker it is not enough to use /etc/hosts on a machine hosting dockers (unraid in your case). There are some tricks to pass that /etc/hosts to docker, but easiest way is to use your own DNS either running on a router or on some server.

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.