To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 13d313ba authored by Reto Da Forno's avatar Reto Da Forno

ping_watchdog and setup script adjusted, unused file removed, ip_address...

ping_watchdog and setup script adjusted, unused file removed, ip_address replaced by ethernet_address
parent d0572ea7
......@@ -2,11 +2,12 @@
#
# Author: Christoph Walser, <walserc@tik.ee.ethz.ch>
# Date: 2011/10/14
#
# Modified on 2019-01-09 (WLAN0 related stuff removed).
# path is needed for ifdown / ifup
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PINGPATH=/var/tmp/ping_watchdog
USBPATH=/sys/bus/platform/devices/gpio/USB_POWER_PORT1_SW/
if [ $# -lt 2 ]
then
......@@ -15,13 +16,7 @@ then
exit 0
fi
# Probe interface:
if /sbin/ifconfig wlan0 &> /dev/null
then
INTERFACE='wlan0'
else
INTERFACE='eth0'
fi
INTERFACE='eth0'
touch $PINGPATH
for TIMEOUT in $@; do true; done
......@@ -46,6 +41,7 @@ then
/bin/sh /etc/network/if-up.d/gumstix_leds_ifup
else
# IP is offline. Increment counter. If counter is bigger than threshold, reboot:
echo "ping watchdog: host unreachable"
COUNTER=`cat $PINGPATH`
if [ ! -s $PINGPATH ]
then
......@@ -61,48 +57,12 @@ else
if [ $COUNTER -ge $HALFTIME ]
then
# WLAN0:
if [ $INTERFACE == 'wlan0' ]
then
# Reinsert the kernel modules which are responsible for WLAN if half the threshold is reached:
/usr/bin/logger "ping_watchdog: reinsert WLAN kernel modules and powercycle USB port 1 due to unreachability for $COUNTER times"
/sbin/ifdown $INTERFACE
/bin/sleep 2
# Turn off USB port to which WLAN is connected to:
/bin/echo "out" > $USBPATH/direction
/bin/echo 0 > $USBPATH/value
/bin/sleep 2
# Remove kernel modules:
/sbin/modprobe -r ar9170usb
/sbin/modprobe -r ath
/sbin/modprobe -r mac80211
/sbin/modprobe -r cfg80211
# Wait:
/bin/sleep 5
# Turn on USB port to which WLAN is connected to:
/bin/echo "out" > $USBPATH/direction
/bin/echo 1 > $USBPATH/value
# Wait some time to let modules initialize
else
# ETH0:
# Just do an ifup/ifdown:
/sbin/ifdown $INTERFACE
/bin/sleep 5
/sbin/ifup $INTERFACE
fi
else
if [ $COUNTER -ge 1 ]
then
# WLAN0:
if [ $INTERFACE == 'wlan0' ]
then
# After 1 unsuccessfull pings, rescan the ether for better wireless networks in range:
/usr/bin/logger "ping_watchdog: try to reconnect to WLAN due to unreachability for $COUNTER times"
/usr/sbin/wpa_cli scan
/usr/sbin/wpa_cli disconnect
/usr/sbin/wpa_cli reconnect
fi
fi
# ETH0:
# Just do an ifup/ifdown:
echo "ping_watchdog: ifdown / ifup on eth0"
/sbin/ifdown $INTERFACE
/bin/sleep 5
/sbin/ifup $INTERFACE
fi
# Increment counter:
......
......@@ -348,7 +348,7 @@ if [ ! "$2" = "-sdsetuponly" ]; then
ssh root@$GUMSTIX "mkdir -p /etc/snmp/scripts/"
cd $SCRIPTPATH
scp snmp/snmpd.conf root@$GUMSTIX:/etc/snmp/.
scp snmp/scripts/wlan_ap_mac.sh snmp/scripts/sht21_dewpoint snmp/scripts/uptime.sh root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/sht21_dewpoint snmp/scripts/uptime.sh root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/cpu_usage_idle.sh snmp/scripts/cpu_usage_system.sh snmp/scripts/cpu_usage_user.sh root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/memoryfragmentation.sh root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/daqsync.sh root@$GUMSTIX:/etc/snmp/scripts/.
......@@ -371,7 +371,7 @@ if [ ! "$2" = "-sdsetuponly" ]; then
scp network/gumstix_leds_ifdown root@$GUMSTIX:/etc/network/if-down.d/;
scp network/gumstix_leds_ifpostdown root@$GUMSTIX:/etc/network/if-post-down.d/;
echo "Moving execution time of USB script which enables WLAN stick"
echo "Moving execution time of USB script which enables USB ports"
ssh root@$GUMSTIX "update-rc.d -f enable-usb-ports.sh remove"
ssh root@$GUMSTIX "update-rc.d enable-usb-ports.sh start 40 S ."
fi
......@@ -386,13 +386,7 @@ if [ ! "$2" = "-sdsetuponly" ]; then
echo "Upload and register watchdogs...";
scp network/ping_watchdog.sh root@$GUMSTIX:/usr/bin/.;
ssh root@$GUMSTIX "sed -i '/ping_watchdog\.sh/d' /etc/crontab";
ssh root@$GUMSTIX "echo \"*/2 * * * * root /usr/bin/ping_watchdog.sh 129.132.177.65 129.132.177.66 10\" >> /etc/crontab";
scp various/climate_watchdog.sh root@$GUMSTIX:/usr/bin/.;
ssh root@$GUMSTIX "sed -i '/climate_watchdog\.sh/d' /etc/crontab";
ssh root@$GUMSTIX "echo \"*/5 * * * * root /usr/bin/climate_watchdog.sh\" >> /etc/crontab";
scp chrony/chrony_watchdog.sh root@$GUMSTIX:/usr/bin/.;
ssh root@$GUMSTIX "sed -i '/chrony_watchdog\.sh/d' /etc/crontab";
ssh root@$GUMSTIX "echo \"*/1 * * * * root /usr/bin/chrony_watchdog.sh\" >> /etc/crontab";
ssh root@$GUMSTIX "echo \"*/2 * * * * root /usr/bin/ping_watchdog.sh carrel 8.8.8.8 10\" >> /etc/crontab";
fi
echo "Creating directory needed for flocklab tests...";
......@@ -467,7 +461,7 @@ if [ ! "$2" = "-sdsetuponly" ]; then
echo "Adjust crontab..."
ssh root@$GUMSTIX "sed -i 's/^\* \* \* \* \* root \/usr\/bin\/probe-connectivity.sh/#&/g' /etc/crontab"
#ssh root@$GUMSTIX "sed -i 's/^3 \* \* \* \* root \/usr\/bin\/chrony-trimrtc.sh/#&/g' /etc/crontab"
ssh root@$GUMSTIX "sed -i 's/^1 \* \* \* \* root \/etc\/network\/if-up.d\/chrony-burst.sh/#&/g' /etc/crontab"
#ssh root@$GUMSTIX "sed -i 's/^1 \* \* \* \* root \/etc\/network\/if-up.d\/chrony-burst.sh/#&/g' /etc/crontab"
fi
if [ ! "$2" = "-sdsetuponly" ]; then
......
#!/bin/sh
#
# __author__ = "Christoph Walser <walser@tik.ee.ethz.ch>"
# __copyright__ = "Copyright 2012, ETH Zurich, Switzerland, Christoph Walser"
# __license__ = "GPL"
# __version__ = "$Revision$"
# __date__ = "$Date$"
# __id__ = "$Id$"
# __source__ = "$URL$"
# Threholds for turning on fan. Fan is turned on when either of the thresholds is reached:
THRESHOLD_ON_TEMP=35
THRESHOLD_ON_HUM=50
# Threholds for turning off fan. Fan is turned off when either of the thresholds is reached:
THRESHOLD_OFF_TEMP=30
THRESHOLD_OFF_HUM=45
SCRIPTNAME="climate_watchdog.sh"
USBPATH=/sys/bus/platform/devices/gpio/USB_POWER_PORT3_SW/
SENSOR_CHECKDIR=/sys/bus/i2c/drivers/sht21/
SENSOR_FILE_TEMP=/sys/bus/i2c/devices/0-0040/temp1_input
SENSOR_FILE_HUM=/sys/bus/i2c/devices/0-0040/humidity1_input
# Probe if temperature sensor is installed and exit if not:
if [ ! -d $SENSOR_CHECKDIR ]
then
exit 0
fi
# Get temperature and humidity:
let TEMP=`/bin/cat $SENSOR_FILE_TEMP`/1000
let HUM=`/bin/cat $SENSOR_FILE_HUM`/1000
# Get current state of fan:
FANSTATE=`/bin/cat $USBPATH/direction`
if [ $FANSTATE == 'out' ]
then
FANSTATE=`/bin/cat $USBPATH/value`
else
FANSTATE=-1
fi
# Turn on fan if a threshold is reached:
if [ $TEMP -ge $THRESHOLD_ON_TEMP ] || [ $HUM -ge $THRESHOLD_ON_HUM ]
then
if [ $FANSTATE -ne 1 ]
then
/bin/echo "out" > $USBPATH/direction
/bin/echo 1 > $USBPATH/value
logger -t $SCRIPTNAME "Turn fan on because one of measured values ($TEMP °C, $HUM %) is above threshold ($THRESHOLD_ON_TEMP °C, $THRESHOLD_ON_HUM %)"
exit 0
fi
fi
# Turn off fan if both thresholds are reached:
if [ $TEMP -le $THRESHOLD_OFF_TEMP ] && [ $HUM -le $THRESHOLD_OFF_HUM ]
then
if [ $FANSTATE -ne 0 ]
then
/bin/echo "out" > $USBPATH/direction
/bin/echo 0 > $USBPATH/value
logger -t $SCRIPTNAME "Turn fan off because measured values ($TEMP °C, $HUM %) are below thresholds ($THRESHOLD_OFF_TEMP °C, $THRESHOLD_OFF_HUM %)"
exit 0
fi
fi
......@@ -165,7 +165,7 @@ def update_configuration_from_db():
for testconfig in ret:
logger.debug("create proxy config for test %d" % testconfig[1])
# get slot mappings
cur.execute("SELECT `observer_id`, `ip_address`, `port_datasender`, `slot` FROM `tbl_serv_map_test_observer_targetimages` `a` left join `tbl_serv_observer` `b` ON (`a`.`observer_fk` = `b`.`serv_observer_key`) WHERE `test_fk` = %d" % testconfig[1])
cur.execute("SELECT `observer_id`, `ethernet_address`, `port_datasender`, `slot` FROM `tbl_serv_map_test_observer_targetimages` `a` left join `tbl_serv_observer` `b` ON (`a`.`observer_fk` = `b`.`serv_observer_key`) WHERE `test_fk` = %d" % testconfig[1])
mapret = cur.fetchall()
mapping = {} # dict obsid -> (ip_address, port)
for m in mapret:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment