Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mrtg disk usage incorrect
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
servermonk
Apprentice
Apprentice


Joined: 07 Nov 2003
Posts: 182
Location: MI

PostPosted: Thu Nov 27, 2003 2:39 am    Post subject: mrtg disk usage incorrect Reply with quote

I've run into several people having trouble getting snmp/mrtg to report the correct disk usage. I came across this fix and didn't see it documented here anywhere so I thought I'd share it:

Problem: snmp queries hrStorageSize.X or hrStorageUsed.X for the current disk data and reports a value exactly 4 times LESS than it's supposed to be.

Reason: Beat's me. If anyone knows the reason behind this odd behavior I'd love to hear it.

Fix: In your mrtg config for the disk usage query that could/should/probably look something like this:

Code:

LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
WorkDir: /full/server/path/to/mrtg
Target[localhost.disk]: hrStorageSize.2&hrStorageUsed.2:communityname@localhost
MaxBytes[localhost.disk]: 200000000000
Title[localhost.disk]: Disk /diskname
PageTop[localhost.disk]: <H1>Disk /diskname</H1>
ShortLegend[localhost.disk]: B
kMG[localhost.disk]: k,M,G,T,P
kilo[localhost.disk]: 1024
YLegend[localhost.disk]: DISK /diskname Utilization
Legend1[localhost.disk]: Disk size
Legend2[localhost.disk]: Disk usage
Legend3[localhost.disk]:
Legend4[localhost.disk]:
LegendI[localhost.disk]: Disk size
LegendO[localhost.disk]: Disk usage
Options[localhost.disk]: growright,gauge,nopercent



Change this line:
Code:

Target[localhost.disk]: hrStorageSize.2&hrStorageUsed.2:communityname@localhost


To this:
Code:

Target[localhost.disk]: hrStorageSize.2&hrStorageUsed.2:communityname@localhost * 4


Note the * 4 at the end to multiply the result of the output by 4.
Please note that the hrStorageSize.X and hrStorageUsed.X statements should have the X changed to whatever disk is being queried. To find the right ones do this:
Code:

snmpwalk -v 2c -c communityname localhost hrStorageDescr



I hope this info helps someone else as much as it helped me :)
_________________
Gentoo makes me wanna shoop.
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Fri Nov 28, 2003 8:53 am    Post subject: Reply with quote

Try also:

Code:

/usr/bin/snmpdf -v 2c -c public localhost


khazad-dum
Back to top
View user's profile Send private message
PoLiPiE
n00b
n00b


Joined: 25 May 2003
Posts: 15
Location: www.pckliniek.be

PostPosted: Sat Dec 06, 2003 12:58 pm    Post subject: Reply with quote

yeah , tnx man , now it works like a charm

i fixed it by doing all the drivers * 4

Check it out :)

tnx khazad-dum and servermonk for the information :)
_________________
www.pckliniek.be
Back to top
View user's profile Send private message
nglrossi
n00b
n00b


Joined: 26 Apr 2003
Posts: 25
Location: Ireland/Italy

PostPosted: Fri May 21, 2004 4:09 pm    Post subject: Re: mrtg disk usage incorrect Reply with quote

servermonk wrote:


Reason: Beat's me. If anyone knows the reason behind this odd behavior I'd love to hear it.


The reason: not every filesystem is reported as 1024 bs..
Code:

host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageAllocationUnits.1 = 4096 Bytes
host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageAllocationUnits.2 = 4096 Bytes
host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageAllocationUnits.3 = 1024 Bytes
host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageAllocationUnits.4 = 4096 Bytes
host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageAllocationUnits.5 = 4096 Bytes


Thank you for the solution ;)
Back to top
View user's profile Send private message
Thisp
n00b
n00b


Joined: 29 Jul 2006
Posts: 46

PostPosted: Tue Aug 08, 2006 8:33 am    Post subject: Reply with quote

I tried this with the mrtg guide here, I substituted ping for disk and used this as the disk.cfg. I changed the workdir to my workdir, and I can't for the life of me get this to even show up on my mrtg page. How would I fix this? Nothing I find on google helps me setup mrtg to monitor disk space.
Back to top
View user's profile Send private message
jkroon
Tux's lil' helper
Tux's lil' helper


Joined: 15 Oct 2003
Posts: 110
Location: South Africa

PostPosted: Mon Aug 14, 2006 5:04 am    Post subject: Reply with quote

Well, not all partitions needs to be multiplied by 4. The following script generates a config that works correctly for all storage devices:

Code:
snmpwalk -Os -c public -v 2c localhost hrStorageDescr |
        sed -nre 's,hrStorageDescr.([0-9]*) = STRING: (.*),\1 \2,p' |
        grep -Ev ' /(proc|sys)($|/)' |
        while read NM DESC; do
                IDENT="stor_$(echo "${DESC}" | tr '[A-Z]/ ' '[a-z]:_')"

                echo "Target[${IDENT}]: hrStorageUsed.${NM}&hrStorageSize.${NM}:public@localhost * hrStorageAllocationUnits.${NM}&hrStorageAllocationUnits.${NM}:public@localhost"
                echo "Title[${IDENT}]: Storage: ${DESC}"
                echo "Kilo[${IDENT}]: 1024"
                echo "MaxBytes[${IDENT}]: 1099511627776"
                echo "ShortLegend[${IDENT}]: iB"
                echo "YLegend[${IDENT}]: Bytes"
                echo "Legend1[${IDENT}]: Used Storage"
                echo "Legend2[${IDENT}]: Total Storage"
                echo "LegendI[${IDENT}]: Used:"
                echo "LegendO[${IDENT}]: Total:"
                echo "Options[${IDENT}]: gauge"
        done > ${storconf}


Then storconf just needs to be "Include: ..."ed from your main mrtg file. Oh, the MaxBytes values == 1TB, so if you have storage devices that is bigger than that you'll need to adjust that value. The reason for manually lower-casing the DESC variable when creating the IDENT is because the files generated by mrtg is lowercased and I later on copy and otherwise manipulate the generated files to be able to include them into my php files. You should also note that I have the following config options in my main config file:

Code:
WorkDir: /var/lib/mrtg

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
Forks: 4

Extension[_]: php
PageTop[_]: \n<!-- PAGE TOP -->\n
PageFoot[_]: \n<!-- PAGE FOOT -->\n

Options[^]: growright,unknaszero,nopercent
#Suppress[_]: ym
RouterUptime[_]: public@localhost


A possible idea is to actually calculate MaxBytes from the script using the values that can be obtained from snmp (aka: To actual storage sizes) after which you can actually remove nopercent from the Options after which mrtg will calculate the storage usage in % in addition to simply stating the amount used.
--
EDIT: Added legends to script and fixed a couple of typos.
_________________
There are 10 kinds of people in the world,
those who understand binary and who don't
Back to top
View user's profile Send private message
sleepingsun
Guru
Guru


Joined: 03 May 2006
Posts: 382
Location: Bosnia

PostPosted: Sat Aug 02, 2008 7:54 pm    Post subject: Reply with quote

Thanks this is great !
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum