- ==================potongdisini=====================================
- # cat /sbin/macduplicate.sh
- #!/bin/sh
- #x=`telnetmikrotik.exp`
- /sbin/sshwrap.exp 10.20.30.1 22000 diag diag "ip arp print without-paging terse file=maclist"
- wget -O /tmp/maclist.txt ftp://diag:diag@10.20.30.1/maclist.txt
- a=`cat /tmp/maclist.txt | cut -f 3 -d "=" | egrep "([0-9A-F]{2}:){5}[0-9A-F]{2}" | cut -f 1 -d " " | sort`
- i=`cat /tmp/maclist.txt | cut -f 3 -d "=" | egrep "([0-9A-F]{2}:){5}[0-9A-F]{2}" | cut -f 1 -d " " | sort | wc -l`
- b=`cat /tmp/maclist.txt | cut -f 3 -d "=" | egrep "([0-9A-F]{2}:){5}[0-9A-F]{2}" | cut -f 1 -d " " | sort | uniq -d`
- j=`cat /tmp/maclist.txt | cut -f 3 -d "=" | egrep "([0-9A-F]{2}:){5}[0-9A-F]{2}" | cut -f 1 -d " " | sort | uniq -d | wc -l`
- rm -rf /tmp/maclist.txt
- x=0
- y=0
- z=0
- alarm=4
- while [ $z -lt $i ]; do
- let "z=$z+1"
- maclist[z]=`echo $a |cut -f $z -d " "`
- # echo "$z- ${maclist[z]}"
- done
- z=0
- while [ $z -lt $j ]; do
- let "z=$z+1"
- macduplist[$z]=`echo $b |cut -f $z -d " "`
- # echo "$z- ${macduplist[$z]}"
- done
- z=0
- y=0
- while [ $y -lt $i ]; do
- let "y=$y+1"
- while [ $z -lt $j ]; do
- let "z=$z+1"
- f=${maclist[$y]}
- g=${macduplist[$z]}
- if [ $f == $g ]; then
- # if [ {$maclist[$y]} == {$macduplist[$z]} ]; then
- let "dupcount[$z]=${dupcount[$z]}+1"
- # echo "$y dup $f $g"
- else
- # echo "$y ${maclist[$y]} ${macduplist[$z]}"
- echo
- fi
- done
- z=0
- done
- z=0
- y=0
- while [ $z -lt $j ]; do
- let "z=$z+1"
- if [ ${dupcount[z]} -ge $alarm ]; then
- # echo "awas! ${macduplist[z]}"
- /sbin/sshwrap.exp 10.20.30.1 22000 diag diag "system script run sirine"
- /sbin/sshwrap.exp 10.20.30.1 22000 diag diag ":log info ${dupcount[z]}-mac-address-${macduplist[z]}-more-than-$alarm-entries"
- fi
- # echo "${macduplist[z]}-${dupcount[z]}"
- done
- #
- ==================potongdisini=====================================
- # cat /sbin/sshwrap.exp
- #!/usr/local/bin/expect -f
- #spawn "ssh $argv 1 -p $argv 2 -l $argv 3 $argv 5"
- #expect assword:
- #send $argv 4\r
- set addr [lindex $argv 0]
- set port [lindex $argv 1]
- set user [lindex $argv 2]
- set password [lindex $argv 3]
- set command [lindex $argv 4]
- spawn ssh $addr -p $port -l $user
- expect assword:
- send $password\r
- expect >
- send $command\r
- expect >
- send quit\r
- #
- ==================potongdisini=====================================
- [yusuf81@linkmedia] > system script print terse from=16
- 0 name=sirine source=:for t from=1000 to=2000 step=20 do={:beep frequency=$t length=10ms; :delay 10ms}\r\n:for t from=2000
- to=1000 step=-20 do={:beep frequency=$t length=10ms; :delay 10ms}
- owner=yusuf81 policy=ftp,read,winbox last-started=dec/08/2008 20:25:16 run-count=48
- [yusuf81@linkmedia] >
4 years ago
No comments:
Post a Comment