#!/usr/bin/env python import gammu import sys # Create state machine object sm = gammu.StateMachine() # Read /etc/gammurc sm.ReadConfig() # Connect to phone sm.Init() # Reads network information from phone netinfo = sm.GetNetworkInfo() # Print information print 'State: %s' % netinfo['State'] if netinfo['State'] != "HomeNetwork": sys.exit(2)  #!/usr/bin/env python import gammu import sys if len(sys.argv) != 3: print 'Usage: sendsms.py number1[,number2][...] "message"' sys.exit(1) # we are going to send first 160 characters only text_message=sys.argv[2][:160] # connect to phone sm = gammu.StateMachine() # Read /etc/gammurc sm.ReadConfig() sm.Init() # send messages for phone_number in sys.argv[1].split(','): sms_message = {'Text': text_message, 'SMSC': {'Location': 1}, 'Number': phone_number} try: sm.SendSMS(sms_message) except: print "Sorry, I can't send message to %s" % phone_number  # 'notify-service-by-sms' command definition
 define command {
         command_name notify-service-by-sms
         command_line /etc/_orgorg/nagios/nagios-sms/sendsms.py $ CONTACTPAGER $ "Nagios - $ NOTIFICATIONTYPE $: $ HOSTALIAS $ / $ SER
 VICEDESC $ is $ SERVICESTATE $ ($ SERVICEOUTPUT $) "
         }
 # 'notify-host-by-sms' command definition
 define command {
         command_name notify-host-by-sms
         command_line /etc/_orgorg/nagios/nagios-sms/sendsms.py $ CONTACTPAGER $ "Nagios - $ NOTIFICATIONTYPE $: Host $ HOSTALIAS $
  is $ HOSTSTATE $ ($ HOSTOUTPUT $) "
         }  # 'check_sendsms' command definition
 define command {
         command_name check_sendsms
         command_line $ USER1 $ / check_sendsms.py
 } / etc / gammurc for bluetooth will look like this [gammu] port = / dev / rfcomm0 connection = at19200
Source: https://habr.com/ru/post/96610/
All Articles