<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Would you mind if I include the content of this as an FAQ on The
Shire?<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>=G=<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Sigurður
Guðbrandsson [mailto:sigurdur@raforninn.is] <br>
<b>Sent:</b> Friday, October 12, 2007 8:36 AM<br>
<b>To:</b> hobbit@hswn.dk<br>
<b>Subject:</b> [hobbit] Custom graphs in hobbit, resend, ATTN Alan Sparks<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>(This
is a resend since the formatting was crapped out in the previous mail)</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Hi.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>The
problem with parsing is to know what you want to parse.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>The
first step is to send your information to hobbit and see it displayed.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Second
step is to configure hobbitlaunch.cfg file to send the data from the column to
your script.<br>
  FROM /etc/hobbit/hobbitlaunch.cfg<br>
[rrdstatus]<br>
        ENVFILE
/usr/lib/hobbit/server/etc/hobbitserver.cfg<br>
        NEEDS hobbitd<br>
        CMD hobbitd_channel --channel=status
--log=$BBSERVERLOGS/rrd-status.log hobbitd_rrd --extra-tests=hitastig
--extra-script=/usr/lib/hobbit/server/ext/rrd_digitemp.pl --rrddir=$BBVAR/rrd
The --extra-tests is the definition of what columns you want to parse. You can
have as many columns as you like, comma seperated.<br>
The --extra-script is the path to the script that you wish to run to do the
parsing. You can only have one there.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Then
you have to edit hobbitserver.cfg and add the test to TEST2RRD and GRAPHS
variables.<br>
Then either reboot the server or kill hobbit_channel processes (they should
restart the next time they are scheduled to run)</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>To
begin to know what you have to parse, just tell the script to write to some
file (overwrite, not append .. Unless of course you want it to grow bigger and
bigger). It should be very similar to what the web site shows.<br>
Alternatively there should be a way to use the bb program to display it, but I
didn't bother finding out how.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Then
of course you do your parsing.<br>
I recommend that you read about RRD graphs and how you can display different
values (is it a counter, is it a variable like temperature, percentage etc etc)
on the official RRD website which slips my mind ATM where it is located ..
Google will probably help.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>You
should receive 3 args from hobbit when it runs your script, it behaves so:
$scriptname $hostname $testname $messagefile The messagefile is a temporary
file which you shall parse.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>The
final stage is to output your information to hobbit in a way it understands,
printing directly to STDOUT.<br>
The format is so, note that you don’t have to have the type GAUGE, replace with
what you need:<br>
DS:<datasetname>:GAUGE:600:0:100<br>
<Testname>.<sensorname>.rrd<br>
<value><br>
DS:<datasetname>:GAUGE:600:0:100<br>
<Testname>.<sensor2name>.rrd<br>
<value><br>
Etc etc..</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>A
tip for the wise, I had a lot of struggle with this when I was making it, and
then realised that I can't have the datasetnames any different in all the
files, it has to be static, that is, one name.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Then
you should check if there are any RRD files being made.<br>
They should be located in /var/lib/hobbit/rrd/<hostname>/</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Then
there comes the fun, to be able to show off your results in a graph. You should
edit hobbitgraph.cfg file for that.<br>
Mine looks like this:<br>
[hitastig]<br>
        FNPATTERN hitastig.(.*).rrd<br>
        TITLE Hitastig<br>
        YAXIS Celsius<br>
       
DEF:h@RRDIDX@=@RRDFN@:temperature:AVERAGE<br>
        LINE2:h@RRDIDX@#@COLOR@:@RRDPARAM@<br>
        GPRINT:h@RRDIDX@:LAST: \: %5.1lf
(cur)<br>
        GPRINT:h@RRDIDX@:MAX: \: %5.1lf
(max)<br>
        GPRINT:h@RRDIDX@:MIN: \: %5.1lf
(min)<br>
        GPRINT:h@RRDIDX@:AVERAGE: \: %5.1lf
