xref: /titanic_52/usr/src/cmd/fm/fmdump/common/asru.c (revision fa9e4066f08beec538e775443c5be79dd423fcab)
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 <strings.h>
31 #include <stdio.h>
32 #include <time.h>
33 
34 /*ARGSUSED*/
35 static int
36 asru_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
37 {
38 	char buf[32];
39 
40 	fmdump_printf(fp, "%-15s.%4.4llu %-32s\n",
41 	    fmdump_date(buf, sizeof (buf), rp),
42 	    rp->rec_nsec / (NANOSEC / 10000), rp->rec_class);
43 
44 	return (0);
45 }
46 
47 /*ARGSUSED*/
48 static int
49 asru_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
50 {
51 	char *uuid = "-";
52 	boolean_t f = 0, u = 0;
53 	char buf[32], state[32];
54 
55 	(void) nvlist_lookup_string(rp->rec_nvl, FM_RSRC_ASRU_UUID, &uuid);
56 	(void) nvlist_lookup_boolean_value(rp->rec_nvl,
57 	    FM_RSRC_ASRU_FAULTY, &f);
58 	(void) nvlist_lookup_boolean_value(rp->rec_nvl,
59 	    FM_RSRC_ASRU_UNUSABLE, &u);
60 
61 	state[0] = '\0';
62 
63 	if (f)
64 		(void) strcat(state, ",faulty");
65 	if (u)
66 		(void) strcat(state, ",unusable");
67 	if (!f && !u)
68 		(void) strcat(state, ",ok");
69 
70 	fmdump_printf(fp, "%-15s.%4.4llu %-36s %s\n",
71 	    fmdump_date(buf, sizeof (buf), rp),
72 	    rp->rec_nsec / (NANOSEC / 10000), uuid, state + 1);
73 
74 	return (0);
75 }
76 
77 static int
78 asru_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
79 {
80 	(void) asru_verb1(lp, rp, fp);
81 
82 	nvlist_print(fp, rp->rec_nvl);
83 	fmdump_printf(fp, "\n");
84 
85 	return (0);
86 }
87 
88 const fmdump_ops_t fmdump_asru_ops = {
89 "asru", {
90 {
91 "TIME                 CLASS",
92 (fmd_log_rec_f *)asru_short
93 }, {
94 "TIME                 UUID                                 STATE",
95 (fmd_log_rec_f *)asru_verb1
96 }, {
97 "TIME                 UUID                                 STATE",
98 (fmd_log_rec_f *)asru_verb2
99 } }
100 };
101