Cisco Plot DSL binbucket ATM

Cisco ATM dsl bin bucket grapher

2

 

—————-

#!/bin/bash

#Be quiet /root/cisco/script.sh >> /dev/null 2>&1

#debug

#set -x

#/debug

#—————————————————

#host data

USER=hegars

PASS=password

HOST=192.168.1.1

#slot data

declare CARD=(0 1)

DATE=`date`

EDATE=`date +%s`

HDIR=/var/www/html

#—————————————————

function_getdata()

{

URL=level/15/exec/-/show/dsl/interface/ATM/0//$CARDS//0

FILE=ATM0.$CARDS.0

echo $FILE on $DATE

## curl get from router

## find it hads and tail

## tr to remove the carrage returns

## awk the line after : and get the 16 bit string

## sed to add spaces between chars

## place it all in an array

ATM=(`echo $(curl -s -u $USER:$PASS http://$HOST/$URL | tail -n 40 | head -n 35 | tr -d ‘\r’|awk ‘/:/ {print $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17}’|sed -e ‘s/\(.\)/\1 /g’)`)

## Check how many entries are in this array

echo “${#ATM[@]} entries included in this Array”

## Convert HEX to DEC

### for each entity in the array echo back into the new DCT array the DEC converted value

DCT=($(for bin in ${ATM[@]}; do echo $((16#`echo $bin`)); done))

## Create an empty file for array conversion values

touch $FILE

## Copy each array entity onto a new line of the file

for FreqSlot in ${DCT[@]};

        do

        echo $FreqSlot >> $FILE;

        done

}

#—————————————————

function_graph()

{

gnuplot -persist << EOF

set terminal png transparent nocrop enhanced size 1000,320 font “arial,8”

set output ‘$HDIR/$FOUT.png’

set title “GMT Bit Bins as of $DATE”

set ylabel “Bits per bin”

set xlabel “Frequency Slot”

set style data lines

x = 0.0

#set terminal dumb size 160,50 aspect 1

plot “$GFILE”

#plot “ATM0.0.0″,”ATM0.1.0”

unset xlabel

unset ylabel

EOF

}

#—————————————————

# Do some stuff

## Create Backups of gifs

echo “Copying current Combo gif to backup”

cp $HDIR/COMBO.png $HDIR/bu/COMBO.`date +%Y`.`date +%m`.`date +%d`.`date +%H`.`date +%M`.png

for backup in ${CARD[@]};

        do

        echo “Copying current $backup gif to backup”

#        cp $HDIR/ATM0.$backup.0.png $HDIR/bu/ATM0.$backup.0.$EDATE.png

        cp $HDIR/ATM0.$backup.0.png $HDIR/bu/ATM0.$backup.0.`date +%Y`.`date +%m`.`date +%d`.`date +%H`.`date +%M`.png

        done

## Create Graph for the two cards.

for data in ${CARD[@]};

        do

        CARDS=${CARD[$data]}

        function_getdata

        GFILE=$FILE

        FOUT=$FILE

        echo “Graphing $GFILE”

        function_graph

        echo “Done”;

done

## Create the Combo Graph

for combo in 1

        do

        echo “Creating Combo graph”

        GFILE=”ATM0.0.0\”,\”ATM0.1.0″

        FOUT=”COMBO”

        function_graph

        echo “Done”;

done

## Clean Up

for clean in ${CARD[@]};

        do

        rm ATM0.$clean.0

        echo “Cleaning up ATM0.$clean.0”

        echo “Done”;

done