I have a problem with generating rrdtool database. I would like to use rrdtool for generating graph to Cacti server. I have some network machines (TAPs), which I'm able to automaticly access only via Telnet. So I wrote a script, which connect to TAP a generate text file with data I'd like to graph, script is started through crone every 10 minutes and text file is rewrited. Data has this format: 111;222;333;444 (numbers only) on one line and countinuous on next lines in same way. Now I need to write next script which update rrd database, but every time I get empty database (NaN). Actually only once time I've been able to update rrd database manualy, other times it didn't work.
My script:
Code: Select all
rrdtool=/usr/bin/rrdtool
img=/var/www/html/cacti/img
cat tap01pn01 | while read radek; do
db=`echo $radek | awk -F ';' '{print $1}'`
echo $db
if [ ! -e $db ]
then
echo "Database doesn't exist and will be created"
rrdtool create $db \
DS:tx:GAUGE:60:0:100000 \
DS:rx:GAUGE:60:0:100000 \
DS:tx_p:GAUGE:60:0:100000 \
DS:rx_p:GAUGE:60:0:100000 \
RRA:MIN:0.5:1:1000
fi
rrdtool update $db -t tx:rx:tx_p:rx_p N:`echo $radek | awk -F ';' '{print $2}' | sed 's/\r$//'`:`echo $radek | awk -F ';' '{print $3}' | sed 's/\r$//'`:`echo $radek | awk -F ';' '{print $4}' | sed 's/\r$//'`:`echo $radek | awk -F ';' '{print $5}' | sed 's/\r$//'`
#echo $radek | awk -F ';' '{print $2}'
$rrdtool graph $img/$db.png \
Can you help me?
Thank you in advance.