/
monit2
executable file
·63 lines (50 loc) · 1.53 KB
/
monit2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#
# Description:
# Wrapper for specmon2 to run from cron
# Auto clean old recordings from /tmp
#
# Author: Bart Somers PE1RIK
#
# Put to 1 to make this run
ENABLED=1
# Put to 1 to automatic clean old recordings in /tmp
# Files older than 2 days are removed
AUTOCLEAN=1
THRESHOLD=10.0
GAIN=40
FREQ=145e6
RUNTIME=3580
DEVICE="rtl=0"
SAMPRATE=2e6
CALVEC=/home/bart/grc/calvec-145M-G40-2048.0.vec
FFTSIZE=2048
# Use the correct tool to run
SPECMON=/home/bart/grc/specmon2.py
# Define the logdir
LOGDIR=/home/bart/log/145
# Start monitoring if enabled.
if [ $ENABLED == 1 ];
then
if [ ! -d $LOGDIR ];
then
mkdir -p $LOGDIR ;
fi
TIMESTAMP=`date +%y%m%d-%H%M`
echo -e "\nLog started at: ${TIMESTAMP}\n" >> $LOGDIR/specmon2.debug
# Specmon with head-block. quits after a defined period of time. (-R)
stdbuf -oL $SPECMON -d $DEVICE -c $CALVEC -T $THRESHOLD -g $GAIN -f $FREQ -s $SAMPRATE -R $RUNTIME -F $FFTSIZE -O $LOGDIR/specmon2-$TIMESTAMP.csv >> $LOGDIR/specmon2.debug 2>&1
# The next lines are for temperature and runtime debugging, mainly on a Raspberry Pi
# TEMPLOG=/tmp/specmon2-`date +%y%m%d`.templog
# date >> $TEMPLOG
# Next line only for Raspberry Pi
# /opt/vc/bin/vcgencmd measure_temp >> $TEMPLOG
fi
# Check to see if autocleaning is enabled.
# Defaults to 2 days old logfiles.
if [ $AUTOCLEAN == 1 ];
then
cleandate=$(date --date="2 days ago" +%y%m%d)
rm -f /tmp/${cleandate}*pvector
fi
exit 0