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 dccccf3b authored by Reto Da Forno's avatar Reto Da Forno

minor fixes and new script added to monitor glossy sync more accurately

parent 095ba676
......@@ -19,7 +19,6 @@
########################################################
# Constants on local computer:
#PACKAGESERVER="schmid.ethz.ch/flocklab-gumstix-ipk"
PACKAGESERVER="http://people.ee.ethz.ch/~perma/gumstix-builds/gumstix-ng/deploy/eglibc/ipk"
TESTMNGMTPATH="testmanagement"
DAQPATH="daq"
......@@ -34,7 +33,6 @@ fi
# Constants on remote Gumstix:
DBPATH="/home/root/mmc/flocklab/db";
TEMPLATEPATH="/home/root/mmc/flocklab/templates";
MOTERUNNERPATH="/home/root/mmc/flocklab/moterunner";
USERSPACEMODULEPATH="/usr/bin";
......@@ -354,7 +352,7 @@ if [ ! "$2" = "-sdsetuponly" ]; then
scp snmp/scripts/daqsync.sh root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/flocklab_templates_md5sum.sh root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/chrony-stats.sh root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/flocklab_glossysync.sh root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/glossysync_stats.py root@$GUMSTIX:/etc/snmp/scripts/.
scp snmp/scripts/daq_pps.py root@$GUMSTIX:/etc/snmp/scripts/.
echo "Upload ssh authorized_keys file..."
......@@ -448,14 +446,6 @@ if [ ! "$2" = "-sdsetuponly" ]; then
ssh root@$GUMSTIX "echo \"lm3370 0x21\" > /sys/bus/i2c/devices/i2c-0/new_device"
fi
echo "Upload IBM moterunner...";
ssh root@$GUMSTIX "mkdir -p $MOTERUNNERPATH/firmware; mkdir -p $MOTERUNNERPATH/proxy; mkdir -p $MOTERUNNERPATH/releases;";
scp -r $VARIOUSPATH/moterunner/firmware/* root@$GUMSTIX:$MOTERUNNERPATH/firmware/;
scp -r $VARIOUSPATH/moterunner/proxy/* root@$GUMSTIX:$MOTERUNNERPATH/proxy/;
echo "Upload latest moterunner release - this may take some time..."
cat $VARIOUSPATH/moterunner/releases/moterunner-8.4-test.tar | ssh root@$GUMSTIX "tar xf - -C $MOTERUNNERPATH/releases --exclude='*/.svn'"
ssh root@$GUMSTIX "chown -R root:root $MOTERUNNERPATH/releases";
if [ ! "$2" = "-sdsetuponly" ]; then
echo "Setup logrotate..."
scp $VARIOUSPATH/logrotate.conf root@$GUMSTIX:/etc/.;
......@@ -471,6 +461,7 @@ if [ ! "$2" = "-sdsetuponly" ]; then
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 'echo "*/5 * * * * root /usr/bin/python /etc/snmp/scripts/glossysync_stats.py update" >> /etc/crontab'
fi
if [ ! "$2" = "-sdsetuponly" ]; then
......
#!/usr/bin/env python
'''
Script to monitor the state of the Glossy Sync protocol used on FlockLab.
Last n lines are loaded from the sync.log file and analyzed.
2019, rdaforno
'''
import sys
import os
import time
import datetime
logfile = "/var/log/sync.log"
logfile2 = "/var/log/sync.log.1"
statsfile = "/tmp/glossysync_stats"
timeframe = 300 # seconds
linecnt = timeframe # 1 line per second
# collect stats and write to file
def updateStats():
# check if file exists
if not os.path.isfile(logfile):
print("file '%s' not found" % logfile)
return False
# check the age of the file
mtime = os.path.getmtime(logfile)
tdiff = int(time.time() - mtime)
if tdiff > timeframe:
print("file '%s' is too old" % logfile)
return False
# load the whole file
f = open(logfile, "r")
lines = f.readlines()
# if not enough lines, also load the previous logfile
if len(lines) < linecnt:
if not os.path.isfile(logfile2):
print("file '%s' not found" % logfile2)
return False
f = open(logfile2, "r")
lines = f.readlines() + lines
rem = timeframe - tdiff
lastline = len(lines) - 1
avgsnr = 0
nrx = 0
count = 0
limit = 0
for i in xrange(lastline, max(lastline - rem, -1), -1):
pos = lines[i].find(" flocklab")
if pos:
try:
dat = lines[i][:pos]
t = time.mktime(datetime.datetime.strptime(dat, "%b %d %H:%M:%S").replace(year=2019).timetuple())
if i == lastline:
limit = t - rem
#print("last valid timestamp is %u" % limit)
elif t < limit:
break
gt = lines[i].find("GT: ")
if gt:
#print(lines[i].rstrip())
syncinfo = lines[i].rstrip()[gt+3:-1].split(",") # remove the dot at the end
if len(syncinfo) == 8: # a valid line must contain 8 elements
snr = int(syncinfo[6]) - int(syncinfo[7]) # SNR = packet RSSI - noise RSSI
avgsnr = avgsnr + snr
count = count + 1
nrx = nrx + int(syncinfo[0])
except ValueError:
pass # conversion failed
if count:
avgsnr = int(avgsnr / count)
nrx = int(nrx * 100 / (5 *count)) # in % (expect exactly 5x RX per flood)
missedpackets = 100 - nrx
missedfloods = int((linecnt - count) * 100 / linecnt) # in %
# each value on a separate line: average SNR (of received packets), % of missed floods, and % of missed packets (of successful floods)
result = "\n%d\n%d\n%d" % (avgsnr, missedfloods, missedpackets)
print(result)
# store results in file
f = open(statsfile, "w")
f.write(result)
# SUCCESS
return True
# read glossysync stats from file
def getStats():
# check if file exists
if not os.path.isfile(statsfile):
#print("file '%s' not found" % statsfile)
return False
# check the age of the file
mtime = os.path.getmtime(statsfile)
if int(time.time() - mtime) > (timeframe * 2):
#print("file '%s' is too old" % statsfile)
return False
f = open(statsfile)
lines = f.readlines()
print("".join(lines))
return True
if __name__== "__main__":
# if any argument is supplied, just read the file content
if len(sys.argv) < 2:
if getStats():
sys.exit(0)
updateStats()
This diff is collapsed.
......@@ -44,7 +44,7 @@ extend memoryfragmentation /bin/sh /etc/snmp/scripts/memoryfragmentation.sh
extend daqsync /bin/sh /etc/snmp/scripts/daqsync.sh
exec flocklabtemplatesmd5sum /bin/sh /etc/snmp/scripts/flocklab_templates_md5sum.sh
exec glossysync /bin/sh /etc/snmp/scripts/flocklab_glossysync.sh
exec glossysync /usr/bin/python /etc/snmp/scripts/glossysync_stats.py
exec daqpps /usr/bin/python /etc/snmp/scripts/daq_pps.py
exec chronyskew /etc/snmp/scripts/chrony-stats.sh 5
......
......@@ -87,6 +87,8 @@ function rrm($dir) {
##############################################################################
*/
function do_login($username, $password) {
global $CONFIG;
// Check username and password:
if (strlen($username)>0 && strlen($password) > 0) {
$db = db_connect();
......@@ -429,12 +431,8 @@ function validate_test($test_config_file, &$errors) {
*/
function trigger_scheduler() {
global $CONFIG;
if ($CONFIG['testmanagementserver']['host'] == 'localhost') {
$cmd = $CONFIG['testmanagementserver']['basedir']."/flocklab_scheduler.py --debug >> /dev/null &";
}
else {
// use SSH as a way to run the script under the user 'flocklab'
$cmd = "ssh ".$CONFIG['testmanagementserver']['user']."@".$CONFIG['testmanagementserver']['host']." '".$CONFIG['testmanagementserver']['basedir']."/flocklab_scheduler.py --debug >> /dev/null &'";
}
exec($cmd , $output, $ret);
return $ret;
}
......
......@@ -22,7 +22,6 @@
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
session_start();
$hostname = $_SERVER['HTTP_HOST'];
$path = dirname($_SERVER['PHP_SELF']);
......
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