(avg)\n</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>The
files it expects are hitastig.<sensorname>.rrd, don't let that extra dot
fool you, it needs to be there.<br>
See in the DEF line, the name I chose for the datasets is temperature. (I
REMIND YOU AGAIN, IT NEEDS TO BE STATIC)</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>If
you do this successfully, you should see a graph in hobbit as soon as you
finish this last thing (just let the website refresh once).</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>For
reference (and of course to future developers that will read the mailing list
archive) I will attach my scripts here so you know what to expect.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>dgitemp.pl
-- This script reads from digitemp values, names and peak values from the MySQL
database and sends them to hobbit.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#!/usr/bin/perl<br>
# This script reads digitemp values and writes them to a # temporary file which
the hobbit client sends out to # the Hobbit Monitor.<br>
# This script really should be rewritten so it will contain subs for
operations.<br>
# That would be much more tidier.<br>
# Written by Sigurdur Gudbrandsson<br>
# <a href="mailto:sigurdur@raforninn.is">sigurdur@raforninn.is</a></span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>use
strict;<br>
use DBI;</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Lets declare our variables</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>my
$db_user = "username"; # Change to whatever your username is my
$db_pass = "password"; # Change to whatever your password is my
$db_name = "stats"; my $table_meta = "digitemp_metadata";
my $table = "digitemp";</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
We need to get some variables from the environment, don't change this my $BB =
$ENV{BB}; my $BBDISP = $ENV{BBDISP}; my $MACHINE = $ENV{MACHINE}; my $BBTMP =
$ENV{BBTMP};</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Change this to whatever you want your test to be named my $testname =
"hitastig";</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Don't change this or your test will never be green my $color =
"green";</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Set this to other than 0 if you want to debug my $debug = 0;</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Lets connect to the database<br>
my $dbh =
DBI->connect("DBI:mysql:$db_name","$db_user","$db_pass")<br>
          or die "I cannot
connect to dbi:mysql:$db_name as $db_user - $DBI::errstr\n";</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Lets get the sensor ID's, names and min/max values</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>my
$sql = "SELECT SerialNumber,name,description,min,max FROM
$db_name.$table_meta";</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>my
$sth = $dbh->prepare($sql) or die "Can't execute statement $sql
because: $DBI::errstr"; $sth->execute();</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>my
(@sensors) = ();<br>
while (my @ary = $sth->fetchrow_array()) {<br>
        if ($ary[3] == "NULL") {<br>
               
$ary[3] = 0.000;<br>
        }<br>
        if ($ary[4] == "NULL") {<br>
               
$ary[4] = 99.999;<br>
        }<br>
        push(@sensors, [@ary]);  #
[@ary] is a reference } $sth->finish();</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Now we have all the sensors in a two dimensional array, @sensors # Also, if
there is a NULL value in min or max, it has been substituted with a value</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Now we will get the temperature of each sensor from the database # and check if
the temp is too high or too low.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>my
$count = 0;<br>
while (@{sensors[$count]}) {<br>
        print "WHILE: entering first
while loop\n" if ($debug);<br>
        my $sql = "SELECT Fahrenheit
FROM $db_name.$table WHERE SerialNumber='$sensors[$count][0]' ORDER BY dtKey
DESC LIMIT 0,1";<br>
        print "SQL: term is \"
$sql \" \n" if ($debug);<br>
        my $sth = $dbh->prepare($sql) or
die "Can't execute statement $sql because: $DBI::errstr";<br>
        $sth->execute();<br>
        $sensors[$count][5] =
$sth->fetchrow_array();<br>
        if ($sensors[$count][5] >
$sensors[$count][4]){<br>
               
print "IF: status for $sensors[$count][1] is red\n" if ($debug);<br>
               
$sensors[$count][6] = "&red";<br>
               
$color = "red";<br>
        }<br>
        elsif ($sensors[$count][5] <
$sensors[$count][3]){<br>
               
print "IF: status for $sensors[$count][1] is yellow\n" if ($debug);<br>
               
$sensors[$count][6] = "&yellow";<br>
               
if ($color != "red"){<br>
                       
$color = "yellow";<br>
               
}<br>
        }<br>
        else {<br>
               
print "IF: status for $sensors[$count][1] is green\n" if ($debug);<br>
               
$sensors[$count][6] = "&green";<br>
        }<br>
        $sth->finish();<br>
        $count++;<br>
}</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
We can close the database now<br>
$dbh->disconnect();</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Next is to get our results into an array # For reference, 0=SerialNumber 1=name
2=description 3=min 4=max 5=value 6=color in our array</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>my
$tmp = "\n";         # First
line in the array<br>
print $color if ($debug);<br>
$count = 0;<br>
while (@{sensors[$count]}) {<br>
        print "WHILE: entering second
while loop\n" if ($debug);<br>
        print "WHILE:
$sensors[$count][1] is being printed\n" if ($debug);<br>
        $tmp = $tmp."   
$sensors[$count][6]    $sensors[$count][1] =
$sensors[$count][5]\n";<br>
        $tmp =
$tmp."            :
min=$sensors[$count][3] max=$sensors[$count][4]\n";<br>
        $tmp =
$tmp."            :
$sensors[$count][2]\n\n";<br>
        $count++;<br>
}</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Now we decode from UTF-8 to latin1 (iso-8859-1) if there is anything in utf8
open(TEMP, ">$BBTMP/$testname.tmp.txt"); print TEMP $tmp;
close(TEMP);</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Now we get the converted data<br>
$tmp = `/usr/bin/iconv -f utf8 -t iso-8859-1 $BBTMP/$testname.tmp.txt`;</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Now finally we output the information to our beloved hobbit my $date =
localtime; my $cmd = "$BB $BBDISP \"status $MACHINE.$testname $color
$date \n $tmp \n \""; system($cmd);</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>print
$cmd if ($debug);<br>
print $tmp if ($debug);</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>exit;</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><br>
Here is the output from this script<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>   
&green    Tölvu_kæling = 21.25 C<br>
            : min=1.000
max=25.000<br>
            : This
sensor has not yet been described<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>   
&green    Verkstæði = 25.81 C<br>
            : min=0.000
max=99.999<br>
            : This
sensor has not yet been described<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>   
&green    Tölvuskápur = 22.12 C<br>
            : min=14.000
max=25.000<br>
            : This
sensor has not yet been described<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>   
&green    Tölvu_kæl_út = 46.38 C<br>
            : min=0.000
max=99.999<br>
            : This
sensor has not yet been described<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>rrd_digitemp.pl
-- This script parses the information from hobbit and produces the channel data
to make the RRD files.<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#!/usr/bin/perl<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>use
strict;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
Input parameters: Hostname, testname (column), and messagefile my
$hostname=$ARGV[0]; my $testname=$ARGV[1]; my $fname=$ARGV[2];<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>my
($line1, @line, @buff, @key, @value, $value, @tmp);<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>open(IN,"$fname");<br>
read(IN, $line1, 10000);<br>
@line=split('\n',$line1);<br>
@buff = grep(/ = /,@line);<br>
close(IN);<br>
chomp(@buff);                                  
# Lets strip the newline if there is any.<br>
for( my $i = 0; $i < scalar(@buff);
$i++)       # Now we go through the whole array
of lines<br>
{<br>
        $buff[$i] = substr($buff[$i],
10);      # Trimming the beginning<br>
        $buff[$i] =~ s/
C//g;                  
# Removing the end<br>
        $buff[$i] =~ s/ //g;                   
# Removing all the whitespace<br>
        @tmp = split('=', $buff[$i]);<br>
        $key[$i] = makesafe($tmp[0]);<br>
        $value[$i] = $tmp[1];<br>
#        print
$buff[$i]."\n";                  
# Printing a test line to view the results<br>
}<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>open(IN,">>/var/log/hobbit/custrrd.log");<br>
write($buff[1]);<br>
close(IN);<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><br>
# The next loop will print out the information for making the RRD file.<br>
for( my $i = 0; $i < scalar(@key); $i++ ) {<br>
        print
"DS:temperature:GAUGE:600:0:100\n";      #
Prints out each sensor name<br>
#       print
"DS:".$key[$i].":GAUGE:600:0:100\n";     
# Prints out each sensor name<br>
        print
$testname.".".$key[$i].".rrd\n";         
# Prints out the rrd file name<br>
        print
$value[$i]."\n";                         
# Prints out the value<br>
}<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>#
This sub produces safe output so hobbit will be able to make the files # (It
seems that hobbit doesn't like special letters in file names) sub makesafe {<br>
        my $word = shift;<br>
        $word =~ s/ö/o/g;<br>
        $word =~ s/á/a/g;<br>
        $word =~ s/í/i/g;<br>
        $word =~ s/é/e/g;<br>
        $word =~ s/ó/o/g;<br>
        $word =~ s/ý/y/g;<br>
        $word =~ s/ú/u/g;<br>
        $word =~ s/æ/ae/g;<br>
        $word =~ s/ð/d/g;<br>
        $word =~ s/þ/th/g;<br>
#       $word =~ s/_//g;<br>
#       $word = lc($word);<br>
        return $word;<br>
}<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>exit;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><br>
I hope this isn't overkill. :)<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>With
regards,<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>------------------------------<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Sigurður
Guðbrandsson<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Raförninn
ehf.<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Suðurhlíð
35<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>105
Reykjavik | Iceland<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><a
href="mailto:sigurdur@raforninn.is">sigurdur@raforninn.is</a> | <a
href="http://www.raforninn.is">www.raforninn.is</a><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Office:
+(354) 552 2070<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Mobile:
+(354) 867 3573<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>------------------------------<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><br>
-----Original Message-----<br>
From: Alan Sparks [mailto:asparks@doublesparks.net]<br>
Sent: 10. október 2007 21:06<br>
To: Sigurður Guðbrandsson<br>
Subject: Re: [hobbit] Custom graphs with multiple data sources<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Since
I am in the same boat with my server (downtime not an option), I am interested
in your approach.  I already have custom scripts for this, but am
interested in what you do differently as far as parsing.  Are you parsing
the incoming messages and re-sending them to Hobbit?  What is the
"proper format?"<br>
Thanks for your reply.<br>
-Alan<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> 
wrote:<br>
> Hi.<br>
><br>
> There is a fourth option, which I took as updating to snapshot caused my
hobbit to break for some reason, and seeing that it is a system I must have up
99% of the day, I just backported.<br>
> Well, that was not the option anyways :)<br>
><br>
> My suggestion is that you make a custom script to parse your information
and create the RRD's (actually the hobbit server manages creating the RRD's ..
You just have to parse the information and send it in the proper format to
hobbit).<br>
> That way you can have your multi-file RRD's (one per balancer or some) and
you don't have to update to snapshot.<br>
><br>
> I wrote my script in perl (my very first perl script .. How I hate the
language ;) and it works very well.<br>
> You will not find it in the Shire, mainly because I haven't posted it
there yet.<br>
><br>
> If you need info on how the information is, and how to parse it, just drop
me a line.<br>
><br>
> With regards,<br>
><br>
><br>
> ------------------------------<br>
><br>
> Sigur ur Gu brandsson<br>
><br>
> Raf rninn ehf.<br>
><br>
> Su urhl   35<br>
><br>
> 105 Reykjavik | Iceland<br>
><br>
> <a href="mailto:sigurdur@raforninn.is">sigurdur@raforninn.is</a> | <a
href="http://www.raforninn.is">www.raforninn.is</a><br>
><br>
> Office: +(354) 552 2070<br>
><br>
> Mobile: +(354) 867 3573<br>
><br>
> ------------------------------<br>
><br>
><br>
> -----Original Message-----<br>
> From: Charles Goyard [mailto:charles.goyard@orange-ftgroup.com]<br>
> Sent: 10. okt ber 2007 06:50<br>
> To: <a href="mailto:hobbit@hswn.dk">hobbit@hswn.dk</a><br>
> Subject: Re: [hobbit] Custom graphs with multiple data sources<br>
><br>
> Hi,<br>
><br>
><br>
> Alan Sparks wrote :<br>
><br>
>   <br>
>> However, with this, I am only able to manage one graph, and one data <br>
>> source, per device.  I would like to graph all the session
values.<br>
>> I would also like to use multiple RRD files.  My experience with
the <br>
>> single-file, multiple-DS approach is that, if I add another virtual, <br>
>> graphing will break (updates error out, probably since the RRD was <br>
>> not created with this new data source defined).<br>
>> [...]<br>
>>     <br>
><br>
> Check the september 2007 mail archives, there's a discussion about it.<br>
><br>
> There's three solutions :<br>
><br>
> - apply a patch I posted on the list (does split-ncv on a testname<br>
>   basis). My patch has a memory leak, so beware (I kill my
hobbitd_rrd<br>
>   every 24h).<br>
> - send "data" messages with a body like
"foo.rrd:mydsname:GAUGE:500<br>
>   (Sorry, no pointers for that one, and it needs a recent
snapshot).<br>
> - take a snapshot or a least the hobbitd/rrd directory from the source,<br>
>   it includes the split-ncv feature without the memory leak
(thank<br>
>   Henrik).<br>
><br>
><br>
> --<br>
> Charles Goyard - <a href="mailto:charles.goyard@orange-ftgroup.com">charles.goyard@orange-ftgroup.com</a>
- (+33) 1 45 38 01<br>
> 31 Orange Business Services - online multimedia  // ing nierie<br>
><br>
> To unsubscribe from the hobbit list, send an e-mail to <br>
> <a href="mailto:hobbit-unsubscribe@hswn.dk">hobbit-unsubscribe@hswn.dk</a><br>
><br>
><br>
> To unsubscribe from the hobbit list, send an e-mail to <br>
> <a href="mailto:hobbit-unsubscribe@hswn.dk">hobbit-unsubscribe@hswn.dk</a><br>
><br>
><br>
><br>
>   <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><br>
--<br>
Alan Sparks, UNIX/Linux Systems Integration and Administration <<a
href="mailto:asparks@doublesparks.net">asparks@doublesparks.net</a>></span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

<p><span style='font-size:10.0pt'>------------------------------<o:p></o:p></span></p>

<p><span style='font-size:10.0pt'>Sigurður Guðbrandsson<br>
Raförninn ehf.<br>
Suðurhlíð 35<br>
105 Reykjavik | Iceland<br>
<a href="mailto:sigurdur@raforninn.is">sigurdur@raforninn.is</a> | <a
href="http://www.raforninn.is/">www.raforninn.is</a></span><br>
<span style='font-size:10.0pt'>Office: +(354) 552 2070<br>
Mobile: +(354) 867 3573<o:p></o:p></span></p>

<p><span style='font-size:10.0pt'>------------------------------<o:p></o:p></span></p>

<div>

<p class=MsoNormal> <o:p></o:p></p>

</div>

</div>

</body>

</html>