Custom disk space script

Hi im new to the forum and relatively new to using Dude as well. I have read the probe thread but im needing something specific to cover us with a variety of different server setups.

I want to create a custom script which from the smtp.conf file says is possible and I am indeed getting the response Im looking for when running the snmpwalk command :

snmpwalk -v 3 -u snmp_user -a md5 -A XXXXXX -l AuthPriv -x DES -X XXXXXX 1.1.1.1 UCD-SNMP-MIB::extResult.1
UCD-SNMP-MIB::extResult.1 = INTEGER: 35

I have put the script in the /etc/snmp/snmpd.conf :

exec snmp_diskspace /bin/bash /usr/local/bin/snmp_diskspace.bash

And as I say I can run the snmpwalk command manually fine and get the expected result so I dont think Im facing an smtp issue.

My issue is getting Dude to pick up the value and ascertain if the service is available or not. Firstly the script is just a basic disk space check looking for percentage used. However I didnt want to use the predefined OIDs as im running on a network with 150+ servers and the mount points (therefore ids) are different across each server.

Therefore to keep things very simple my script checks ALL filesystems (just a simple df -k) and reports the highest space used which I then want to use as the trigger.

My function in dude states this :

oid(“UCD-SNMP-MIB::extResult.1”)

Which if I run it manually from the Dude server it replies perfectly with the percentage im after.

The probe ive set it to use says :

Agent : Default
Available : highest_diskspace() < 80
Error : if (highest_diskspace() > 80, “”, “down”)
Value : highest_diskspace()
Unit : %

I have set up the service in one of the servers im testing this with which all works fine manually, but if I click reprobe or wait for its polling interval it always says ‘down’

I think thats all the config I have set up but if I missed something important let me know and I will reply to this post.

The only things im a bit uncertain on are :

  1. the probe available/error syntax
  2. From the oid im using (oid(“UCD-SNMP-MIB::extResult.1”) should I be using the exit code/result, or simply make the script echo the value and exit with a 0

Look forward to hearing from someone with some skills in this !!!

Thanks

UPDATE :
Just to add as it seems that its Dude not recognising the snmp poll as i can run it manually from the server fine, I have just checked and added the specific MIB file (UCD-SNMP-MIB) into Dude. However it hasnt fixed my issue.

Any help appreciated !!

Are you using the execute function to run a script? If so you can troubleshoot by placing your execute on a device label to see which result you are actually getting.

I have managed to get around this (almost) using a different method, but it would still be good to get this way working as well as it might be useful for other things...

I have added the following in the /etc/snmp/snmp.conf file on the server I wish to run it on :

exec snmp_diskspace /bin/bash /usr/local/bin/snmp_diskspace.bash

Which then the notes in the conf file suggests I should be able to refer to each of the following oids :

% snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.8

enterprises.ucdavis.extTable.extEntry.extIndex.1 = 2

enterprises.ucdavis.extTable.extEntry.extNames.1 = "shelltest"

enterprises.ucdavis.extTable.extEntry.extCommand.1 = "/bin/sh /tmp/shtest"

enterprises.ucdavis.extTable.extEntry.extResult.1 = 35

enterprises.ucdavis.extTable.extEntry.extOutput.1 = "hello world."

enterprises.ucdavis.extTable.extEntry.extErrFix.1 = 0

As I say it works fine if I run it manually on the server, and on the dude server command line, just not in Dude itself

Im not sure how you mean 'by placing your execute on a device label' to troubleshoot it??

As I say ive managed to get round this particular one in a way that is ok but not perfect... I decided to use the 'max' function to look at a branch and tell me the highest disk space used percentage across all filesystems. That works fine, but my slight issue is I am unable to get the index of the said value in order to display '/xxxx is 80%'. Ive tried all of the array functions and find functions but cant find any that will look down a branch at various elements to look for a specific number and return me the index id

To clarify…

For example right click on a device, select appearance click the down arrow across from label.
In the label add this:
[oid(“1.3.6.1.2.1.1.4.0”)] <-That should put the system contact on the appearance of the device.

To execute a command in windows put this on a device label:
[execute(“test.bat”,1,“c:\”)] <-I thought make this work in linux to prove the function works. Note: This works in windows.
[execute(“snmp thing”,1,"\usr\local")] ← never tried this on a label.
Note: Returns 1st result.

Make a function that executes the script, Place that on a device label. Once you get the label to show correctly then make a probe that calls the function which will do the compare on the error line.

Note: I don’t think the dude understands this; oid(“UCD-SNMP-MIB::extResult.1”) therefore syntax error.

HTH,
Lebowski

ok thanks i understand what you mean now! will give it a go when i get a chance and let you know

I did the following… Created 24 functions and 12 probes… Disk31xxxx through Disk42xxxx. Incrementing oids as needed. Disks are such a pain to monitor!!!

function: disk31name oid(“1.3.6.1.2.1.25.2.3.1.3.31” ,10,5)
function: disk31test if(array_size(oid_column(“1.3.6.1.2.1.25.2.3.1.6”,10,5)),round((oid(“1.3.6.1.2.1.25.2.3.1.6.31”,10,5)/oid(“1.3.6.1.2.1.25.2.3.1.5.31”,10,5))*100),“False”)

Probe: Centosdisk31
available: disk31test()<>“False”
error: if(disk31test()<>“False”,if(disk31test() < 90, “”, concatenate("Warning: ", disk31name(), “is “, disk31test(),”%”)), “Failed read 1st disk”)
value: disk31test()
graph: %

Note: The if inside an if on the error line of the probe and the function generating “False” if the function can’t read the OID therefore the function probe combo work together. Also note that if your disk is 0% utilization it will generate a false positive which you can solve by adding 1 in the function and subtracting 1 in the probe.

Please share if you get it working!
Lebowski