Print this page
7711 SMF: Finish implementing support for degraded state

@@ -21,10 +21,11 @@
 
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  * Copyright (c) 2015, Joyent, Inc. All rights reserved.
+ * Copyright 2017 RackTop Systems.
  */
 
 /*
  * Service state explanation.  For select services, display a description, the
  * state, and possibly why the service is in that state, what's causing it to

@@ -1194,10 +1195,13 @@
                 /*
                  * If we're running, add a self-pointer in case we're
                  * excluding another service.
                  */
                 add_svcptr(svcp->causes, svcp);
+                if (strcmp(svcp->state, SCF_STATE_STRING_DEGRADED) == 0)
+                        add_svcptr(g_causes, svcp);
+
                 return (UU_WALK_NEXT);
         }
 
         if (strcmp(svcp->state, SCF_STATE_STRING_MAINT) == 0) {
                 add_svcptr(svcp->causes, svcp);

@@ -1486,10 +1490,14 @@
                                     sizeof (buf));
                         } else if (WEXITSTATUS(stat) == SMF_EXIT_ERR_FATAL) {
                                 (void) strlcpy(buf, gettext(
                                     "exited with $SMF_EXIT_ERR_FATAL"),
                                     sizeof (buf));
+                        } else if (WEXITSTATUS(stat) == SMF_EXIT_MON_DEGRADE) {
+                                (void) strlcpy(buf, gettext(
+                                    "exited with $SMF_EXIT_MON_DEGRADE"),
+                                    sizeof (buf));
                         } else {
                                 (void) snprintf(buf, sizeof (buf),
                                     gettext("exited with status %d"),
                                     WEXITSTATUS(stat));
                         }

@@ -1806,21 +1814,38 @@
                             svcp->next_state);
                         dc = DC_TRANSITION;
                 }
 
         } else if (strcmp(svcp->state, SCF_STATE_STRING_DEGRADED) == 0) {
-                (void) puts(gettext("Reason: Degraded by an administrator."));
+                if (strcmp(svcp->aux_state, "administrative_request") == 0) {
+                        (void) puts(gettext("Reason: Degraded by an "
+                            "administrator."));
                 dc = DC_ADMINDEGR;
+                } else if (strcmp(svcp->aux_state, "service_request") == 0) {
+                        if (svcp->aux_fmri) {
+                                (void) printf(gettext("Reason: Degraded by "
+                                    "\"%s\"\n"), svcp->aux_fmri);
+                                print_aux_fmri_logs(svcp->aux_fmri);
+                        } else {
+                                (void) puts(gettext("Reason: Degraded by "
+                                    "another service."));
+                        }
+                } else if (strcmp(svcp->aux_state, "method_failed") == 0) {
+                        print_method_failure(svcp, &dc);
+                } else {
+                        (void) puts(gettext("Reason: Unknown."));
+                        dc = DC_UNKNOWN;
+                }
 
         } else {
                 (void) printf(gettext("Reason: Not in valid state (%s).\n"),
                     svcp->state);
                 dc = DC_INVALIDSTATE;
         }
 
 diagcode:
-        if (g_msgbase != NULL)
+        if (g_msgbase != NULL && dc != NULL)
                 (void) printf(gettext("   See: %s%s\n"), g_msgbase, dc);
 }
 
 static void
 print_manpage(int verbose)