The following patch will integrate gammu with thold plugin (version 0.4.9) for cacti
diff -wur thold/includes/polling.php /var/www/html/cacti/plugins/thold/includes/polling.php
--- thold/includes/polling.php 2011-11-13 01:29:49.000000000 +0700
+++ /var/www/html/cacti/plugins/thold/includes/polling.php 2012-02-14 12:27:39.394797954 +0700
@@ -159,6 +159,7 @@
}
$alert_email = read_config_option('alert_email');
+ $alert_sms = read_config_option('thold_send_sms');
$ping_failure_count = read_config_option('ping_failure_count');
// Lets find hosts that were down, but are now back up
@@ -291,6 +292,10 @@
} elseif ($alert_email != '') {
thold_mail($alert_email, '', $subject, $msg, '');
}
+
+ if ($alert_sms == 'on') {
+ thold_sms($subject);
+ }
}
}
}
@@ -380,6 +385,10 @@
} elseif ($alert_email != '') {
thold_mail($alert_email, '', $subject, $msg, '');
}
+
+ if ($alert_sms == 'on') {
+ thold_sms($subject);
+ }
}
}
diff -wur thold/includes/settings.php /var/www/html/cacti/plugins/thold/includes/settings.php
--- thold/includes/settings.php 2011-11-13 01:29:49.000000000 +0700
+++ /var/www/html/cacti/plugins/thold/includes/settings.php 2012-02-14 12:53:03.294901356 +0700
@@ -336,6 +336,24 @@
'method' => 'checkbox',
'default' => 'off'
),
+ 'thold_send_sms' => array(
+ 'friendly_name' => 'Also Send Alerts as SMS',
+ 'description' => 'If checked, this will cause all Alerts to also be sent as SMS.',
+ 'method' => 'checkbox',
+ 'default' => 'off'
+ ),
+ 'thold_gammu_smsd_inject_path' => array(
+ 'friendly_name' => 'Path to gammu-smsd-inject',
+ 'description' => 'This is the path to gammu sms inject binary',
+ 'method' => 'textbox',
+ 'max_length' => 255,
+ ),
+ 'thold_sms_number' => array(
+ 'friendly_name' => 'SMS Contact',
+ 'description' => 'This is the SMS Number to contact. Separated by semicolon (;)',
+ 'method' => 'textbox',
+ 'max_length' => 255,
+ ),
'thold_baseline_header' => array(
'friendly_name' => 'Default Baseline Settings',
'method' => 'spacer',
Only in thold/includes: .settings.php.swp
diff -wur thold/thold_functions.php /var/www/html/cacti/plugins/thold/thold_functions.php
--- thold/thold_functions.php 2011-11-13 01:29:49.000000000 +0700
+++ /var/www/html/cacti/plugins/thold/thold_functions.php 2012-02-14 13:01:58.867790532 +0700
@@ -3105,3 +3105,26 @@
return $xml;
}
+
+function thold_sms($msg) {
+ global $debug;
+
+ $gammu_output = array();
+ $gammu_return = 999;
+ $gammu_smsd_inject_path = trim(read_config_option('thold_gammu_smsd_inject_path'));
+ $sms = trim(read_config_option('thold_sms_number'));
+
+ $sms_numbers = explode(';', $sms);
+ foreach($sms_numbers as $key => $value) {
+ $gammu_smsd_inject_command = $gammu_smsd_inject_path . ' EMS ' . trim($value) . ' -text "' . $msg . '"';
+ exec($gammu_smsd_inject_command, $gammu_output, $gammu_return);
+
+ if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_DEBUG || $debug) {
+ cacti_log('DEBUG: gammu-sms-inject called with command ==>' . $gammu_smsd_inject_command, true, 'POLLER');
+ foreach ($gammu_output as $key => $value) {
+ cacti_log('DEBUG: gammu-sms-inject output ==> ' . $key . ' = ' . $value, true, 'POLLER');
+ }
+ cacti_log('DEBUG: gammu-sms-inject return value ==> ' . $gammu_return, true, 'POLLER');
+ }
+ }
+}
Tidak ada komentar:
Posting Komentar