xref: /illumos-gate/usr/src/cmd/fm/fmdump/common/error.c (revision 711890bc9379ceea66272dc8d4981812224ea86e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <fmdump.h>
30 #include <stdio.h>
31 #include <time.h>
32 
33 /*ARGSUSED*/
34 static int
35 err_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
36 {
37 	char buf[32];
38 
39 	fmdump_printf(fp, "%-15s.%4.4llu %-32s\n",
40 	    fmdump_date(buf, sizeof (buf), rp),
41 	    rp->rec_nsec / (NANOSEC / 10000), rp->rec_class);
42 
43 	return (0);
44 }
45 
46 /*ARGSUSED*/
47 static int
48 err_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
49 {
50 	uint64_t ena = 0;
51 	char buf[32];
52 
53 	(void) nvlist_lookup_uint64(rp->rec_nvl, FM_EREPORT_ENA, &ena);
54 
55 	fmdump_printf(fp, "%-15s.%4.4llu %-37s 0x%016llx\n",
56 	    fmdump_date(buf, sizeof (buf), rp),
57 	    rp->rec_nsec / (NANOSEC / 10000), rp->rec_class, ena);
58 
59 	return (0);
60 }
61 
62 /*ARGSUSED*/
63 static int
64 err_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
65 {
66 	char buf[32];
67 
68 	fmdump_printf(fp, "%-20s.%9.9llu %s\n",
69 	    fmdump_year(buf, sizeof (buf), rp), rp->rec_nsec, rp->rec_class);
70 
71 	nvlist_print(fp, rp->rec_nvl);
72 	fmdump_printf(fp, "\n");
73 	return (0);
74 }
75 
76 const fmdump_ops_t fmdump_err_ops = {
77 "error", {
78 {
79 "TIME                 CLASS",
80 (fmd_log_rec_f *)err_short
81 }, {
82 "TIME                 CLASS                                 ENA",
83 (fmd_log_rec_f *)err_verb1
84 }, {
85 "TIME                           CLASS",
86 (fmd_log_rec_f *)err_verb2
87 } }
88 };
89