Twitter

by acls us

PowerTXT alerts via Twilio and Node Red into Zabbix

Zabbix

Node RedTwilio

PowerTXT

   

A proof of concept for a client operating 56-60 Networks around the UK. Each Network has its own ADSL/FTTC/Cable/Fibre Backhaul Internet connection and Network Manager Server. The power to the Backhaul equipment is Monitored and Controlled via a TekView PowerTXT device which sends SMS messages for Power/Temperature events and accepts command via SMS to control the power and configure the device. Their overall Network is Monitored via Zabbix which needed to be aware of Power Outage events.

 

The approach used was to set the PowerTXT device to send it's status Text messages via the Mobile Network to a Mobile Number create on Twilio. The Twilio Mobile Number being configured to send the SMS wrapped in an http request to Node Red. A Node Red Flow takes the http request and extracts the "From" Mobile number and the Text data from the message, constructs a "zabbix_sender" command to use to pass the message to Zabbix which is stored aa "Zabbix trapper" data. The Node Red Flow also creates the response to the original https request from Twilio so it knows the request has been processed and there is no reply SMS to send. These also a bit of Debug logging to catch whats going on.

 Node Red Flow

The next stage will be to add to the Node Red Flow so that it will delete the original SMS from Twilio after its been processed and for it to parse the body of the SMS from the PowerTXT to detect Power OFF and ON event to pass to Zabbix.

(Part 2 is here)

 

Parsing TFL Tube Line Status with Pentaho

TFL Pentaho In a previous article I wrong about using TRL Tube Line Status via the old API (rather than the new Unified API), formatting and storing the data in Zabbix to be displayed on a Grafana Dashboard. In this article, I'm using the new TFL Unified API to grab TFL Tube Line Status in a JSON structure and parsing that data using Pentaho to produce a simple CSV file with a Date/Time, a Tube Line Name and a Status of the Tube Line.

Having signed up for access to the new TFL Unified API and having had a look at the example RESTful web calls for data, I fired up an example query to get the TFL Tube Line Statuses.

The first element of the JSON Array returned looks like this;

{
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
"id": "bakerloo",
"name": "Bakerloo",
"modeName": "tube",
"disruptions": [],
"created": "2018-06-12T17:24:37.747Z",
"modified": "2018-06-12T17:24:37.747Z",
"lineStatuses":
[
{
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
"id": 0,
"statusSeverity": 10,
"statusSeverityDescription": "Good Service",
"created": "0001-01-01T00:00:00",
"validityPeriods": []
}
],
"routeSections": [],
"serviceTypes":
[
{
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
"name": "Regular",
"uri": "/Line/Route?ids=Bakerloo&serviceTypes=Regular"
}
],
"crowding":
{
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
}
}

However, all I wanted was the TFL Tube Line Name "name": "Bakerloo" and the Status "statusSeverityDescription": "Good Service" (marked in yellow above). The following Pentaho Transformation does the work required

Transformation

The step "Generate Rows" is just used to set the API URL to be used by the "HTTP Client" step which send the RESTful API request to the TRL Servers. The returned JSON data is passed to the "JSON Input" step which parses out the Line Name and Line Status data. The "Get System Info" step just added the current Date/Time that is sent with the parsed data to the "Text file output" step that write the CSV file.

The only "tricky" bit is parsing the returned JSON structure. This uses JSONPath definitions to tell the JSON parser step where to find the data in the JSON structure.

For the Line Name the JSONPath was "$.[*].name" which instructs the JSON parser to get the "name" from each top level array element. For the Line Status the JSONPath was "$.[*].lineStatuses[0].statusSeverityDescription" which instructs the JSON parser to get the "statusSeverityDescription" from the first element of the "lineStatuses" array from each top level array element.

The results being...

date_time,line_name,line_status"
2018/06/22 15:12:41,"Bakerloo","Good Service"
2018/06/22 15:12:41,"Central","Good Service"
2018/06/22 15:12:41,"Circle","Good Service"
2018/06/22 15:12:41,"District","Good Service"
2018/06/22 15:12:41,"Hammersmith & City","Good Service"
2018/06/22 15:12:41,"Jubilee","Good Service"
2018/06/22 15:12:41,"Metropolitan","Good Service"
2018/06/22 15:12:41,"Northern","Good Service"
2018/06/22 15:12:41,"Piccadilly","Good Service"
2018/06/22 15:12:41,"Victoria","Good Service"
2018/06/22 15:12:41,"Waterloo & City","Good Service"

 

 

Asterisk/FreePBX caught by the CODECs

 

Asterisk FreePBX

Having just installed and migrated a client from an old Asterisk/FreePBX system running on CentOS 5 at Rackspace to a nice new installation on Ubuntu 16.04 at Amazon Lightsail and having deleted the old system as the testing all came out clean, 24 hours running passed and then strange reports of calls that just go dead after connecting. Most calls ran through OK but some particular called numbers rang (just once) were connected but then no audio at all.

Looking through the Asterisk logs didn't show anything to write home about. The FreePBX script ran through ok, started the SIP call via a SIP Trunk Provider, all the correct responses came back, the RTP audio stream was established but the client could not hear any audio on the call. After a while the call clears down. Nothing odd showing at all in the log.

Checked all the Firewall rules to see if anything might be getting in the way of the RTP audio stream but all the rules looked fine. Then it was time to look deeper and run a packet trace. This needed to capture the SIP and RTP conversations to a capture file to download and analyse via Wireshark. "tcpdump udp portrange 1024-65535 -vvvv -s 0 -w dump.pcap" to capture the traffic.

Loaded up the capture file in Wireshark and again every thing looked ok. The SIP handshaking to INVITE the call all showed OK, the RTP handshake and stream all looks OK. The great VOIP analysis tools in Wireshark allowed me to unpick the RTP audio stream and play it ok. In this particular case an announcement to say the offices were closed.

The announcement got me thinking "was the end point another VOIP system?". It turned out that the numbers that had been reported to me as having this problem were VOIP so I started to look at the CODECs involved. The SIP Trunk was setup, as it had been in the old Asterisk/FreePBX, to use ulaw and alaw CODECs. I noticed from the packet capture that the RTP stream had decided to use alaw (G 711 A). So, initially just as a test, I changed the SIP Provider Trunk to use ulaw (G 711 U) only. Tested some calls, all working ok now.

FreePBX 14.0.3.6 Asterisk 13.1.0 with a SIP Trunk Provider making SIP/RTP connections to another VOIP system with an alaw (G 711 A) CODEC fails to decode the audio, change the Trunk to use a ulaw (G 711 U) CODEC, all is well.