Bash script for rrdtool


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash script for rrdtool
# 1  
Old 10-16-2013
Bash script for rrdtool

Hello all,

I am very new to shell scripting. I messed with basic examples in college, but this this the first work related project I am trying to work on. I am trying to test the rrdtool on our office wan link by measuring the bandwidth utilization. The script concept is fairly easy, but I am seeing many different results online and I am not sure which to follow. I am trying to create a script that:

retrieves the result of (snmpget -v 2c -c community IF-MIB::ifInOctets.4)
places it into variable $in
retrieve the result of (snmpget -v 2c -c community IF-MIB::ifOutOctets.4)
places it into variable $out

and use rrdtool update to update the information in the variables created
# 2  
Old 10-16-2013
You will need to parse the return from your snmpget's in order to supply the rrdtool with the information.

To get information
Code:
in=`snmpget -v 2c -c community IF-MIB::ifInOctets.4`
or 
in=$(snmpget -v 2c -c community IF-MIB::ifInOctets.4)

Post the format of the rrdtool command and what you want to send it from the ouput of your snmpget. You will either use cut or awk to parse the ouput. You can do this before variable assignment; something like...
Code:
in=`snmpget -v 2c -c community IF-MIB::ifInOctets.4 | awk ...`


Last edited by Don Cragun; 10-16-2013 at 02:00 PM.. Reason: Fix CODE tags.
# 3  
Old 10-16-2013
Just wanted to apologize in advance for my scripting incompetency, as I mentioned, I am a newbie. This is my current output:

Code:
$ snmpget -v 2c -c dctmonitor 192.168.0.254 interfaces.ifTable.ifEntry.ifInOctets.4
           IF-MIB::ifInOctets.4 = Counter32: 1782127772
$ snmpget -v 2c -c dctmonitor 192.168.0.254 interfaces.ifTable.ifEntry.ifOutOctets.4
           IF-MIB::ifOutOctets.4 = Counter32: 4188241610

I created the rrtooldabase called bandwidth.rrd
Code:
#!/bin/bash
rrdfile=$(home/atetu/rrdtool/bin/bandwidth.rrd)
rrdtool=$(/usr/bin/rrdtool)

My next step would be to declare the variables and fill then with information:
Code:
BandOut=`snmpget -v 2c -c community IF-MIB::ifOutOctets.4 | awk ...`
BandIn=`snmpget -v 2c -c community IF-MIB::ifInOctets.4 | awk _____'  # not sure what info to insert there.


Last edited by Scott; 10-16-2013 at 03:47 PM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Python-rrdtool try except rrdtool.error module object has no attribute error

I have this code that gives this error on Linux and will be grateful if you can help import rrdtool try: ret_asd = rrdtool.update(myfile.rrd,'N:%s:%s' %(metric1, metric2)); except rrdtool.error, e: print e When i run the above i get the below error except... (1 Reply)
Discussion started by: kaf3773
1 Replies

3. Red Hat

Why do we use RRDtool in MRTG?

Hi Guys, Why do we use RRDtool in MRTG? I have implemented MRTG for some routers, I have read some notes about RRDTOOL also but don't know what is use of these tool. Any one one please explain me the use of RRDTOOL in their own words? (1 Reply)
Discussion started by: manalisharmabe
1 Replies

4. UNIX for Dummies Questions & Answers

RRDtool consolidation not going as expected

Hello all, I am new to RRDtool and have made a RRDtool database with one data-source. Information of this data-source is stored in four different RRA's with different intervals for different time spans. Database create command: rrdtool create /root/mde.rrd --step 300 \... (2 Replies)
Discussion started by: ArtOfLosing
2 Replies

5. UNIX for Dummies Questions & Answers

rrdtool question

Hi, DEF:clients=cccam.rrd:kliensek:AVERAGE DEF:activeclients=cccam_actclient.rrd:activeclients:AVERAGE "LINE1:clients#0000FF:Connected clients" COMMENT:" \n" "LINE2:activeclients#99FF00:Active clients" COMMENT:" \n" GPRINT:clients:LAST:'Current'\%5.0lf%s COMMENT:" \n"... (2 Replies)
Discussion started by: adriankoooo
2 Replies

6. HP-UX

compiling the RRDtool

I tried to compile the RRDtool on HP-UX (IA56). I have gcc-3.4.3 and perl 5.8.0 I got this: Writing Makefile for RRDs cd perl-shared && make /opt/perl/bin/perl /opt/perl/lib/5.8.0/ExtUtils/xsubpp -typemap /opt/perl/lib/5.8.0/ExtUtils/typemap RRDs.xs > RRDs.xsc && mv... (2 Replies)
Discussion started by: Kalin
2 Replies
Login or Register to Ask a Question