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
55609Scy152378 * Common Development and Distribution License (the "License").
65609Scy152378 * 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*12967Sgavin.maltby@oracle.com * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate */
240Sstevel@tonic-gate
250Sstevel@tonic-gate #include <fmdump.h>
260Sstevel@tonic-gate #include <stdio.h>
270Sstevel@tonic-gate #include <time.h>
280Sstevel@tonic-gate
290Sstevel@tonic-gate /*ARGSUSED*/
300Sstevel@tonic-gate static int
err_short(fmd_log_t * lp,const fmd_log_record_t * rp,FILE * fp)310Sstevel@tonic-gate err_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
320Sstevel@tonic-gate {
330Sstevel@tonic-gate char buf[32];
340Sstevel@tonic-gate
355609Scy152378 fmdump_printf(fp, "%-20s %-32s\n",
365609Scy152378 fmdump_date(buf, sizeof (buf), rp), rp->rec_class);
370Sstevel@tonic-gate
380Sstevel@tonic-gate return (0);
390Sstevel@tonic-gate }
400Sstevel@tonic-gate
410Sstevel@tonic-gate /*ARGSUSED*/
420Sstevel@tonic-gate static int
err_verb1(fmd_log_t * lp,const fmd_log_record_t * rp,FILE * fp)430Sstevel@tonic-gate err_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
440Sstevel@tonic-gate {
450Sstevel@tonic-gate uint64_t ena = 0;
460Sstevel@tonic-gate char buf[32];
470Sstevel@tonic-gate
480Sstevel@tonic-gate (void) nvlist_lookup_uint64(rp->rec_nvl, FM_EREPORT_ENA, &ena);
490Sstevel@tonic-gate
505609Scy152378 fmdump_printf(fp, "%-20s %-37s 0x%016llx\n",
515609Scy152378 fmdump_date(buf, sizeof (buf), rp), rp->rec_class, ena);
520Sstevel@tonic-gate
530Sstevel@tonic-gate return (0);
540Sstevel@tonic-gate }
550Sstevel@tonic-gate
560Sstevel@tonic-gate /*ARGSUSED*/
570Sstevel@tonic-gate static int
err_verb23_cmn(fmd_log_t * lp,const fmd_log_record_t * rp,FILE * fp,nvlist_prtctl_t pctl)58*12967Sgavin.maltby@oracle.com err_verb23_cmn(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp,
59*12967Sgavin.maltby@oracle.com nvlist_prtctl_t pctl)
600Sstevel@tonic-gate {
610Sstevel@tonic-gate char buf[32];
620Sstevel@tonic-gate
630Sstevel@tonic-gate fmdump_printf(fp, "%-20s.%9.9llu %s\n",
640Sstevel@tonic-gate fmdump_year(buf, sizeof (buf), rp), rp->rec_nsec, rp->rec_class);
650Sstevel@tonic-gate
66*12967Sgavin.maltby@oracle.com if (pctl)
67*12967Sgavin.maltby@oracle.com nvlist_prt(rp->rec_nvl, pctl);
68*12967Sgavin.maltby@oracle.com else
69*12967Sgavin.maltby@oracle.com nvlist_print(fp, rp->rec_nvl);
70*12967Sgavin.maltby@oracle.com
710Sstevel@tonic-gate fmdump_printf(fp, "\n");
720Sstevel@tonic-gate return (0);
730Sstevel@tonic-gate }
740Sstevel@tonic-gate
75*12967Sgavin.maltby@oracle.com static int
err_verb2(fmd_log_t * lp,const fmd_log_record_t * rp,FILE * fp)76*12967Sgavin.maltby@oracle.com err_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
77*12967Sgavin.maltby@oracle.com {
78*12967Sgavin.maltby@oracle.com return (err_verb23_cmn(lp, rp, fp, NULL));
79*12967Sgavin.maltby@oracle.com }
80*12967Sgavin.maltby@oracle.com
81*12967Sgavin.maltby@oracle.com static int
err_pretty(fmd_log_t * lp,const fmd_log_record_t * rp,FILE * fp)82*12967Sgavin.maltby@oracle.com err_pretty(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
83*12967Sgavin.maltby@oracle.com {
84*12967Sgavin.maltby@oracle.com nvlist_prtctl_t pctl;
85*12967Sgavin.maltby@oracle.com int rc;
86*12967Sgavin.maltby@oracle.com
87*12967Sgavin.maltby@oracle.com if ((pctl = nvlist_prtctl_alloc()) != NULL) {
88*12967Sgavin.maltby@oracle.com nvlist_prtctl_setdest(pctl, fp);
89*12967Sgavin.maltby@oracle.com nvlist_prtctlop_nvlist(pctl, fmdump_render_nvlist, NULL);
90*12967Sgavin.maltby@oracle.com }
91*12967Sgavin.maltby@oracle.com
92*12967Sgavin.maltby@oracle.com rc = err_verb23_cmn(lp, rp, fp, pctl);
93*12967Sgavin.maltby@oracle.com
94*12967Sgavin.maltby@oracle.com nvlist_prtctl_free(pctl);
95*12967Sgavin.maltby@oracle.com return (rc);
96*12967Sgavin.maltby@oracle.com }
97*12967Sgavin.maltby@oracle.com
980Sstevel@tonic-gate const fmdump_ops_t fmdump_err_ops = {
990Sstevel@tonic-gate "error", {
1000Sstevel@tonic-gate {
1010Sstevel@tonic-gate "TIME CLASS",
1020Sstevel@tonic-gate (fmd_log_rec_f *)err_short
1030Sstevel@tonic-gate }, {
1040Sstevel@tonic-gate "TIME CLASS ENA",
1050Sstevel@tonic-gate (fmd_log_rec_f *)err_verb1
1060Sstevel@tonic-gate }, {
1070Sstevel@tonic-gate "TIME CLASS",
1080Sstevel@tonic-gate (fmd_log_rec_f *)err_verb2
1099501SRobert.Johnston@Sun.COM }, {
110*12967Sgavin.maltby@oracle.com "TIME CLASS",
111*12967Sgavin.maltby@oracle.com (fmd_log_rec_f *)err_pretty
112*12967Sgavin.maltby@oracle.com }, {
1139501SRobert.Johnston@Sun.COM NULL, NULL
1140Sstevel@tonic-gate } }
1150Sstevel@tonic-gate };
116