#!/bin/bash # 120914 --ro # ARG-1 ID # ARG-2 to tail # ARG-3 Filname # Most cases this script is called via cron # with the arguments above. Of course you'll # change the path's below. # Flow is simple. Each sensor should have a # filter function and plot function. # # 1) Filter function uses seltag to extracr data # and create a tmp with data # # 2) plot function uses gnuplot # # Depending on the ID different filter/plot functions # are used. DATA=/var/log/sensors.dat PTH=/usr/local/scripts WEB=/www/www.herjulf.net/projects/sensor/environmental TMP=/tmp/sens.dat DEST=/var/www/www.herjulf.net/projects/sensor/environmental function plot() { cd /tmp #tail -$1 $DATA > $TMP /opt/gnuplot/bin/gnuplot < $PLOT > $DEST/$1 } function remove_temp() { rm -r $TMP } function filter_AC_LED() { # Filter out sensor and remove tags so gnuplot can be used. tail -$2 $DATA | grep $1 | grep ^20 | cat $DATA | grep $1 | grep ^20 | tail -$2 | /sbin/seltag 2 ID=%s T=%s RSSI=%s P1=%s P1_T=%s > $TMP } # ------ Finally we do the work ----------- # And of course you add filter and plots for # The senors you want. ## Check if LED energy plot if wanted if [ 0007f == $1 ]; then TMP=/tmp/main_power.dat filter_AC_LED $1 $2 PLOT=/usr/local/scripts/sens-energy-meter-LED.gp plot $3 fi # Done clean-up remove_temp