Best way for reboot condition on Sensor Loss

Discussion of the Meteohub software package

Moderator: Mattk

Post Reply
bottkars
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: Sun Feb 24, 2013 5:31 pm

Best way for reboot condition on Sensor Loss

Post by bottkars » Sun Jan 24, 2016 2:26 pm

Hello all,


i a still running on iConnect, and recently added a WM300.
However, i am still facing some Sensor disconnects where the USB Connected WMR is no longer reachable.
A reboot always solves the Problem.

most of the time we can find events like datalog: Wetterdatenaufzeichnung seit mehr als 30 Minuten ohne neue Daten

Is there a way to force the system to do a reboot if Datalogger no longer receives Updates ?

I could cron into the eventlogs to do so, but i am looking more for a if condition x then do y in the Meteohub system ....
http://www.bottnet.de
Wetterstation Oregon Scientific WMR200
Meteohub on iconnect

bottkars
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: Sun Feb 24, 2013 5:31 pm

Re: Best way for reboot condition on Sensor Loss

Post by bottkars » Wed Feb 10, 2016 3:15 pm

i created a watchdog script for this that runs in my environment
an email is sent via msmtp using muttclient,
and the server is automatically restarted.
that also eliminates the need for my nightly reboots :-)
( fo mail,, i added a set from="meteohub@maildom" reflecting the settings from the mailconfig in meteohub in root#s .muttrc,
and copied the .msmtprc from meteohub )
and

Code: Select all

meteohub:~# more check_usb.sh 
   #!/bin/bash
    #
    # watchdog servive to onitor the loss of usb connetion to wmr on meteohub
    #
    # Runs as a cron job to keep an eye on ringbuffer entries for USBDEVFS 
    #
    # This needs to be run as root or a user that can monitor system services.
    #

    NAME=USBHID
    USBERROR='USBDEVFS_CONTROL failed cmd hidlog54'
    START=/usr/sbin/$NAME
    NOTIFY=send.to@maildom
    NOTIFYCC=cc.to@maildom
    NOTICE=/tmp/notice.txt 
    DMESG=/bin/dmesg
    GREP=/bin/grep
    PS=/bin/ps
    NOP=/bin/true
    SHUTDOWN='shutdown -r now' 
    DATE=/bin/date
    MAIL=/usr/bin/mutt
    RM=/bin/rm

    ERROMESG=$($DMESG | $GREP "$USBERROR")
    case "$?" in
     0)
      
	# we found error in dmesg and have to restart 
	echo "$NAME encountered $USBERROR. Running automated system restart now"

     echo "$NAME encountered $USBERROR. Running automated system restart now `$D
ATE`" > $NOTICE

    $MAIL -s $USERROR  -- $NOTIFY $NOTIFYCC < $NOTICE
     $RM -f $NOTICE
     $SHUTDOWN 
     ;;
     1)
     echo "$NAME is RUNNING"
    $NOP 
    ;;
    esac

    exit
http://www.bottnet.de
Wetterstation Oregon Scientific WMR200
Meteohub on iconnect

Post Reply