Friday, 27 January 2012

Munin about logarithmically

As you all know, I like to graph, (OK, being honest - I need to graph.) So when I create a nifty new plug-in to monitor the charge in my laptop battery, (acpi_volt) I was feeling rather smug. It uses

 acpi -i

to find out two pieces of information. The first is how charged the batter is. (Somewhere between 0 and 100 percent.) The second, (and this is the science bit) is the design capacity in mAh, and the mAh at last full capacity. This is cool. We get two lines, one showing how much charge is left in the battery and another showing how much milk is left in the bottle. (I know that my laptop battery should not suffer from any memory effect or milk-bottle effect, but it does. I don't know what chemical fingers are responsible, but over the past three years the length of time that I can run it off the battery has dropped from about 90 minutes to about 20.)

So I click on the graph to see the day,week,month,year view and *gasp* no month graph.
I console myself that sometimes it takes a while for munin to have enough data in the rrd files to bother creating the month and year graphs. So I go to bed. The next day it has managed to create a year graph, but still no month graph.

I smile. I have been a sysadmin.
- this I know how to solve.

I start with the usual suspects, (file/dir permissions in /var/lib/munin and other munin locations specified in /etc/munin/munin.conf )

Nothing. I check that I can collect the data remotely, and that the acpi_volt.rrd files have valid data in them, (they do.)

hmm - I have never got this far with a munin problem. I guess we will have to go deeper.
su -s /bin/bash munin
munin@laptop:~$ /usr/share/munin/munin-graph --service acpi_volt --nolazy --list-images --month --noyear --noday --noweek

produces the expected output
/var/www/munin/localdomain/localhost.localdomain-acpi_volt-month.png

but it lies!
ls -la ls -la /var/www/munin/localdomain/localhost.localdomain-acpi_volt-month.png
ls: cannot access /var/www/munin/localdomain/localhost.localdomain-acpi_volt-month.png: No such file or directory

ok. how about adding --debug to the end of that
DEBUG: Expanding specials "volt0","volt1","".
DEBUG: Checking field lengths "volt0","volt1","".
DEBUG: Treating fields "volt0","volt1","".
DEBUG: Processing field "volt0".
DEBUG: single_value: Checking field "ARRAY(0x8a0ea38)".
DEBUG: Drawing field "volt0".
DEBUG: Processing field "volt1".
DEBUG: Drawing field "volt1".


rrdtool "graph" "--font"
"LEGEND:7:monospace"
"--font"
"UNIT:7:/usr/share/munin/VeraMono.ttf"
"--font"
"AXIS:7:/usr/share/munin/VeraMono.ttf"
"/var/www/munin/localdomain/localhost.localdomain-acpi_volt-month.png"
"--title"
"Voltages - by month"
"--start"
"-33d"
"--base"
"1000"
"--logarithmic"
"--vertical-label"
"Volt"
"--height"
"175"
"--width"
"400"
"--imgformat"
"PNG"
"DEF:gvolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:AVERAGE"
"DEF:ivolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:MIN"
"DEF:avolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:MAX"
"CDEF:cvolt0=gvolt0"
"COMMENT: "
"COMMENT: Cur\:"
"COMMENT:Min\:"
"COMMENT:Avg\:"
"COMMENT:Max\: \j"
"LINE1.6:gvolt0#22ff22:Full "
"GPRINT:cvolt0:LAST:%6.2lf%s"
"GPRINT:ivolt0:MIN:%6.2lf%s"
"GPRINT:gvolt0:AVERAGE:%6.2lf%s"
"GPRINT:avolt0:MAX:%6.2lf%s\j"

"DEF:gvolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:AVERAGE"
"DEF:ivolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:MIN"
"DEF:avolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:MAX"
"CDEF:cvolt1=gvolt1"
"LINE1.6:gvolt1#0022ff:capacity "
"GPRINT:cvolt1:LAST:%6.2lf%s"
"GPRINT:ivolt1:MIN:%6.2lf%s"
"GPRINT:gvolt1:AVERAGE:%6.2lf%s"
"GPRINT:avolt1:MAX:%6.2lf%s\j"
"COMMENT:Last update\: Fri Jan 27 16\:45\:03 2012\r"
"--end"
"1327672800"
hmm, that all looks ok. Lets take a closer look at the data:

rrdtool info /var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd
rrdtool info /var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd
rrd_version = "0003"
step = 300
last_update = 1327685404
ds[42].type = "GAUGE"
ds[42].minimal_heartbeat = 600
ds[42].min = NaN
ds[42].max = NaN
ds[42].last_ds = "100"
ds[42].value = 4.0290790000e+02
ds[42].unknown_sec = 0
rra[0].cf = "AVERAGE"
rra[0].rows = 576
rra[0].cur_row = 88
rra[0].pdp_per_row = 1
rra[0].xff = 5.0000000000e-01
rra[0].cdp_prep[0].value = NaN
rra[0].cdp_prep[0].unknown_datapoints = 0
rra[1].cf = "MIN"
rra[1].rows = 576
rra[1].cur_row = 197
rra[1].pdp_per_row = 1
rra[1].xff = 5.0000000000e-01
rra[1].cdp_prep[0].value = NaN
rra[1].cdp_prep[0].unknown_datapoints = 0
rra[2].cf = "MAX"
rra[2].rows = 576
rra[2].cur_row = 509
rra[2].pdp_per_row = 1
rra[2].xff = 5.0000000000e-01
rra[2].cdp_prep[0].value = NaN
rra[2].cdp_prep[0].unknown_datapoints = 0
...
yup that all looks good, (to me). So lets graph by hand:

rrdtool graphv /var/www/munin/localdomain/localhost.localdomain-acpi_volt-month.png \
-W "Alexx Roche" --end now --start end-33d \
DEF:gvolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:AVERAGE \
DEF:ivolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:MIN \
DEF:avolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:MAX \
CDEF:cvolt0=gvolt0 \
DEF:gvolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:AVERAGE \
DEF:ivolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:MIN \
DEF:avolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:MAX \
LINE1.6:gvolt0#22ff22:Full LINE1.6:gvolt1#0022ff:capacity

yup, that works, (but does not look pretty.) So lets keep adding configurations.


rrdtool graphv /var/www/munin/localdomain/localhost.localdomain-acpi_volt-month.png \
--title "Voltages - by month" \
--end now --start end-33d \
DEF:gvolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:AVERAGE \
DEF:ivolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:MIN \
DEF:avolt0=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt0-g.rrd:42:MAX \
CDEF:cvolt0=gvolt0 \
DEF:gvolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:AVERAGE \
DEF:ivolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:MIN \
DEF:avolt1=/var/lib/munin/localdomain/localhost.localdomain-acpi_volt-volt1-g.rrd:42:MAX \
CDEF:cvolt1=gvolt1 \
--font LEGEND:7:monospace \
--font UNIT:7:/usr/share/munin/VeraMono.ttf \
--font AXIS:7:/usr/share/munin/VeraMono.ttf \
--base 1000 \
--vertical-label "Volt" \
--height 175 \
--width 400 \
--imgformat PNG \
COMMENT:" " \
COMMENT:" Cur\:" \
COMMENT:"Min\:" \
COMMENT:"Avg\:" \
COMMENT:"Max\: \j" \
LINE1.6:gvolt0#22ff22:Full  \
GPRINT:cvolt0:LAST:%6.2lf%s \
GPRINT:ivolt0:MIN:%6.2lf%s \
GPRINT:gvolt0:AVERAGE:%6.2lf%s \
GPRINT:"avolt0:MAX:%6.2lf%s\j" \
LINE1.6:gvolt1#0022ff:capacity  \
GPRINT:cvolt1:LAST:%6.2lf%s \
GPRINT:ivolt1:MIN:%6.2lf%s \
GPRINT:gvolt1:AVERAGE:%6.2lf%s \
GPRINT:"avolt1:MAX:%6.2lf%s\j" \
"COMMENT:Last update (by LxR)\: Fri Jan 27 16\:45\:03 2012\r"

ah ha! --logarithmic seems to break it. Just for the monthly graph? (Some may ask why I was graphic logarithmically rational numbers between 0..100 but that is not the point.)
 I do not see why munin would not alert or at least log, (somewhere in /var/log/munin/) something to mention that the graphing did not happen, (and even more oddly, for just one of the four graphs.)

So I changed acpi_volt to graph_args => '-1 0' and now I have all four... but I still do not know why rrdtool refused to graph. (Part of me want to keep the .rrd so that others can test it, but I'm not sure how much help that would be.)

No comments:

Post a Comment

About this blog

Sort of a test blog... until it isn't