пятница, 21 октября 2016 г.

Sending SMS notifications from OpenIndiana zone with Huawei E1550

I want to receive SMS notifications when something is terribly wrong in our data center. One part of the problem is OpenNMS, and we know how to configure it. But another part is actually sending SMS.

As only physical server with normal USB ports which we have is self-assembled SuperMicro storage, running OpenIndiana, we want to create OI zone, which can send SMS. First of all, we'll need some USB modem. I use Huawei e1550, which was already switched to modem-only mode (AT^U2DIAG=0) on Windows PC. Let's look at prtconf -v (looking for HUAWEI):

     device, instance #0
                    Driver properties:
                        name='pm-components' type=string items=3 dev=none
                            value='NAME= usbsacm0 Power' + '0=USB D3 State' + '3=USB D0 State'
                    Hardware properties:
                        name='driver-minor' type=int items=1
                        name='driver-major' type=int items=1
                        name='high-speed' type=boolean
                        name='configuration#' type=int items=1
                        name='usb-product-name' type=string items=1
                            value='HUAWEI Mobile'
                        name='usb-vendor-name' type=string items=1
                            value='HUAWEI Technology'
                        name='usb-raw-cfg-descriptors' type=byte items=85
                        name='usb-dev-descriptor' type=byte items=18
                        name='usb-release' type=int items=1
                        name='usb-num-configs' type=int items=1
                        name='usb-revision-id' type=int items=1
                        name='usb-product-id' type=int items=1
                        name='usb-vendor-id' type=int items=1
                        name='compatible' type=string items=3
                            value='usb12d1,1001.0' + 'usb12d1,1001' + 'usb,device'
                        name='reg' type=int items=1
                        name='assigned-address' type=int items=1

If modem was switched to modem-only mode, you'll see

value='usb12d1,1001.0' + 'usb12d1,1001' + 'usb,device'
in 'compatible' field.So, let's say OI that it should use usbsacm to talk to it:

# update_drv -a -i 'usb12d1,1001' usbsacm

Now you should have /dev/term/0 - 3 devices and can use tip to talk to /dev/term/0:

# tip /dev/term/0

Let's create zone and pass /dev/term/0 to the zone:

# zonecfg -z  sms1
sms1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:sms1> create
zonecfg:sms1> set zonepath=/zones/sms1
zonecfg:sms1> set brand=ipkg
zonecfg:sms1> set autoboot=true
zonecfg:sms1> set ip-type=exclusive
zonecfg:sms1> add net
zonecfg:sms1:net> set physical=sms10
zonecfg:sms1:net> end
zonecfg:sms1> add device
zonecfg:sms1:device> set match=/dev/term/0
zonecfg:sms1:device> end
zonecfg:sms1> exit
# zfs create data0/zones/sms1
# zoneadm -z sms1 install
# zoneadm -z sms1 boot

Now we can configure network in our zone:

# zlogin sms1
# ipadm create-if sms10
# ipadm create-addr -T static -alocal= sms10/v4
# route add -p -net 0
# cp /etc/nsswitch.dns /etc/nsswitch.conf
# echo 'nameserver' >  /etc/resolv.conf
# svcadm enable dns/client

We'll use gammu utilities to send sms:

# pkg install utility/gammu

Your /etc/gammurc (or ~/.gammurc) should look like:

device = /dev/term/0
connection = at

If everything is fine, now you can send SMS:

# gammu sendsms TEXT +7myphone -text "test" 

Комментариев нет:

Отправить комментарий