source: trunk/DataCheck/Monitoring/CheckNetworkStatus.sh@ 17850

Last change on this file since 17850 was 17530, checked in by Daniela Dorner, 11 years ago
improved logging output to be sent via email
  • Property svn:executable set to *
File size: 1016 bytes
Line 
1#!/bin/bash
2
3numnetworks=6
4
5vals=(`/sbin/ifconfig -s | tr -s ' ' | cut -d' ' -f1,5,9 | grep -v RX `)
6#echo ${vals[@]}
7#echo ${#vals[@]}
8
9numvals=`echo " $numnetworks * 3 + 3" | bc -l`
10#echo $numvals
11if [ ${#vals[@]} -ne $numvals ]
12then
13 echo "ERROR Not all "$numnetworks" networks available."
14 exit
15fi
16
17for (( i=0 ; i < $numnetworks ; i++ ))
18do
19 query="SELECT fRXErrors, fTXErrors FROM NetworkErrors WHERE fEth="$i" ORDER BY fTime DESC LIMIT 0,1;"
20 #echo $query
21 errors=( `/usr/bin/mysql -u systemstatus --host=fact01 systemstatus -s -e "$query"` )
22 #echo ${errors[@]}
23 if [ ${errors[0]} -lt ${vals[$i*3+1]} ]
24 then
25 echo "RX errors increased to "${errors[0]}" on eth"$i
26 fi
27 if [ ${errors[1]} -lt ${vals[$i*3+2]} ]
28 then
29 echo "TX errors increased to "${errors[0]}" on eth"$i
30 fi
31 query="INSERT NetworkErrors SET fEth="$i", fRXErrors="${vals[$i*3+1]}", fTXErrors="${vals[$i*3+2]}", fTime=Now()"
32 /usr/bin/mysql -u systemstatus --host=fact01 systemstatus -e "$query"
33done
34
Note: See TracBrowser for help on using the repository browser.