From 2bd075d7ec47ececdedb2ff7556261086e9622a3 Mon Sep 17 00:00:00 2001
From: Fulvio Galeazzi <fulvio.galeazzi@garr.it>
Date: Wed, 4 Apr 2018 09:22:34 +0200
Subject: [PATCH] 2018-04-04:  FG;  Updated cephHealth, now relying on Perl
 script.

---
 Ceph/Config/userparameter_ceph.conf |  2 +-
 Ceph/Script/cephHealth.pl           | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Ceph/Config/userparameter_ceph.conf b/Ceph/Config/userparameter_ceph.conf
index 157c8d1..713d8c7 100644
--- a/Ceph/Config/userparameter_ceph.conf
+++ b/Ceph/Config/userparameter_ceph.conf
@@ -1,4 +1,4 @@
-UserParameter=ceph.health,/etc/zabbix/scripts/ceph_health.sh
+UserParameter=ceph.health[*],/etc/zabbix/scripts/cephHealth.pl $1 --status -s "clock skew"
 # Global
 UserParameter=ceph.global.objs[*],/etc/zabbix/scripts/cephUsage.pl $1 -o
 UserParameter=ceph.global.objsdeg[*],/etc/zabbix/scripts/cephHealth.pl $1 --od
diff --git a/Ceph/Script/cephHealth.pl b/Ceph/Script/cephHealth.pl
index 425b636..82ebd8d 100755
--- a/Ceph/Script/cephHealth.pl
+++ b/Ceph/Script/cephHealth.pl
@@ -238,9 +238,18 @@ foreach my $_line (@_data)
 	if (exists $statusHash{$fields[0]}) {
 	    $status = $statusHash{$fields[0]};
 	    if ($status == 1) {
-#		if (@matchStr) {
-#	    
-#		}
+		my $matchedStr = 1;
+		if (@matchStr) {
+		    my @statusMsgs = split(/;/, $_line);
+		    foreach my $aMsg (@statusMsgs) {
+			my $thisMatches = 0;
+			foreach my $aMatch (@matchStr) {
+			    $thisMatches = 1 if ($aMsg =~ /$aMatch/);
+			}
+			$matchedStr = $matchedStr * $thisMatches;
+		    }
+		    $status = 0 if ($matchedStr);
+		}
 	    }
 	} else {
 	    $status = 2;
-- 
GitLab