BASH   106

statclock

Guest on 22nd April 2022 01:25:22 AM

  1. #!/bin/sh
  2.  
  3. host="$1"
  4. community="$2"
  5.  
  6. obtain() {
  7.   snmpwalk -v1 -c "$community" $host .1.3.6.1.4.1.2021.11 | (
  8.   s=0
  9.   while read o e t v
  10.   do
  11.     case "$o" in
  12. #    *ssCpuRawUser*|*ssCpuRawNice*|*ssCpuRawSystem*|*ssCpuRawIdle*|*ssCpuRawInterrupt*|*CpuRawKernel*)
  13.     *ssCpuRawUser*|*ssCpuRawNice*|*ssCpuRawIdle*|*ssCpuRawInterrupt*|*CpuRawKernel*)
  14.          s=$(($s+$v))
  15.          ;;
  16.     esac
  17.   done
  18.   echo $s
  19.  )  
  20. }
  21.  
  22. prev=`obtain`
  23. while :
  24. do
  25.  sleep 1
  26.  new=`obtain`
  27.  echo $(($new-$prev))
  28.  prev=$new
  29. done

Raw Paste


Login or Register to edit or fork this paste. It's free.