{"id":97,"date":"2018-05-25T14:38:05","date_gmt":"2018-05-25T14:38:05","guid":{"rendered":"https:\/\/hegars83.wordpress.com\/?p=97"},"modified":"2019-10-15T16:57:46","modified_gmt":"2019-10-15T06:57:46","slug":"script-cicso-plot-dsl-binbucket-atm","status":"publish","type":"post","link":"https:\/\/blog.hegars.com\/?p=97","title":{"rendered":"Cisco Plot DSL binbucket ATM"},"content":{"rendered":"<p><strong>Cisco ATM dsl bin bucket grapher<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-98\" src=\"http:\/\/blog.hegars.com\/wp-content\/uploads\/2018\/05\/2-1.gif\" alt=\"2\" width=\"1000\" height=\"320\"><\/p>\n<p>&nbsp;<\/p>\n<p class=\"p1\"><b>&#8212;&#8212;&#8212;&#8212;&#8212;-<\/b><\/p>\n<p class=\"p1\">#!\/bin\/bash<\/p>\n<p class=\"p1\">#Be quiet \/root\/cisco\/script.sh &gt;&gt; \/dev\/null 2&gt;&amp;1<\/p>\n<p class=\"p1\">#debug<\/p>\n<p class=\"p1\">#set -x<\/p>\n<p class=\"p1\">#\/debug<\/p>\n<p class=\"p1\">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p class=\"p1\">#host data<\/p>\n<p class=\"p1\">USER=hegars<\/p>\n<p class=\"p1\">PASS=password<\/p>\n<p class=\"p1\">HOST=192.168.1.1<\/p>\n<p class=\"p1\">#slot data<\/p>\n<p class=\"p1\">declare CARD=(0 1)<\/p>\n<p class=\"p1\">DATE=`date`<\/p>\n<p class=\"p1\">EDATE=`date +%s`<\/p>\n<p class=\"p1\">HDIR=\/var\/www\/html<\/p>\n<p class=\"p1\">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p class=\"p1\">function_getdata()<\/p>\n<p class=\"p1\">{<\/p>\n<p class=\"p1\">URL=level\/15\/exec\/-\/show\/dsl\/interface\/ATM\/0\/\/$CARDS\/\/0<\/p>\n<p class=\"p1\">FILE=ATM0.$CARDS.0<\/p>\n<p class=\"p1\">echo $FILE on $DATE<\/p>\n<p class=\"p1\">## curl get from router<\/p>\n<p class=\"p1\">## find it hads and tail<\/p>\n<p class=\"p1\">## tr to remove the carrage returns<\/p>\n<p class=\"p1\">## awk the line after : and get the 16 bit string<\/p>\n<p class=\"p1\">## sed to add spaces between chars<\/p>\n<p class=\"p1\">## place it all in an array<\/p>\n<p class=\"p1\">ATM=(`echo $(curl -s -u $USER:$PASS http:\/\/$HOST\/$URL | tail -n 40 | head -n 35 | tr -d &#8216;\\r&#8217;|awk &#8216;\/:\/ {print $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17}&#8217;|sed -e &#8216;s\/\\(.\\)\/\\1 \/g&#8217;)`)<\/p>\n<p class=\"p1\">## Check how many entries are in this array<\/p>\n<p class=\"p1\">echo &#8220;${#ATM[@]} entries included in this Array&#8221;<\/p>\n<p class=\"p1\">## Convert HEX to DEC<\/p>\n<p class=\"p1\">### for each entity in the array echo back into the new DCT array the DEC converted value<\/p>\n<p class=\"p1\">DCT=($(for bin in ${ATM[@]}; do echo $((16#`echo $bin`)); done))<\/p>\n<p class=\"p1\">## Create an empty file for array conversion values<\/p>\n<p class=\"p1\">touch $FILE<\/p>\n<p class=\"p1\">## Copy each array entity onto a new line of the file<\/p>\n<p class=\"p1\">for FreqSlot in ${DCT[@]};<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>do<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>echo $FreqSlot &gt;&gt; $FILE;<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>done<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p class=\"p1\">function_graph()<\/p>\n<p class=\"p1\">{<\/p>\n<p class=\"p1\">gnuplot -persist &lt;&lt; EOF<\/p>\n<p class=\"p1\">set terminal png transparent nocrop enhanced size 1000,320 font &#8220;arial,8&#8221;<\/p>\n<p class=\"p1\">set output &#8216;$HDIR\/$FOUT.png&#8217;<\/p>\n<p class=\"p1\">set title &#8220;GMT Bit Bins as of $DATE&#8221;<\/p>\n<p class=\"p1\">set ylabel &#8220;Bits per bin&#8221;<\/p>\n<p class=\"p1\">set xlabel &#8220;Frequency Slot&#8221;<\/p>\n<p class=\"p1\">set style data lines<\/p>\n<p class=\"p1\">x = 0.0<\/p>\n<p class=\"p1\">#set terminal dumb size 160,50 aspect 1<\/p>\n<p class=\"p1\">plot &#8220;$GFILE&#8221;<\/p>\n<p class=\"p1\">#plot &#8220;ATM0.0.0&#8243;,&#8221;ATM0.1.0&#8221;<\/p>\n<p class=\"p1\">unset xlabel<\/p>\n<p class=\"p1\">unset ylabel<\/p>\n<p class=\"p1\">EOF<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p class=\"p1\"># Do some stuff<\/p>\n<p class=\"p1\">## Create Backups of gifs<\/p>\n<p class=\"p1\">echo &#8220;Copying current Combo gif to backup&#8221;<\/p>\n<p class=\"p1\">cp $HDIR\/COMBO.png $HDIR\/bu\/COMBO.`date +%Y`.`date +%m`.`date +%d`.`date +%H`.`date +%M`.png<\/p>\n<p class=\"p1\">for backup in ${CARD[@]};<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>do<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>echo &#8220;Copying current $backup gif to backup&#8221;<\/p>\n<p class=\"p1\">#<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>cp $HDIR\/ATM0.$backup.0.png $HDIR\/bu\/ATM0.$backup.0.$EDATE.png<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>cp $HDIR\/ATM0.$backup.0.png $HDIR\/bu\/ATM0.$backup.0.`date +%Y`.`date +%m`.`date +%d`.`date +%H`.`date +%M`.png<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>done<\/p>\n<p class=\"p1\">## Create Graph for the two cards.<\/p>\n<p class=\"p1\">for data in ${CARD[@]};<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>do<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>CARDS=${CARD[$data]}<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>function_getdata<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>GFILE=$FILE<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>FOUT=$FILE<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>echo &#8220;Graphing $GFILE&#8221;<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>function_graph<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>echo &#8220;Done&#8221;;<\/p>\n<p class=\"p1\">done<\/p>\n<p class=\"p1\">## Create the Combo Graph<\/p>\n<p class=\"p1\">for combo in 1<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>do<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>echo &#8220;Creating Combo graph&#8221;<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>GFILE=&#8221;ATM0.0.0\\&#8221;,\\&#8221;ATM0.1.0&#8243;<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>FOUT=&#8221;COMBO&#8221;<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>function_graph<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>echo &#8220;Done&#8221;;<\/p>\n<p class=\"p1\">done<\/p>\n<p class=\"p1\">## Clean Up<\/p>\n<p class=\"p1\">for clean in ${CARD[@]};<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>do<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>rm ATM0.$clean.0<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>echo &#8220;Cleaning up ATM0.$clean.0&#8221;<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>echo &#8220;Done&#8221;;<\/p>\n<p class=\"p1\">done<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cisco ATM dsl bin bucket grapher &nbsp; &#8212;&#8212;&#8212;&#8212;&#8212;- #!\/bin\/bash #Be quiet \/root\/cisco\/script.sh &gt;&gt; \/dev\/null 2&gt;&amp;1 #debug #set -x #\/debug #&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; #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 #&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 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 ## [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[5,6,3,30],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/97"}],"collection":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=97"}],"version-history":[{"count":5,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":885,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions\/885"}],"wp:attachment":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}