Add some fancy schmancy unicode to our monitoring alert scripts
This commit is contained in:
parent
2c410a1a7c
commit
128b3bd982
@ -181,9 +181,9 @@
|
|||||||
- name: check_by_ssh
|
- name: check_by_ssh
|
||||||
command: "$USER1$/check_by_ssh -H $HOSTADDRESS$ -F /opt/nagios/etc/ssh_config -t 30 -q -i /opt/nagios/etc/id_ed25519 -l nagios-checker -C \"$ARG1$\""
|
command: "$USER1$/check_by_ssh -H $HOSTADDRESS$ -F /opt/nagios/etc/ssh_config -t 30 -q -i /opt/nagios/etc/id_ed25519 -l nagios-checker -C \"$ARG1$\""
|
||||||
- name: notify-host-by-matrix
|
- name: notify-host-by-matrix
|
||||||
command: "/usr/bin/printf \"%b\" \"$NOTIFICATIONTYPE$ - $HOSTNAME$ is $HOSTSTATE$\\nAddress: $HOSTADDRESS$\\nInfo: $HOSTOUTPUT$\\nDate/Time: $LONGDATETIME$\" | /opt/Custom-Nagios-Plugins/notify-by-matrix"
|
command: "/usr/bin/printf \"%b\" \"$NOTIFICATIONTYPE$\\n$HOSTNAME$ is $HOSTSTATE$\\nAddress: $HOSTADDRESS$\\nInfo: $HOSTOUTPUT$\\nDate/Time: $LONGDATETIME$\" | /opt/Custom-Nagios-Plugins/notify-by-matrix"
|
||||||
- name: notify-service-by-matrix
|
- name: notify-service-by-matrix
|
||||||
command: "/usr/bin/printf \"%b\" \"$NOTIFICATIONTYPE$ - Service $HOSTALIAS$ - $SERVICEDESC$ is $SERVICESTATE$\\nInfo: $SERVICEOUTPUT$\\nDate/Time: $LONGDATETIME$\" | /opt/Custom-Nagios-Plugins/notify-by-matrix"
|
command: "/usr/bin/printf \"%b\" \"$NOTIFICATIONTYPE$\\nService $HOSTALIAS$ - $SERVICEDESC$ is $SERVICESTATE$\\nInfo: $SERVICEOUTPUT$\\nDate/Time: $LONGDATETIME$\" | /opt/Custom-Nagios-Plugins/notify-by-matrix"
|
||||||
nagios_services:
|
nagios_services:
|
||||||
# Agentless checks
|
# Agentless checks
|
||||||
- name: HTTP
|
- name: HTTP
|
||||||
|
@ -16,6 +16,53 @@ MX_ROOM="{{ nagios_matrix_room }}"
|
|||||||
# Get a TXN to prefix this particular message with
|
# Get a TXN to prefix this particular message with
|
||||||
MX_TXN="$(date "+%s")$(( RANDOM % 9999 ))"
|
MX_TXN="$(date "+%s")$(( RANDOM % 9999 ))"
|
||||||
|
|
||||||
|
# Read the first line from STDIN
|
||||||
|
# This is supposed to be the NOTIFICATIONTYPE
|
||||||
|
read notiftype
|
||||||
|
prefix=""
|
||||||
|
# https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/macrolist.html#notificationtype
|
||||||
|
case "$notiftype" in
|
||||||
|
PROBLEM)
|
||||||
|
# Large Red Circle (U+1F534)
|
||||||
|
prefix="🔴"
|
||||||
|
;;
|
||||||
|
RECOVERY)
|
||||||
|
# Large Green Circle (U+1F7E2)
|
||||||
|
prefix="🟢"
|
||||||
|
;;
|
||||||
|
ACKNOWLEDGEMENT)
|
||||||
|
# Symbol For Acknowledge (U+2406)
|
||||||
|
prefix="␆"
|
||||||
|
;;
|
||||||
|
FLAPPINGSTART)
|
||||||
|
# Large Orange Circle (U+1F7E0)
|
||||||
|
prefix="🟠"
|
||||||
|
;;
|
||||||
|
FLAPPINGSTOP)
|
||||||
|
# Large Green Circle (U+1F7E2)
|
||||||
|
prefix="🟢"
|
||||||
|
;;
|
||||||
|
FLAPPINGDISABLED)
|
||||||
|
# Bell with Cancellation Stroke (U+1F515)
|
||||||
|
prefix="🔕"
|
||||||
|
;;
|
||||||
|
DOWNTIMESTART)
|
||||||
|
# Bell with Cancellation Stroke (U+1F515)
|
||||||
|
prefix="🔕"
|
||||||
|
;;
|
||||||
|
DOWNTIMEEND)
|
||||||
|
# Bell (U+1F514)
|
||||||
|
prefix="🔔"
|
||||||
|
;;
|
||||||
|
DOWNTIMECANCELLED)
|
||||||
|
# Bell (U+1F514)
|
||||||
|
prefix="🔔"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
prefix="$notiftype - "
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Read a message from STDIN
|
# Read a message from STDIN
|
||||||
# NOTE: This is dangerous and stupid and unsanitized
|
# NOTE: This is dangerous and stupid and unsanitized
|
||||||
read message
|
read message
|
||||||
@ -29,6 +76,6 @@ curl -X PUT \
|
|||||||
--header 'Accept: application/json' \
|
--header 'Accept: application/json' \
|
||||||
-d "{
|
-d "{
|
||||||
\"msgtype\": \"m.text\",
|
\"msgtype\": \"m.text\",
|
||||||
\"body\": \"$message\"
|
\"body\": \"$prefix $message\"
|
||||||
}" \
|
}" \
|
||||||
"$MX_SERVER/_matrix/client/unstable/rooms/$MX_ROOM/send/m.room.message/$MX_TXN?access_token=$MX_TOKEN"
|
"$MX_SERVER/_matrix/client/unstable/rooms/$MX_ROOM/send/m.room.message/$MX_TXN?access_token=$MX_TOKEN"
|
||||||
|
Loading…
Reference in New Issue
Block a user