Either a change in newer Perl libraries or version 5 of the vSphere Perl SDK has meant that certificates are now being checked by default, and the check_esx.pl plugin is returning something like the following as output:
CHECK_ESX.PL CRITICAL - Server version unavailable at 'https://vcenter-server.domain.com:443/sdk/vimService.wsdl' at /usr/share/perl/5.10/VMware/VICommon.pm line 545, <AUTH_FILE> line 2.
Here’s a quick patch to add a -i option which will disable the certificate check.
I’ve been working on our monitoring system lately and one of the things we need to be able to do is escalate alerts through to technicians after hours as they usually aren’t great at checking their emails. There are many internet based email and API to SMS services out there, however I decided to construct one from hardware lying around the office. There were two main drivers for this:
1. We can purchase blocks of 5000 txts for $12 from our provider, that’s way cheaper than any online service I’ve seen.
2. The monitoring system needs to be-able to alert us should the upstream internet feed go offline, in which case an external SMS service is no use.
For the purposes of this project I used the following hardware:
So the hardware is pretty easy to put together, you could use any router running Mikrotik with either a USB or Serial GSM modem. There is a list of supported 3G dongles on the Mikrotik wiki. The only reason for using a Alix board here is because it was spare from another job – Usually I would recommend something like a RB411U for this task there are a wide selection of boards at routerboard.com – be cautious of the RB411UAHR if you want to use the USB port as this does not provide external power to the USB modem.
Once all the hardware is assembled, you can boot the router and check to ensure the modem is visible. It should show up under /port like this:
[admin@MikroTik] > /port print
Flags: I - inactive
# NAME CHANNELS USED-BY BAUD-R
0 serial0 1 Serial Console 9600
1 usb2 3 9600
Take a note of the port that modem is registering as, in this case USB2 - we will need for the next step, which is to go ahead and send yourself a test text message. This can be done from the /tool/sms command as follows (obviously replacing the port and dst values with your port and cellphone number):
If this is not working for you, you may wish to enable logging for GSM or check with your phone provider to ensure you have sufficient credit
Once you’ve confirmed SMS functionality, we need to enable the API and setup a user for the gateway. I’ve configured a user group as below with minimal permissions:
/ip service set api disabled=no
/user group add name=sms policy=api,test,read
/user add name=sms-user password=test123 group=sms
You’ll also want to setup some basic firewalling on your router – I haven’t really covered that here but its generally a good idea to keep the bad guys out.
So that’s your Mikrotik gateway setup – now to make it useful…
The best way to get access to your new SMS gateway is via the API. We could script telnet or SSH or something to login and send the SMS message, but Mikrotik have been kind enough to put together an API so lets make some use of it. You can use your favorite language to access the API, most languages have clients written for them already – check http://wiki.mikrotik.com/wiki/Manual:API#See_also for more info.
First you will want to download the API client and place it somewhere useful on your system. Next copy and paste the script below to a suitable location on your system.
You will want to change the variables near the top of the script to the username, password and port we setup earlier. You may also need to change the path of the included lib depending on where your system can find Mtik.pm.
All that’s left to do is to make the script executable and test it.