Ejemplo n.º 1
0
<?php

plugin_listener('plugin_settings', 'pushover_plugin_settings');
plugin_listener('plugin_user_settings', 'pushover_plugin_user_settings');
plugin_listener('send_methods', 'pushover_plugin_send_methods');
function pushover_plugin_settings()
{
    return array('pushover_plugin_application_token' => array('friendly_name' => 'Pushover application token', 'default' => '', 'type' => 'string'));
}
function pushover_plugin_user_settings()
{
    return array('pushover_plugin_user_key' => array('friendly_name' => 'Pushover user key', 'default' => '', 'type' => 'string'));
}
function pushover_plugin_send_methods()
{
    return array('pushover_plugin_notify' => 'Pushover');
}
function pushover_plugin_notify($check, $check_result, $subscription)
{
    $user = new User($subscription->getUserId());
    global $status_array;
    $check_status = $status_array[$check_result->getStatus()];
    $check_name = $check->prepareName();
    $check_value = $check_result->prepareValue();
    $check_warning_level = $check->getWarn();
    $check_error_level = $check->getError();
    $check_type = $check->getType();
    $title = "{$check_status} for {$check_name}";
    $message = "Check returned: {$check_value}\n" . "Warning {$check_type} is: {$check_warning_level}\n" . "Error {$check_type} is: {$check_error_level}";
    $data = array('token' => sys_var('pushover_plugin_application_token'), 'user' => usr_var('pushover_plugin_user_key', $user->getUserId()), 'message' => $message, 'title' => $title, 'url' => $GLOBALS['TATTLE_DOMAIN'] . '/' . CheckResult::makeURL('list', $check_result));
    $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)));
Ejemplo n.º 2
0
<? 

plugin_listener('plugin_settings','email_plugin_settings');
plugin_listener('send_methods','email_plugin_send_methods');
plugin_listener('plugin_user_settings','email_plugin_user_settings');

