Using an event from AMI to trigger a bash script

I am curious about AMI… I am wanting to watch for a single event (RXUNKEY,1999), I don’t think I need a socket connection as a couple hundred ms is no big deal in this case. Is there a simple way to watch for that event alone using AMI?

Sure, but not with AMI. Something like this bash script, maybe?

#! /bin/bash
result = (asterisk -rx "rpt show vars")

# then grep result, do something and loop.

Don’t have a terminal in front of me so above is just a swag, ymmv.

I don’t see an RXUNKEY. Here’s the vars from my node:

rpt showvars 2532
Variable listing for node 2532:
   RPT_TXKEYED=0
   RPT_ETXKEYED=0
   RPT_RXKEYED=0
   RPT_NUMLINKS=4
   RPT_LINKS=4,T2534,T49370,T49372,T49371
   RPT_NUMALINKS=2
   RPT_ALINKS=2,2534TU,49370TU
   RPT_AUTOPATCHUP=0
    -- 8 variables

Do you have something else?

Hmmm, read this:

https://wiki.allstarlink.org/wiki/Event_Management

Will that do you want to do?

WOW! Yes, that article is amazing. “Where a user can specify actions to be taken when certain events occur” - awesome, great find Tim!

Currently I am using my old tried and true method of tail, grep and awk as you likely suspected. Just trying to explore new ways to do the same things, currently tailing from my archive directory - /var/log/asterisk/tmp/NODE#####/YYYYDDMM.txt
and that looks like this:

20190625201018,RXKEY,1999
20190625201018,TXKEY,MAIN
20190625201018,RXUNKEY,1999
20190625201019,RXKEY,1999
20190625201021,RXUNKEY,1999
20190625201023,TXUNKEY,MAIN
20190625201115,RXKEY,1999
20190625201115,TXKEY,MAIN
20190625201115,RXUNKEY,1999
20190625201115,RXKEY,1999
20190625201127,RXUNKEY,1999
20190625201133,TXUNKEY,MAIN

These events don’t display much more data than what is already available, but it is cool that you can take action on a few things right from the rpt.conf file. One piece of data that is easier to pull (and poll both) from the sub-system directly is the adjacent node information.

The normal commands such as rpt stats, rpt lstats, and rpt nodes do not display what is seen in the image below. Some of the commands such as rpt xnode and rpt showvars DO display this information and I usually pull data from the output of those commands. But I have never watched the output and compared while keyed/unkeyed and looked at them side by side.

While keyed up, the node the repeater is receiving from has a ‘K’ indicator! I would have never noticed that if not for the article you linked. Thank you.

2 Likes