updated README.md
[RaspiRouter.git] / usr / bin / monitor_luftinternet
CommitLineData
b3ad812d
T
1#!/bin/bash
2
3while : ; do
4setterm -inversescreen off
5#0. fetch data:
6 #1. lsusb
7 dispchar a
8 usb=$(lsusb)
9 #2. ps
10 dispchar b
11 proc=$(ps ax)
12
13#1. check hardware
14 #1.1 check umts modem
15 echo -n "UMTS: "
16 dispchar c
17 if [[ $(echo "$usb" | grep "12d1:1506") ]] ; then
18 echo -n "OK"
19 else
20 echo "Not Found"
21 setterm -inversescreen
22 echo -e "\n\n*** Replug Modem ***\n\n"
23disp "UMTS Fatal Error" #Modem Error: fatal!
24 sleep 5 #read -p "press enter" #while : ; do; done #halt exec
25 fi
26 if [[ $(echo "$usb" | grep "12d1:14fe") ]] ; then
27 echo -n "wrong mode"
28 usb_modeswitch -v 12d1 -p 14fe -V 12d1 -P 1506 -M
29'55534243123456780000000000000011062000000100000000000000000000'
30disp "UMTS Modeswitch" #Modem Warning: mode
31 continue
32 fi
33 #1.2 check wlan stick
34 echo -ne "\nWLAN: "
35 dispchar d
36 if [[ $(echo "$usb" | grep "0cf3:9271") ]] ; then
37 echo -n "OK"
38 else
39 echo "error"
40 setterm -inversescreen
41 echo -e "\n\n*** Replug WiFi ***\n\n"
42disp "WiFi Fatal Error" #WiFi Error: fatal!
43 sleep 5 #read -p "press enter" #while : ; do; done #halt exec
44 fi
45#2. check services
46 #2.1 check hostapd
47 echo -ne "\nhostapd: "
48 dispchar e
49 if [[ $(echo "$proc" | grep "hostapd" | grep -v "grep") ]] ; then
50 echo -n "OK"
51 else
52 echo -n "restarting"
53 #hostpad /etc/hostapd.conf &
54 service hostapd restart
55disp "hostapd restart" #Service warning: hostapd
56 continue
57 fi
58 #2.2 check dnsmasq
59 echo -ne "\ndnsmasq: "
60 dispchar f
61 if [[ $(echo "$proc" | grep "dnsmasq" | grep -v "grep") ]] ; then
62 echo -n "OK"
63 else
64 echo -n "restarting"
65 service dnsmasq restart
66disp "dnsmasq restart" #Service warning: dnsmasq
67 continue
68 fi
69 #2.3 check wvdial
70 echo -ne "\nwvdial: "
71 dispchar g
72 if [[ $(echo "$proc" | grep "wvdial" | grep -v "grep") ]] ; then
73 echo -n "OK"
74 else
75 echo -n "restarting"
76 killall dial
77 killall wvdial
78 #killall modem-manager
79 dial & #wvdial &
80disp "wvdial restart" #Service warning: wvdial
81 continue
82 fi
83#3. check conncection
84 #3.1 check ping
85 echo -ne "\nPING: "
86 dispchar h
87 if [[ $(ping google.com -c 4 -i 0.2) ]] ; then
88 echo -n "OK"
89 #3.1-2 check http
90 echo -ne "\nWGET: "
91 dispchar i
92 wget -q --tries=3 --timeout=5 http://google.com/generate_204 -O - &>/dev/null
93 if [[ $? -eq 0 ]] ; then
94 echo -n "OK"
95 #4 OK, get client list
96 clients=$(iw dev wlan0 station dump|grep Station|wc -l)
97 echo "\nClients: $clients"
98disp "Luftinternet $clients"
99#disp "Luftinternet :)"
100#disp "Luftinternet $(iw dev wlan0 station dump|grep Station|wc -l)"
101 else
102 echo "Unknown Error"
103disp "wget error unknw" #Unknown Error: wget!
104 fi
105 else
106 echo "ping error"
107disp "ping error unknw" #ping error
108 fi
109
110echo -ne "\n\n"
111
112#break
113dispchar +
114dispprogress #sleep 10 #dispprogress is a python script that displays a cursor and waits approx 8sec
115done
116
Imprint / Impressum