[rrd-users] multiple stack graph

Simon Hobson linux at thehobsons.co.uk
Mon Aug 23 11:15:38 CEST 2010


James Nunnerley wrote:
>I've just added a second disk to one of the servers I monitor, and 
>would like to show the disk usage on both disks.  The existing graph 
>shows % usage in a stack (i.e. used and avail), so I thought to show 
>both, I could keep the existing stack, and make the second in a 
>negative form - i.e. so they are either side of the axis... I've put 
>it together, but can't work out why it isn't working...

That should work, but it might help just a teensie bit if you gave 
some clue as to the meaning of "not working" ! Does it mean you get a 
plot but it doesn't look like you expect, or nothing happens, or you 
get an error, or ... ?


>/usr/bin/rrdtool graph /var/www/graphs/192.168.43.254.disk-day.png 
>-s -1day -a PNG -i -z --alt-y-grid -h 125 -l 0 -u 100 -r \
>--color SHADEA#EAE9EE --color SHADEB#EAE9EE --color BACK#EAE9EE 
>--vertical-label "partition used %" -t "Disk usage" -b 1024 \
>DEF:used1=/etc/rrdtool/192.168.43.254.disk.rrd:used:AVERAGE 
>DEF:avail1=/etc/rrdtool/192.168.43.254.disk.rrd:avail:AVERAGE \
>DEF:used2=/etc/rrdtool/192.168.43.254.disk1.rrd:used:AVERAGE 
>DEF:avail2=/etc/rrdtool/192.168.43.254.disk1.rrd:avail:AVERAGE \
>CDEF:total1=used1,avail1,+ CDEF:usedpct1=100,used1,total1,/,* 
>CDEF:availpct1=100,avail1,total1,/,* AREA:usedpct1#4169E1:"used 
>disk" \
>STACK:availpct1#32CD32:"free disk"\\j CDEF:MBavail1=avail1,1048576,* 
>CDEF:MBused1=used1,1048576,* CDEF:MBtotal1=total1,1048576,* \
>CDEF:total2=used2,avail2,+ CDEF:usedpct2=100,used2,total2,/,* 
>CDEF:availpct2=100,avail2,total2,/,* CDEF:usedpct2neg=0,usedpct2,- \
>CDEF:availpct2neg=0,availpct2,- AREA:usedpct2neg#4169E1:"used disk" 
>STACK:availpct2neg#32CD32:"free disk"\\j \
>CDEF:MBavail2=avail2,1048576,* CDEF:MBused2=used2,1048576,* 
>CDEF:MBtotal2=total2,1048576,* \
>GPRINT:MBavail1:LAST:"free disk\\: %3.2lf%Sb" 
>GPRINT:MBused1:LAST:"used disk\\: %3.2lf%Sb" 
>GPRINT:MBtotal1:LAST:"total disk\\: %3.2lf%Sb"\\j \
>GPRINT:usedpct1:MAX:"maximal used disk\\:%3.2lf%%" 
>GPRINT:usedpct1:AVERAGE:"average used disk\\:%3.2lf%%" \
>GPRINT:usedpct1:LAST:"current used disk\\:%3.2lf%%"\\j 
>GPRINT:availpct1:MAX:"maximal free disk\\:%3.2lf%%" \
>GPRINT:availpct1:AVERAGE:"average free disk\\:%3.2lf%%" 
>GPRINT:availpct1:LAST:"current free disk\\:%3.2lf%%"\\j \
>GPRINT:MBavail2:LAST:"free disk\\: %3.2lf%Sb" 
>GPRINT:MBused2:LAST:"used disk\\: %3.2lf%Sb" 
>GPRINT:MBtotal2:LAST:"total disk\\: %3.2lf%Sb"\\j \
>GPRINT:usedpct2:MAX:"maximal used disk\\:%3.2lf%%" 
>GPRINT:usedpct2:AVERAGE:"average used disk\\:%3.2lf%%" \
>GPRINT:usedpct2:LAST:"current used disk\\:%3.2lf%%"\\j 
>GPRINT:availpct2:MAX:"maximal free disk\\:%3.2lf%%" \
>GPRINT:availpct2:AVERAGE:"average free disk\\:%3.2lf%%" 
>GPRINT:availpct2:LAST:"current free disk\\:%3.2lf%%"\\j
>
>Can anyone shed any light?

