9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Zabbix覚書

Posted at

順次加筆予定

障害を検知したらTweetさせてみるテスト

※Tweetするアカウントの取得や設定は今回は割愛

###Actionの設定
アクションのコンディション等は各自必要な条件を記載

####Actionのオペレーション設定

  • オペレーションのタイプ
  • リモードコマンドを選択
  • リモートコマンド

{HOSTNAME}:/usr/bin/php /etc/externalscript/tweet.php {EVENT.TIME} {ITEM.NAME}
```

Operation

tweet script

twitteroauthを利用してtweetする

<?php

require_once("twitteroauth.php");                                                                             
                                                                                                                           
$consumerKey = "[CONSUMER_KEY]";                                                                                 
$consumerSecret = "[CONSUMER_SECRET]";                                                     
$accessToken = "[ACCESS_TOKEN]";                                                       
$accessTokenSecret = "[ACCESS_TOKEN_SECRET]";
                                                                                                                           

$body = "[ALERT] " . $argv[1] . " :  " . $argv[2] . "で障害なう";

$twObj = new TwitterOAuth($consumerKey,$consumerSecret,$accessToken,$accessTokenSecret);                                   

$req = $twObj->OAuthRequest("https://api.twitter.com/1.1/statuses/update.json","POST",array("status"=> $body ));
?>

####結果ツイート

Operation

9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?