なんでも書いてみてー
Zabbix からアラートが飛んでくるよー
techsup とかのメンテナンス情報はここに書くよー
825 git clone https://github.com/sstephenson/rbenv.git ~/.rbenv 826 git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build 827 echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile 828 echo 'eval "$(rbenv init -)"' >> ~/.bash_profile 829 source ~/.bash_profile 830 rbenv install --list 831 rbenv install -v 2.0.0-p648 832 rbenv global 2.0.0-p648 833 ruby -v 834 git clone https://github.com/torut/mail-to-slack.git 846 gem install mail 847 gem install slack-notifier --no-ri --no-rdoc
[root@v157-7-130-26 ~]# cat /home/slack/mail-to-slack.rb
#!/root/.rbenv/shims/ruby
WEBHOCKURL = "https://hooks.slack.com/services/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"
CHANNEL = "#general"
require 'mail'
require 'slack-notifier'
mail = Mail.new(STDIN.read)
attachment = {
color: "#36a64f",
pretext: mail.subject,
author_name: "適当なユーザ名",
text: mail.body.decoded.encode('UTF-8', mail.charset)
}
attachment['color'] = "good" if mail.subject.index('OK') === 0
notifier = Slack::Notifier.new WEBHOCKURL
notifier.channel = CHANNEL
#notifier.username = mail.from.first
notifier.username = "適当なユーザ名"
notifier.ping '', attachments: [ attachment ]
ユーザ slack を追加する。
/etc/alias に以下を追加する。
slack: "| /home/slack/mail-to-slack.rb"
特に制限なくSQL の処理をしているのでこんなことに・・
PROBLEM Date / Time ---------------- 2016.01.03 / 15:23:59 Status ---------------- PROBLEM Host ---------------- ubDevsrv Trigger ---------------- Disk I/O is overloaded on ubDevsrv: 66.7 %