Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- LFILE="/var/lib/dhcp/dhcpd.leases"
- TMPFILE="/tmp/dhcp-statuscount.txt"
- declare -A StateArray
- awk '/lease|^ *binding state|hardware|starts|! next/ { printf "%s", $0 } /\}/ {print "\n"}' ${LFILE}| tr -d \; | grep \: > ${TMPFILE}
- while read a b c d e f g h i state j k hwa rest
- do
- StateArray[${hwa}]="${state}"
- done < "${TMPFILE}"
- Active=0
- for Address in ${!StateArray[*]}
- do
- if [ "${StateArray[${Address}]}" = "active" ] ; then Active=$(( ${Active} + 1 )) ; fi
- done
- echo $Active
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement