sh Slack的简单和愚蠢的Nagios命令。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Slack的简单和愚蠢的Nagios命令。相关的知识,希望对你有一定的参考价值。

#!/bin/bash

WEBHOST_NAGIOS="<Host that nagios is runing on>"
SLACK_CHANNEL="#<Channel name>"
SLACK_BOTNAME="<Bot Name>"
WEBHOOK_URL="<Webhook URL>" #Get it from Slack Incoming WebHooks setup instruction

#Set the message icon based on Nagios service state
if [ "$NAGIOS_SERVICESTATE" = "OK" ]
then
    ICON_EMOJI=":thumbsup:"
elif [ "$NAGIOS_SERVICESTATE" = "WARNING" ]
then
    ICON_EMOJI=":loundspeaker:"
elif [ "$NAGIOS_SERVICESTATE" = "CRITICAL" ]
then
    ICON_EMOJI=":broken_heart:"
elif [ "$NAGIOS_SERVICESTATE" = "UNKNOWN" ]
then
    ICON_EMOJI=":troll:"
else
    ICON_EMOJI=":octocat:"
fi


#request for posting to a channel
curl -X POST --data "payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"${SLACK_BOTNAME}\", \"icon_emoji\": \":vertical_traffic_light:\", \"text\": \"${ICON_EMOJI} HOST: ${NAGIOS_HOSTNAME}   SERVICE: ${NAGIOS_SERVICEDISPLAYNAME} STATE: ${NAGIOS_SERVICESTATE} MESSAGE: ${NAGIOS_SERVICEOUTPUT} <http://${WEBHOST_NAGIOS}/cgi-bin/nagios3/extinfo.cgi?host=${NAGIOS_HOSTNAME}|See Nagios>\"}" ${WEBHOOK_URL}

以上是关于sh Slack的简单和愚蠢的Nagios命令。的主要内容,如果未能解决你的问题,请参考以下文章

Nagios 松弛通道集成

sh slack-macos-night-mode.sh

sh 从Linux fail2ban,ssh auth和其他操作向Slack发送通知

sh 从Linux fail2ban,ssh auth和其他操作向Slack发送通知

sh 如果进程不再运行,则通知松弛通道/用户 - 以:./ slack_notify.sh <在proc中正在查看的内容开始

求: linux下 nagios中文汉化包,及详细 使用 说明