[packages/cacti-plugin-thold] Fix for an undefined variable error
jajcus
jajcus at pld-linux.org
Mon Dec 10 08:41:07 CET 2012
commit 7b7e64ac21e896980698b11259e4e87f9346ee07
Author: Jacek Konieczny <j.konieczny at eggsoft.pl>
Date: Mon Dec 10 08:40:00 2012 +0100
Fix for an undefined variable error
In some circumstances Cacti crontab would send mails with:
PHP Notice: Undefined variable: subject in
/usr/share/cacti/plugins/thold/thold_functions.php on line 1626
...i-plugin-thold-undefined_variable_subject.patch | 28 ++++++++++++++++++++++
cacti-plugin-thold.spec | 3 +++
2 files changed, 31 insertions(+)
---
diff --git a/cacti-plugin-thold.spec b/cacti-plugin-thold.spec
index fae28e9..31c856a 100644
--- a/cacti-plugin-thold.spec
+++ b/cacti-plugin-thold.spec
@@ -10,6 +10,7 @@ License: GPL v2
Group: Applications/WWW
Source0: http://docs.cacti.net/_media/plugin:thold-v%{version}-3.tgz
# Source0-md5: 18fa28a60cafa0d9821fb5d9a8cf7823
+Patch0: %{name}-undefined_variable_subject.patch
URL: http://docs.cacti.net/plugin:thold
BuildRequires: rpm-php-pearprov >= 4.4.2-11
Requires: cacti
@@ -46,6 +47,8 @@ mv %{plugin}/{LICENSE,README} .
%{__rm} thold/includes/.settings.php.swp
+%patch0 -p1
+
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{plugindir}
diff --git a/cacti-plugin-thold-undefined_variable_subject.patch b/cacti-plugin-thold-undefined_variable_subject.patch
new file mode 100644
index 0000000..dc78734
--- /dev/null
+++ b/cacti-plugin-thold-undefined_variable_subject.patch
@@ -0,0 +1,28 @@
+diff -dur cacti-plugin-thold-0.4.9.orig/thold/thold_functions.php cacti-plugin-thold-0.4.9/thold/thold_functions.php
+--- cacti-plugin-thold-0.4.9.orig/thold/thold_functions.php 2011-11-12 19:29:49.000000000 +0100
++++ cacti-plugin-thold-0.4.9/thold/thold_functions.php 2012-12-10 08:37:38.000000000 +0100
+@@ -1589,10 +1589,13 @@
+ /* re-alert? */
+ $ra = ($item['bl_fail_count'] > $bl_fail_trigger && ($item['bl_fail_count'] % ($item['repeat_alert'] == '' ? $realert : $item['repeat_alert'])) == 0);
+
+- if ($item['bl_fail_count'] == $bl_fail_trigger || $ra) {
++ $notify = ($item['bl_fail_count'] == $bl_fail_trigger || $ra);
++
++ $subject = ($notify ? "ALERT: " : "TRIGGER: ") . $item['name'] . ($thold_show_datasource ? " [$name]" : '') . ' ' . ($ra ? 'is still' : 'went') . ' ' . ($breach_up ? 'above' : 'below') . " calculated baseline threshold " . ($breach_up ? $item['thold_hi'] : $item['thold_low']) . " with $currentval";
++
++ if ($notify) {
+ thold_debug('Alerting is necessary');
+
+- $subject = "ALERT: " . $item['name'] . ($thold_show_datasource ? " [$name]" : '') . ' ' . ($ra ? 'is still' : 'went') . ' ' . ($breach_up ? 'above' : 'below') . " calculated baseline threshold " . ($breach_up ? $item['thold_hi'] : $item['thold_low']) . " with $currentval";
+
+ if ($logset == 1) {
+ logger($item['name'], $breach_up, ($breach_up ? $item['thold_hi'] : $item['thold_low']), $currentval, $item['bl_fail_trigger'], $item['bl_fail_count'], $url);
+@@ -2032,7 +2035,7 @@
+ $syslog_facility = LOG_DAEMON;
+ }
+
+- openlog('CactiTholdLog', LOG_PID | LOG_PERROR, $syslog_facility);
++ openlog('CactiTholdLog', LOG_PID, $syslog_facility);
+
+ if (strval($breach_up) == 'ok') {
+ syslog($syslog_level, $desc . ' restored to normal with ' . $currentval . ' at trigger ' . $trigger . ' out of ' . $triggerct . " - ". $urlbreach);
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/cacti-plugin-thold.git/commitdiff/7b7e64ac21e896980698b11259e4e87f9346ee07
More information about the pld-cvs-commit
mailing list