Does any one have a SNMP disk usage script for Linux ?

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
dbenders
Posts: 28
Joined: Mon Oct 14, 2002 2:02 pm
Location: Santiago, CHILE

Does any one have a SNMP disk usage script for Linux ?

Post by dbenders »

Does any one have a SNMP disk usage script for Linux ?
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

What about the simple one that comes with cacti in 'scripts/diskfree.pl'?

The newest cacti.sql file includes the data input as well, but in case you don't have it, here are the settings.

Name:

Code: Select all

Get Free Disk Space
Input String:

Code: Select all

perl <path_cacti>/scripts/diskfree.pl <partition>
Output String:

Code: Select all

<megabytes>:<percent>
Then define the following fields:

Name: Disk Partition
Data Name: partition
Input/Output: Input
Update RRA: No

Name: Megabytes Free
Data Name: megabytes
Input/Output: Output
Update RRA: Yes

Name: Percent Free
Data Name: percent
Input/Output: Output
Update RRA: No

-Ian
dbenders
Posts: 28
Joined: Mon Oct 14, 2002 2:02 pm
Location: Santiago, CHILE

Thanks IAN, but I'm looking for an SNMP version....

Post by dbenders »

It looks like you are talking about a local disk usage.

If not, where you define the SNMP Community in this script?
sayasif
Posts: 24
Joined: Thu Sep 12, 2002 12:28 am
Location: India

Post by sayasif »

hi

you can use the snmpdf -c communitystring ip to get the disk space, real memory and swap. Now you need a script to catch the values of the output. So you gotta write one or let me know if you require the script that I have written.


ACE
ONE MORE DAY WASTED !
BSDeality
Posts: 35
Joined: Tue Oct 08, 2002 7:56 am
Location: Connecticut
Contact:

Post by BSDeality »

I'd be interested in see the script, i'm relatively new to cacti and snmp monitoring, so i'd like to see an example of the snmp disk monitoring if possible.
[url=http://geekfort.com/cacti/graph_view.php?action=tree]Geekfort.com/cacti[/url]
bocasman
Posts: 24
Joined: Mon Aug 19, 2002 8:27 am
Location: Panama
Contact:

Post by bocasman »

Hi dbenders,

I don't have an specific script for plot swap, real mem and disk space, but I have two separate ones to monitor swap and real mem.

Idea stolen from Gilson :wink: , BTW thanks again Gilson!

these are the scripts:


For RAM:

Code: Select all

#!/bin/sh
  memTotalReal=`$1 -Ont $2 $3 .1.3.6.1.4.1.2021.4.5.0|cut -d" " -f3`
  memAvailReal=`$1 -Ont $2 $3 .1.3.6.1.4.1.2021.4.6.0|cut -d" " -f3`
let  "memUsedReal=$memTotalReal-$memAvailReal"

echo $memTotalReal $memUsedReal $memAvailReal
For SWAP:

Code: Select all

#!/bin/sh
  memTotalSwap=`$1 -Ont $2 $3 .1.3.6.1.4.1.2021.4.3.0|cut -d" " -f3`
  memAvailSwap=`$1 -Ont $2 $3 .1.3.6.1.4.1.2021.4.4.0|cut -d" " -f3`
let  "memUsedSwap=$memTotalSwap-$memAvailSwap"

echo $memTotalSwap $memUsedSwap $memAvailSwap
Remember that these scripts are for linux pc's!

With this two scrits in your server all what you have to do is fallow the instrctions tha Gilson have post in http://www.raxnet.net/board/viewtopic.php?t=622

Only keep in mind that the output of these scripts gona be:
TotalMem UsedMem AvailableMem
Any way, if you need any more help, only ask for it!
Regards,
BM
dbenders
Posts: 28
Joined: Mon Oct 14, 2002 2:02 pm
Location: Santiago, CHILE

Script wanted to monitor RAM and Disk usage

Post by dbenders »

Hi sayasif,

Can you please post here the script you have written, that way I will save some time or learn another way to do the same, always is good to see new scripts from others.

Thanks for you TIP.

:wink:
dbenders
Posts: 28
Joined: Mon Oct 14, 2002 2:02 pm
Location: Santiago, CHILE

Problem doing the command directly

Post by dbenders »

Hi bocasman,

I just tried to run the command directly, but I get only a -1 value:

Code: Select all

shell# /usr/bin/snmpget -Ont myhost mysnmpcomunity .1.3.6.1.4.1.2021.4.5.0
shell# .1.3.6.1.4.1.2021.4.5.0 = -1
Same with the OID .1.3.6.1.4.1.2021.4.6.0

Any idea what is wrong?

Maybe the UCD-SNMP version???

mine are:

[root@host]# rpm -qa|grep snmp
ucd-snmp-4.2.5-7.73.0
ucd-snmp-utils-4.2.5-7.73.0
ucd-snmp-devel-4.2.5-7.73.0
php-snmp-4.1.2-7
Guest

Post by Guest »

I'm running NET-SNMP version: 5.0.6, and configured the OID's for diskspace in the snmpd:

Code: Select all

disk / 10000

# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.9
 enterprises.ucdavis.diskTable.dskEntry.diskIndex.1 = 0
 enterprises.ucdavis.diskTable.dskEntry.diskPath.1 = "/" Hex: 2F
 enterprises.ucdavis.diskTable.dskEntry.diskDevice.1 = "/dev/hda1"
 enterprises.ucdavis.diskTable.dskEntry.diskMinimum.1 = 10000
 enterprises.ucdavis.diskTable.dskEntry.diskTotal.1 = 837130
 enterprises.ucdavis.diskTable.dskEntry.diskAvail.1 = 316325
 enterprises.ucdavis.diskTable.dskEntry.diskUsed.1 = 437092
 enterprises.ucdavis.diskTable.dskEntry.diskPercent.1 = 58
 enterprises.ucdavis.diskTable.dskEntry.diskErrorFlag.1 = 0
 enterprises.ucdavis.diskTable.dskEntry.diskErrorMsg.1 = ""
http://hobbes.sa-char.net/cacti/graph.p ... &rraid=all


although it returns a NAN value for used diskspace, don't know why that is.
agismaniax
Posts: 5
Joined: Mon Jul 19, 2004 4:11 am
Contact:

Post by agismaniax »

Try this:

1. Choose your device
2. Associated Data Queries -> SNMP - Get Mounted Partitions
3. Associated Graph Templates -> Host MIB - Available Disk Space
4. Create Graphs for this Host
5. Choose your disk partition

This is work for Windows and Linux.

Hope this help...
melchandra
Cacti User
Posts: 311
Joined: Tue Jun 29, 2004 12:52 pm
Location: Indiana

Post by melchandra »

It was VERY easy for me. Use "snmpconf -g basic_setup". This will create a snmpd.conf file for you. You can specify partitions you want to monitor, usernames, passwords... it's very easy to use (i.e. I got through it without reading any documentation, first time through) The net-snmp daemon will use the host MIB which gives all sorts of information about disk partitions among other things.
Dave
Wunk
Posts: 37
Joined: Fri Mar 05, 2004 8:34 am
Contact:

Post by Wunk »

Generic setup for an snmpd.conf is to start with a blank.., and put in the following:

rocommunity putapasswordhere
disk / 10000
disk /tmp 10000


That's it.., it'll let you monitor Processor, memory, interfaces, the above mentioned disk partitions (add the ones you need) and load..
Jeroen Wunnink
Easyhosting.nl Sysadmin
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests