From 4330fa95594e44c1fac17f8161cc14f8dd4e9d85 Mon Sep 17 00:00:00 2001
From: Graham Knop <gknop@omniti.com>
Date: Mon, 5 Dec 2011 15:33:59 -0500
Subject: [PATCH] return empty results if svcs fails, allowing SMF failures to
 be noticed

---
 lib/Core/SmfDisabled.pm    | 6 ++++++
 lib/Core/SmfMaintenance.pm | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/lib/Core/SmfDisabled.pm b/lib/Core/SmfDisabled.pm
index 7594c81..145878d 100644
--- a/lib/Core/SmfDisabled.pm
+++ b/lib/Core/SmfDisabled.pm
@@ -79,6 +79,12 @@ sub handler {
     };
     my $svcs_output = run_command("$svcs_path -a");
     my @lines = grep { $_ ne '' } split /\n/, $svcs_output;
+
+    # svcs/smf is broken
+    if ($? && ! @lines) {
+        return {};
+    }
+
     for my $line (@lines) {
         my ($state, $start, $name) = split /\s+/, $line, 3;
         if ($name =~ $pattern) {
diff --git a/lib/Core/SmfMaintenance.pm b/lib/Core/SmfMaintenance.pm
index d2af6cb..e2c6f2e 100644
--- a/lib/Core/SmfMaintenance.pm
+++ b/lib/Core/SmfMaintenance.pm
@@ -71,6 +71,10 @@ sub handler {
     my @maintenance_services = map((split(/\s+/, $_))[2],
         grep(/^maintenance/, split(/\n/, $output)));
 
+    # svcs/smf is broken
+    if ($? && ! @maintenance_services) {
+        return {};
+    }
 
     return {
         "count" => [scalar(@maintenance_services), "i"],
-- 
GitLab