xref: /titanic_41/usr/src/cmd/fm/fmdump/common/asru.c (revision 1dd08564e4a3aafe66b00aee6f222b0885346fe8)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <fmdump.h>
29 #include <strings.h>
30 #include <stdio.h>
31 #include <time.h>
32 
33 /*ARGSUSED*/
34 static int
35 asru_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
36 {
37 	char buf[32];
38 
39 	fmdump_printf(fp, "%-20s %-32s\n",
40 	    fmdump_date(buf, sizeof (buf), rp), rp->rec_class);
41 
42 	return (0);
43 }
44 
45 /*ARGSUSED*/
46 static int
47 asru_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
48 {
49 	char *uuid = "-";
50 	boolean_t f = 0, u = 0;
51 	char buf[32], state[32];
52 
53 	(void) nvlist_lookup_string(rp->rec_nvl, FM_RSRC_ASRU_UUID, &uuid);
54 	(void) nvlist_lookup_boolean_value(rp->rec_nvl,
55 	    FM_RSRC_ASRU_FAULTY, &f);
56 	(void) nvlist_lookup_boolean_value(rp->rec_nvl,
57 	    FM_RSRC_ASRU_UNUSABLE, &u);
58 
59 	state[0] = '\0';
60 
61 	if (f)
62 		(void) strcat(state, ",faulty");
63 	if (u)
64 		(void) strcat(state, ",unusable");
65 	if (!f && !u)
66 		(void) strcat(state, ",ok");
67 
68 	fmdump_printf(fp, "%-20s %-36s %s\n",
69 	    fmdump_date(buf, sizeof (buf), rp), uuid, state + 1);
70 
71 	return (0);
72 }
73 
74 static int
75 asru_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
76 {
77 	(void) asru_verb1(lp, rp, fp);
78 
79 	nvlist_print(fp, rp->rec_nvl);
80 	fmdump_printf(fp, "\n");
81 
82 	return (0);
83 }
84 
85 const fmdump_ops_t fmdump_asru_ops = {
86 "asru", {
87 {
88 "TIME                 CLASS",
89 (fmd_log_rec_f *)asru_short
90 }, {
91 "TIME                 UUID                                 STATE",
92 (fmd_log_rec_f *)asru_verb1
93 }, {
94 "TIME                 UUID                                 STATE",
95 (fmd_log_rec_f *)asru_verb2
96 } }
97 };
98