With that jumbled up mess, not a chance ! Were you trying to make it 
hard to read ? Sorry, but I really cannot understand how people can 
work with such jumbled up code - unless they are entering an 
obfuscated C contest :D Presenting something that hard to read when 
asking for help smacks of "I don't value others time enough to make 
my question easy to read", to which the response might well be "why 
should anyone help then". And look at what I expect to happen when my 
mailer wraps your wide text to about 70 characters !
http://www.catb.org/~esr/faqs/smart-questions.html#code

Below, I've reformatted it to be readable (I'm feeling generous this 
morning, though I haven't bothered with all the "\"s), it looks OK to 
me apart from a couple of "\j"s at the end of the STACK commands.


/usr/bin/rrdtool graph /var/www/graphs/192.168.43.254.disk-day.png
-s -1day -a PNG -i -z --alt-y-grid -h 125 -l 0 -u 100 -r \
--color SHADEA#EAE9EE --color SHADEB#EAE9EE --color BACK#EAE9EE
--vertical-label "partition used %" -t "Disk usage" -b 1024 \

DEF:used1=/etc/rrdtool/192.168.43.254.disk.rrd:used:AVERAGE 
DEF:avail1=/etc/rrdtool/192.168.43.254.disk.rrd:avail:AVERAGE \
DEF:used2=/etc/rrdtool/192.168.43.254.disk1.rrd:used:AVERAGE 
DEF:avail2=/etc/rrdtool/192.168.43.254.disk1.rrd:avail:AVERAGE \

CDEF:total1=used1,avail1,+
CDEF:usedpct1=100,used1,total1,/,*
CDEF:availpct1=100,avail1,total1,/,*

AREA:usedpct1#4169E1:"used disk" \
STACK:availpct1#32CD32:"free disk"\\j

CDEF:MBavail1=avail1,1048576,*
CDEF:MBused1=used1,1048576,*
CDEF:MBtotal1=total1,1048576,* \

CDEF:total2=used2,avail2,+
CDEF:usedpct2=100,used2,total2,/,*
CDEF:availpct2=100,avail2,total2,/,*
CDEF:usedpct2neg=0,usedpct2,- \
CDEF:availpct2neg=0,availpct2,-

AREA:usedpct2neg#4169E1:"used disk"
STACK:availpct2neg#32CD32:"free disk"\\j \

CDEF:MBavail2=avail2,1048576,*
CDEF:MBused2=used2,1048576,*
CDEF:MBtotal2=total2,1048576,* \

GPRINT:MBavail1:LAST:"free disk\\: %3.2lf%Sb"
GPRINT:MBused1:LAST:"used disk\\: %3.2lf%Sb"
GPRINT:MBtotal1:LAST:"total disk\\: %3.2lf%Sb"\\j \
GPRINT:usedpct1:MAX:"maximal used disk\\:%3.2lf%%"
GPRINT:usedpct1:AVERAGE:"average used disk\\:%3.2lf%%" \
GPRINT:usedpct1:LAST:"current used disk\\:%3.2lf%%"\\j
GPRINT:availpct1:MAX:"maximal free disk\\:%3.2lf%%" \
GPRINT:availpct1:AVERAGE:"average free disk\\:%3.2lf%%"
GPRINT:availpct1:LAST:"current free disk\\:%3.2lf%%"\\j \
GPRINT:MBavail2:LAST:"free disk\\: %3.2lf%Sb"
GPRINT:MBused2:LAST:"used disk\\: %3.2lf%Sb"
GPRINT:MBtotal2:LAST:"total disk\\: %3.2lf%Sb"\\j \
GPRINT:usedpct2:MAX:"maximal used disk\\:%3.2lf%%"
GPRINT:usedpct2:AVERAGE:"average used disk\\:%3.2lf%%" \
GPRINT:usedpct2:LAST:"current used disk\\:%3.2lf%%"\\j
GPRINT:availpct2:MAX:"maximal free disk\\:%3.2lf%%" \
GPRINT:availpct2:AVERAGE:"average free disk\\:%3.2lf%%"
GPRINT:availpct2:LAST:"current free disk\\:%3.2lf%%"\\j


-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.



More information about the rrd-users mailing list