Created
September 6, 2016 11:59
-
-
Save star3am/6dcf7318773750ef399e929162473ceb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/collectd/collectd.conf | |
LoadPlugin exec | |
<Plugin exec> | |
NotificationExec "sys:sys" "/usr/bin/slack.sh" | |
</Plugin> | |
# /usr/bin/slack.sh | |
#!/bin/bash -x | |
PATH=/usr/bin:/bin:$PATH | |
input=$(cat) | |
echo $input | tee -a /tmp/collectd.log | |
Plugin=$(field Plugin) | |
#PluginInstance=$(field PluginInstance) | |
#Type=$(field Type) | |
#TypeInstance=$(field TypeInstance) | |
Host=$(field Host) | |
#Severity=$(field Severity) | |
#Time=$(field Time) | |
Message=$(sed '1,/^$/d' <<< "$input") | |
data_empty=$(uptime) | |
host=$(hostname -f) | |
curl -X POST --data-urlencode 'payload={"channel": "#autoscale", "username": "\'"${host}"\'", "text": "\'"${Message}"\'", "icon_emoji": ":ghost:"}' https://SLACK_URL | |
# /tmp/collectd.log | |
==> /tmp/collectd.log <== | |
Severity: WARNING Time: 1473161973.966 Host: localhost Plugin: load Type: load DataSource: shortterm CurrentValue: 1.740000e+00 WarningMin: nan WarningMax: 1.000000e+00 FailureMin: nan FailureMax: 2.000000e+00 Host localhost, plugin load type load: Data source "shortterm" is currently 1.740000. That is above the warning threshold of 1.000000. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment