Advertisement
Guest User

Untitled

a guest
Oct 1st, 2012
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/bash
  2. LFILE="/var/lib/dhcp/dhcpd.leases"
  3. TMPFILE="/tmp/dhcp-statuscount.txt"
  4.  
  5. declare -A StateArray
  6.  
  7. awk '/lease|^ *binding state|hardware|starts|! next/ { printf "%s", $0 } /\}/ {print "\n"}' ${LFILE}| tr -d \; | grep \: > ${TMPFILE}
  8.  
  9. while read a b c d e f g h i state j k hwa rest
  10. do
  11.  StateArray[${hwa}]="${state}"
  12. done < "${TMPFILE}"
  13.  
  14. Active=0
  15. for Address in ${!StateArray[*]}
  16. do
  17.  if [ "${StateArray[${Address}]}" = "active" ] ; then Active=$(( ${Active} + 1 )) ; fi
  18. done
  19.  
  20. echo $Active
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement