Topics

Adding COS activity to home/IRLP/log


mytruckownsit
 

 

Hello all,

I’ve looked around on the web, groups and didn’t find anything that upgrades the original logging script to add timestamped COS activity. It seems like it would be a simple script addition but I can’t even find the script that creates the log files. I figured I’d ask before a spent too much time reinventing the wheel.

 

Regards,

Ross kc7rjk


k9dc
 

What are you trying to find or track down?

The primary log file ~/log/messages includes all connection information, although not every COS or PTT trigger.

COS, PTT, DTMF, AUX information is available with the output from the ‘readinput’ command. but that is intended as a troubleshooting tool, not for logging. Therefore it does not include timestamps. That would be an enormous amount of information, and quickly fill up our meager disks.

-k9dc

On Feb 6, 2020, at 03:55, mytruckownsit <kc7rjk@...> wrote:

Hello all,
I’ve looked around on the web, groups and didn’t find anything that upgrades the original logging script to add timestamped COS activity. It seems like it would be a simple script addition but I can’t even find the script that creates the log files. I figured I’d ask before a spent too much time reinventing the wheel.

Regards,
Ross kc7rjk


Nosey Nick VA3NNW
 

k9dc wrote:
COS, PTT, DTMF, AUX information is available with the output from the ‘readinput’ command. but that is intended as a troubleshooting tool, not for logging. Therefore it does not include timestamps. That would be an enormous amount of information, and quickly fill up our meager disks.
I get mine in /var/log/messages...

Feb  6 03:57:42 stn241 repeater: COS ACTIVE
Feb  6 03:57:44 stn241 repeater: COS INACTIVE
Feb  6 03:57:44 stn241 repeater: COS ACTIVE
Feb  6 03:57:46 stn241 repeater: COS INACTIVE
Feb  6 04:05:06 stn241 repeater: PTT ACTIVE
Feb  6 04:05:30 stn241 repeater: PTT INACTIVE
Feb  6 05:05:06 stn241 repeater: PTT ACTIVE
Feb  6 05:05:29 stn241 repeater: PTT INACTIVE

Did I do something special to make that happen? "readinput | logger"
perhaps? If I did it, I can't see where    :-D

You could presumably add it to /home/irlp/custom/rc.irlp with the
`/bin/su - -c "blah" repeater` stuff wrapped around it.

The pirlp version of "readinput" is pretty inefficient, BTW, it's
continually re-opening and re-reading
/sys/class/gpio/gpio[various]/value every 50ms or so, total of about
20,000 OS calls a second, instead of far more efficient event-driven
"/edge" methods. This can use about 3% CPU on a pi, which is quite a lot
worse than it sounds. I was idly considering re-implementing it using
something like https://github.com/larsks/gpio-watch except the DTMF
would be quite a bit more fiddly.

/home/irlp/bin/dtmf is what's used by IRLP itself, it's still polling,
but waits half a second between polling the gpio[various]/values, at
least when idle. "Only" 2600 OS calls/sec, I guess 0.3% CPU. I don't
think bin/dtmf can be used to log much more than it already does to
~repeater/log/messages though.

As for "meager disks", I've used a grand total of 1.8GB out of an 11GB
partition on a 16GB SDCard. Only 150kB of that is /var/log/messages (and
rotated versions thereof). If I wanted 128GB could get a USB thumb drive
for less than $20. That would be enough to store 1 COS event per second
for approx 45 years... by which time, if Moore's Law continues to hold
out (doubtful) I'll be able to buy about 500 petabytes in something the
size of my fingernail for about the same money. Even without Moore's
Law, I think my ham radio budget can afford $20 every 45 years   :-)

More seriously, wear-levelling, lifetime of the SDCard flash memory,
lifetime of the PI ITSELF is probably a far bigger concern than storage
space for COS events.

73! Nick VA3NNW

--
"Nosey" Nick Waterman, VA3NNW/G7RZQ, K2 #5209.
use Std::Disclaimer; sig@...
Others will look to you for stability, so hide when you bite your nails.


David Cameron - IRLP
 

As usual in linux, there are many ways to "skin a cat"....

I have used "ts" a lot - part of the moreutils package. So as root, install the package

apt-get install moreutils

(it will ask about dependencies, which is fine)

Then, you can run anything that "outputs" to the screen and pipe it it "ts" and get a timestamped output:

/home/irlp/bin/readinput | ts

Feb 06 11:54:23 COS ACTIVE
Feb 06 11:54:24 DTMF 7
Feb 06 11:54:25 DTMF 3
Feb 06 11:54:28 COS ACTIVE

As usual, CTRL-C will exit

If you want to log this, you can do something like

/home/irlp/bin/readinput | ts >> /home/irlp/log/readinput_log &

