<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><font color="#004040"><strong></strong></font></font>Actually, its a simple script. I'm not also a programmer.<br><br>#!/bin/sh<br>file=/usr/local/apache2/htdocs/mrtg/clients/Link/10.10.0.222.110.html<br>com2=`cat $file | egrep "kb/s|b/s" | awk 'NR == 3 {print}' | awk -F\> '{print $2}' |awk -F\( '{print $1}'` <br>com3=`cat $file | egrep "kb/s|b/s" | awk 'NR == 6 {print}' | awk -F\> '{print $2}' |awk -F\( '{print $1}'` <br>time=`date +%F\ %k:%M`<br>time1=`date +%F`<br><br>echo "TIME : $time Current IN : $com2 | Current OUT : $com3" >> /home1/usr1/nelsonts/coloc_script/chatlink_$time1.txt<br><br>I cron the script every 5 minutes so it gets what you see in Current In/Out.<br><br>It would be much
easier if I could have the value in kb/s or in b/s. It just could be the two of them.<br><br>Any advise?<br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Luis Carlos Solano <lsolano@racsa.co.cr><br>To: mrtg@lists.oetiker.ch<br>Sent: Monday, November 19, 2007 11:48:21 AM<br>Subject: Re: [mrtg] how to have fix value in mrtg output<br><br><br><br>Nelson Serafica wrote:<br>> I need to dump the current in/out to a text file every 5 minutes. I <br>> already create script but the problem is mrtg provide output in a <br>> different value. Sometimes it is in kb/s. Sometimes it is in b/s. I <br>> need it to be fix. I need to sort the traffic by kb/s/<br><br>I'd recommend do the "fix" in your script, not in MRTG.<br><br>I mean: if you're using -for example- php, you can
"explode" the line <br>you've just read and play with it. If the line you're getting is <br>space-separated:<br><br>$string = "In 16.0 kb/s (0.0%) 2824.0 b/s (0.0%) 5640.0 b/s (0.0%)";<br>$exploded_line = explode(" ", $string);<br>print_r($exploded_line);<br><br>you get then:<br><br>Array<br>(<br> [0] => In<br> [1] => 16.0<br> [2] => kb/s<br> [3] => (0.0%)<br> [4] => 2824.0<br> [5] => b/s<br> [6] => (0.0%)<br> [7] => 5640.0<br> [8] => b/s<br> [9] => (0.0%)<br>)<br><br>so, the code continues<br><br>if($exploded_line[2] == 'b/s') {<br> $exploded_line[4] = $exploded_line[4]/1000<br>}<br>...<br>...<br>...<br><br>then you write your file.<br><br>Luis Carlos.<br><br>PSs:<br><br>1. I'm not a good programmer.<br>2. I cheated: I fixed the line, so there is only 1 space between each <br>chunk,
you have to work on this :-)<br><br><br><br><br>_______________________________________________<br>mrtg mailing list<br><a ymailto="mailto:mrtg@lists.oetiker.ch" href="mailto:mrtg@lists.oetiker.ch">mrtg@lists.oetiker.ch</a><br><a href="https://lists.oetiker.ch/cgi-bin/listinfo/mrtg" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/mrtg</a><br></div><br></div></div><br>
<hr size="1"><FONT face=Arial size=-1>
Platonic friends of the opposite sex - the real deal?<br>Be a better buddy<br>
<a href="http://ph.answers.yahoo.com/dir/index;_ylt=AsCq4OcgSoQ9qZZdke2cnGhL5Qt.;_ylv=3?link=over&sid=396545433">Find out at Yahoo! Answers</a></FONT>
</body></html>