-
Notifications
You must be signed in to change notification settings - Fork 0
/
bihourly.sh
executable file
·65 lines (55 loc) · 1.15 KB
/
bihourly.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# @(#) $Id: bihourly.sh,v 1.2 2006/07/28 18:19:32 leres Exp $ (LBL)
#
# bihourly arpwatch job
#
PATH=${PATH}:/usr/local/sbin
export PATH
#
cd /var/lib/arpwatch
#
list="`cat list`"
cname="`cat cname`"
temp1=/tmp/bihourly.1.$$
temp2=/tmp/bihourly.2.$$
d=/tmp/errs
# imperfect hack
l=/tmp/bihourly.lock
if [ -f ${l} ]; then
echo "skipping arpwatch bihourly job, lock file exists"
exit
fi
trap 'rm -f ${l}; exit 1' 1 2 3 15
touch ${l}
alist=""
for r in ${list}; do \
arpfetch ${r} ${cname} > ${r} 2> ${temp1}
if [ -s ${temp1} ]; then
echo "arpfetch ${r} errors:"
xr=${d}/${r}.$$
echo "(file ${r} saved in ${xr})"
mkdir -p ${d}
cp ${r} ${xr}
sed -e 's/^/ /' ${temp1}
continue
fi
alist="${alist} ${r}"
done
arpsnmp -d ${alist} > ${temp1} 2>&1
sed -e '/arpsnmp: suppressed DECnet flip flop/d' ${temp1} > ${temp2}
if [ -s ${temp2} ]; then
mail -s "`hostname` arpwatch report" \
[email protected] < ${temp2}
fi
rm -f ${temp1} ${temp2}
d=/www/NETINFO/arpwatch
f=arp.dat
cp ${f} ${d}
f=ethercodes.dat
diff ethercodes.dat ${d} >>/dev/null 2>&1
if [ $? -ne 0 ]; then
echo Updating ${d}/${f}
cp ${f} ${d}
fi
rm ${l}
exit 0