Tuesday, 2 June 2020

Sending SMS alerts from Check_MK WATO

I am lazy!
so this is very very brief

Setup SNS Subscription -> SNS

 

 

 

Setup AWS IAM policies 

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "VisualEditor0",
      "Effect": "Allow",
      "Action": "sns:Publish",
      "Resource": "arn:aws:sns:*:<ARN ID>:<Name>"
    }
  ]
}

 

*/ Setup WATO access key for account


*/ Setup WATO Tag


Notification with default None, and SMS as an option 

*/ Create batch to test SMS

 I created it in /usr/local/bin/sms_alert.sh
 #!/bin/sh
export AWS_ACCESS_KEY_ID=AKIAXXXX
export AWS_SECRET_ACCESS_KEY=SECRET_KEY
export AWS_DEFAULT_REGION=us-east-1
env | grep NOTIFY_ | sort > $OMD_ROOT/tmp/foobar.out

HOST=`cat  $OMD_ROOT/tmp/foobar.out | grep NOTIFY_HOSTNAME | cut -d = -f 2`
SERVICE=`cat  $OMD_ROOT/tmp/foobar.out | grep NOTIFY_SERVICEDESC |  cut -d = -f 2`
ADDRESS=`cat  $OMD_ROOT/tmp/foobar.out | grep NOTIFY_HOST_ADDRESS_4 |  cut -d = -f 2`
STATE=`cat  $OMD_ROOT/tmp/foobar.out | grep NOTIFY_SERVICESTATE |  cut -d = -f 2`

aws sns publish --topic-arn arn:aws:sns:us-east-1:<ARN ID>:<NAME> --message "HOSTNAME: $HOST, SERVICE: $SERVICE, IP: $ADDRESS STATE: $STATE"

*/Symlink batch file to local/share/check_mk/notifications/

This is the important bit. If it ain't here it's not appearing in the notificaitons method

*/Under WATO Notifications -> Add rule -> Notificatoin method

 

 

  Go to the host server in WATO and tag it with notification -> SMS