Update RDDTool with shell script from text file

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
pencakj
Posts: 2
Joined: Fri Sep 02, 2016 7:25 am

Update RDDTool with shell script from text file

Post by pencakj »

Hello all,

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 \
Official website was my inspiration with lines in this script, I have to say I don't understand it completely.

Can you help me?

Thank you in advance.
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Re: Update RDDTool with shell script from text file

Post by phalek »

No need to update the RRD files directly. Just create a script that presents the data to Cacti.

Look here for a a small HowTo: http://docs.cacti.net/manual:088:3a_adv ... put_method
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
pencakj
Posts: 2
Joined: Fri Sep 02, 2016 7:25 am

Re: Update RDDTool with shell script from text file

Post by pencakj »

Thank you, I'll try this.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests