Feeding data from shell script in Graphite Graph
Hi,
I am trying to feed data from shell script in Graphite real time graph software. i've written a simple script:: ======================================================== #!/bin/bash date=`date +%s` hostname=`hostname --short` server="192.168.6.240" port=2003 ping -c 5 www.google.com | cut -d ":" -f2 > ping_result.txt grep "icmp" ping_result.txt |cut -d " " -f4 |cut -d "=" -f2 > ping_resut.txt a=`cat ping_result.txt` nc -v -c "echo \"carbon.$hostname.ping.google.latency $a $date\"" $server $port ; ======================================================== my graphite server ip is 192.168.6.240. this code is for pinging google and the output will be the RTA time. but whenever i execute it then i find no graph on graphite. Wht's the wrong with it ? |
First of all, please use [code][/code] tags around your code, to preserve formatting and to improve readability.
You need to give us some more details here. What exactly is the output that the script supposed to produce, and what does it actually produce? I'm not familiar with graphite, and the command doesn't even appear in your script, so I'm assuming that it's meant only to produce output in a format that graphite can read. So does it? I don't know much about nc either, but this line still doesn't look quite right to me. Is this how the command syntax supposed to look? The manpage for my version of netcat doesn't even mention a -c option; and do you really want to send it the literal "echo" string here? Code:
nc -v -c "echo \"carbon.$hostname.ping.google.latency $a $date\"" $server $port ; See here for more on script debugging: http://mywiki.wooledge.org/BashGuide...ices#Debugging Also, these two lines are quite wasteful: Code:
ping -c 5 www.google.com | cut -d ":" -f2 > ping_result.txt Something like this: Code:
date="$( date +%s )" Notice also that $(..) is highly recommended over `..` |
Quote:
THanks Thanks and thanks a lot...I dont know wht happened but after i edit scritp according ur advise...it works!!!!...Gr8 Help .....Thnks again.... |
I've been recently looking for graphite users. I've recently added support to collectl for allowing it to directly send anything it collectl to graphite but have not yet released it. Only thing is I'd like to get some people to try it out before I ship it. Anyone interested?
-mark |
All times are GMT -5. The time now is 09:04 PM. |