- 论坛徽章:
- 0
|
原帖由 merlin852 于 2008-1-17 11:25 发表
贴你的脚本看看
/etc/crontab:
20 */1 * * * root /root/check.sh
/var/log/cron:
Jan 17 08:20:00 ns000 CROND[8594]: (root) CMD (/root/check.sh)
Jan 17 09:20:00 ns000 CROND[8621]: (root) CMD (/root/check.sh)
Jan 17 10:20:00 ns000 CROND[8648]: (root) CMD (/root/check.sh)
Jan 17 11:20:00 ns000 CROND[8675]: (root) CMD (/root/check.sh)
cat /root/check.sh:
#!/bin/bash
>/root/temp.txt
tcpdump -nnnv udp >>/root/temp.txt &
time_for_check=`date "+%R" -d'1 minute'`
sleep 120
killall tcpdump
data=`grep "$time_for_check" /root/temp.txt|grep "53:"|wc -l`
getip=`ip a|grep eth0|awk 'END{print $2}'|cut -d'/' -f1`
hostname=`hostname`
mysql -h 222.*.*.* -u user -p password databaes -e "insert into data values ('','$hostname','$getip','$data',now())"
[ 本帖最后由 xmbbx 于 2008-1-17 11:44 编辑 ] |
|