This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Configure NetVault to send warnings to Slack

Hi

I thought I would share this little script that I wrote.

If you are like me you probably would like to get rid of all warning emails and send them to your Slack channel instead. We use Slack, which is great, and we have configured incoming webhooks in order to be able to receive chat messages from different systems in our environment.

If you run your NetVault server on Linux this is quite easy.

Just place the script below in /usr/netvault/scripts/global/slack.sh and go to:


Configure Notifications -> Editing Global Notification Profile -> Job -> Job Failed

and click the checkbox that says: [Slack method]

Like so:

 

When a warning comes it looks like this in Slack:

 

 

*snip*

#!/bin/bash
# NVNAMESTARTSlack method NVNAMEEND
# NVCOMMENTSTARTSend Slack message when job fails.
# No extra variables are needed for this notification method.NVCOMMENTEND
################################################################################

message=`env | grep NVEVENTMSG | cut -d= -f2`

function post_to_slack () {
SLACK_MESSAGE="$1"
SLACK_URL=hooks.slack.com/.../your-service-identifier-part-here

case "$2" in
INFO)
SLACK_ICON=':slack:'
;;
WARNING)
SLACK_ICON=':warning:'
;;
ERROR)
SLACK_ICON=':bangbang:'
;;
*)
SLACK_ICON=':slack:'
;;
esac

curl -X POST --data "payload={\"text\": \"${SLACK_ICON} Message from NetVault: ${SLACK_MESSAGE}\"}" ${SLACK_URL}
}

post_to_slack "$message" "WARNING"
exit 0

*snip*