Zabbix: LLD monitoring of Yeastar TG SIM cards
A few months ago, I acquired a Yeastar TG200 GSM gateway . The equipment itself is good, not to mention the egg operator, which periodically lays a pig. That's why there was a need to have up-to-date information about the status of SIM-ok and respond to dumps. The problem is only one thing: in this device, as in the entire series, there is no SNMP. But there is an API (AMI). I did not find a ready-made solution, so I decided to make my
- Template
- Script
- netcat is nc (preinstalled on Ubuntu)
- enable API on device
Template
The template was created on the basis of version 4.2, but, perhaps, it will work on earlier versions. The main thing is that your version supports preprocessing of LLD dependent elements.
Out of the box data on IMSI, SMS center, operator, signal strength, statuses and last action is monitored. If you wish, you can very simply create another prototype with the desired conversion. Also in the template there are several triggers, including a drop in the SIM interface and its replacement. It is worth mentioning that only inserted SIM cards are detected. This is disabled in the detection filters (you never know, maybe someone needs it). Of course, the script must lie in externalscripts and have execute rights to other users.
Hardware - Yeastar TG.xml
Script
yeastarsim.sh
The script receives the following parameters:
$ 1 - discovery or span number that will discover discovery
$ 2 - {HOST.CONN} - node address
$ 3 - {$ APIUSER} - API username
$ 4 - {$ APIPASS} - API password
When the discovery is requested, the script Gives JSON with all SIM-cards, their status, spans and numbers (one less for readability). At the request of the span, full information without censorship for parsing.
Therefore, for correct operation, you need to specify the macros {$ APIUSER} and {$ APIPASS} in each node to which this template is attached. If such macros already exist, simply rename them in the template, say, to {$ TGAPIUSER} and {$ TGAPIPASS}. If you use the same passwords for the API on all gateways, use global macros. I repeat, the API on the gateway side must be activated, the credentials must be correct.
Bonus
As a bonus, I’ll leave a script for sending SMS from Zabbix. The script must be put in the alertscripts folder and given permission to execute to other users.
yeastarsms.sh
Next, go to Administration → Alert Methods → Create an Alert Method and select Script . The name of the script should match the name of the file (in my case, yeastarsms.sh). The script itself accepts the following variables (parameters):
$ 1 - gateway ip or dns
$ 2 - API username
$ 3 - API password
$ 4 - SIM port as it is (for example 1)
$ 5 - receiver (I use {ALERT.SENDTO})
$ 6 - message (I use {ALERT.SUBJECT})
When changing the order of parameters, the script will not work .
I will be glad to suggestions and comments.
PS: Modified triggers for SIM replacement and removal. Download the template.