Temat: Tester połączenia LTE z logowaniem zdarzeń do pliku *.txt
Mam skrypcik który sprawdza połącczenie LTE który wygląda tak:
#!/bin/sh
data=`date +"%Y-%m-%d %H:%M:%S"`
if ! ping -q -c 1 -W 10 google.com > /dev/null; then
echo ""$data Brak polaczenia z internetem ! Ponawiam polaczenie z internetem >> /mnt/dysk/log/wan_tester_log.txt && (ifup wan) &
fi
sleep 20
data2=`date +"%Y-%m-%d %H:%M:%S"`
if ! ping -q -c 1 -W 10 google.com > /dev/null; then
echo ""$data2 Nadal brak polaczenia z internetem ! Restartuje router. >> /mnt/dysk/log/wan_tester_log.txt && (vnstat -u) && (reboot)
fiWszystko ładnie loguje do pliku:
2016-06-11 19:48:00 Brak polaczenia z internetem ! Ponawiam polaczenie z internetem
2016-06-12 00:34:00 Brak polaczenia z internetem ! Ponawiam polaczenie z internetem
2016-06-12 06:08:00 Brak polaczenia z internetem ! Ponawiam polaczenie z internetem
2016-06-12 11:00:20 Nadal brak polaczenia z internetem ! Restartuje router.
2016-06-12 12:28:20 Nadal brak polaczenia z internetem ! Restartuje router.
2016-06-12 16:20:20 Nadal brak polaczenia z internetem ! Restartuje router.
2016-06-12 16:36:20 Nadal brak polaczenia z internetem ! Restartuje router.Tylko zastanawia mnie jedna rzecz patrząc w logi systemu bo jak mam log z testera z 2016-06-12 06:08:00 ponawiam połączenie widzę że skrypt podnosi połączenie tak jak to widać w logach poniżej:
Sun Jun 12 06:08:00 2016 cron.info crond[1459]: USER root pid 29071 cmd /bin/tester.sh
Sun Jun 12 06:08:10 2016 daemon.notice netifd: Interface 'wan_6' is now down
Sun Jun 12 06:08:10 2016 daemon.notice netifd: Interface 'wan_6' has link connectivity loss
Sun Jun 12 06:08:10 2016 daemon.warn dnsmasq[2333]: no servers found in /tmp/resolv.conf.auto, will retry
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan (29082): Stopping network
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan_4 (23475): Received SIGTERM
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_4' is now down
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_4' is disabled
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_4' has link connectivity loss
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan (29082): Command failed: Permission denied
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan' is now down
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan' is setting up now
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan (29113): Waiting for network registration
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan (29113): "Invalid network mode"
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan (29113): Starting network internet
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan (29113): Starting DHCP
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan' is now up
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Network device 'wwan0' link is up
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Network alias 'wwan0' link is up
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_4' is enabled
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_4' has link connectivity
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_4' is setting up now
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan (29113): Command failed: Unknown error
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_6' is enabled
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_6' has link connectivity
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_6' is setting up now
Sun Jun 12 06:08:11 2016 daemon.notice netifd: Interface 'wan_6' is now up
Sun Jun 12 06:08:11 2016 daemon.notice netifd: wan (29113): Command failed: Unknown error
Sun Jun 12 06:08:11 2016 user.notice root: qmi bringup failed, retry in 15s
Sun Jun 12 06:08:12 2016 daemon.notice netifd: wan_4 (29165): udhcpc (v1.23.2) started
Sun Jun 12 06:08:12 2016 daemon.notice netifd: wan_4 (29165): Sending discover...
Sun Jun 12 06:08:12 2016 daemon.notice netifd: wan_4 (29165): Sending select for 10.*.*.27...
Sun Jun 12 06:08:12 2016 daemon.notice netifd: wan_4 (29165): Lease of 10.*.*.27 obtained, lease time 7200
Sun Jun 12 06:08:12 2016 daemon.notice netifd: Interface 'wan_4' is now up
Sun Jun 12 06:08:12 2016 daemon.info dnsmasq[2333]: reading /tmp/resolv.conf.auto
Sun Jun 12 06:08:12 2016 daemon.info dnsmasq[2333]: using local addresses only for domain lan
Sun Jun 12 06:08:12 2016 daemon.info dnsmasq[2333]: using nameserver 89.*.*.21#53
Sun Jun 12 06:08:12 2016 daemon.info dnsmasq[2333]: using nameserver 89.*.*.21#53
Sun Jun 12 06:08:12 2016 user.notice firewall: Reloading firewall due to ifup of wan (wwan0)
Sun Jun 12 06:08:14 2016 user.notice ddns-scripts[29272]: myddns_ipv4: PID '29272' started at 2016-06-12 06:08
Sun Jun 12 06:08:14 2016 user.warn ddns-scripts[29272]: myddns_ipv4: Service section disabled! - TERMINATE
Sun Jun 12 06:08:14 2016 user.warn ddns-scripts[29272]: myddns_ipv4: PID '29272' exit WITH ERROR '1' at 2016-06-12 06:08
Sun Jun 12 06:10:00 2016 cron.info crond[1459]: USER root pid 29501 cmd /bin/odczytdobazy.sh
Sun Jun 12 06:10:00 2016 cron.info crond[1459]: USER root pid 29502 cmd /bin/tester.shAle jak już mam log z testera np z godziny 2016-06-12 16:36:20 z informacją restartuje router to w logach systemu mam tylko tyle:
Sun Jun 12 16:36:00 2016 cron.info crond[1458]: USER root pid 3211 cmd /bin/tester.sh
Sun Jun 12 16:36:31 2016 daemon.info procd: - shutdown -
Sun Jun 12 16:36:32 2016 authpriv.info dropbear[1477]: Early exit: Terminated by signalWidząc te restarty chciałbym je wyeliminować tylko że jak w logach nie ma nic to nie wiem czego szukać. I teraz pytanie czy skrypt który napisałem jest źle napisany i dlatego nic nie widzę w logach. Bo zanim zrobi reboot powinien zrobić vnstat -u a w logach tego nie widzę ? Może jakieś wskazówki czy sugestie bardziej doświadczonych.