// Poor Mans Module Settings
function email_plugin_settings(){
  return array( 
              'smtp_server' => array('friendly_name' => 'SMTP Server', 
                                     'default' => 'smtp.gmail.com',
                                     'type' => 'string'),
              'smtp_port' => array('friendly_name' => 'SMTP Port',
                                   'default' => 465, 
                                   'type' => 'integer'),
              'smtp_user' => array('friendly_name' => 'SMTP Username',
                                   'default' => '*****@*****.**',
                                   'type' => 'email'),
              'smtp_pass' => array('friendly_name' => 'SMTP Password',
                                   'default' => 'example',
                                   'type' => 'password'),
              'email_from' => array('friendly_name' => 'Alert Email From Address',
                                    'default' => '*****@*****.**',
                                    'type' => 'email'),
              'email_from_display' => array('friendly_name' => 'Alert Email Display Name',
                                            'default' => 'Tattle Processor',
                                            'type' => 'string'),
              'email_subject' => array('friendly_name' => 'Alert Email Subject',
                                       'default' => 'Tattle : Alert from {check_name}', 
                                       'type' => 'string')
              );
Ejemplo n.º 3
0
<?php

plugin_listener('plugin_settings', 'irccat_settings');
plugin_listener('plugin_user_settings', 'irccat_user_settings');
plugin_listener('send_methods', 'irccat_send_methods');
function irccat_settings()
{
    return array('irccat_hostname' => array('friendly_name' => 'IRCcat hostname', 'default' => '127.0.0.1', 'type' => 'string'), 'irccat_subject' => array('friendly_name' => 'IRCcat Subject', 'default' => 'Tattle {check_state} Alert for "{check_name}"', 'type' => 'string'), 'irccat_port' => array('friendly_name' => 'IRCcat Port', 'default' => '12345', 'type' => 'int'));
}
function irccat_user_settings()
{
    return array('irccat_ircnick' => array('friendly_name' => 'IRCcat Nickname', 'default' => '', 'type' => 'string'), 'irccat_channel' => array('friendly_name' => 'IRCcat Channel', 'default' => '', 'type' => 'string'));
}
function irccat_send_methods()
{
    return array('irccat_notify' => 'IRCcat');
}
function irccat_notify($check, $check_result, $subscription)
{
    global $status_array;
    $state = $status_array[$check_result->getStatus()];
    if ($state == 'OK') {
        $event_type = 'resolve';
    } else {
        $event_type = 'trigger';
    }
    $user = new User($subscription->getUserId());
    $irccat_channel = usr_var('irccat_channel', $user->getUserId());
    $irccat_ircnick = usr_var('irccat_ircnick', $user->getUserId());
    if (!empty($irccat_channel)) {
        $irc_target = $irccat_channel;
Ejemplo n.º 4
0
<?php

plugin_listener('plugin_settings', 'hipchat_settings');
plugin_listener('send_methods', 'hipchat_send_methods');
plugin_listener('plugin_user_settings', 'hipchat_user_settings');
function hipchat_settings()
{
    return array('hipchat_apikey' => array('friendly_name' => 'HipChat v2 API Key', 'default' => '', 'type' => 'string'), 'hipchat_room' => array('friendly_name' => 'HipChat Room to Notify', 'default' => '', 'type' => 'integer'), 'hipchat_warning_color' => array('friendly_name' => 'Hipchat Color for Warnings', 'default' => 'yellow', 'type' => 'string'), 'hipchat_error_color' => array('friendly_name' => 'Hipchat Color for Errors', 'default' => 'red', 'type' => 'string'), 'hipchat_ok_color' => array('friendly_name' => 'Hipchat Color for OK', 'default' => 'green', 'type' => 'string'), 'hipchat_notify' => array('friendly_name' => 'Hipchat Plugin Enabled', 'default' => true, 'type' => 'bool'));
}
function hipchat_user_settings()
{
    return array('hipchat_user' => array('friendly_name' => 'HipChat @ mention name', 'default' => '', 'type' => 'string'));
}
function hipchat_send_methods()
{
    return array('hipchat_notify' => 'HipChat Group', 'hipchat_user_notify' => 'HipChat User');
}
// Message is being sent to the global HipChat Group
function hipchat_notify($check, $check_result, $subscription)
{
    return hipchat_master_notify($check, $check_result, $subscription, false);
}
// Message is being sent to the user via @Mention
function hipchat_user_notify($check, $check_result, $subscription)
{
    return hipchat_master_notify($check, $check_result, $subscription, true);
}
// Actuall send the message
function hipchat_master_notify($check, $check_result, $subscription, $toUser = true)
{
    global $status_array;
Ejemplo n.º 5
0
<?php

plugin_listener('plugin_settings', 'pagerduty_settings');
plugin_listener('send_methods', 'pagerduty_send_methods');
function pagerduty_settings()
{
    return array('pagerduty_servicekey' => array('friendly_name' => 'PagerDuty Service Key', 'default' => '', 'type' => 'string'), 'pagerduty_subject' => array('friendly_name' => 'Pager Duty Alert Subject', 'default' => 'Tattle : {check_name} is {check_state}', 'type' => 'string'));
}
function pagerduty_send_methods()
{
    return array('pagerduty_notify' => 'PagerDuty');
}
function pagerduty_notify($check, $check_result)
{
    global $status_array;
    $state = $status_array[$check_result->getStatus()];
    if ($state == 'OK') {
        $event_type = 'resolve';
    } else {
        $event_type = 'trigger';
    }
    $data = array('service_key' => sys_var('pagerduty_servicekey'), 'incident_key' => 'tattle_' . $check->getCheckId(), 'event_type' => $event_type, 'description' => str_replace(array('{check_name}', '{check_state}'), array($check->prepareName(), $state), sys_var('pagerduty_subject')), 'details' => array('state' => $state, 'current_value' => $check_result->prepareValue(), 'error_level' => $check->getError(), 'warning_level' => $check->getWarn()));
    $ctx = stream_context_create(array('http' => array('method' => 'POST', 'header' => 'Content-Type:application/x-www-form-urlencodedi\\r\\n', 'content' => json_encode($data))));
    file_get_contents('https://events.pagerduty.com/generic/2010-04-15/create_event.json', null, $ctx);
}