Print this page
OS-1840 fmdump shall emit JSON


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 #include <fmdump.h>
  26 #include <stdio.h>
  27 #include <strings.h>

  28 
  29 /*ARGSUSED*/
  30 static int
  31 flt_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
  32 {
  33         char buf[32], str[32];
  34         char *class = NULL, *uuid = "-", *code = "-";
  35 
  36         static const struct {
  37                 const char *class;
  38                 const char *tag;
  39         } tags[] = {
  40                 { FM_LIST_SUSPECT_CLASS,        "Diagnosed" },
  41                 { FM_LIST_REPAIRED_CLASS,       "Repaired" },
  42                 { FM_LIST_RESOLVED_CLASS,       "Resolved" },
  43                 { FM_LIST_UPDATED_CLASS,        "Updated" },
  44                 { FM_LIST_ISOLATED_CLASS,       "Isolated" },
  45         };
  46 
  47         (void) nvlist_lookup_string(rp->rec_nvl, FM_SUSPECT_UUID, &uuid);


 184                 fmdump_printf(fp, "  ");
 185                 efp->do_func(lp, &rp->rec_xrefs[i], fp);
 186         }
 187 
 188         fmdump_printf(fp, "\n");
 189         if (pctl)
 190                 nvlist_prt(rp->rec_nvl, pctl);
 191         else
 192                 nvlist_print(fp, rp->rec_nvl);
 193         fmdump_printf(fp, "\n");
 194 
 195         return (0);
 196 }
 197 
 198 static int
 199 flt_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
 200 {
 201         return (flt_verb23_cmn(lp, rp, fp, NULL));
 202 }
 203 
 204 
 205 static int
 206 flt_pretty(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
 207 {
 208         nvlist_prtctl_t pctl;
 209         int rc;
 210 
 211         if ((pctl = nvlist_prtctl_alloc()) != NULL) {
 212                 nvlist_prtctl_setdest(pctl, fp);
 213                 nvlist_prtctlop_nvlist(pctl, fmdump_render_nvlist, NULL);
 214         }
 215 
 216         rc = flt_verb23_cmn(lp, rp, fp, pctl);
 217 
 218         nvlist_prtctl_free(pctl);
 219         return (rc);
 220 }
 221 
 222 /*
 223  * There is a lack of uniformity in how the various entries in our diagnosis
 224  * are terminated.  Some end with one newline, others with two.  This makes the


 268 "fault", {
 269 {
 270 "TIME                 UUID                                 SUNW-MSG-ID "
 271                                                                 "EVENT",
 272 (fmd_log_rec_f *)flt_short
 273 }, {
 274 "TIME                 UUID                                 SUNW-MSG-ID "
 275                                                                 "EVENT",
 276 (fmd_log_rec_f *)flt_verb1
 277 }, {
 278 "TIME                           UUID"
 279 "                                 SUNW-MSG-ID",
 280 (fmd_log_rec_f *)flt_verb2
 281 }, {
 282 "TIME                           UUID"
 283 "                                 SUNW-MSG-ID",
 284 (fmd_log_rec_f *)flt_pretty
 285 }, {
 286 NULL,
 287 (fmd_log_rec_f *)flt_msg



 288 } }
 289 };


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  24  */
  25 
  26 #include <fmdump.h>
  27 #include <stdio.h>
  28 #include <strings.h>
  29 #include <alloca.h>
  30 
  31 /*ARGSUSED*/
  32 static int
  33 flt_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
  34 {
  35         char buf[32], str[32];
  36         char *class = NULL, *uuid = "-", *code = "-";
  37 
  38         static const struct {
  39                 const char *class;
  40                 const char *tag;
  41         } tags[] = {
  42                 { FM_LIST_SUSPECT_CLASS,        "Diagnosed" },
  43                 { FM_LIST_REPAIRED_CLASS,       "Repaired" },
  44                 { FM_LIST_RESOLVED_CLASS,       "Resolved" },
  45                 { FM_LIST_UPDATED_CLASS,        "Updated" },
  46                 { FM_LIST_ISOLATED_CLASS,       "Isolated" },
  47         };
  48 
  49         (void) nvlist_lookup_string(rp->rec_nvl, FM_SUSPECT_UUID, &uuid);


 186                 fmdump_printf(fp, "  ");
 187                 efp->do_func(lp, &rp->rec_xrefs[i], fp);
 188         }
 189 
 190         fmdump_printf(fp, "\n");
 191         if (pctl)
 192                 nvlist_prt(rp->rec_nvl, pctl);
 193         else
 194                 nvlist_print(fp, rp->rec_nvl);
 195         fmdump_printf(fp, "\n");
 196 
 197         return (0);
 198 }
 199 
 200 static int
 201 flt_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
 202 {
 203         return (flt_verb23_cmn(lp, rp, fp, NULL));
 204 }
 205 

 206 static int
 207 flt_pretty(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
 208 {
 209         nvlist_prtctl_t pctl;
 210         int rc;
 211 
 212         if ((pctl = nvlist_prtctl_alloc()) != NULL) {
 213                 nvlist_prtctl_setdest(pctl, fp);
 214                 nvlist_prtctlop_nvlist(pctl, fmdump_render_nvlist, NULL);
 215         }
 216 
 217         rc = flt_verb23_cmn(lp, rp, fp, pctl);
 218 
 219         nvlist_prtctl_free(pctl);
 220         return (rc);
 221 }
 222 
 223 /*
 224  * There is a lack of uniformity in how the various entries in our diagnosis
 225  * are terminated.  Some end with one newline, others with two.  This makes the


 269 "fault", {
 270 {
 271 "TIME                 UUID                                 SUNW-MSG-ID "
 272                                                                 "EVENT",
 273 (fmd_log_rec_f *)flt_short
 274 }, {
 275 "TIME                 UUID                                 SUNW-MSG-ID "
 276                                                                 "EVENT",
 277 (fmd_log_rec_f *)flt_verb1
 278 }, {
 279 "TIME                           UUID"
 280 "                                 SUNW-MSG-ID",
 281 (fmd_log_rec_f *)flt_verb2
 282 }, {
 283 "TIME                           UUID"
 284 "                                 SUNW-MSG-ID",
 285 (fmd_log_rec_f *)flt_pretty
 286 }, {
 287 NULL,
 288 (fmd_log_rec_f *)flt_msg
 289 }, {
 290 NULL,
 291 (fmd_log_rec_f *)fmdump_print_json
 292 } }
 293 };