annotate usr/src/cmd/fm/fmadm/common/faulty.c @ 14183:68927c785889 default tip

4099 SMF methods without absolute paths no longer work Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Dan McDonald <danmcd@nexenta.com>
author Jerry Jelinek <jerry.jelinek@joyent.com>
date Fri, 06 Sep 2013 09:20:56 -0700
parents b5c2b5db80d6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1 /*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
2 * CDDL HEADER START
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
3 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
5 * Common Development and Distribution License (the "License").
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
6 * You may not use this file except in compliance with the License.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
7 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
10 * See the License for the specific language governing permissions
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
11 * and limitations under the License.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
12 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
18 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
19 * CDDL HEADER END
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
20 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
21 /*
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
22 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
23 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
24
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
25 #include <sys/types.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
26 #include <fmadm.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
27 #include <errno.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
28 #include <limits.h>
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
29 #include <strings.h>
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
30 #include <stdio.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
31 #include <unistd.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
32 #include <sys/wait.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
33 #include <sys/stat.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
34 #include <fcntl.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
35 #include <fm/fmd_log.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
36 #include <sys/fm/protocol.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
37 #include <fm/libtopo.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
38 #include <fm/fmd_adm.h>
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
39 #include <fm/fmd_msg.h>
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
40 #include <dlfcn.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
41 #include <sys/systeminfo.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
42 #include <sys/utsname.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
43 #include <libintl.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
44 #include <locale.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
45 #include <sys/smbios.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
46 #include <libdevinfo.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
47 #include <stdlib.h>
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
48
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
49 #define offsetof(s, m) ((size_t)(&(((s*)0)->m)))
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
50
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
51 /*
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
52 * Fault records are added to catalog by calling add_fault_record_to_catalog()
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
53 * records are stored in order of importance to the system.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
54 * If -g flag is set or not_suppressed is not set and the class fru, fault,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
55 * type are the same then details are merged into an existing record, with uuid
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
56 * records are stored in time order.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
57 * For each record information is extracted from nvlist and merged into linked
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
58 * list each is checked for identical records for which percentage certainty are
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
59 * added together.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
60 * print_catalog() is called to print out catalog and release external resources
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
61 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
62 * /---------------\
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
63 * status_rec_list -> | | -|
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
64 * \---------------/
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
65 * \/
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
66 * /---------------\ /-------\ /-------\
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
67 * status_fru_list | status_record | -> | uurec | -> | uurec | -|
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
68 * \/ | | |- | | <- | |
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
69 * /-------------\ | | \-------/ \-------/
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
70 * | | -> | | \/ \/
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
71 * \-------------/ | | /-------\ /-------\
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
72 * \/ | | -> | asru | -> | asru |
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
73 * --- | | | | <- | |
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
74 * | | \-------/ \-------/
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
75 * status_asru_list | class |
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
76 * \/ | resource | /-------\ /-------\
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
77 * /-------------\ | fru | -> | list | -> | list |
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
78 * | | -> | serial | | | <- | |
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
79 * \-------------/ | | \-------/ \-------/
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
80 * \/ \---------------/
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
81 * --- \/ /\
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
82 * /---------------\
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
83 * | status_record |
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
84 * \---------------/
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
85 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
86 * Fmadm faulty takes a number of options which affect the format of the
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
87 * output displayed. By default, the display reports the FRU and ASRU along
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
88 * with other information on per-case basis as in the example below.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
89 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
90 * --------------- ------------------------------------ -------------- -------
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
91 * TIME EVENT-ID MSG-ID SEVERITY
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
92 * --------------- ------------------------------------ -------------- -------
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
93 * Sep 21 10:01:36 d482f935-5c8f-e9ab-9f25-d0aaafec1e6c AMD-8000-2F Major
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
94 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
95 * Fault class : fault.memory.dimm_sb
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
96 * Affects : mem:///motherboard=0/chip=0/memory-controller=0/dimm=0/rank=0
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
97 * faulted but still in service
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
98 * FRU : "CPU 0 DIMM 0" (hc://.../memory-controller=0/dimm=0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
99 * faulty
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
100 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
101 * Description : The number of errors associated with this memory module has
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
102 * exceeded acceptable levels. Refer to
13605
b5c2b5db80d6 763 FMD msg URLs should refer to something visible
Joshua M. Clulow <josh@sysmgr.org>
parents: 12618
diff changeset
103 * http://illumos.org/msg/AMD-8000-2F for more information.
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
104 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
105 * Response : Pages of memory associated with this memory module are being
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
106 * removed from service as errors are reported.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
107 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
108 * Impact : Total system memory capacity will be reduced as pages are
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
109 * retired.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
110 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
111 * Action : Schedule a repair procedure to replace the affected memory
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
112 * module. Use fmdump -v -u <EVENT_ID> to identify the module.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
113 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
114 * The -v flag is similar, but adds some additonal information such as the
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
115 * resource. The -s flag is also similar but just gives the top line summary.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
116 * All these options (ie without the -f or -r flags) use the print_catalog()
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
117 * function to do the display.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
118 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
119 * The -f flag changes the output so that it appears sorted on a per-fru basis.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
120 * The output is somewhat cut down compared to the default output. If -f is
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
121 * used, then print_fru() is used to print the output.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
122 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
123 * -----------------------------------------------------------------------------
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
124 * "SLOT 2" (hc://.../hostbridge=3/pciexrc=3/pciexbus=4/pciexdev=0) faulty
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
125 * 5ca4aeb3-36...f6be-c2e8166dc484 2 suspects in this FRU total certainty 100%
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
126 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
127 * Description : A problem was detected for a PCI device.
13605
b5c2b5db80d6 763 FMD msg URLs should refer to something visible
Joshua M. Clulow <josh@sysmgr.org>
parents: 12618
diff changeset
128 * Refer to http://illumos.org/msg/PCI-8000-7J
b5c2b5db80d6 763 FMD msg URLs should refer to something visible
Joshua M. Clulow <josh@sysmgr.org>
parents: 12618
diff changeset
129 * for more information.
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
130 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
131 * Response : One or more device instances may be disabled
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
132 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
133 * Impact : Possible loss of services provided by the device instances
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
134 * associated with this fault
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
135 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
136 * Action : Schedule a repair procedure to replace the affected device.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
137 * Use fmdump -v -u <EVENT_ID> to identify the device or contact
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
138 * Sun for support.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
139 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
140 * The -r flag changes the output so that it appears sorted on a per-asru basis.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
141 * The output is very much cut down compared to the default output, just giving
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
142 * the asru fmri and state. Here print_asru() is used to print the output.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
143 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
144 * mem:///motherboard=0/chip=0/memory-controller=0/dimm=0/rank=0 degraded
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
145 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
146 * For all fmadm faulty options, the sequence of events is
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
147 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
148 * 1) Walk through all the cases in the system using fmd_adm_case_iter() and
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
149 * for each case call dfault_rec(). This will call add_fault_record_to_catalog()
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
150 * This will extract the data from the nvlist and call catalog_new_record() to
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
151 * save the data away in various linked lists in the catalogue.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
152 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
153 * 2) Once this is done, the data can be supplemented by using
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
154 * fmd_adm_rsrc_iter(). However this is now only necessary for the -i option.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
155 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
156 * 3) Finally print_catalog(), print_fru() or print_asru() are called as
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
157 * appropriate to display the information from the catalogue sorted in the
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
158 * requested way.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
159 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
160 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
161
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
162 typedef struct name_list {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
163 struct name_list *next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
164 struct name_list *prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
165 char *name;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
166 uint8_t pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
167 uint8_t max_pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
168 ushort_t count;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
169 int status;
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
170 char *label;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
171 } name_list_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
172
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
173 typedef struct ari_list {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
174 char *ari_uuid;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
175 struct ari_list *next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
176 } ari_list_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
177
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
178 typedef struct uurec {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
179 struct uurec *next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
180 struct uurec *prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
181 char *uuid;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
182 ari_list_t *ari_uuid_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
183 name_list_t *asru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
184 uint64_t sec;
10234
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
185 nvlist_t *event;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
186 } uurec_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
187
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
188 typedef struct uurec_select {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
189 struct uurec_select *next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
190 char *uuid;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
191 } uurec_select_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
192
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
193 typedef struct host_id {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
194 char *chassis;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
195 char *server;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
196 char *platform;
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
197 char *domain;
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
198 char *product_sn;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
199 } hostid_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
200
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
201 typedef struct host_id_list {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
202 hostid_t hostid;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
203 struct host_id_list *next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
204 } host_id_list_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
205
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
206 typedef struct status_record {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
207 hostid_t *host;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
208 int nrecs;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
209 uurec_t *uurec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
210 char *severity; /* in C locale */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
211 char *msgid;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
212 name_list_t *class;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
213 name_list_t *resource;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
214 name_list_t *asru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
215 name_list_t *fru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
216 name_list_t *serial;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
217 uint8_t not_suppressed;
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
218 uint8_t injected;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
219 } status_record_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
220
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
221 typedef struct sr_list {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
222 struct sr_list *next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
223 struct sr_list *prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
224 struct status_record *status_record;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
225 } sr_list_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
226
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
227 typedef struct resource_list {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
228 struct resource_list *next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
229 struct resource_list *prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
230 sr_list_t *status_rec_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
231 char *resource;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
232 uint8_t not_suppressed;
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
233 uint8_t injected;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
234 uint8_t max_pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
235 } resource_list_t;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
236
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
237 sr_list_t *status_rec_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
238 resource_list_t *status_fru_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
239 resource_list_t *status_asru_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
240
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
241 static int max_display;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
242 static int max_fault = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
243 static topo_hdl_t *topo_handle;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
244 static host_id_list_t *host_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
245 static int n_server;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
246 static int opt_g;
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
247 static fmd_msg_hdl_t *fmadm_msghdl = NULL; /* handle for libfmd_msg calls */
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
248
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
249 static char *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
250 format_date(char *buf, size_t len, uint64_t sec)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
251 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
252 if (sec > LONG_MAX) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
253 (void) fprintf(stderr,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
254 "record time is too large for 32-bit utility\n");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
255 (void) snprintf(buf, len, "0x%llx", sec);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
256 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
257 time_t tod = (time_t)sec;
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
258 time_t now = time(NULL);
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
259 if (tod > now+60 ||
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
260 tod < now - 6L*30L*24L*60L*60L) { /* 6 months ago */
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
261 (void) strftime(buf, len, "%b %d %Y ",
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
262 localtime(&tod));
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
263 } else {
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
264 (void) strftime(buf, len, "%b %d %T", localtime(&tod));
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
265 }
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
266 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
267
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
268 return (buf);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
269 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
270
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
271 static hostid_t *
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
272 find_hostid_in_list(char *platform, char *chassis, char *server, char *domain,
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
273 char *product_sn)
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
274 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
275 hostid_t *rt = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
276 host_id_list_t *hostp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
277
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
278 if (platform == NULL)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
279 platform = "-";
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
280 if (server == NULL)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
281 server = "-";
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
282 hostp = host_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
283 while (hostp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
284 if (hostp->hostid.platform &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
285 strcmp(hostp->hostid.platform, platform) == 0 &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
286 hostp->hostid.server &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
287 strcmp(hostp->hostid.server, server) == 0 &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
288 (chassis == NULL || hostp->hostid.chassis == NULL ||
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
289 strcmp(chassis, hostp->hostid.chassis) == 0) &&
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
290 (product_sn == NULL || hostp->hostid.product_sn == NULL ||
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
291 strcmp(product_sn, hostp->hostid.product_sn) == 0) &&
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
292 (domain == NULL || hostp->hostid.domain == NULL ||
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
293 strcmp(domain, hostp->hostid.domain) == 0)) {
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
294 rt = &hostp->hostid;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
295 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
296 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
297 hostp = hostp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
298 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
299 if (rt == NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
300 hostp = malloc(sizeof (host_id_list_t));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
301 hostp->hostid.platform = strdup(platform);
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
302 hostp->hostid.product_sn =
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
303 product_sn ? strdup(product_sn) : NULL;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
304 hostp->hostid.server = strdup(server);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
305 hostp->hostid.chassis = chassis ? strdup(chassis) : NULL;
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
306 hostp->hostid.domain = domain ? strdup(domain) : NULL;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
307 hostp->next = host_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
308 host_list = hostp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
309 rt = &hostp->hostid;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
310 n_server++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
311 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
312 return (rt);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
313 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
314
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
315 static hostid_t *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
316 find_hostid(nvlist_t *nvl)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
317 {
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
318 char *platform = NULL, *chassis = NULL, *server = NULL, *domain = NULL;
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
319 char *product_sn = NULL;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
320 nvlist_t *auth, *fmri;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
321 hostid_t *rt = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
322
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
323 if (nvlist_lookup_nvlist(nvl, FM_SUSPECT_DE, &fmri) == 0 &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
324 nvlist_lookup_nvlist(fmri, FM_FMRI_AUTHORITY, &auth) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
325 (void) nvlist_lookup_string(auth, FM_FMRI_AUTH_PRODUCT,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
326 &platform);
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
327 (void) nvlist_lookup_string(auth, FM_FMRI_AUTH_PRODUCT_SN,
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
328 &product_sn);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
329 (void) nvlist_lookup_string(auth, FM_FMRI_AUTH_SERVER, &server);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
330 (void) nvlist_lookup_string(auth, FM_FMRI_AUTH_CHASSIS,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
331 &chassis);
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
332 (void) nvlist_lookup_string(auth, FM_FMRI_AUTH_DOMAIN, &domain);
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
333 rt = find_hostid_in_list(platform, chassis, server,
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
334 domain, product_sn);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
335 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
336 return (rt);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
337 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
338
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
339 static char *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
340 get_nvl2str_topo(nvlist_t *nvl)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
341 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
342 char *name = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
343 char *tname;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
344 int err;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
345 char *scheme = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
346 char *mod_name = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
347 char buf[128];
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
348
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
349 if (topo_handle == NULL)
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
350 topo_handle = topo_open(TOPO_VERSION, 0, &err);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
351 if (topo_fmri_nvl2str(topo_handle, nvl, &tname, &err) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
352 name = strdup(tname);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
353 topo_hdl_strfree(topo_handle, tname);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
354 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
355 (void) nvlist_lookup_string(nvl, FM_FMRI_SCHEME, &scheme);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
356 (void) nvlist_lookup_string(nvl, FM_FMRI_MOD_NAME, &mod_name);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
357 if (scheme && strcmp(scheme, FM_FMRI_SCHEME_FMD) == 0 &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
358 mod_name) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
359 (void) snprintf(buf, sizeof (buf), "%s:///module/%s",
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
360 scheme, mod_name);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
361 name = strdup(buf);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
362 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
363 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
364 return (name);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
365 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
366
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
367 static int
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
368 set_priority(char *s)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
369 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
370 int rt = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
371
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
372 if (s) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
373 if (strcmp(s, "Minor") == 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
374 rt = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
375 else if (strcmp(s, "Major") == 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
376 rt = 10;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
377 else if (strcmp(s, "Critical") == 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
378 rt = 100;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
379 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
380 return (rt);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
381 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
382
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
383 static int
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
384 cmp_priority(char *s1, char *s2, uint64_t t1, uint64_t t2, uint8_t p1,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
385 uint8_t p2)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
386 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
387 int r1, r2;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
388 int rt;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
389
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
390 r1 = set_priority(s1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
391 r2 = set_priority(s2);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
392 rt = r1 - r2;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
393 if (rt == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
394 if (t1 > t2)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
395 rt = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
396 else if (t1 < t2)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
397 rt = -1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
398 else
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
399 rt = p1 - p2;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
400 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
401 return (rt);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
402 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
403
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
404 /*
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
405 * merge two lists into one, by comparing enties in new and moving into list if
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
406 * name is not there or free off memory for names which are already there
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
407 * add_pct indicates if pct is the sum or highest pct
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
408 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
409 static name_list_t *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
410 merge_name_list(name_list_t **list, name_list_t *new, int add_pct)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
411 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
412 name_list_t *lp, *np, *sp, *rt = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
413 int max_pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
414
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
415 rt = *list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
416 np = new;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
417 while (np) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
418 lp = *list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
419 while (lp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
420 if (strcmp(lp->name, np->name) == 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
421 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
422 lp = lp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
423 if (lp == *list)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
424 lp = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
425 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
426 if (np->next == new)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
427 sp = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
428 else
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
429 sp = np->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
430 if (lp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
431 lp->status |= (np->status & FM_SUSPECT_FAULTY);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
432 if (add_pct) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
433 lp->pct += np->pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
434 lp->count += np->count;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
435 } else if (np->pct > lp->pct) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
436 lp->pct = np->pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
437 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
438 max_pct = np->max_pct;
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
439 if (np->label)
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
440 free(np->label);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
441 free(np->name);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
442 free(np);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
443 np = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
444 if (max_pct > lp->max_pct) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
445 lp->max_pct = max_pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
446 if (lp->max_pct > lp->prev->max_pct &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
447 lp != *list) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
448 lp->prev->next = lp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
449 lp->next->prev = lp->prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
450 np = lp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
451 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
452 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
453 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
454 if (np) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
455 lp = *list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
456 if (lp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
457 if (np->max_pct > lp->max_pct) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
458 np->next = lp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
459 np->prev = lp->prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
460 lp->prev->next = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
461 lp->prev = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
462 *list = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
463 rt = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
464 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
465 lp = lp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
466 while (lp != *list &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
467 np->max_pct < lp->max_pct) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
468 lp = lp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
469 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
470 np->next = lp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
471 np->prev = lp->prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
472 lp->prev->next = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
473 lp->prev = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
474 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
475 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
476 *list = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
477 np->next = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
478 np->prev = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
479 rt = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
480 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
481 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
482 np = sp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
483 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
484 return (rt);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
485 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
486
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
487 static name_list_t *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
488 alloc_name_list(char *name, uint8_t pct)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
489 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
490 name_list_t *nlp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
491
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
492 nlp = malloc(sizeof (*nlp));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
493 nlp->name = strdup(name);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
494 nlp->pct = pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
495 nlp->max_pct = pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
496 nlp->count = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
497 nlp->next = nlp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
498 nlp->prev = nlp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
499 nlp->status = 0;
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
500 nlp->label = NULL;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
501 return (nlp);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
502 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
503
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
504 static status_record_t *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
505 new_record_init(uurec_t *uurec_p, char *msgid, name_list_t *class,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
506 name_list_t *fru, name_list_t *asru, name_list_t *resource,
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
507 name_list_t *serial, boolean_t not_suppressed,
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
508 hostid_t *hostid, boolean_t injected)
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
509 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
510 status_record_t *status_rec_p;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
511
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
512 status_rec_p = (status_record_t *)malloc(sizeof (status_record_t));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
513 status_rec_p->nrecs = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
514 status_rec_p->host = hostid;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
515 status_rec_p->uurec = uurec_p;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
516 uurec_p->next = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
517 uurec_p->prev = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
518 uurec_p->asru = asru;
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
519 if ((status_rec_p->severity = fmd_msg_getitem_id(fmadm_msghdl, NULL,
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
520 msgid, FMD_MSG_ITEM_SEVERITY)) == NULL)
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
521 status_rec_p->severity = strdup("unknown");
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
522 status_rec_p->class = class;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
523 status_rec_p->fru = fru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
524 status_rec_p->asru = asru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
525 status_rec_p->resource = resource;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
526 status_rec_p->serial = serial;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
527 status_rec_p->msgid = strdup(msgid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
528 status_rec_p->not_suppressed = not_suppressed;
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
529 status_rec_p->injected = injected;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
530 return (status_rec_p);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
531 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
532
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
533 /*
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
534 * add record to given list maintaining order higher priority first.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
535 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
536 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
537 add_rec_list(status_record_t *status_rec_p, sr_list_t **list_pp)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
538 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
539 sr_list_t *tp, *np, *sp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
540 int order;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
541 uint64_t sec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
542
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
543 np = malloc(sizeof (sr_list_t));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
544 np->status_record = status_rec_p;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
545 sec = status_rec_p->uurec->sec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
546 if ((sp = *list_pp) == NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
547 *list_pp = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
548 np->next = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
549 np->prev = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
550 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
551 /* insert new record in front of lower priority */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
552 tp = sp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
553 order = cmp_priority(status_rec_p->severity,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
554 sp->status_record->severity, sec,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
555 tp->status_record->uurec->sec, 0, 0);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
556 if (order > 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
557 *list_pp = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
558 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
559 tp = sp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
560 while (tp != sp &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
561 cmp_priority(status_rec_p->severity,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
562 tp->status_record->severity, sec,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
563 tp->status_record->uurec->sec, 0, 0)) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
564 tp = tp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
565 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
566 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
567 np->next = tp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
568 np->prev = tp->prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
569 tp->prev->next = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
570 tp->prev = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
571 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
572 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
573
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
574 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
575 add_resource(status_record_t *status_rec_p, resource_list_t **rp,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
576 resource_list_t *np)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
577 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
578 int order;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
579 uint64_t sec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
580 resource_list_t *sp, *tp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
581 status_record_t *srp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
582 char *severity = status_rec_p->severity;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
583
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
584 add_rec_list(status_rec_p, &np->status_rec_list);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
585 if ((sp = *rp) == NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
586 np->next = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
587 np->prev = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
588 *rp = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
589 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
590 /*
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
591 * insert new record in front of lower priority
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
592 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
593 tp = sp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
594 srp = sp->status_rec_list->status_record;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
595 sec = status_rec_p->uurec->sec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
596 order = cmp_priority(severity, srp->severity, sec,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
597 srp->uurec->sec, np->max_pct, sp->max_pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
598 if (order > 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
599 *rp = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
600 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
601 srp = tp->status_rec_list->status_record;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
602 while (tp != sp &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
603 cmp_priority(severity, srp->severity, sec,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
604 srp->uurec->sec, np->max_pct, sp->max_pct) < 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
605 tp = tp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
606 srp = tp->status_rec_list->status_record;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
607 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
608 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
609 np->next = tp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
610 np->prev = tp->prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
611 tp->prev->next = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
612 tp->prev = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
613 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
614 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
615
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
616 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
617 add_resource_list(status_record_t *status_rec_p, name_list_t *fp,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
618 resource_list_t **rpp)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
619 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
620 int order;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
621 resource_list_t *np, *end;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
622 status_record_t *srp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
623
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
624 np = *rpp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
625 end = np;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
626 while (np) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
627 if (strcmp(fp->name, np->resource) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
628 np->not_suppressed |= status_rec_p->not_suppressed;
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
629 np->injected |= status_rec_p->injected;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
630 srp = np->status_rec_list->status_record;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
631 order = cmp_priority(status_rec_p->severity,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
632 srp->severity, status_rec_p->uurec->sec,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
633 srp->uurec->sec, fp->max_pct, np->max_pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
634 if (order > 0 && np != end) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
635 /*
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
636 * remove from list and add again using
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
637 * new priority
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
638 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
639 np->prev->next = np->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
640 np->next->prev = np->prev;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
641 add_resource(status_rec_p,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
642 rpp, np);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
643 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
644 add_rec_list(status_rec_p,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
645 &np->status_rec_list);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
646 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
647 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
648 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
649 np = np->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
650 if (np == end) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
651 np = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
652 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
653 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
654 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
655 if (np == NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
656 np = malloc(sizeof (resource_list_t));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
657 np->resource = fp->name;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
658 np->not_suppressed = status_rec_p->not_suppressed;
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
659 np->injected = status_rec_p->injected;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
660 np->status_rec_list = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
661 np->max_pct = fp->max_pct;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
662 add_resource(status_rec_p, rpp, np);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
663 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
664 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
665
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
666 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
667 add_list(status_record_t *status_rec_p, name_list_t *listp,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
668 resource_list_t **glistp)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
669 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
670 name_list_t *fp, *end;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
671
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
672 fp = listp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
673 end = fp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
674 while (fp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
675 add_resource_list(status_rec_p, fp, glistp);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
676 fp = fp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
677 if (fp == end)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
678 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
679 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
680 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
681
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
682 /*
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
683 * add record to rec, fru and asru lists.
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
684 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
685 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
686 catalog_new_record(uurec_t *uurec_p, char *msgid, name_list_t *class,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
687 name_list_t *fru, name_list_t *asru, name_list_t *resource,
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
688 name_list_t *serial, boolean_t not_suppressed,
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
689 hostid_t *hostid, boolean_t injected, boolean_t dummy_fru)
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
690 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
691 status_record_t *status_rec_p;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
692
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
693 status_rec_p = new_record_init(uurec_p, msgid, class, fru, asru,
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
694 resource, serial, not_suppressed, hostid, injected);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
695 add_rec_list(status_rec_p, &status_rec_list);
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
696 if (status_rec_p->fru && !dummy_fru)
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
697 add_list(status_rec_p, status_rec_p->fru, &status_fru_list);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
698 if (status_rec_p->asru)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
699 add_list(status_rec_p, status_rec_p->asru, &status_asru_list);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
700 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
701
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
702 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
703 get_serial_no(nvlist_t *nvl, name_list_t **serial_p, uint8_t pct)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
704 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
705 char *name;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
706 char *serial = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
707 char **lserial = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
708 uint64_t serint;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
709 name_list_t *nlp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
710 int j;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
711 uint_t nelem;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
712 char buf[64];
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
713
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
714 if (nvlist_lookup_string(nvl, FM_FMRI_SCHEME, &name) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
715 if (strcmp(name, FM_FMRI_SCHEME_CPU) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
716 if (nvlist_lookup_uint64(nvl, FM_FMRI_CPU_SERIAL_ID,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
717 &serint) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
718 (void) snprintf(buf, sizeof (buf), "%llX",
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
719 serint);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
720 nlp = alloc_name_list(buf, pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
721 (void) merge_name_list(serial_p, nlp, 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
722 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
723 } else if (strcmp(name, FM_FMRI_SCHEME_MEM) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
724 if (nvlist_lookup_string_array(nvl,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
725 FM_FMRI_MEM_SERIAL_ID, &lserial, &nelem) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
726 nlp = alloc_name_list(lserial[0], pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
727 for (j = 1; j < nelem; j++) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
728 name_list_t *n1lp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
729 n1lp = alloc_name_list(lserial[j], pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
730 (void) merge_name_list(&nlp, n1lp, 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
731 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
732 (void) merge_name_list(serial_p, nlp, 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
733 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
734 } else if (strcmp(name, FM_FMRI_SCHEME_HC) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
735 if (nvlist_lookup_string(nvl, FM_FMRI_HC_SERIAL_ID,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
736 &serial) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
737 nlp = alloc_name_list(serial, pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
738 (void) merge_name_list(serial_p, nlp, 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
739 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
740 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
741 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
742 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
743
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
744 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
745 extract_record_info(nvlist_t *nvl, name_list_t **class_p,
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
746 name_list_t **fru_p, name_list_t **serial_p, name_list_t **resource_p,
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
747 name_list_t **asru_p, boolean_t *dummy_fru, uint8_t status)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
748 {
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
749 nvlist_t *lfru, *lasru, *rsrc;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
750 name_list_t *nlp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
751 char *name;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
752 uint8_t lpct = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
753 char *lclass = NULL;
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
754 char *label;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
755
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
756 (void) nvlist_lookup_uint8(nvl, FM_FAULT_CERTAINTY, &lpct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
757 if (nvlist_lookup_string(nvl, FM_CLASS, &lclass) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
758 nlp = alloc_name_list(lclass, lpct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
759 (void) merge_name_list(class_p, nlp, 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
760 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
761 if (nvlist_lookup_nvlist(nvl, FM_FAULT_FRU, &lfru) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
762 name = get_nvl2str_topo(lfru);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
763 if (name != NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
764 nlp = alloc_name_list(name, lpct);
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
765 nlp->status = status & ~(FM_SUSPECT_UNUSABLE |
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
766 FM_SUSPECT_DEGRADED);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
767 free(name);
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
768 if (nvlist_lookup_string(nvl, FM_FAULT_LOCATION,
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
769 &label) == 0)
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
770 nlp->label = strdup(label);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
771 (void) merge_name_list(fru_p, nlp, 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
772 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
773 get_serial_no(lfru, serial_p, lpct);
10656
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
774 } else if (nvlist_lookup_nvlist(nvl, FM_FAULT_RESOURCE, &rsrc) != 0) {
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
775 /*
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
776 * No FRU or resource. But we want to display the repair status
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
777 * somehow, so create a dummy FRU field.
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
778 */
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
779 *dummy_fru = 1;
10656
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
780 nlp = alloc_name_list(dgettext("FMD", "None"), lpct);
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
781 nlp->status = status & ~(FM_SUSPECT_UNUSABLE |
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
782 FM_SUSPECT_DEGRADED);
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
783 (void) merge_name_list(fru_p, nlp, 1);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
784 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
785 if (nvlist_lookup_nvlist(nvl, FM_FAULT_ASRU, &lasru) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
786 name = get_nvl2str_topo(lasru);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
787 if (name != NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
788 nlp = alloc_name_list(name, lpct);
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
789 nlp->status = status & ~(FM_SUSPECT_NOT_PRESENT |
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
790 FM_SUSPECT_REPAIRED | FM_SUSPECT_REPLACED |
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
791 FM_SUSPECT_ACQUITTED);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
792 free(name);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
793 (void) merge_name_list(asru_p, nlp, 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
794 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
795 get_serial_no(lasru, serial_p, lpct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
796 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
797 if (nvlist_lookup_nvlist(nvl, FM_FAULT_RESOURCE, &rsrc) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
798 name = get_nvl2str_topo(rsrc);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
799 if (name != NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
800 nlp = alloc_name_list(name, lpct);
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
801 nlp->status = status;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
802 free(name);
8245
7dbd13b3b276 6763249 eft is disabled on fmadm repair when serdsuffix feature is used
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 7275
diff changeset
803 if (nvlist_lookup_string(nvl, FM_FAULT_LOCATION,
7dbd13b3b276 6763249 eft is disabled on fmadm repair when serdsuffix feature is used
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 7275
diff changeset
804 &label) == 0)
7dbd13b3b276 6763249 eft is disabled on fmadm repair when serdsuffix feature is used
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 7275
diff changeset
805 nlp->label = strdup(label);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
806 (void) merge_name_list(resource_p, nlp, 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
807 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
808 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
809 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
810
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
811 static void
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
812 add_fault_record_to_catalog(nvlist_t *nvl, uint64_t sec, char *uuid)
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
813 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
814 char *msgid = "-";
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
815 uint_t i, size = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
816 name_list_t *class = NULL, *resource = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
817 name_list_t *asru = NULL, *fru = NULL, *serial = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
818 nvlist_t **nva;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
819 uint8_t *ba;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
820 uurec_t *uurec_p;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
821 hostid_t *host;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
822 boolean_t not_suppressed = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
823 boolean_t any_present = 0;
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
824 boolean_t injected = 0;
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
825 boolean_t dummy_fru = 0;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
826
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
827 (void) nvlist_lookup_string(nvl, FM_SUSPECT_DIAG_CODE, &msgid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
828 (void) nvlist_lookup_uint32(nvl, FM_SUSPECT_FAULT_SZ, &size);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
829 (void) nvlist_lookup_boolean_value(nvl, FM_SUSPECT_MESSAGE,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
830 &not_suppressed);
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
831 (void) nvlist_lookup_boolean_value(nvl, FM_SUSPECT_INJECTED, &injected);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
832
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
833 if (size != 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
834 (void) nvlist_lookup_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
835 &nva, &size);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
836 (void) nvlist_lookup_uint8_array(nvl, FM_SUSPECT_FAULT_STATUS,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
837 &ba, &size);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
838 for (i = 0; i < size; i++) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
839 extract_record_info(nva[i], &class, &fru, &serial,
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
840 &resource, &asru, &dummy_fru, ba[i]);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
841 if (!(ba[i] & FM_SUSPECT_NOT_PRESENT) &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
842 (ba[i] & FM_SUSPECT_FAULTY))
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
843 any_present = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
844 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
845 /*
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
846 * also suppress if no resources present
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
847 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
848 if (any_present == 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
849 not_suppressed = 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
850 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
851
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
852 uurec_p = (uurec_t *)malloc(sizeof (uurec_t));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
853 uurec_p->uuid = strdup(uuid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
854 uurec_p->sec = sec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
855 uurec_p->ari_uuid_list = NULL;
10234
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
856 uurec_p->event = NULL;
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
857 (void) nvlist_dup(nvl, &uurec_p->event, 0);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
858 host = find_hostid(nvl);
10656
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
859 catalog_new_record(uurec_p, msgid, class, fru, asru,
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
860 resource, serial, not_suppressed, host, injected, dummy_fru);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
861 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
862
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
863 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
864 update_asru_state_in_catalog(const char *uuid, const char *ari_uuid)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
865 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
866 sr_list_t *srp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
867 uurec_t *uurp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
868 ari_list_t *ari_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
869
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
870 srp = status_rec_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
871 if (srp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
872 for (;;) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
873 uurp = srp->status_record->uurec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
874 while (uurp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
875 if (strcmp(uuid, uurp->uuid) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
876 ari_list = (ari_list_t *)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
877 malloc(sizeof (ari_list_t));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
878 ari_list->ari_uuid = strdup(ari_uuid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
879 ari_list->next = uurp->ari_uuid_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
880 uurp->ari_uuid_list = ari_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
881 return;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
882 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
883 uurp = uurp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
884 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
885 if (srp->next == status_rec_list)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
886 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
887 srp = srp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
888 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
889 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
890 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
891
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
892 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
893 print_line(char *label, char *buf)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
894 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
895 char *cp, *ep, *wp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
896 char c;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
897 int i;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
898 int lsz;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
899 char *padding;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
900
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
901 lsz = strlen(label);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
902 padding = malloc(lsz + 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
903 for (i = 0; i < lsz; i++)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
904 padding[i] = ' ';
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
905 padding[i] = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
906 cp = buf;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
907 ep = buf;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
908 c = *ep;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
909 (void) printf("\n");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
910 while (c) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
911 i = lsz;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
912 wp = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
913 while ((c = *ep) != NULL && (wp == NULL || i < 80)) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
914 if (c == ' ')
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
915 wp = ep;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
916 else if (c == '\n') {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
917 i = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
918 *ep = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
919 do {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
920 ep++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
921 } while ((c = *ep) != NULL && c == ' ');
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
922 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
923 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
924 ep++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
925 i++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
926 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
927 if (i >= 80 && wp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
928 *wp = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
929 ep = wp + 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
930 c = *ep;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
931 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
932 (void) printf("%s%s\n", label, cp);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
933 cp = ep;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
934 label = padding;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
935 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
936 free(padding);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
937 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
938
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
939 static void
10234
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
940 print_dict_info_line(nvlist_t *e, fmd_msg_item_t what, const char *linehdr)
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
941 {
10234
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
942 char *cp = fmd_msg_getitem_nv(fmadm_msghdl, NULL, e, what);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
943
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
944 if (cp) {
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
945 print_line(dgettext("FMD", linehdr), cp);
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
946 free(cp);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
947 }
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
948 }
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
949
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
950 static void
10234
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
951 print_dict_info(nvlist_t *nvl)
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
952 {
10234
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
953 print_dict_info_line(nvl, FMD_MSG_ITEM_DESC, "Description : ");
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
954 print_dict_info_line(nvl, FMD_MSG_ITEM_RESPONSE, "Response : ");
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
955 print_dict_info_line(nvl, FMD_MSG_ITEM_IMPACT, "Impact : ");
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
956 print_dict_info_line(nvl, FMD_MSG_ITEM_ACTION, "Action : ");
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
957 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
958
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
959 static void
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
960 print_name(name_list_t *list, char *padding, int *np, int pct, int full)
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
961 {
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
962 char *name;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
963
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
964 name = list->name;
8245
7dbd13b3b276 6763249 eft is disabled on fmadm repair when serdsuffix feature is used
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 7275
diff changeset
965 if (list->label) {
7dbd13b3b276 6763249 eft is disabled on fmadm repair when serdsuffix feature is used
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 7275
diff changeset
966 (void) printf("%s \"%s\" (%s)", padding, list->label, name);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
967 *np += 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
968 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
969 (void) printf("%s %s", padding, name);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
970 *np += 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
971 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
972 if (list->pct && pct > 0 && pct < 100) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
973 if (list->count > 1) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
974 if (full) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
975 (void) printf(" %d @ %s %d%%\n", list->count,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
976 dgettext("FMD", "max"),
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
977 list->max_pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
978 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
979 (void) printf(" %s %d%%\n",
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
980 dgettext("FMD", "max"),
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
981 list->max_pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
982 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
983 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
984 (void) printf(" %d%%\n", list->pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
985 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
986 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
987 (void) printf("\n");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
988 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
989 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
990
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
991 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
992 print_asru_status(int status, char *label)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
993 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
994 char *msg = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
995
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
996 switch (status) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
997 case 0:
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
998 msg = dgettext("FMD", "ok and in service");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
999 break;
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1000 case FM_SUSPECT_DEGRADED:
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1001 msg = dgettext("FMD", "service degraded, "
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1002 "but associated components no longer faulty");
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1003 break;
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1004 case FM_SUSPECT_FAULTY | FM_SUSPECT_DEGRADED:
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1005 msg = dgettext("FMD", "faulted but still "
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1006 "providing degraded service");
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1007 break;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1008 case FM_SUSPECT_FAULTY:
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1009 msg = dgettext("FMD", "faulted but still in service");
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1010 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1011 case FM_SUSPECT_UNUSABLE:
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1012 msg = dgettext("FMD", "out of service, "
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1013 "but associated components no longer faulty");
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1014 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1015 case FM_SUSPECT_FAULTY | FM_SUSPECT_UNUSABLE:
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1016 msg = dgettext("FMD", "faulted and taken out of service");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1017 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1018 default:
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1019 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1020 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1021 if (msg) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1022 (void) printf("%s %s\n", label, msg);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1023 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1024 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1025
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1026 static void
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1027 print_fru_status(int status, char *label)
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1028 {
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1029 char *msg = NULL;
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1030
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1031 if (status & FM_SUSPECT_NOT_PRESENT)
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1032 msg = dgettext("FMD", "not present");
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1033 else if (status & FM_SUSPECT_FAULTY)
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1034 msg = dgettext("FMD", "faulty");
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1035 else if (status & FM_SUSPECT_REPLACED)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1036 msg = dgettext("FMD", "replaced");
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1037 else if (status & FM_SUSPECT_REPAIRED)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1038 msg = dgettext("FMD", "repair attempted");
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1039 else if (status & FM_SUSPECT_ACQUITTED)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1040 msg = dgettext("FMD", "acquitted");
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1041 else
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1042 msg = dgettext("FMD", "removed");
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1043 (void) printf("%s %s\n", label, msg);
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1044 }
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1045
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1046 static void
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1047 print_rsrc_status(int status, char *label)
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1048 {
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1049 char *msg = "";
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1050
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1051 if (status & FM_SUSPECT_NOT_PRESENT)
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1052 msg = dgettext("FMD", "not present");
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1053 else if (status & FM_SUSPECT_FAULTY) {
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1054 if (status & FM_SUSPECT_DEGRADED)
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1055 msg = dgettext("FMD",
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1056 "faulted but still providing degraded service");
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1057 else if (status & FM_SUSPECT_UNUSABLE)
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1058 msg = dgettext("FMD",
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1059 "faulted and taken out of service");
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1060 else
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1061 msg = dgettext("FMD", "faulted but still in service");
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1062 } else if (status & FM_SUSPECT_REPLACED)
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1063 msg = dgettext("FMD", "replaced");
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1064 else if (status & FM_SUSPECT_REPAIRED)
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1065 msg = dgettext("FMD", "repair attempted");
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1066 else if (status & FM_SUSPECT_ACQUITTED)
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1067 msg = dgettext("FMD", "acquitted");
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1068 else
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1069 msg = dgettext("FMD", "removed");
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1070 (void) printf("%s %s\n", label, msg);
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1071 }
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1072
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1073 static void
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1074 print_name_list(name_list_t *list, char *label,
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1075 int limit, int pct, void (func1)(int, char *), int full)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1076 {
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1077 char *name;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1078 char *padding;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1079 int i, j, l, n;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1080 name_list_t *end = list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1081
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1082 l = strlen(label);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1083 padding = malloc(l + 1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1084 for (i = 0; i < l; i++)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1085 padding[i] = ' ';
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1086 padding[l] = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1087 (void) printf("%s", label);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1088 name = list->name;
8245
7dbd13b3b276 6763249 eft is disabled on fmadm repair when serdsuffix feature is used
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 7275
diff changeset
1089 if (list->label)
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1090 (void) printf(" \"%s\" (%s)", list->label, name);
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1091 else
8245
7dbd13b3b276 6763249 eft is disabled on fmadm repair when serdsuffix feature is used
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 7275
diff changeset
1092 (void) printf(" %s", name);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1093 if (list->pct && pct > 0 && pct < 100) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1094 if (list->count > 1) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1095 if (full) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1096 (void) printf(" %d @ %s %d%%\n", list->count,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1097 dgettext("FMD", "max"), list->max_pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1098 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1099 (void) printf(" %s %d%%\n",
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1100 dgettext("FMD", "max"), list->max_pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1101 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1102 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1103 (void) printf(" %d%%\n", list->pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1104 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1105 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1106 (void) printf("\n");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1107 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1108 if (func1)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1109 func1(list->status, padding);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1110 n = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1111 j = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1112 while ((list = list->next) != end) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1113 if (limit == 0 || n < limit) {
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1114 print_name(list, padding, &n, pct, full);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1115 if (func1)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1116 func1(list->status, padding);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1117 } else
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1118 j++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1119 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1120 if (j == 1) {
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1121 print_name(list->prev, padding, &n, pct, full);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1122 } else if (j > 1) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1123 (void) printf("%s... %d %s\n", padding, j,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1124 dgettext("FMD", "more entries suppressed,"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1125 " use -v option for full list"));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1126 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1127 free(padding);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1128 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1129
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1130 static int
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1131 asru_same_status(name_list_t *list)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1132 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1133 name_list_t *end = list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1134 int status = list->status;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1135
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1136 while ((list = list->next) != end) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1137 if (status == -1) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1138 status = list->status;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1139 continue;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1140 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1141 if (list->status != -1 && status != list->status) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1142 status = -1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1143 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1144 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1145 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1146 return (status);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1147 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1148
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1149 static int
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1150 serial_in_fru(name_list_t *fru, name_list_t *serial)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1151 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1152 name_list_t *sp = serial;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1153 name_list_t *fp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1154 int nserial = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1155 int found = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1156 char buf[128];
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1157
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1158 while (sp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1159 fp = fru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1160 nserial++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1161 (void) snprintf(buf, sizeof (buf), "serial=%s", sp->name);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1162 buf[sizeof (buf) - 1] = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1163 while (fp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1164 if (strstr(fp->name, buf) != NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1165 found++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1166 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1167 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1168 fp = fp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1169 if (fp == fru)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1170 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1171 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1172 sp = sp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1173 if (sp == serial)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1174 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1175 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1176 return (found == nserial ? 1 : 0);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1177 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1178
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1179 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1180 print_sup_record(status_record_t *srp, int opt_i, int full)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1181 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1182 char buf[32];
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1183 uurec_t *uurp = srp->uurec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1184 int n, j, k, max;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1185 int status;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1186 ari_list_t *ari_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1187
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1188 n = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1189 max = max_fault;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1190 if (max < 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1191 max = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1192 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1193 j = max / 2;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1194 max -= j;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1195 k = srp->nrecs - max;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1196 while ((uurp = uurp->next) != NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1197 if (full || n < j || n >= k || max_fault == 0 ||
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1198 srp->nrecs == max_fault+1) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1199 if (opt_i) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1200 ari_list = uurp->ari_uuid_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1201 while (ari_list) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1202 (void) printf("%-15s %s\n",
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1203 format_date(buf, sizeof (buf),
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1204 uurp->sec), ari_list->ari_uuid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1205 ari_list = ari_list->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1206 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1207 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1208 (void) printf("%-15s %s\n",
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1209 format_date(buf, sizeof (buf), uurp->sec),
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1210 uurp->uuid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1211 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1212 } else if (n == j)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1213 (void) printf("... %d %s\n", srp->nrecs - max_fault,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1214 dgettext("FMD", "more entries suppressed"));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1215 n++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1216 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1217 (void) printf("\n");
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1218 (void) printf("%s %s", dgettext("FMD", "Host :"),
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1219 srp->host->server);
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1220 if (srp->host->domain)
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1221 (void) printf("\t%s %s", dgettext("FMD", "Domain :"),
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1222 srp->host->domain);
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1223 (void) printf("\n%s %s", dgettext("FMD", "Platform :"),
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1224 srp->host->platform);
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
1225 (void) printf("\t%s %s", dgettext("FMD", "Chassis_id :"),
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1226 srp->host->chassis ? srp->host->chassis : "");
10462
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
1227 (void) printf("\n%s %s\n\n", dgettext("FMD", "Product_sn :"),
ec0e4f3134ef PSARC/2007/650 Product Serial Number for FMRI
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 10234
diff changeset
1228 srp->host->product_sn? srp->host->product_sn : "");
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1229 if (srp->class)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1230 print_name_list(srp->class,
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1231 dgettext("FMD", "Fault class :"), 0, srp->class->pct,
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1232 NULL, full);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1233 if (srp->asru) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1234 status = asru_same_status(srp->asru);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1235 if (status != -1) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1236 print_name_list(srp->asru,
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1237 dgettext("FMD", "Affects :"),
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1238 full ? 0 : max_display, 0, NULL, full);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1239 print_asru_status(status, " ");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1240 } else
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1241 print_name_list(srp->asru,
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1242 dgettext("FMD", "Affects :"),
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1243 full ? 0 : max_display, 0, print_asru_status, full);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1244 }
9120
fe1f7d8cd967 6533823 need better way of proxying faults across event transport
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 8245
diff changeset
1245 if (full || srp->fru == NULL || srp->asru == NULL) {
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1246 if (srp->resource) {
10656
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1247 status = asru_same_status(srp->resource);
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1248 if (status != -1) {
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1249 print_name_list(srp->resource,
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1250 dgettext("FMD", "Problem in :"),
10656
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1251 full ? 0 : max_display, 0, NULL, full);
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1252 print_rsrc_status(status, " ");
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1253 } else
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1254 print_name_list(srp->resource,
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1255 dgettext("FMD", "Problem in :"),
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1256 full ? 0 : max_display, 0,
10656
217544b3cf73 6778240 generic historic diagnosis rules
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10462
diff changeset
1257 print_rsrc_status, full);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1258 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1259 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1260 if (srp->fru) {
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1261 status = asru_same_status(srp->fru);
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1262 if (status != -1) {
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1263 print_name_list(srp->fru, dgettext("FMD",
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1264 "FRU :"), 0,
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1265 srp->fru->pct == 100 ? 100 : srp->fru->max_pct,
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1266 NULL, full);
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1267 print_fru_status(status, " ");
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1268 } else
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1269 print_name_list(srp->fru, dgettext("FMD",
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1270 "FRU :"), 0,
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1271 srp->fru->pct == 100 ? 100 : srp->fru->max_pct,
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1272 print_fru_status, full);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1273 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1274 if (srp->serial && !serial_in_fru(srp->fru, srp->serial) &&
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1275 !serial_in_fru(srp->asru, srp->serial)) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1276 print_name_list(srp->serial, dgettext("FMD", "Serial ID. :"),
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1277 0, 0, NULL, full);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1278 }
10234
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
1279 print_dict_info(srp->uurec->event);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1280 (void) printf("\n");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1281 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1282
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1283 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1284 print_status_record(status_record_t *srp, int summary, int opt_i, int full)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1285 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1286 char buf[32];
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1287 uurec_t *uurp = srp->uurec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1288 static int header = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1289 char *head;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1290 ari_list_t *ari_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1291
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1292 if (!summary || !header) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1293 if (opt_i) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1294 head = "--------------- "
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1295 "------------------------------------ "
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1296 "-------------- ---------\n"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1297 "TIME CACHE-ID"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1298 " MSG-ID"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1299 " SEVERITY\n--------------- "
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1300 "------------------------------------ "
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1301 " -------------- ---------";
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1302 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1303 head = "--------------- "
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1304 "------------------------------------ "
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1305 "-------------- ---------\n"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1306 "TIME EVENT-ID"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1307 " MSG-ID"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1308 " SEVERITY\n--------------- "
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1309 "------------------------------------ "
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1310 " -------------- ---------";
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1311 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1312 (void) printf("%s\n", dgettext("FMD", head));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1313 header = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1314 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1315 if (opt_i) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1316 ari_list = uurp->ari_uuid_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1317 while (ari_list) {
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1318 (void) printf("%-15s %-37s %-14s %-9s %s\n",
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1319 format_date(buf, sizeof (buf), uurp->sec),
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1320 ari_list->ari_uuid, srp->msgid, srp->severity,
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1321 srp->injected ? dgettext("FMD", "injected") : "");
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1322 ari_list = ari_list->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1323 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1324 } else {
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1325 (void) printf("%-15s %-37s %-14s %-9s %s\n",
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1326 format_date(buf, sizeof (buf), uurp->sec),
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1327 uurp->uuid, srp->msgid, srp->severity,
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1328 srp->injected ? dgettext("FMD", "injected") : "");
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1329 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1330
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1331 if (!summary)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1332 print_sup_record(srp, opt_i, full);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1333 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1334
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1335 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1336 print_catalog(int summary, int opt_a, int full, int opt_i, int page_feed)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1337 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1338 status_record_t *srp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1339 sr_list_t *slp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1340
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1341 slp = status_rec_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1342 if (slp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1343 for (;;) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1344 srp = slp->status_record;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1345 if (opt_a || srp->not_suppressed) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1346 if (page_feed)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1347 (void) printf("\f\n");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1348 print_status_record(srp, summary, opt_i, full);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1349 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1350 if (slp->next == status_rec_list)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1351 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1352 slp = slp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1353 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1354 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1355 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1356
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1357 static name_list_t *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1358 find_fru(status_record_t *srp, char *resource)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1359 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1360 name_list_t *rt = NULL;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1361 name_list_t *fru = srp->fru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1362
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1363 while (fru) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1364 if (strcmp(resource, fru->name) == 0) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1365 rt = fru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1366 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1367 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1368 fru = fru->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1369 if (fru == srp->fru)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1370 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1371 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1372 return (rt);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1373 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1374
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1375 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1376 print_fru_line(name_list_t *fru, char *uuid)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1377 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1378 if (fru->pct == 100) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1379 (void) printf("%s %d %s %d%%\n", uuid, fru->count,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1380 dgettext("FMD", "suspects in this FRU total certainty"),
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1381 100);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1382 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1383 (void) printf("%s %d %s %d%%\n", uuid, fru->count,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1384 dgettext("FMD", "suspects in this FRU max certainty"),
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1385 fru->max_pct);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1386 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1387 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1388
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1389 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1390 print_fru(int summary, int opt_a, int opt_i, int page_feed)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1391 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1392 resource_list_t *tp = status_fru_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1393 status_record_t *srp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1394 sr_list_t *slp, *end;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1395 uurec_t *uurp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1396 name_list_t *fru;
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1397 int status;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1398 ari_list_t *ari_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1399
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1400 while (tp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1401 if (opt_a || tp->not_suppressed) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1402 if (page_feed)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1403 (void) printf("\f\n");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1404 if (!summary)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1405 (void) printf("-----------------------------"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1406 "---------------------------------------"
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1407 "----------\n");
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1408 slp = tp->status_rec_list;
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1409 end = slp;
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1410 do {
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1411 srp = slp->status_record;
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1412 if (!srp->not_suppressed) {
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1413 slp = slp->next;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1414 continue;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1415 }
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1416 fru = find_fru(srp, tp->resource);
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1417 if (fru) {
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1418 if (fru->label)
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1419 (void) printf("\"%s\" (%s) ",
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1420 fru->label, fru->name);
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1421 else
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1422 (void) printf("%s ",
6002
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1423 fru->name);
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1424 break;
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1425 }
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1426 slp = slp->next;
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1427 } while (slp != end);
470eddf7e261 6660427 Inconsistant labels on pciexbus faults
stephh
parents: 5255
diff changeset
1428
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1429 slp = tp->status_rec_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1430 end = slp;
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1431 status = 0;
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1432 do {
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1433 srp = slp->status_record;
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1434 if (!srp->not_suppressed) {
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1435 slp = slp->next;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1436 continue;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1437 }
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1438 fru = srp->fru;
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1439 while (fru) {
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1440 if (strcmp(tp->resource,
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1441 fru->name) == 0)
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1442 status |= fru->status;
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1443 fru = fru->next;
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1444 if (fru == srp->fru)
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1445 break;
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1446 }
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1447 slp = slp->next;
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1448 } while (slp != end);
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1449 if (status & FM_SUSPECT_NOT_PRESENT)
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1450 (void) printf(dgettext("FMD", "not present"));
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1451 else if (status & FM_SUSPECT_FAULTY)
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1452 (void) printf(dgettext("FMD", "faulty"));
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1453 else if (status & FM_SUSPECT_REPLACED)
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1454 (void) printf(dgettext("FMD", "replaced"));
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1455 else if (status & FM_SUSPECT_REPAIRED)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1456 (void) printf(dgettext("FMD",
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1457 "repair attempted"));
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1458 else if (status & FM_SUSPECT_ACQUITTED)
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1459 (void) printf(dgettext("FMD", "acquitted"));
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1460 else
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1461 (void) printf(dgettext("FMD", "removed"));
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1462
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1463 if (tp->injected)
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1464 (void) printf(dgettext("FMD", " injected\n"));
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1465 else
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1466 (void) printf(dgettext("FMD", "\n"));
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1467
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1468 slp = tp->status_rec_list;
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1469 end = slp;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1470 do {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1471 srp = slp->status_record;
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1472 if (!srp->not_suppressed) {
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1473 slp = slp->next;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1474 continue;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1475 }
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1476 uurp = srp->uurec;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1477 fru = find_fru(srp, tp->resource);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1478 if (fru) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1479 if (opt_i) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1480 ari_list = uurp->ari_uuid_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1481 while (ari_list) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1482 print_fru_line(fru,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1483 ari_list->ari_uuid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1484 ari_list =
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1485 ari_list->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1486 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1487 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1488 print_fru_line(fru, uurp->uuid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1489 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1490 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1491 slp = slp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1492 } while (slp != end);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1493 if (!summary) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1494 slp = tp->status_rec_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1495 end = slp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1496 do {
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1497 srp = slp->status_record;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1498 if (!srp->not_suppressed) {
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1499 slp = slp->next;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1500 continue;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1501 }
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1502 if (srp->serial &&
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1503 !serial_in_fru(srp->fru,
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1504 srp->serial)) {
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1505 print_name_list(srp->serial,
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1506 dgettext("FMD",
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1507 "Serial ID. :"),
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1508 0, 0, NULL, 1);
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1509 break;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1510 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1511 slp = slp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1512 } while (slp != end);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1513 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1514 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1515 tp = tp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1516 if (tp == status_fru_list)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1517 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1518 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1519 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1520
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1521 static void
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1522 print_asru(int opt_a)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1523 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1524 resource_list_t *tp = status_asru_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1525 status_record_t *srp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1526 sr_list_t *slp, *end;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1527 char *msg;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1528 int status;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1529 name_list_t *asru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1530
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1531 while (tp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1532 if (opt_a || tp->not_suppressed) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1533 status = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1534 slp = tp->status_rec_list;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1535 end = slp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1536 do {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1537 srp = slp->status_record;
11416
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1538 if (!srp->not_suppressed) {
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1539 slp = slp->next;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1540 continue;
c13e2db06244 6679339 undiag messages should be converted to a more useful event
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11050
diff changeset
1541 }
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1542 asru = srp->asru;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1543 while (asru) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1544 if (strcmp(tp->resource,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1545 asru->name) == 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1546 status |= asru->status;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1547 asru = asru->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1548 if (asru == srp->asru)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1549 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1550 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1551 slp = slp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1552 } while (slp != end);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1553 switch (status) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1554 case 0:
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1555 msg = dgettext("FMD", "ok");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1556 break;
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1557 case FM_SUSPECT_DEGRADED:
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1558 msg = dgettext("FMD", "degraded");
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1559 break;
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1560 case FM_SUSPECT_FAULTY | FM_SUSPECT_DEGRADED:
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1561 msg = dgettext("FMD", "degraded");
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1562 break;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1563 case FM_SUSPECT_FAULTY:
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1564 msg = dgettext("FMD", "degraded");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1565 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1566 case FM_SUSPECT_UNUSABLE:
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1567 msg = dgettext("FMD", "unknown");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1568 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1569 case FM_SUSPECT_FAULTY | FM_SUSPECT_UNUSABLE:
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1570 msg = dgettext("FMD", "faulted");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1571 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1572 default:
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1573 msg = "";
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1574 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1575 }
10928
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1576 (void) printf("%-69s %s", tp->resource, msg);
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1577 if (tp->injected)
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1578 (void) printf(dgettext("FMD", " injected\n"));
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1579 else
eb060666c73f 6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 10656
diff changeset
1580 (void) printf(dgettext("FMD", "\n"));
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1581 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1582 tp = tp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1583 if (tp == status_asru_list)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1584 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1585 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1586 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1587
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1588 static int
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1589 uuid_in_list(char *uuid, uurec_select_t *uurecp)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1590 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1591 while (uurecp) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1592 if (strcmp(uuid, uurecp->uuid) == 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1593 return (1);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1594 uurecp = uurecp->next;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1595 }
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1596 return (0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1597 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1598
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1599 static int
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1600 dfault_rec(const fmd_adm_caseinfo_t *acp, void *arg)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1601 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1602 int64_t *diag_time;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1603 uint_t nelem;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1604 int rt = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1605 char *uuid = "-";
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1606 uurec_select_t *uurecp = (uurec_select_t *)arg;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1607
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1608 if (nvlist_lookup_int64_array(acp->aci_event, FM_SUSPECT_DIAG_TIME,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1609 &diag_time, &nelem) == 0 && nelem >= 2) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1610 (void) nvlist_lookup_string(acp->aci_event, FM_SUSPECT_UUID,
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1611 &uuid);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1612 if (uurecp == NULL || uuid_in_list(uuid, uurecp))
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1613 add_fault_record_to_catalog(acp->aci_event, *diag_time,
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
1614 uuid);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1615 } else {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1616 rt = -1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1617 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1618 return (rt);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1619 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1620
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1621 /*ARGSUSED*/
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1622 static int
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1623 dstatus_rec(const fmd_adm_rsrcinfo_t *ari, void *unused)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1624 {
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1625 update_asru_state_in_catalog(ari->ari_case, ari->ari_uuid);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1626 return (0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1627 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1628
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1629 static int
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1630 get_cases_from_fmd(fmd_adm_t *adm, uurec_select_t *uurecp, int opt_i)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1631 {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1632 int rt = FMADM_EXIT_SUCCESS;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1633
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1634 /*
10234
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
1635 * These calls may fail with Protocol error if message payload is
c4cea2ed5803 6839705 libtopo needs updates in order to cope with ILOM 3
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9501
diff changeset
1636 * too big
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1637 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1638 if (fmd_adm_case_iter(adm, NULL, dfault_rec, uurecp) != 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1639 die("failed to get case list from fmd");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1640 if (opt_i && fmd_adm_rsrc_iter(adm, 1, dstatus_rec, NULL) != 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1641 die("failed to get case status from fmd");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1642 return (rt);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1643 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1644
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1645 /*
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1646 * fmadm faulty command
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1647 *
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1648 * -a show hidden fault records
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1649 * -f show faulty fru's
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1650 * -g force grouping of similar faults on the same fru
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1651 * -n number of fault records to display
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1652 * -p pipe output through pager
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1653 * -r show faulty asru's
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1654 * -s print summary of first fault
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1655 * -u print listed uuid's only
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1656 * -v full output
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1657 */
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1658
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1659 int
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1660 cmd_faulty(fmd_adm_t *adm, int argc, char *argv[])
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1661 {
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1662 int opt_a = 0, opt_v = 0, opt_p = 0, opt_s = 0, opt_r = 0, opt_f = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1663 int opt_i = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1664 char *pager;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1665 FILE *fp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1666 int rt, c, stat;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1667 uurec_select_t *tp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1668 uurec_select_t *uurecp = NULL;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1669
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1670 while ((c = getopt(argc, argv, "afgin:prsu:v")) != EOF) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1671 switch (c) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1672 case 'a':
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1673 opt_a++;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1674 break;
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1675 case 'f':
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1676 opt_f++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1677 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1678 case 'g':
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1679 opt_g++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1680 break;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1681 case 'i':
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1682 opt_i++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1683 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1684 case 'n':
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1685 max_fault = atoi(optarg);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1686 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1687 case 'p':
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1688 opt_p++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1689 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1690 case 'r':
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1691 opt_r++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1692 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1693 case 's':
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1694 opt_s++;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1695 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1696 case 'u':
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1697 tp = (uurec_select_t *)malloc(sizeof (uurec_select_t));
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1698 tp->uuid = optarg;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1699 tp->next = uurecp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1700 uurecp = tp;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1701 opt_a = 1;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1702 break;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1703 case 'v':
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1704 opt_v++;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1705 break;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1706 default:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1707 return (FMADM_EXIT_USAGE);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1708 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1709 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1710 if (optind < argc)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1711 return (FMADM_EXIT_USAGE);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1712
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
1713 if ((fmadm_msghdl = fmd_msg_init(NULL, FMD_MSG_VERSION)) == NULL)
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
1714 return (FMADM_EXIT_ERROR);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1715 rt = get_cases_from_fmd(adm, uurecp, opt_i);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1716 if (opt_p) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1717 if ((pager = getenv("PAGER")) == NULL)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1718 pager = "/usr/bin/more";
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1719 fp = popen(pager, "w");
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1720 if (fp == NULL) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1721 rt = FMADM_EXIT_ERROR;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1722 opt_p = 0;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1723 } else {
11050
be69f645ce17 6894028 Some fm libraries are not lint clean
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 10928
diff changeset
1724 (void) dup2(fileno(fp), 1);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1725 setbuf(stdout, NULL);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1726 (void) fclose(fp);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1727 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1728 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1729 max_display = max_fault;
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1730 if (opt_f)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1731 print_fru(opt_s, opt_a, opt_i, opt_p && !opt_s);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1732 if (opt_r)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1733 print_asru(opt_a);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1734 if (opt_f == 0 && opt_r == 0)
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1735 print_catalog(opt_s, opt_a, opt_v, opt_i, opt_p && !opt_s);
9501
f84d3cc28d24 PSARC 2009/265 fmdump -m
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 9120
diff changeset
1736 fmd_msg_fini(fmadm_msghdl);
12618
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1737 if (topo_handle)
0e5eaf4bf546 6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents: 11416
diff changeset
1738 topo_close(topo_handle);
5255
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1739 if (opt_p) {
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1740 (void) fclose(stdout);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1741 (void) wait(&stat);
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1742 }
8dc347a9bd70 PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents: 0
diff changeset
1743 return (rt);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1744 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1745
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1746 int
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1747 cmd_flush(fmd_adm_t *adm, int argc, char *argv[])
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1748 {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1749 int i, status = FMADM_EXIT_SUCCESS;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1750
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1751 if (argc < 2 || (i = getopt(argc, argv, "")) != EOF)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1752 return (FMADM_EXIT_USAGE);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1753
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1754 for (i = 1; i < argc; i++) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1755 if (fmd_adm_rsrc_flush(adm, argv[i]) != 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1756 warn("failed to flush %s", argv[i]);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1757 status = FMADM_EXIT_ERROR;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1758 } else
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1759 note("flushed resource history for %s\n", argv[i]);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1760 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1761
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1762 return (status);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1763 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1764
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1765 int
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1766 cmd_repair(fmd_adm_t *adm, int argc, char *argv[])
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1767 {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1768 int err;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1769
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1770 if (getopt(argc, argv, "") != EOF)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1771 return (FMADM_EXIT_USAGE);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1772
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1773 if (argc - optind != 1)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1774 return (FMADM_EXIT_USAGE);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1775
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1776 /*
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1777 * argument could be a uuid, an fmri (asru, fru or resource)
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1778 * or a label. Try uuid first, If that fails try the others.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1779 */
6228
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1780 err = fmd_adm_case_repair(adm, argv[optind]);
b8f7c3bfc29b 6372069 fmadm repair command should accept the FRU label as an argument
stephh
parents: 6002
diff changeset
1781 if (err != 0)
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1782 err = fmd_adm_rsrc_repaired(adm, argv[optind]);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1783
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1784 if (err != 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1785 die("failed to record repair to %s", argv[optind]);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1786
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1787 note("recorded repair to %s\n", argv[optind]);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1788 return (FMADM_EXIT_SUCCESS);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1789 }
7275
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1790
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1791 int
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1792 cmd_repaired(fmd_adm_t *adm, int argc, char *argv[])
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1793 {
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1794 int err;
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1795
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1796 if (getopt(argc, argv, "") != EOF)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1797 return (FMADM_EXIT_USAGE);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1798
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1799 if (argc - optind != 1)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1800 return (FMADM_EXIT_USAGE);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1801
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1802 /*
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1803 * argument could be an fmri (asru, fru or resource) or a label.
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1804 */
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1805 err = fmd_adm_rsrc_repaired(adm, argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1806 if (err != 0)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1807 die("failed to record repair to %s", argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1808
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1809 note("recorded repair to of %s\n", argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1810 return (FMADM_EXIT_SUCCESS);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1811 }
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1812
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1813 int
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1814 cmd_replaced(fmd_adm_t *adm, int argc, char *argv[])
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1815 {
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1816 int err;
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1817
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1818 if (getopt(argc, argv, "") != EOF)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1819 return (FMADM_EXIT_USAGE);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1820
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1821 if (argc - optind != 1)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1822 return (FMADM_EXIT_USAGE);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1823
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1824 /*
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1825 * argument could be an fmri (asru, fru or resource) or a label.
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1826 */
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1827 err = fmd_adm_rsrc_replaced(adm, argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1828 if (err != 0)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1829 die("failed to record replacement of %s", argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1830
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1831 note("recorded replacement of %s\n", argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1832 return (FMADM_EXIT_SUCCESS);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1833 }
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1834
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1835 int
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1836 cmd_acquit(fmd_adm_t *adm, int argc, char *argv[])
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1837 {
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1838 int err;
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1839
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1840 if (getopt(argc, argv, "") != EOF)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1841 return (FMADM_EXIT_USAGE);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1842
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1843 if (argc - optind != 1 && argc - optind != 2)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1844 return (FMADM_EXIT_USAGE);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1845
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1846 /*
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1847 * argument could be a uuid, an fmri (asru, fru or resource)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1848 * or a label. Or it could be a uuid and an fmri or label.
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1849 */
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1850 if (argc - optind == 2) {
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1851 err = fmd_adm_rsrc_acquit(adm, argv[optind], argv[optind + 1]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1852 if (err != 0)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1853 err = fmd_adm_rsrc_acquit(adm, argv[optind + 1],
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1854 argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1855 } else {
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1856 err = fmd_adm_case_acquit(adm, argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1857 if (err != 0)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1858 err = fmd_adm_rsrc_acquit(adm, argv[optind], "");
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1859 }
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1860
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1861 if (err != 0)
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1862 die("failed to record acquital of %s", argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1863
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1864 note("recorded acquital of %s\n", argv[optind]);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1865 return (FMADM_EXIT_SUCCESS);
1157db66a604 PSARC/2008/487 Repair Observability changes
stephh
parents: 6228
diff changeset
1866 }