1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate #include <fmdump.h> 30*0Sstevel@tonic-gate #include <stdio.h> 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /*ARGSUSED*/ 33*0Sstevel@tonic-gate static int 34*0Sstevel@tonic-gate flt_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 35*0Sstevel@tonic-gate { 36*0Sstevel@tonic-gate char buf[32], *uuid = "-", *code = "-"; 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate (void) nvlist_lookup_string(rp->rec_nvl, FM_SUSPECT_UUID, &uuid); 39*0Sstevel@tonic-gate (void) nvlist_lookup_string(rp->rec_nvl, FM_SUSPECT_DIAG_CODE, &code); 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate fmdump_printf(fp, "%-15s.%4.4llu %-32s %s\n", 42*0Sstevel@tonic-gate fmdump_date(buf, sizeof (buf), rp), 43*0Sstevel@tonic-gate rp->rec_nsec / (NANOSEC / 10000), uuid, code); 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate return (0); 46*0Sstevel@tonic-gate } 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate static int 49*0Sstevel@tonic-gate flt_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 50*0Sstevel@tonic-gate { 51*0Sstevel@tonic-gate uint_t i, size = 0; 52*0Sstevel@tonic-gate nvlist_t **nva; 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate (void) flt_short(lp, rp, fp); 55*0Sstevel@tonic-gate (void) nvlist_lookup_uint32(rp->rec_nvl, FM_SUSPECT_FAULT_SZ, &size); 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate if (size != 0) { 58*0Sstevel@tonic-gate (void) nvlist_lookup_nvlist_array(rp->rec_nvl, 59*0Sstevel@tonic-gate FM_SUSPECT_FAULT_LIST, &nva, &size); 60*0Sstevel@tonic-gate } 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate for (i = 0; i < size; i++) { 63*0Sstevel@tonic-gate char *class = NULL, *rname = NULL, *fname = NULL; 64*0Sstevel@tonic-gate nvlist_t *fru, *rsc; 65*0Sstevel@tonic-gate uint8_t pct = 0; 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate (void) nvlist_lookup_uint8(nva[i], FM_FAULT_CERTAINTY, &pct); 68*0Sstevel@tonic-gate (void) nvlist_lookup_string(nva[i], FM_CLASS, &class); 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate if (nvlist_lookup_nvlist(nva[i], FM_FAULT_FRU, &fru) == 0) 71*0Sstevel@tonic-gate fname = fmdump_nvl2str(fru); 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate if (nvlist_lookup_nvlist(nva[i], FM_FAULT_RESOURCE, &rsc) == 0) 74*0Sstevel@tonic-gate rname = fmdump_nvl2str(rsc); 75*0Sstevel@tonic-gate else if (nvlist_lookup_nvlist(nva[i], FM_FAULT_ASRU, &rsc) == 0) 76*0Sstevel@tonic-gate rname = fmdump_nvl2str(rsc); 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate fmdump_printf(fp, " %3u%% %s\n" 79*0Sstevel@tonic-gate " FRU: %s\n rsrc: %s\n\n", 80*0Sstevel@tonic-gate pct, class ? class : "-", 81*0Sstevel@tonic-gate fname ? fname : "-", rname ? rname : "-"); 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate free(fname); 84*0Sstevel@tonic-gate free(rname); 85*0Sstevel@tonic-gate } 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate return (0); 88*0Sstevel@tonic-gate } 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate static int 91*0Sstevel@tonic-gate flt_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 92*0Sstevel@tonic-gate { 93*0Sstevel@tonic-gate const struct fmdump_fmt *efp = &fmdump_err_ops.do_formats[FMDUMP_VERB1]; 94*0Sstevel@tonic-gate const struct fmdump_fmt *ffp = &fmdump_flt_ops.do_formats[FMDUMP_VERB1]; 95*0Sstevel@tonic-gate uint_t i; 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate fmdump_printf(fp, "%s\n", ffp->do_hdr); 98*0Sstevel@tonic-gate (void) flt_short(lp, rp, fp); 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate if (rp->rec_nrefs != 0) 101*0Sstevel@tonic-gate fmdump_printf(fp, "\n %s\n", efp->do_hdr); 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate for (i = 0; i < rp->rec_nrefs; i++) { 104*0Sstevel@tonic-gate fmdump_printf(fp, " "); 105*0Sstevel@tonic-gate efp->do_func(lp, &rp->rec_xrefs[i], fp); 106*0Sstevel@tonic-gate } 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate fmdump_printf(fp, "\n"); 109*0Sstevel@tonic-gate nvlist_print(fp, rp->rec_nvl); 110*0Sstevel@tonic-gate fmdump_printf(fp, "\n"); 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate return (0); 113*0Sstevel@tonic-gate } 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate const fmdump_ops_t fmdump_flt_ops = { 116*0Sstevel@tonic-gate "fault", { 117*0Sstevel@tonic-gate { 118*0Sstevel@tonic-gate "TIME UUID SUNW-MSG-ID", 119*0Sstevel@tonic-gate (fmd_log_rec_f *)flt_short 120*0Sstevel@tonic-gate }, { 121*0Sstevel@tonic-gate "TIME UUID SUNW-MSG-ID", 122*0Sstevel@tonic-gate (fmd_log_rec_f *)flt_verb1 123*0Sstevel@tonic-gate }, { 124*0Sstevel@tonic-gate NULL, 125*0Sstevel@tonic-gate (fmd_log_rec_f *)flt_verb2 126*0Sstevel@tonic-gate } } 127*0Sstevel@tonic-gate }; 128