<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 http-equiv=Content-Type content="text/html; charset=us-ascii">
<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:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-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.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;}
@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=MsoPlainText><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>Hi,<o:p></o:p></span></b></p>
<p class=MsoPlainText><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'><o:p> </o:p></span></b></p>
<p class=MsoPlainText><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>I am using the following script to draw a graph using rrdtool. But
it is not displaying any value. When I check with “rrdtool fetch”
command it displayed as “nan”. Please help on this.<o:p></o:p></span></b></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>use lib qw(/lib/perl/5.8.0/i386-linux-thread-multi/);<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>use RRDs;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>#$dt= print localtime();<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>$ipadd="192.168.3.1" ;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>sub trim($)<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>{<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'> my $string = shift;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'> $string =~ s/^\s+//;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'> $string =~ s/\s+$//;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'> return $string;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>}<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'><o:p> </o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>sub gettrap{<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>$getval= join (" ", "snmpget -v2c -c admin"
,$ipadd,$_[0],"|");<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>open (SNMPGET,"$getval");<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>$val=<SNMPGET>;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>chop($val);<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>return split (/:/ , $val);<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>}<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'><o:p> </o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>sub castStrInt {<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>
my $t;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'> foreach my $d (split(//,
shift())) {<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'> $t = $t * 10 + $d;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'> }<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'> return $t;<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>}<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'><o:p> </o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>@in =gettrap("1.3.6.1.2.1.2.2.1.10.14");<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>@out= gettrap("1.3.6.1.2.1.2.2.1.16.14");<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>$kin=trim($in[3]);<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>$kout=trim($out[3]);<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>$intin=castStrInt($kin);<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>$intout=castStrInt($kout);<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>#system("rrdtool update /var/www/html/testrrd/myrouter.rrd
N:$intin:$intout");<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>#system("rrdtool update /var/www/html/testrrd/myrouter1.rrd
N:$intin:$intout");<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>RRDs::update ("myrouter.rrd",
"N:$intin:$intout");<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'>RRDs::graph
("myrouter-day.png","--start=-86400",
"DEF:inoctets=myrouter.rrd:input:AVERAGE",
"DEF:outoctets=myrouter.rrd:output:AVERAGE",
"AREA:inoctets#FF00ff:In traffic", "LINE1:outoctets#FF00FF:Out
traffic");<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#4F6228'><o:p> </o:p></span></p>
<p class=MsoPlainText><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>Thanks & BR,<o:p></o:p></span></b></p>
<p class=MsoPlainText><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>Gayan Amarasiri<o:p></o:p></span></b></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'><o:p> </o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'><o:p> </o:p></span></p>
<p class=MsoPlainText><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'><o:p> </o:p></span></p>
</div>
<DIV>
**********************************************************************************************<BR>
This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.<BR>
**********************************************************************************************<BR>
</DIV></body>
</html>