{"id":95,"date":"2014-01-13T17:53:59","date_gmt":"2014-01-13T16:53:59","guid":{"rendered":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/?p=95"},"modified":"2014-01-28T07:17:25","modified_gmt":"2014-01-28T06:17:25","slug":"interface-load-snmp","status":"publish","type":"post","link":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/?p=95","title":{"rendered":"Interface Load (SNMP )"},"content":{"rendered":"<p>Dieser Beitrag beschreibt ein Shell Script um die Interface Auslastung eines Routers anzuzeigen. Die Abfragen erfolgen per SNMP Protokoll.<br \/>\nBez\u00fcglich der Zeitintervalle ist zu beachten, dass nicht alle Router Interface Daten im Sekunden Takt liefern (z.B. bei Cisco ASR Routern werden nur alle 10 Sekunden die Interface Counter aktualisiert).<\/p>\n<p>Das Script ifload nutzt graph.fnc f\u00fcr die Grafische ASCII Darstellung. Beide Dateien m\u00fcssen sich im gleichen Verzeichniss befinden. Ansonsten m\u00fcssen die SNMP Tools (snmpget, snmpwalk) installiert sein. Alle Scripte sind in meinem Home Directory im Subfolder \u201esnmp\u201c abgelegt, von wo ich ifload starte.<\/p>\n<pre class=\"toolbar:2 striped:false marking:false ranges:false nums:false nums-toggle:false wrap-toggle:false plain:false plain-toggle:false popup:false expand-toggle:false decode-attributes:false trim-whitespace:false trim-code-tag:false mixed:false show_mixed:false lang:default decode:true\" title=\"Usage of ifload\">Usage of ifload:\n\n  ifload &lt;HOSTNAME&gt; [INTERFACE] [-i|-h|-g|-c &lt;community&gt;]\n\n  -i &lt;nnn&gt; : Interval in Seconds, default = 10\n  -h       : this Help message\n  -g       : enable Graphic (ASCII) view\n  -d       : enable Debug\n\n  -c &lt;community&gt; : set community String, default: public\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Ein Beispiel:<\/p>\n<pre class=\"toolbar:2 striped:false marking:false ranges:false nums:false nums-toggle:false wrap-toggle:false plain:false plain-toggle:false popup:false expand-toggle:false decode-attributes:false trim-whitespace:false trim-code-tag:false mixed:false show_mixed:false lang:default decode:true\" title=\"Example of ifload\">\nifload - Mon Jan 13 12:19:46 CET 2014  Start: 12:18:27  Interval: 63  Range: 60 s\nDevice Name: test_router_de\nInterface: Gi0\/1.101  Descr.: *** Primary VPN WAN Link ***\nBandwidth: 300M\nIOS:  7300 Software (C7300-JS-M), Version XX.X(XX)XXX, RELEASE SOFTWARE (fc1)\n\n------------------------------------------------------------------------------------------\nDate       Data (Bps)    Error         Discard       Load %        CPU Load %\nTime       In     Out    In     Out    In     Out    In     Out    5sec   1min   5min\n------------------------------------------------------------------------------------------\n18:19:46   28M    81M    0      0      0      0      9      27     48     42     39\n\nINPUT:\n\n 61M2 |                   O                                         | 61M2\n      |                   O                                    .    |\n      |                   O                                    O    |\n      |                   O               o                    O    |\n      |                   O               O                    O    |\n      |           o       O               O                   oOO   |\n      |           O  o   oO   O           O   .           . ..OOO   |\n 27M6 | ----------O--O---OO--OO.-O.o-O.o--O--OO.--O.--oo-OOOOOOOO.o | 27M6\n 19M4 | .     ...oO..OO .OOOoOOOoOOO.OOOooOoOOOOoOOOoOOO.OOOOOOOOOO | 19M4\n\nOUTPUT:\n\n 92M5 |                      O                                      | 92M5\n      |                      O                                  O   |\n      |             .        O.                                 O . |\n      |             O . O    OO       o                       ooO O |\n      | .  .        OoO O  o OO.  . o O               oO     oOOOOO |\n 68M8 | OooO.-----OOOOO-O.oO-OOO..OOOOO---------------OO.---.OOOOOO | 68M8\n      | OOOOO Oo OOOOOOoOOOOOOOOOOOOOOOOoO      O    oOOO ..OOOOOOO |\n      | OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.O.  OOO   OOOOOOOOOOOOOO |\n 51M8 | OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO. OOOO.OOOOOOOOOOOOOOO | 51M8\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Quelltext zum Script <strong>ifload<\/strong><\/p>\n<pre class=\"minimize:true lang:sh decode:true\" title=\"ifload\">#!\/bin\/bash\n#\n# Klaus Scheffer\n\nDEBUG=0\nHOST=$1\nIFNAME=\"\"\nINTERVAL=10\nGRAPH=0\nSTARTTIME=$(date \"+%H:%M:%S\")\nSNMPBINPATH=\/usr\/bin\nAWKBIN=\/bin\/awk\nCOMMUNITY=public\n\nifloadhelp() {\ncat &lt;&lt;EOF\nUsage of $(basename $0):\n\n  $(basename $0) &lt;HOSTNAME&gt; [INTERFACE] [-i|-h|-g|-c &lt;community&gt;]\n\n  -i &lt;nnn&gt; : Interval in Seconds, default = $INTERVAL\n  -h       : this Help message\n  -g       : enable Graphic (ASCII) view\n  -d       : enable Debug\n\n  -c &lt;community&gt; : set community String, default: public\n\nEOF\n\nexit 0\n}\n\n# load my presettings from homedirectory\n[ -e ~\/.ifload.conf ] &amp;&amp; . ~\/.ifload.conf\n\nif [ \"$HOST\" == \"\" ]; then\n  echo -e \"Error: Wrong usage!\\n\\n\"\n  ifloadhelp\n  exit 1\nfi\nshift\n[ $# -gt 0 ] &amp;&amp; IFNAME=$1\n\nwhile [ $# -gt 0 ]; do\n  case $1 in\n    -i)\n      INTERVAL=$2\n      shift\n    ;;\n    -h)\n      ifloadhelp\n    ;;\n    -g)\n      GRAPH=1\n    ;;\n    -d)\n      DEBUG=1\n    ;;\n    -c)\n      COMMUNITY=$2\n      shift\n    ;;\n  esac\n  shift\ndone\n\n#echo \"$HOST $IFNAME $INTERVAL $GRAPH\"\n#exit 0\n\nif [ $GRAPH -gt 0 ]; then\n  . .\/graph.fnc\n  DATA_IN=$(for i in $(seq 60); do echo \"0\"; done)\n  DATA_OUT=$(for i in $(seq 60); do echo \"0\"; done)\n  i=0\nfi\n\nDEVNAME=$($SNMPBINPATH\/snmpget -v 2c -O v -c $COMMUNITY $HOST SNMPv2-MIB::sysName.0 | awk '{print $2}' | awk -F. '{print $1}')\nSYSDESCR=$($SNMPBINPATH\/snmpget -v 2c -O v -c $COMMUNITY $HOST SNMPv2-MIB::sysDescr.0 | head -n1 | cut -d',' -f2-60)\n# echo \"$SNMPBINPATH\/snmpget -v 2c -O v -c $COMMUNITY $HOST SNMPv2-MIB::sysName.0\"\nif [ -z $DEVNAME ]; then\n  echo \"Error: Device unreacheable or without Name!\"\n  exit 1\n#else\n[ $DEBUG ] &amp;&amp; echo \"Device Name: $DEVNAME\"\nfi\n\nif [ \"${IFNAME}\" == \"\" ]; then\n  echo \"Choose one of the following Interfaces:\"\n  $SNMPBINPATH\/snmpwalk -v 2c -c $COMMUNITY $HOST IF-MIB::ifName | awk '{ print $1 \" : \" $4 }'\n  exit 0\nfi\n\nCHKNUM() {\n  if [[ $1 = *[[:digit:]]* ]]; then\n    echo $1\n  else\n    echo \"0\"\n  fi\n}\n\n# $1 = N0  (T = now)\n# $2 = N1  (T = last intervall)\n# $3 = COUNTERLENGTH (Bits)\nCALCDIFF() {\n  N0=$(CHKNUM $1)\n  N1=$(CHKNUM $2)\n  COUNTERLENGTH=$3\n  if [ $N0 -ge $N1 ]; then\n    let D=N0-N1\n  else\n    D=$(bc &lt;&lt;&lt; \"(2^$COUNTERLENGTH)-$N1+$N0\")\n  fi\n  echo $D\n}\n\nGETCOUNTER() {\n  local ct=$(echo $COUNTER | cut -d\" \" -f $1)\n  if [ \"$ct\" == 'No' ]; then\n    echo 0\n  else\n    echo $ct | sed 's\/[A-Za-z: ]\/\/g'\n  fi\n}\n\nAUTORANGE() {\n  local f=$1\n  local ar=${f\/\\.*}\n  local div=1\n  [ $ar -ge 1 ] &amp;&amp; div=1 &amp;&amp; x=\" \"\n  [ $ar -ge 1000 ] &amp;&amp; div=1000 &amp;&amp; x=\"k\"\n  [ $ar -ge 1000000 ] &amp;&amp; div=1000000 &amp;&amp; x=\"M\"\n  [ $ar -ge 1000000000 ] &amp;&amp; div=1000000000 &amp;&amp; x=\"G\"\n  let arr=ar\/div\n  echo \"$arr$x\"\n}\n\nGREP_IFNAME=\"${IFNAME}$\"\n#echo $GREP_IFNAME\n#echo \"snmpwalk -v 2c -c $COMMUNITY $HOST IF-MIB::ifName | grep \\\"$GREP_IFNAME\\\"\"\nIFINDEX=$($SNMPBINPATH\/snmpwalk -v 2c -c $COMMUNITY $HOST IF-MIB::ifName | grep \"$GREP_IFNAME\" | awk '{ print $1 }' | awk -F\".\" '{ print $2 }')\n[ $DEBUG -gt 0 ] &amp;&amp; echo \"Intercae $IFNAME = Interface ID $IFINDEX\"\nif [ \"$IFINDEX\" == \"\" ]; then\n  echo \"Error: ${IFNAME} unkown on this Device!\"\n  exit 1\nfi\n\n[ $DEBUG -gt 0 ] &amp;&amp; echo \"IFSPEED=$($SNMPBINPATH\/snmpget -v 2c -c $COMMUNITY $HOST IF-MIB::ifSpeed.$IFINDEX)\"\nIFSPEED=$($SNMPBINPATH\/snmpget -v 2c -c $COMMUNITY $HOST IF-MIB::ifSpeed.$IFINDEX | awk '{ print $4 }')\nIFALIAS=$($SNMPBINPATH\/snmpget -v 2c -c $COMMUNITY $HOST IF-MIB::ifAlias.$IFINDEX | awk '{print substr($0,index($0,$4))}')\n\nDIV=1\n[ $IFSPEED -gt 1000000 ] &amp;&amp; DIV=1000\n[ $IFSPEED -gt 10000000 ] &amp;&amp; DIV=1000000\n[ $IFSPEED -gt 100000000 ] &amp;&amp; DIV=1000000\n\ncase $DIV in\n  1)\n    OF=Bps\n  ;;\n  1000)\n    OF=kBps\n  ;;\n  1000000)\n    OF=MBps\n  ;;\n  1000000000)\n    OF=GBps\n  ;;\n  *)\n    OF=Bps\n  ;;\nesac\n\n# echo \"IFSPEED($IFSPEED)=$(AUTORANGE $IFSPEED)\"\n\nN=0\nD_TS=0\nD_IN=0\nD_OUT=0\nD_EIN=0\nD_EOUT=0\nD_DISCIN=0\nD_DISCOUT=0\nA_TS=0\nA_IN=0\nA_OUT=0\nA_EIN=0\nA_EOUT=0\nA_DISCIN=0\nA_DISCOUT=0\n\n# IF-MIB::ifHCInOctets\n\nif [ $DIV -ge 1000000 ]; then\n  MIBLIST=\"SNMPv2-MIB::sysUpTime.0 IF-MIB::ifHCInOctets.$IFINDEX IF-MIB::ifHCOutOctets.$IFINDEX IF-MIB::ifInErrors.$IFINDEX IF-MIB::ifOutErrors.$IFINDEX IF-MIB::ifInDiscards.$IFINDEX IF-MIB::ifOutDiscards.$IFINDEX SNMPv2-SMI::enterprises.9.2.1.56.0 SNMPv2-SMI::enterprises.9.2.1.57.0 SNMPv2-SMI::enterprises.9.2.1.58.0\"\nelse\n  MIBLIST=\"SNMPv2-MIB::sysUpTime.0 IF-MIB::ifInOctets.$IFINDEX IF-MIB::ifOutOctets.$IFINDEX IF-MIB::ifInErrors.$IFINDEX IF-MIB::ifOutErrors.$IFINDEX IF-MIB::ifInDiscards.$IFINDEX IF-MIB::ifOutDiscards.$IFINDEX SNMPv2-SMI::enterprises.9.2.1.56.0 SNMPv2-SMI::enterprises.9.2.1.57.0 SNMPv2-SMI::enterprises.9.2.1.58.0\"\nfi\n\nCOUNTER=$($SNMPBINPATH\/snmpget -v 2c -c $COMMUNITY $HOST $MIBLIST | sed 's\/:\/\/g' | awk '{ print $3 }')\n\nclear\nwhile [ 1 == 1 ]; do\n\n  LOAD=$($SNMPBINPATH\/snmpget -v 2c -c $COMMUNITY $HOST $MIBLIST | awk '{ print $4 }' | xargs)\n\n  if [ $DEBUG -eq 1 ]; then\n    echo \"IFINDEX = $IFINDEX\"\n    echo \"$SNMPBINPATH\/snmpget -v 2c -c $COMMUNITY $HOST $MIBLIST\"\n    echo \"n=$N load=$LOAD\"\n  else\n\n  # echo \"n=$N load=$LOAD\"\n\n  RANGE=\n\n  TS=$(echo $LOAD | cut -d\" \" -f 1 | sed 's\/[()]\/\/g')\n  IN=$(echo $LOAD | cut -d\" \" -f 2)\n  OUT=$(echo $LOAD | cut -d\" \" -f 3)\n  ERRIN=$(echo $LOAD | cut -d\" \" -f 4)\n  ERROUT=$(echo $LOAD | cut -d\" \" -f 5)\n  DISCIN=$(echo $LOAD | cut -d\" \" -f 6)\n  DISCOUT=$(echo $LOAD | cut -d\" \" -f 7)\n  CPU5=$(echo $LOAD | cut -d\" \" -f 8)\n  CPU60=$(echo $LOAD | cut -d\" \" -f 9)\n  CPU300=$(echo $LOAD | cut -d\" \" -f 10)\n\n  let D_TS=TS-A_TS\n  let RANGE=INTERVAL*60\n  D_IN=$(CALCDIFF $IN $A_IN $(GETCOUNTER 2))\n  D_OUT=$(CALCDIFF $OUT $A_OUT $(GETCOUNTER 3))\n  D_EIN=$(CALCDIFF $ERRIN $A_EIN $(GETCOUNTER 4))\n  D_EOUT=$(CALCDIFF $ERROUT $A_EOUT $(GETCOUNTER 5))\n  D_DISCIN=$(CALCDIFF $DISCIN $A_DISCIN $(GETCOUNTER 6))\n  D_DISCOUT=$(CALCDIFF $DISCOUT $A_DISCOUT $(GETCOUNTER 7))\n\n  A_TS=$TS\n  A_IN=$IN\n  A_OUT=$OUT\n  A_EIN=$ERRIN\n  A_EOUT=$ERROUT\n  A_DISCIN=$DISCIN\n  A_DISCOUT=$DISCOUT\n\n  # 1 Octett = 8 Bit\n  #let BPS_IN=D_IN*8*100\/D_TS\n  #let BPS_OUT=D_OUT*8*100\/D_TS\n  #let BPS_EIN=D_EIN*8*100\/D_TS\n  #let BPS_EOUT=D_EOUT*8*100\/D_TS\n\n  BPS_IN=$(echo \"$D_IN*8*100\/$D_TS\" | bc -l)\n  BPS_OUT=$(echo \"$D_OUT*8*100\/$D_TS\" | bc -l)\n  BPS_EIN=$(echo \"$D_EIN*8*100\/$D_TS\" | bc -l)\n  BPS_EOUT=$(echo \"$D_EOUT*8*100\/$D_TS\" | bc -l)\n\n  IFLOAD_IN=$(echo \"$BPS_IN*100\/$IFSPEED\" | bc -l)\n  IFLOAD_OUT=$(echo \"$BPS_OUT*100\/$IFSPEED\" | bc -l)\n\n  if [ $GRAPH -eq 0 ]; then\n    BPS_IN=$(AUTORANGE $BPS_IN)\n    BPS_OUT=$(AUTORANGE $BPS_OUT)\n    BPS_EIN=$(AUTORANGE $BPS_EIN)\n    BPS_EOUT=$(AUTORANGE $BPS_EOUT)\n\n    if [ $N -eq 0 ]; then\n      echo -e \"\\e[H$(basename $0) - $(date)  Start: $STARTTIME  Interval: $N  Range: $RANGE s\"\n      echo \"Device Name: $DEVNAME\"\n      echo \"Interface: $IFNAME  Descr.: $IFALIAS\"\n      echo \"Bandwidth: $(AUTORANGE $IFSPEED)\"\n      echo -e \"IOS: $SYSDESCR\\n\"\n      printf \"%49s\\n\" \"------------------------------------------------------------------------------------------\"\n      printf \"%-10s %-13s %-13s %-13s %-13s %-13s\\n\" Date \"Data (Bps)\" Error Discard \"Load %\" \"CPU Load %\"\n      printf \"%-10s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s\\n\" Time In Out In Out In Out In Out 5sec 1min 5min\n      printf \"%49s\\n\" \"------------------------------------------------------------------------------------------\"\n    else\n      # echo \"$(date \"+%H:%M:%S\") ($TS) In\/Out=$BPS_IN\/$BPS_OUT $OF  Err(In\/Out)=$D_EIN\/$D_EOUT  Load(In\/Out)=$IFLOAD_IN\/$IFLOAD_OUT%\"\n      # printf \"%-10s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s\\n\" $(date \"+%H:%M:%S\") $BPS_IN $BPS_OUT $D_EIN $D_EOUT $D_DISCIN $D_DISCOUT $IFLOAD_IN $IFLOAD_OUT $CPU5 $CPU60 $CPU300\n      printf \"%-10s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s\\n\" $(date \"+%H:%M:%S\") $BPS_IN $BPS_OUT $D_EIN $D_EOUT $D_DISCIN $D_DISCOUT ${IFLOAD_IN\/\\.*} ${IFLOAD_OUT\/\\.*} $CPU5 $CPU60 $CPU300\n    fi\n  else\n\n    DATA_IN=$(echo $DATA_IN $BPS_IN | cut -d' ' -f2-60)\n    DATA_OUT=$(echo $DATA_OUT $BPS_OUT | cut -d' ' -f2-60)\n\n    echo -e \"\\e[H$(basename $0) - $(date)  Start: $STARTTIME  Interval: $N  Range: $RANGE s\"\n    echo \"Device Name: $DEVNAME\"\n    echo \"Interface: $IFNAME  Descr.: $IFALIAS\"\n    echo \"Bandwidth: $(AUTORANGE $IFSPEED)\"\n    echo -e \"IOS: $SYSDESCR\\n\"\n    printf \"%49s\\n\" \"------------------------------------------------------------------------------------------\"\n    printf \"%-10s %-13s %-13s %-13s %-13s %-13s\\n\" Date \"Data (Bps)\" Error Discard \"Load %\" \"CPU Load %\"\n    printf \"%-10s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s\\n\" Time In Out In Out In Out In Out 5sec 1min 5min\n    printf \"%49s\\n\" \"------------------------------------------------------------------------------------------\"\n    printf \"%-10s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s\\n\" $(date \"+%H:%M:%S\") $(AUTORANGE $BPS_IN) $(AUTORANGE $BPS_OUT) $D_EIN $D_EOUT $D_DISCIN $D_DISCOUT ${IFLOAD_IN\/\\.*} ${IFLOAD_OUT\/\\.*} $CPU5 $CPU60 $CPU300\n\n    echo -e \"\\nINPUT:\\n\"\n    graph 9 $DATA_IN\n    echo -e \"\\nOUTPUT:\\n\"\n    graph 9 $DATA_OUT\n\n  fi\n  fi\n  sleep $INTERVAL\n  let N=N+1\n\n  [ $N -gt 600 ] &amp;&amp; exit 0\n\ndone\n\n#\n#end<\/pre>\n<p>&nbsp;<\/p>\n<p>Funktion f\u00fcr Ascii Grafik Ausgabe: <strong>graph.fnc<\/strong> (Original Source: <a title=\"http:\/\/bashscripts.org, Ascii Graphing\" href=\"http:\/\/bashscripts.org\/forum\/viewtopic.php?f=7&amp;t=1141\">Bashscripts.org, Ascii Graphing<\/a>)<\/p>\n<pre class=\"minimize:true lang:sh decode:true\" title=\"graph.fnc\">#!\/bin\/bash\n## graph.fnc -- by Patsie\n# Shell function that draws a graph with average line in ASCII\n# The graph will have a width equal to the number of data points\n# and a height equal to the first argument\n# Usage: graph &lt;height&gt; &lt;val1&gt; [&lt;val2&gt; [&lt;...&gt;]]\n\nfunction graph {\n  height=$1; shift;\n\n  echo \"$@\" | awk -v height=$height 'BEGIN { }\n    ## convert big numbers to short kilo\/mega\/giga etc numbers\n    function pow1k(bignum) {\n      metric=1;\n      num=bignum;\n\n      # devide by 1000 until we have got a small enough number\n      while (num&gt;=1000) { metric++; num\/=1000; }\n      num=int(num);\n\n      # get SI prefix (kilo, mega, giga, tera, peta, exa, zotta, yotta)\n      si=substr(\" KMGTPEZY\", metric, 1);\n\n      # get a division remainder to total our number of characters to a maximum of 4\n      division=substr(bignum, length(num)+1, 3-length(num));\n\n      # right align the output\n      str=sprintf(\"%s%c%s\", num, si, division);\n      return(sprintf(\"% 4s\", str));\n    }\n  {\n    # get smallest, largest and total of all numbers\n    min=max=tot=$1;\n    for (x=2; x&lt;=NF; x++) { tot+=$x; if ($x&gt;max) max=$x; if ($x&lt;min) min=$x; }\n\n    # the difference between largest and smallest number is out working area\n    diff=max-min;\n    if (diff==0) diff=1;                                # all numbers are the same?!\n    # some fancy math to get the average of all numbers\n    avg=(tot\/NF);\n    avgfull=int(((avg-min)*height\/diff));               # average full\n    avghalf=int(((avg-min)*height\/diff)%1+0.5);         # average half\n\n    # fill arrays bars\n    for (x=1; x&lt;=NF; x++) {\n      v=$x-min;                                         # our value\n      i=0;array[x]=\"\";                                  # blank the array\n      full=int((v*height\/diff));                        # how many full?\n      ttrd=int((v*height\/diff)%1+0.333);                # 2\/3rd full?\n      otrd=int((v*height\/diff)%1+0.666);                # 1\/3rd full?\n      while (i&lt;full)   { array[x]=array[x]\"O\"; i++; }   # fill all fulls\n      if    (ttrd&gt;0)   { array[x]=array[x]\"o\"; i++; }   # fill 2\/3rd\n      else if (otrd&gt;0) { array[x]=array[x]\".\"; i++; }   # or 1\/3rd\n\n      # average line or blank\n      while (i&lt;height) {                                # fill to the top\n         if (i==avgfull)                                # with average line\n           if (avghalf&gt;0) array[x]=array[x]\"-\";\n           else array[x]=array[x]\"_\";\n         else array[x]=array[x]\" \";                     # or mostly blanks\n         i++;\n      }\n    }\n\n    # display output\n    for (y=height; y&gt;0; y--) {\n      line=\"\"; num=\"    \";                              # blank line and number\n      if (y==avgfull+1) { num=pow1k(int(avg)); }        # show average number\n      if (y==height)    { num=pow1k(max); }             # show maximum number\n      if (y==1)         { num=pow1k(min); }             # show minimum number\n\n      for (x=1; x&lt;=NF; x++)                             # do for all data values\n        line=line\"\"substr(array[x],y,1);                # create line from arrays\n      printf(\" %s | %s | %s\\n\", num, line, num);        # display 1 line\n    }\n  }'\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Dieser Beitrag beschreibt ein Shell Script um die Interface Auslastung eines Routers anzuzeigen. Die Abfragen erfolgen per SNMP Protokoll. Bez\u00fcglich der Zeitintervalle ist zu beachten, dass nicht alle Router Interface Daten im Sekunden Takt liefern (z.B. bei Cisco ASR Routern &hellip; <a href=\"https:\/\/www.scheffer-online.de\/blog\/wordpress\/?p=95\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[9,11,12,10],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-cisco","tag-cisco-2","tag-network","tag-netzwerk","tag-snmp"],"_links":{"self":[{"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=95"}],"version-history":[{"count":27,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/95\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}