10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53323Scindi * Common Development and Distribution License (the "License"). 63323Scindi * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*6276Scy152378 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <fmdump.h> 290Sstevel@tonic-gate #include <stdio.h> 303323Scindi #include <strings.h> 310Sstevel@tonic-gate 320Sstevel@tonic-gate /*ARGSUSED*/ 330Sstevel@tonic-gate static int 340Sstevel@tonic-gate flt_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 350Sstevel@tonic-gate { 36*6276Scy152378 char buf[32], str[32]; 37*6276Scy152378 char *class = NULL, *uuid = "-", *code = "-"; 380Sstevel@tonic-gate 390Sstevel@tonic-gate (void) nvlist_lookup_string(rp->rec_nvl, FM_SUSPECT_UUID, &uuid); 400Sstevel@tonic-gate (void) nvlist_lookup_string(rp->rec_nvl, FM_SUSPECT_DIAG_CODE, &code); 410Sstevel@tonic-gate 42*6276Scy152378 (void) nvlist_lookup_string(rp->rec_nvl, FM_CLASS, &class); 43*6276Scy152378 if (class != NULL && strcmp(class, FM_LIST_REPAIRED_CLASS) == 0) { 44*6276Scy152378 (void) snprintf(str, sizeof (str), "%s %s", code, "Repaired"); 45*6276Scy152378 code = str; 46*6276Scy152378 } 47*6276Scy152378 485609Scy152378 fmdump_printf(fp, "%-20s %-32s %s\n", 495609Scy152378 fmdump_date(buf, sizeof (buf), rp), uuid, code); 500Sstevel@tonic-gate 510Sstevel@tonic-gate return (0); 520Sstevel@tonic-gate } 530Sstevel@tonic-gate 540Sstevel@tonic-gate static int 550Sstevel@tonic-gate flt_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 560Sstevel@tonic-gate { 570Sstevel@tonic-gate uint_t i, size = 0; 580Sstevel@tonic-gate nvlist_t **nva; 590Sstevel@tonic-gate 600Sstevel@tonic-gate (void) flt_short(lp, rp, fp); 610Sstevel@tonic-gate (void) nvlist_lookup_uint32(rp->rec_nvl, FM_SUSPECT_FAULT_SZ, &size); 620Sstevel@tonic-gate 630Sstevel@tonic-gate if (size != 0) { 640Sstevel@tonic-gate (void) nvlist_lookup_nvlist_array(rp->rec_nvl, 650Sstevel@tonic-gate FM_SUSPECT_FAULT_LIST, &nva, &size); 660Sstevel@tonic-gate } 670Sstevel@tonic-gate 680Sstevel@tonic-gate for (i = 0; i < size; i++) { 691414Scindi char *class = NULL, *rname = NULL, *aname = NULL, *fname = NULL; 703323Scindi char *loc = NULL; 711414Scindi nvlist_t *fru, *asru, *rsrc; 720Sstevel@tonic-gate uint8_t pct = 0; 730Sstevel@tonic-gate 740Sstevel@tonic-gate (void) nvlist_lookup_uint8(nva[i], FM_FAULT_CERTAINTY, &pct); 750Sstevel@tonic-gate (void) nvlist_lookup_string(nva[i], FM_CLASS, &class); 760Sstevel@tonic-gate 770Sstevel@tonic-gate if (nvlist_lookup_nvlist(nva[i], FM_FAULT_FRU, &fru) == 0) 780Sstevel@tonic-gate fname = fmdump_nvl2str(fru); 790Sstevel@tonic-gate 801414Scindi if (nvlist_lookup_nvlist(nva[i], FM_FAULT_ASRU, &asru) == 0) 811414Scindi aname = fmdump_nvl2str(asru); 821414Scindi 831414Scindi if (nvlist_lookup_nvlist(nva[i], FM_FAULT_RESOURCE, &rsrc) == 0) 841414Scindi rname = fmdump_nvl2str(rsrc); 851414Scindi 863323Scindi if (nvlist_lookup_string(nva[i], FM_FAULT_LOCATION, &loc) 873323Scindi == 0) { 883530Srb144127 if (fname && strncmp(fname, FM_FMRI_LEGACY_HC_PREFIX, 893323Scindi sizeof (FM_FMRI_LEGACY_HC_PREFIX)) == 0) 903323Scindi loc = fname + sizeof (FM_FMRI_LEGACY_HC_PREFIX); 913323Scindi } 923323Scindi 933323Scindi 941414Scindi fmdump_printf(fp, " %3u%% %s\n\n", 951414Scindi pct, class ? class : "-"); 960Sstevel@tonic-gate 971414Scindi /* 981414Scindi * Originally we didn't require FM_FAULT_RESOURCE, so if it 991414Scindi * isn't defined in the event, display the ASRU FMRI instead. 1001414Scindi */ 1011414Scindi fmdump_printf(fp, " Problem in: %s\n", 1021414Scindi rname ? rname : aname ? aname : "-"); 1031414Scindi 1041414Scindi fmdump_printf(fp, " Affects: %s\n", 1051414Scindi aname ? aname : "-"); 1061414Scindi 1073323Scindi fmdump_printf(fp, " FRU: %s\n", 1081414Scindi fname ? fname : "-"); 1090Sstevel@tonic-gate 1103323Scindi fmdump_printf(fp, " Location: %s\n\n", 1113323Scindi loc ? loc : "-"); 1123323Scindi 1130Sstevel@tonic-gate free(fname); 1141414Scindi free(aname); 1150Sstevel@tonic-gate free(rname); 1160Sstevel@tonic-gate } 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate return (0); 1190Sstevel@tonic-gate } 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate static int 1220Sstevel@tonic-gate flt_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 1230Sstevel@tonic-gate { 1240Sstevel@tonic-gate const struct fmdump_fmt *efp = &fmdump_err_ops.do_formats[FMDUMP_VERB1]; 1250Sstevel@tonic-gate const struct fmdump_fmt *ffp = &fmdump_flt_ops.do_formats[FMDUMP_VERB1]; 1260Sstevel@tonic-gate uint_t i; 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate fmdump_printf(fp, "%s\n", ffp->do_hdr); 1290Sstevel@tonic-gate (void) flt_short(lp, rp, fp); 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate if (rp->rec_nrefs != 0) 1320Sstevel@tonic-gate fmdump_printf(fp, "\n %s\n", efp->do_hdr); 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate for (i = 0; i < rp->rec_nrefs; i++) { 1350Sstevel@tonic-gate fmdump_printf(fp, " "); 1360Sstevel@tonic-gate efp->do_func(lp, &rp->rec_xrefs[i], fp); 1370Sstevel@tonic-gate } 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate fmdump_printf(fp, "\n"); 1400Sstevel@tonic-gate nvlist_print(fp, rp->rec_nvl); 1410Sstevel@tonic-gate fmdump_printf(fp, "\n"); 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate return (0); 1440Sstevel@tonic-gate } 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate const fmdump_ops_t fmdump_flt_ops = { 1470Sstevel@tonic-gate "fault", { 1480Sstevel@tonic-gate { 1490Sstevel@tonic-gate "TIME UUID SUNW-MSG-ID", 1500Sstevel@tonic-gate (fmd_log_rec_f *)flt_short 1510Sstevel@tonic-gate }, { 1520Sstevel@tonic-gate "TIME UUID SUNW-MSG-ID", 1530Sstevel@tonic-gate (fmd_log_rec_f *)flt_verb1 1540Sstevel@tonic-gate }, { 1550Sstevel@tonic-gate NULL, 1560Sstevel@tonic-gate (fmd_log_rec_f *)flt_verb2 1570Sstevel@tonic-gate } } 1580Sstevel@tonic-gate }; 159