°Ô½Ã¹° 1,357°Ç
   
DHCP server ¸ð´ÏÅ͸µ ½ºÅ©¸³Æ®
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2016-08-23 (È­) 10:45 Á¶È¸ : 3108
±ÛÁÖ¼Ò :
                                
Å×½ºÆ® ȯ°æ
# cat /etc/redhat-release
CentOS release 6.5 (Final)


[root@localhost ~]# cat dhcp_monitor.sh
#!/bin/bash

rm /tmp/showdhcp.log &
rm /tmp/tmp* &
tempFile=$(mktemp)

cat /var/lib/dhcpd/dhcpd.leases \
  | grep \
      -e '^lease ' \
      -e '^  binding state' \
      -e hardware \
      -e client-hostname \
      -e } >$tempFile.1

sed -e "s/^lease \(.*\) {$/\1~/" \
    -e "s/^  binding state \(.*\);$/\1~/" \
    -e "s/^  hardware ethernet \(.*\);$/\1~/" \
    -e "s/  client-hostname \(.*\);$/\1~/" \
    -e "s/^}//" \
    $tempFile.1 > $tempFile.2

sed -e ":'loop';/~$/N;s/~\n/,/;t'loop'" \
    -e "s/,$//" \
    -e "s/,/\t/g" \
    $tempFile.2 | sort > $tempFile.3

sed -e'$!N;/^\(.*\)\n\1$/!P;D' $tempFile.3 > $tempFile.4

print=$(printf "IP Addr\t\tStatus\t\tMAC\t\tHost Name\n")
cat $tempFile.4 > /tmp/showdhcp.log &
sed -i "1i $print" /tmp/showdhcp.log
#rm -rvf /tmp/Non_Active_User*
#rm -rvf /tmp/Active_User*
#cp -rvf $tempFile.4 /tmp/showdhcp.log &
free=$(grep -o -w 'free' /tmp/showdhcp.log | wc -w)
active=$(grep -o -w 'active' /tmp/showdhcp.log | wc -w)
echo -e ""
echo -e "--------- Total Count- Active & Non Active -----------"
echo -e ""
echo -e "Total Active User :"       $free
echo -e "Total Non Active User :"   $active
echo -e "------------------------------------------------------"
#sed -n '/free/p' /tmp/showdhcp.log > /tmp/Non_Active_User_$(date +"%Y-%m-%d__%H%M%S").log
#sed -n '/active/p' /tmp/showdhcp.log > /tmp/Active_User_$(date +"%Y-%m-%d__%H%M%S").log
rm $tempFile.*
#rm -rvf /tmp/showdhcp.log
#rm -rvf /tmp/tmp* &


[root@localhost ~]# sh dhcp_monitor.sh

--------- Total Count- Active & Non Active -----------

Total Active User : 35
Total Non Active User : 11
------------------------------------------------------


[root@localhost ~]# cat /tmp/showdhcp.log



Ãâó
http://www.ostechnix.com/monitor-dhcp-server-usage/

À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.