SMS - 整合遠傳簡訊API

    申請/開通簡訊 API

    • 遠傳系統以綁用戶端 IP 方式
    • 開通後會有兩個重要參數,用來作 API 傳遞用
      1. Sys ID
      2. Source Address

    測試遠傳API

    With lynx:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    With wget:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    With curl:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    With curl + XML file:

    # curl -H "Content-Type: application/x-www-form-urlencoded" -d @send.xml http://61.20.32.60:6600/mpushapi/smssubmit
    

    撰寫發送簡訊的SHELL

    sendSMS.sh:見附檔

    設定 Nagios

    準備簡訊傳送的 script
    cp sendSMS.sh /usr/local/nagios/libexec/
    chown 0755 /usr/local/nagios/libexec/sendSMS.sh 
    
    編輯 commands.cfg
    # 'notify-host-by-sms' command definition
    define command{
            command_name    notify-host-by-sms
            command_line    $USER1$/sendSMS.sh -t "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -n $CONTACTPAGER$
            }
    
    # 'notify-service-by-sms' command definition
    define command{
            command_name    notify-service-by-sms
            command_line    $USER1$/sendSMS.sh -t "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -n $CONTACTPAGER$
            }
    
    編輯 templates.cfg
    define contact{
            name                            generic-contact-sms
            service_notification_period     24x7  
            host_notification_period        24x7 
            service_notification_options    w,u,c,r,f,s 
            host_notification_options       d,u,r,f,s 
            service_notification_commands   notify-service-by-sms
            host_notification_commands      notify-host-by-sms 
            register                        0 
            } 
    編輯 contacts.cfg
    define contact{
            contact_name                    alang-sms
            use                             generic-contact-sms
            alias                           A-Lang's Mobile Phone
            pager                           0953123456
            }
    
    define contactgroup{
            contactgroup_name       it-admins-sms
            alias                   Administrators with SMS
            members                 alang-sms
            } 
    
    編輯 localhost.cfg

    先用 localhost 的 HTTP 服務來測試

    define service{
            use                             local-service         ; Name of service template to use
            host_name                       localhost
            service_description             HTTP
            contact_groups                  it-admins-sms
            check_command                   check_http! -u /nagios-test.html
            notifications_enabled           1
            }
    
    標籤 (Edit tags)
    • No tags

    文件 1

    文件大小日期附件上傳者 
     sendSMS.sh
    無描述
    3.75 KB11:51, 14 Jan 2014alang動作
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core