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 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 22*1414Scindi 230Sstevel@tonic-gate /* 24*1414Scindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 250Sstevel@tonic-gate * Use is subject to license terms. 260Sstevel@tonic-gate */ 270Sstevel@tonic-gate 280Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 290Sstevel@tonic-gate 300Sstevel@tonic-gate #include <fmdump.h> 310Sstevel@tonic-gate #include <stdio.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate /*ARGSUSED*/ 340Sstevel@tonic-gate static int 350Sstevel@tonic-gate flt_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 360Sstevel@tonic-gate { 370Sstevel@tonic-gate char buf[32], *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 420Sstevel@tonic-gate fmdump_printf(fp, "%-15s.%4.4llu %-32s %s\n", 430Sstevel@tonic-gate fmdump_date(buf, sizeof (buf), rp), 440Sstevel@tonic-gate rp->rec_nsec / (NANOSEC / 10000), uuid, code); 450Sstevel@tonic-gate 460Sstevel@tonic-gate return (0); 470Sstevel@tonic-gate } 480Sstevel@tonic-gate 490Sstevel@tonic-gate static int 500Sstevel@tonic-gate flt_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 510Sstevel@tonic-gate { 520Sstevel@tonic-gate uint_t i, size = 0; 530Sstevel@tonic-gate nvlist_t **nva; 540Sstevel@tonic-gate 550Sstevel@tonic-gate (void) flt_short(lp, rp, fp); 560Sstevel@tonic-gate (void) nvlist_lookup_uint32(rp->rec_nvl, FM_SUSPECT_FAULT_SZ, &size); 570Sstevel@tonic-gate 580Sstevel@tonic-gate if (size != 0) { 590Sstevel@tonic-gate (void) nvlist_lookup_nvlist_array(rp->rec_nvl, 600Sstevel@tonic-gate FM_SUSPECT_FAULT_LIST, &nva, &size); 610Sstevel@tonic-gate } 620Sstevel@tonic-gate 630Sstevel@tonic-gate for (i = 0; i < size; i++) { 64*1414Scindi char *class = NULL, *rname = NULL, *aname = NULL, *fname = NULL; 65*1414Scindi nvlist_t *fru, *asru, *rsrc; 660Sstevel@tonic-gate uint8_t pct = 0; 670Sstevel@tonic-gate 680Sstevel@tonic-gate (void) nvlist_lookup_uint8(nva[i], FM_FAULT_CERTAINTY, &pct); 690Sstevel@tonic-gate (void) nvlist_lookup_string(nva[i], FM_CLASS, &class); 700Sstevel@tonic-gate 710Sstevel@tonic-gate if (nvlist_lookup_nvlist(nva[i], FM_FAULT_FRU, &fru) == 0) 720Sstevel@tonic-gate fname = fmdump_nvl2str(fru); 730Sstevel@tonic-gate 74*1414Scindi if (nvlist_lookup_nvlist(nva[i], FM_FAULT_ASRU, &asru) == 0) 75*1414Scindi aname = fmdump_nvl2str(asru); 76*1414Scindi 77*1414Scindi if (nvlist_lookup_nvlist(nva[i], FM_FAULT_RESOURCE, &rsrc) == 0) 78*1414Scindi rname = fmdump_nvl2str(rsrc); 79*1414Scindi 80*1414Scindi fmdump_printf(fp, " %3u%% %s\n\n", 81*1414Scindi pct, class ? class : "-"); 820Sstevel@tonic-gate 83*1414Scindi /* 84*1414Scindi * Originally we didn't require FM_FAULT_RESOURCE, so if it 85*1414Scindi * isn't defined in the event, display the ASRU FMRI instead. 86*1414Scindi */ 87*1414Scindi fmdump_printf(fp, " Problem in: %s\n", 88*1414Scindi rname ? rname : aname ? aname : "-"); 89*1414Scindi 90*1414Scindi fmdump_printf(fp, " Affects: %s\n", 91*1414Scindi aname ? aname : "-"); 92*1414Scindi 93*1414Scindi fmdump_printf(fp, " FRU: %s\n\n", 94*1414Scindi fname ? fname : "-"); 950Sstevel@tonic-gate 960Sstevel@tonic-gate free(fname); 97*1414Scindi free(aname); 980Sstevel@tonic-gate free(rname); 990Sstevel@tonic-gate } 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate return (0); 1020Sstevel@tonic-gate } 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate static int 1050Sstevel@tonic-gate flt_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 1060Sstevel@tonic-gate { 1070Sstevel@tonic-gate const struct fmdump_fmt *efp = &fmdump_err_ops.do_formats[FMDUMP_VERB1]; 1080Sstevel@tonic-gate const struct fmdump_fmt *ffp = &fmdump_flt_ops.do_formats[FMDUMP_VERB1]; 1090Sstevel@tonic-gate uint_t i; 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate fmdump_printf(fp, "%s\n", ffp->do_hdr); 1120Sstevel@tonic-gate (void) flt_short(lp, rp, fp); 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate if (rp->rec_nrefs != 0) 1150Sstevel@tonic-gate fmdump_printf(fp, "\n %s\n", efp->do_hdr); 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate for (i = 0; i < rp->rec_nrefs; i++) { 1180Sstevel@tonic-gate fmdump_printf(fp, " "); 1190Sstevel@tonic-gate efp->do_func(lp, &rp->rec_xrefs[i], fp); 1200Sstevel@tonic-gate } 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate fmdump_printf(fp, "\n"); 1230Sstevel@tonic-gate nvlist_print(fp, rp->rec_nvl); 1240Sstevel@tonic-gate fmdump_printf(fp, "\n"); 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate return (0); 1270Sstevel@tonic-gate } 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate const fmdump_ops_t fmdump_flt_ops = { 1300Sstevel@tonic-gate "fault", { 1310Sstevel@tonic-gate { 1320Sstevel@tonic-gate "TIME UUID SUNW-MSG-ID", 1330Sstevel@tonic-gate (fmd_log_rec_f *)flt_short 1340Sstevel@tonic-gate }, { 1350Sstevel@tonic-gate "TIME UUID SUNW-MSG-ID", 1360Sstevel@tonic-gate (fmd_log_rec_f *)flt_verb1 1370Sstevel@tonic-gate }, { 1380Sstevel@tonic-gate NULL, 1390Sstevel@tonic-gate (fmd_log_rec_f *)flt_verb2 1400Sstevel@tonic-gate } } 1410Sstevel@tonic-gate }; 142