BE CAREFUL THOUGH - if you run multiple instances of this, or don't kill off the other instances you can end up with many of these running at the same time, and as Nick points out, it is not the most processor efficient way to read the GPIO.

Dave Cameron

On 2020-02-06 06:03, Nosey Nick VA3NNW wrote:
k9dc wrote:
COS, PTT, DTMF, AUX information is available with the output from the ‘readinput’ command. but that is intended as a troubleshooting tool, not for logging. Therefore it does not include timestamps. That would be an enormous amount of information, and quickly fill up our meager disks.
I get mine in /var/log/messages...
Feb  6 03:57:42 stn241 repeater: COS ACTIVE
Feb  6 03:57:44 stn241 repeater: COS INACTIVE
Feb  6 03:57:44 stn241 repeater: COS ACTIVE
Feb  6 03:57:46 stn241 repeater: COS INACTIVE
Feb  6 04:05:06 stn241 repeater: PTT ACTIVE
Feb  6 04:05:30 stn241 repeater: PTT INACTIVE
Feb  6 05:05:06 stn241 repeater: PTT ACTIVE
Feb  6 05:05:29 stn241 repeater: PTT INACTIVE
Did I do something special to make that happen? "readinput | logger"
perhaps? If I did it, I can't see where    :-D
You could presumably add it to /home/irlp/custom/rc.irlp with the
`/bin/su - -c "blah" repeater` stuff wrapped around it.
The pirlp version of "readinput" is pretty inefficient, BTW, it's
continually re-opening and re-reading
/sys/class/gpio/gpio[various]/value every 50ms or so, total of about
20,000 OS calls a second, instead of far more efficient event-driven
"/edge" methods. This can use about 3% CPU on a pi, which is quite a lot
worse than it sounds. I was idly considering re-implementing it using
something like https://github.com/larsks/gpio-watch except the DTMF
would be quite a bit more fiddly.
/home/irlp/bin/dtmf is what's used by IRLP itself, it's still polling,
but waits half a second between polling the gpio[various]/values, at
least when idle. "Only" 2600 OS calls/sec, I guess 0.3% CPU. I don't
think bin/dtmf can be used to log much more than it already does to
~repeater/log/messages though.
As for "meager disks", I've used a grand total of 1.8GB out of an 11GB
partition on a 16GB SDCard. Only 150kB of that is /var/log/messages (and
rotated versions thereof). If I wanted 128GB could get a USB thumb drive
for less than $20. That would be enough to store 1 COS event per second
for approx 45 years... by which time, if Moore's Law continues to hold
out (doubtful) I'll be able to buy about 500 petabytes in something the
size of my fingernail for about the same money. Even without Moore's
Law, I think my ham radio budget can afford $20 every 45 years   :-)
More seriously, wear-levelling, lifetime of the SDCard flash memory,
lifetime of the PI ITSELF is probably a far bigger concern than storage
space for COS events.
73! Nick VA3NNW
--
"Nosey" Nick Waterman, VA3NNW/G7RZQ, K2 #5209.
use Std::Disclaimer; sig@...
Others will look to you for stability, so hide when you bite your nails.


Craig - K1BDX - Node 8724
 

On 2/6/20, mytruckownsit <kc7rjk@...> wrote:

Hello all,
I’ve looked around on the web, groups and didn’t find anything that upgrades
the original logging script to add timestamped COS activity. It seems like
it would be a simple script addition but I can’t even find the script that
creates the log files. I figured I’d ask before a spent too much time
reinventing the wheel.

Regards,
Ross kc7rjk

Here is a little script I wrote a while back that runs as user
repeater that records cos and ptt with a time and date stamp



#!/bin/bash

# This script logs and reports PTT and COS with time and date
#

echo "craig's activity log is running"

x=0
ptt_now=0
cos_now=0

while true; do
sleep 1
ptt_last=$ptt_now
cos_last=$cos_now

x=`expr $x + 1`

if $BIN/pttstate; then
ptt_now=0
else
ptt_now=1
fi

if $BIN/cosstate ; then
cos_now=0
else
cos_now=1
fi

if [ "$cos_now" -gt "$cos_last" ] ; then
echo -n "COS is active - "
date
x=0
fi

if [ "$cos_now" -lt "$cos_last" ] ; then
echo -n "COS is inactive - "
date
echo "$x seconds"
x=0
echo ""
fi

if [ "$ptt_now" -gt "$ptt_last" ] ; then
echo -n "PTT is active - "
date
x=0
fi

if [ "$ptt_now" -lt "$ptt_last" ] ; then
echo -n "PTT is inactive - "
date
echo "$x seconds"
x=0
echo ""
fi

done