Background:
IRLP has a readinput binary for troubleshooting. This reports; cos active, cos inactive, ptt active, ptt inactive, and all dtmf decoded. Since this Linux computer is always connected to your repeater system you can use it as a data basis to generate a visual graph of system activity using gnuplot, a portable command-line driven interactive data and function plotting utility.
This is handy to identify when the system is most active. You can have
the graph export to a club website or just about anything you can think
of. I have the file output use the day of week name in it, so you can
easily look at weeks worth of data.
Step One: is to generate a log with timestamps of COS
activity.
Here is a simple perl timestamp wrapper.
readinput | timestamp >> log
#!/usr/bin/perl
#
# timestamp
# Add a time stamp to each line received from STDIN
# send results to STDOUT
while (<>) {
chomp;
$ts = `date '+%b %d %Y %T'`;
chomp $ts;
print "$ts: $_\n";
}
The permissions on this are set to 750 and that it is owned by repeater.
Here is a sample output: /home/irlp/bin/readinput | /home/irlp/custom/timestamp
Jun 13 2004 12:14:32: COS ACTIVE
Jun 13 2004 12:14:33: COS INACTIVE
Jun 13 2004 12:14:41: COS ACTIVE
Jun 13 2004 12:14:41: DTMF 6
Jun 13 2004 12:14:42: DTMF 9
Jun 13 2004 12:14:42: COS INACTIVE
Jun 13 2004 12:14:43: PTT ACTIVE
Jun 13 2004 12:15:21: PTT INACTIVE
You can use something like "readinput | timestamp >> log" to dump this to a file
Entry in /home/irlp/custom/custom.crons
# MM HH DD MO DOW 0=sun 1=mon
#
# Stop readinput logging 11:51pm
51 23 * * * (/usr/bin/killall -TERM timestamp > /dev/null 2>&1)
#Daily backup of logs to remote machine for further analysis & processing
52 23 * * * (/home/irlp/custom/copylogs > /dev/null 2>&1)
#Restart readinput logging
54 23 * * * (/home/irlp/custom/logreadinput > /dev/null 2>&1)
# FILENAME: /home/irlp/custom/logreadinput
# This script logs all COS, PTT and DTMF activity to disk. It is
# presently stopped and restarted by custom.crons each day
# This allows daily a log back-up
#
# You can manually stop all readinput logging by issuing:
# killall -TERM timestamp
# Delete log file each day so it doesn't grow in size
/bin/rm -f /home/irlp/log/readinputlog > /dev/null 2>&1
# Restart readinput logging with timestamping
/home/irlp/bin/readinput | /home/irlp/custom/timestamp >> /home/irlp/log/readinputlog
&
#!/usr/bin/expect
#
# This example program copies all the log in /home/irlp/log/ to a remote server
# for further crunching/analysis
# Manually invoke as ./copylogs > /dev/null 2>&1 to suppress screen
output
# Need to set the timeout to infinite.
set timeout 3000
spawn scp -r /home/irlp/log/ login@192.168.1.xxx:
send "\r"
expect "word:"
send "password\r"
expect "]"
Step Two: Is to parse this on the remote machine and make a simple graph.
This script makes a simple graph as 'log.png'
It needs gnuplot 4.0.
--
#!/usr/bin/perl
# Setup
#
sub System {
if ((0xffff & system $args) != 0 ) {
print STDERR "error: $!\n";
exit 1;
}
}
$log1 = "log"; # Main unedited log
$log2 = "log.1";
$log3 = "log.2";
$log4 = "log.3";
$log5 = "log.4";
$log6 = "log.5";
$log7 = "log.6";
# Get main log date
#
$logdate = `/usr/bin/head -n 1 $log1`;
($a, $b, $c, $d, $e, $f) = split / /, $logdate;
$log_date = sprintf "%s %s, %s", $a, $b, $c;
# Clear out other dates
#
&System($args = "grep \"$a $b\" $log1 > $log2");
# Clear out local PTT & DTMF entries
#
&System($args = "grep -E -v '(PTT|DTMF|FORCE)' $log2 > $log3");
# Remove date entry and isolate time
#
&System($args = "cat $log3 | awk '{print \$4 \"\t\" \$6}' > $log4");
# Convert ACTIVE and INACTIVE to numerical values
#
&System($args = "cat $log4 | sed 's/INACTIVE/0/g' > $log5");
&System($args = "cat $log5 | sed 's/ACTIVE/1/g' > $log6");
# Clear off the last ":"
#
&System($args = "cat $log6 | awk -F: '{print \$1 \":\" \$2 \":\" \$3 \"\t\" \$4}' > $log7");
open F, "> log.gp";
print F "set xlabel \"Time - $log_date\"\n";
print F "set ylabel \"COS Activity\"\n";
print F "set nokey\n";
print F "set ticscale 2 1\n";
print F "set tics out\n";
print F "set samples 300\n";
print F "set autoscale\n";
print F "set xtics\n";
print F "set mxtics 8\n";
print F "set terminal png\n";
# Creates a dynamic filename based on the date
print F "set output \"COS-`date +%A`.png\"\n";
#print F "set output \"log.png\"\n";
print F "set xdata time\n";
print F "set timefmt \"%H:%M:%S\"\n";
print F "set format x \"%H:%M\"\n";
print F "set format y \"\"\n";
print F "set style line 1 lt 1 lw 1\n";
print F "plot \"$log7\" using 1:2 with imp ls 1\n";
close F;
&System($args = "/usr/bin/gnuplot log.gp");
exit;
Sample Output:
