Zabbix only support Jabber as IM media, but we can write a script media for other IMs.
- Get and install phurple - it is a php extension for libpurple (libpurple is core lib of Pidgin)
Make sure you install php-cli php-dev libpcre libpurple
Download lastest phurple @ http://sourceforge.net/projects/phurple/
Create a sendIM.php script @ /home/zabbix/bin
- chmod a+x sendIM.php
- Create a script media type in zabbix. Type sendIM.php in script name.
- Assign media for a user. Type user IM account in send to.
- Create an action with Action operations is send message to the user.
Now we can play a flash game, if any problem zabbix will send a message for us
- Get and install phurple - it is a php extension for libpurple (libpurple is core lib of Pidgin)
Make sure you install php-cli php-dev libpcre libpurple
Download lastest phurple @ http://sourceforge.net/projects/phurple/
Code:
# phpize && ./configure --enable-phurple && make && make install # cp phurple.so /usr/lib/php5/20060613/ (the dir may different in your computer)
PHP Code:
#! /usr/bin/php -n
<?php
if(!extension_loaded('phurple')) {
dl('phurple.' . PHP_SHLIB_SUFFIX);
}
//printf("1:%s; 2:%s; 3:%s",$_SERVER["argv"][1], $_SERVER["argv"][2], $_SERVER["argv"][3]);
class CustomPhurpleClient extends PhurpleClient {
protected function initInternal()
{
}
protected function onSignedOn($connection)
{
$account = $connection->getAccount();
if($account->get("auto-login")) {
$buddy = $_SERVER["argv"][1]; // your account
$title = $_SERVER["argv"][2]; // subject
$body = $_SERVER["argv"][3]; // message
$conversation = new PhurpleConversation(PhurpleClient::CONV_TYPE_IM, $account, $buddy);
$conversation->sendIM($title."\n".$body);
$this->deleteAccount($account);
}
}
}
try {
$user_dir = "/tmp/phphurple-test";
if(!file_exists($user_dir) || !is_dir($user_dir)) {
mkdir($user_dir);
}
PhurpleClient::setUserDir($user_dir);
PhurpleClient::setDebug(false);
PhurpleClient::setUiId("TestUI");
$client = CustomPhurpleClient::getInstance();
//your msn account here
//$client->addAccount("msn:[email protected]:[email protected]:1863");
//your yahoo acccount here
$client->addAccount("yahoo://user_name:[email protected]:5050");
$client->connect();
$client->runLoop();
} catch (Exception $e) {
echo "[Phurple]: " . $e->getMessage() . "\n";
die();
}
?>
- Create a script media type in zabbix. Type sendIM.php in script name.
- Assign media for a user. Type user IM account in send to.
- Create an action with Action operations is send message to the user.
Now we can play a flash game, if any problem zabbix will send a message for us