Mercurial > illumos > illumos-gate
annotate usr/src/cmd/fm/fmadm/common/faulty.c @ 6002:470eddf7e261
6660427 Inconsistant labels on pciexbus faults
6660642 updated fmadm faulty should display DIMM location for memory faults
author | stephh |
---|---|
date | Wed, 13 Feb 2008 03:58:20 -0800 |
parents | 8dc347a9bd70 |
children | b8f7c3bfc29b |
rev | line source |
---|---|
0 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
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 | 7 * |
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 * or http://www.opensolaris.org/os/licensing. | |
10 * See the License for the specific language governing permissions | |
11 * and limitations under the License. | |
12 * | |
13 * When distributing Covered Code, include this CDDL HEADER in each | |
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 * If applicable, add the following below this CDDL HEADER, with the | |
16 * fields enclosed by brackets "[]" replaced with your own identifying | |
17 * information: Portions Copyright [yyyy] [name of copyright owner] | |
18 * | |
19 * CDDL HEADER END | |
20 */ | |
21 /* | |
6002 | 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
0 | 23 * Use is subject to license terms. |
24 */ | |
25 | |
26 #pragma ident "%Z%%M% %I% %E% SMI" | |
27 | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
28 #include <sys/types.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
29 #include <fmadm.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
30 #include <errno.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
31 #include <limits.h> |
0 | 32 #include <strings.h> |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
33 #include <stdio.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
34 #include <unistd.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
35 #include <sys/wait.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
36 #include <sys/stat.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
37 #include <fcntl.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
38 #include <fm/fmd_log.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
39 #include <sys/fm/protocol.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
40 #include <fm/libtopo.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
41 #include <fm/fmd_adm.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
42 #include <dlfcn.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
43 #include <sys/systeminfo.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
44 #include <sys/utsname.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
45 #include <libintl.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
46 #include <locale.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
47 #include <sys/smbios.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
48 #include <libdevinfo.h> |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
49 #include <stdlib.h> |
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 #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
|
52 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
53 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
54 * catalog_setup() must be called to setup support functions. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
55 * 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
|
56 * 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
|
57 * 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
|
58 * 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
|
59 * records are stored in time order. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
60 * 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
|
61 * 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
|
62 * added together. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
63 * 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
|
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 * status_rec_list -> | | -| |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
67 * \---------------/ |
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 * status_fru_list | status_record | -> | uurec | -> | uurec | -| |
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 * /-------------\ | | \-------/ \-------/ |
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 * \/ | | -> | asru | -> | asru | |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
76 * --- | | | | <- | | |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
77 * | | \-------/ \-------/ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
78 * status_asru_list | class | |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
79 * \/ | resource | /-------\ /-------\ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
80 * /-------------\ | fru | -> | list | -> | list | |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
81 * | | -> | serial | | | <- | | |
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 * \/ \---------------/ |
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 * | status_record | |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
87 * \---------------/ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
88 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
89 * 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
|
90 * 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
|
91 * 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
|
92 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
93 * --------------- ------------------------------------ -------------- ------- |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
94 * TIME EVENT-ID MSG-ID SEVERITY |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
95 * --------------- ------------------------------------ -------------- ------- |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
96 * 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
|
97 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
98 * Fault class : fault.memory.dimm_sb |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
99 * Affects : mem:///motherboard=0/chip=0/memory-controller=0/dimm=0/rank=0 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
100 * degraded but still in service |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
101 * 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
|
102 * faulty |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
103 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
104 * 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
|
105 * exceeded acceptable levels. Refer to |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
106 * http://sun.com/msg/AMD-8000-2F for more information. |
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 * 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
|
109 * removed from service as errors are reported. |
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 * 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
|
112 * retired. |
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 * 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
|
115 * 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
|
116 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
117 * 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
|
118 * 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
|
119 * 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
|
120 * function to do the display. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
121 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
122 * 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
|
123 * 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
|
124 * 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
|
125 * |
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 * "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
|
128 * 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
|
129 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
130 * Description : A problem was detected for a PCI device. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
131 * Refer to http://sun.com/msg/PCI-8000-7J for more information. |
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 * 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
|
134 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
135 * 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
|
136 * associated with this fault |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
137 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
138 * 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
|
139 * 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
|
140 * Sun for support. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
141 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
142 * 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
|
143 * 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
|
144 * 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
|
145 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
146 * 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
|
147 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
148 * 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
|
149 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
150 * 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
|
151 * 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
|
152 * 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
|
153 * 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
|
154 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
155 * 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
|
156 * 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
|
157 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
158 * 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
|
159 * 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
|
160 * requested way. |
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 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
163 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
164 typedef struct name_list { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
165 struct name_list *next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
166 struct name_list *prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
167 char *name; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
168 uint8_t pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
169 uint8_t max_pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
170 ushort_t count; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
171 int status; |
6002 | 172 char *label; |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
173 } name_list_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
174 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
175 typedef struct ari_list { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
176 char *ari_uuid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
177 struct ari_list *next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
178 } ari_list_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
179 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
180 typedef struct uurec { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
181 struct uurec *next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
182 struct uurec *prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
183 char *uuid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
184 ari_list_t *ari_uuid_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
185 name_list_t *asru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
186 uint64_t sec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
187 } uurec_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
188 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
189 typedef struct uurec_select { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
190 struct uurec_select *next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
191 char *uuid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
192 } uurec_select_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
193 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
194 typedef struct host_id { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
195 char *chassis; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
196 char *server; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
197 char *platform; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
198 } hostid_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
199 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
200 typedef struct host_id_list { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
201 hostid_t hostid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
202 struct host_id_list *next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
203 } host_id_list_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
204 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
205 typedef struct status_record { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
206 hostid_t *host; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
207 int nrecs; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
208 uurec_t *uurec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
209 char *severity; /* in C locale */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
210 char *msgid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
211 name_list_t *class; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
212 name_list_t *resource; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
213 name_list_t *asru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
214 name_list_t *fru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
215 name_list_t *serial; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
216 char *url; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
217 uint8_t not_suppressed; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
218 } status_record_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
219 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
220 typedef struct sr_list { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
221 struct sr_list *next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
222 struct sr_list *prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
223 struct status_record *status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
224 } sr_list_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
225 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
226 typedef struct resource_list { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
227 struct resource_list *next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
228 struct resource_list *prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
229 sr_list_t *status_rec_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
230 char *resource; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
231 uint8_t not_suppressed; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
232 uint8_t max_pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
233 } resource_list_t; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
234 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
235 typedef struct tgetlabel_data { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
236 char *label; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
237 char *fru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
238 } tgetlabel_data_t; |
0 | 239 |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
240 sr_list_t *status_rec_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
241 resource_list_t *status_fru_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
242 resource_list_t *status_asru_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
243 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
244 static char *locale; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
245 static char *nlspath; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
246 static int max_display; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
247 static int max_fault = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
248 static topo_hdl_t *topo_handle; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
249 static char *topo_handle_uuid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
250 static host_id_list_t *host_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
251 static int n_server; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
252 static int opt_g; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
253 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
254 static char * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
255 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
|
256 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
257 if (sec > LONG_MAX) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
258 (void) fprintf(stderr, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
259 "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
|
260 (void) snprintf(buf, len, "0x%llx", sec); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
261 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
262 time_t tod = (time_t)sec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
263 (void) strftime(buf, len, "%b %d %T", localtime(&tod)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
264 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
265 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
266 return (buf); |
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 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
269 static hostid_t * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
270 find_hostid_in_list(char *platform, char *chassis, char *server) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
271 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
272 hostid_t *rt = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
273 host_id_list_t *hostp; |
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 if (platform == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
276 platform = "-"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
277 if (server == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
278 server = "-"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
279 hostp = host_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
280 while (hostp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
281 if (hostp->hostid.platform && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
282 strcmp(hostp->hostid.platform, platform) == 0 && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
283 hostp->hostid.server && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
284 strcmp(hostp->hostid.server, server) == 0 && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
285 (chassis == NULL || hostp->hostid.chassis == NULL || |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
286 strcmp(chassis, hostp->hostid.chassis) == 0)) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
287 rt = &hostp->hostid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
288 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
289 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
290 hostp = hostp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
291 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
292 if (rt == NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
293 hostp = malloc(sizeof (host_id_list_t)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
294 hostp->hostid.platform = strdup(platform); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
295 hostp->hostid.server = strdup(server); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
296 hostp->hostid.chassis = chassis ? strdup(chassis) : NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
297 hostp->next = host_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
298 host_list = hostp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
299 rt = &hostp->hostid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
300 n_server++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
301 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
302 return (rt); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
303 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
304 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
305 static hostid_t * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
306 find_hostid(nvlist_t *nvl) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
307 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
308 char *platform = NULL, *chassis = NULL, *server = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
309 nvlist_t *auth, *fmri; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
310 hostid_t *rt = NULL; |
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 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
|
313 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
|
314 (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
|
315 &platform); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
316 (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
|
317 (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
|
318 &chassis); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
319 rt = find_hostid_in_list(platform, chassis, server); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
320 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
321 return (rt); |
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 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
324 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
325 catalog_setup(void) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
326 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
327 char *tp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
328 int pl; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
329 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
330 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
331 * All FMA event dictionaries use msgfmt(1) message objects to produce |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
332 * messages, even for the C locale. We therefore want to use dgettext |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
333 * for all message lookups, but its defined behavior in the C locale is |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
334 * to return the input string. Since our input strings are event codes |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
335 * and not format strings, this doesn't help us. We resolve this nit |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
336 * by setting NLSPATH to a non-existent file: the presence of NLSPATH |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
337 * is defined to force dgettext(3C) to do a full lookup even for C. |
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 nlspath = getenv("NLSPATH"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
340 if (nlspath == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
341 putenv("NLSPATH=/usr/lib/fm/fmd/fmd.cat"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
342 else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
343 pl = strlen(nlspath) + sizeof ("NLSPATH=") + 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
344 tp = malloc(pl); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
345 (void) snprintf(tp, pl, "NLSPATH=%s", nlspath); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
346 nlspath = tp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
347 } |
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 locale = setlocale(LC_MESSAGES, ""); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
350 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
351 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
352 static char * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
353 get_dict_url(char *id) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
354 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
355 char *url = "http://sun.com/msg/"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
356 int msz = sizeof (url) + strlen(id) + 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
357 char *cp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
358 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
359 cp = malloc(msz); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
360 (void) snprintf(cp, msz, "%s%s", url, id); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
361 return (cp); |
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 static char * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
365 get_dict_msg(char *id, char *idx, int unknown, int translate) |
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 char mbuf[128]; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
368 char *msg; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
369 char dbuf[32]; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
370 char *p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
371 int restore_env = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
372 int restore_locale = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
373 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
374 p = strchr(id, '-'); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
375 if (p == NULL || p == id || (p - id) >= 32) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
376 msg = mbuf; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
377 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
378 strncpy(dbuf, id, (size_t)(p - id)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
379 dbuf[(size_t)(p - id)] = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
380 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
381 (void) snprintf(mbuf, sizeof (mbuf), "%s.%s", id, idx); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
382 if (translate == 0 || nlspath == NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
383 (void) setlocale(LC_MESSAGES, "C"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
384 restore_locale = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
385 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
386 bindtextdomain("FMD", "/usr/lib/locale"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
387 msg = dgettext(dbuf, mbuf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
388 if (msg == mbuf) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
389 (void) setlocale(LC_MESSAGES, "C"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
390 restore_locale = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
391 msg = dgettext(dbuf, mbuf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
392 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
393 if (msg == mbuf) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
394 putenv("NLSPATH=/usr/lib/fm/fmd/fmd.cat"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
395 restore_env = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
396 (void) setlocale(LC_MESSAGES, "C"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
397 msg = dgettext(dbuf, mbuf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
398 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
399 if (restore_locale) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
400 (void) setlocale(LC_MESSAGES, locale); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
401 if (restore_env && nlspath) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
402 putenv(nlspath); |
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 if (msg == mbuf) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
405 if (unknown) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
406 msg = "unknown"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
407 else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
408 msg = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
409 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
410 return (msg); |
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 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
413 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
414 * compare two fru strings which are made up of substrings seperated by '/' |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
415 * return true if every substring is the same in the two strings, or if a |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
416 * substring is null in one. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
417 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
418 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
419 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
420 frucmp(char *f1, char *f2) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
421 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
422 char c1, c2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
423 int i = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
424 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
425 for (;;) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
426 c1 = *f1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
427 c2 = *f2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
428 if (c1 == c2) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
429 i = (c1 == '/') ? 0 : i + 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
430 } else if (i == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
431 if (c1 == '/') { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
432 do { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
433 f2++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
434 } while ((c2 = *f2) != 0 && c2 != '/'); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
435 if (c2 == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
436 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
437 } else if (c2 == '/') { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
438 do { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
439 f1++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
440 } while ((c1 = *f1) != 0 && c1 != '/'); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
441 if (c1 == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
442 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
443 } else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
444 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
445 } else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
446 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
447 if (c1 == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
448 return (0); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
449 f1++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
450 f2++; |
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 return (1); |
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 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
455 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
456 tgetlabel(topo_hdl_t *thp, tnode_t *node, void *arg) |
0 | 457 { |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
458 int err; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
459 char *fru_name, *lname; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
460 nvlist_t *fru = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
461 int rt = TOPO_WALK_NEXT; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
462 tgetlabel_data_t *tdp = (tgetlabel_data_t *)arg; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
463 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
464 if (topo_node_fru(node, &fru, NULL, &err) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
465 if (topo_fmri_nvl2str(thp, fru, &fru_name, &err) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
466 if (frucmp(tdp->fru, fru_name) == 0 && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
467 topo_node_label(node, &lname, &err) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
468 tdp->label = strdup(lname); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
469 topo_hdl_strfree(thp, lname); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
470 rt = TOPO_WALK_TERMINATE; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
471 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
472 topo_hdl_strfree(thp, fru_name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
473 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
474 nvlist_free(fru); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
475 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
476 return (rt); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
477 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
478 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
479 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
480 label_get_topo(void) |
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 int err; |
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 topo_handle = topo_open(TOPO_VERSION, 0, &err); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
485 if (topo_handle) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
486 topo_handle_uuid = topo_snap_hold(topo_handle, NULL, &err); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
487 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
488 } |
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 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
491 label_release_topo(void) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
492 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
493 if (topo_handle_uuid) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
494 topo_hdl_strfree(topo_handle, topo_handle_uuid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
495 if (topo_handle) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
496 topo_snap_release(topo_handle); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
497 topo_close(topo_handle); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
498 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
499 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
500 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
501 static char * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
502 get_fmri_label(char *fru) |
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 topo_walk_t *twp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
505 tgetlabel_data_t td; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
506 int err; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
507 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
508 td.label = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
509 td.fru = fru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
510 if (topo_handle == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
511 label_get_topo(); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
512 if (topo_handle_uuid) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
513 twp = topo_walk_init(topo_handle, FM_FMRI_SCHEME_HC, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
514 tgetlabel, &td, &err); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
515 if (twp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
516 topo_walk_step(twp, TOPO_WALK_CHILD); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
517 topo_walk_fini(twp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
518 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
519 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
520 return (td.label); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
521 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
522 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
523 static char * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
524 get_nvl2str_topo(nvlist_t *nvl) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
525 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
526 char *name = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
527 char *tname; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
528 int err; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
529 char *scheme = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
530 char *mod_name = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
531 char buf[128]; |
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 if (topo_handle == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
534 label_get_topo(); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
535 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
|
536 name = strdup(tname); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
537 topo_hdl_strfree(topo_handle, tname); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
538 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
539 (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
|
540 (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
|
541 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
|
542 mod_name) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
543 (void) snprintf(buf, sizeof (buf), "%s:///module/%s", |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
544 scheme, mod_name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
545 name = strdup(buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
546 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
547 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
548 return (name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
549 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
550 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
551 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
552 set_priority(char *s) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
553 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
554 int rt = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
555 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
556 if (s) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
557 if (strcmp(s, "Minor") == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
558 rt = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
559 else if (strcmp(s, "Major") == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
560 rt = 10; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
561 else if (strcmp(s, "Critical") == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
562 rt = 100; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
563 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
564 return (rt); |
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 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
568 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
|
569 uint8_t p2) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
570 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
571 int r1, r2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
572 int rt; |
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 r1 = set_priority(s1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
575 r2 = set_priority(s2); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
576 rt = r1 - r2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
577 if (rt == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
578 if (t1 > t2) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
579 rt = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
580 else if (t1 < t2) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
581 rt = -1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
582 else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
583 rt = p1 - p2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
584 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
585 return (rt); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
586 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
587 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
588 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
589 * 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
|
590 * 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
|
591 * 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
|
592 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
593 static name_list_t * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
594 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
|
595 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
596 name_list_t *lp, *np, *sp, *rt = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
597 int max_pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
598 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
599 rt = *list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
600 np = new; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
601 while (np) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
602 lp = *list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
603 while (lp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
604 if (strcmp(lp->name, np->name) == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
605 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
606 lp = lp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
607 if (lp == *list) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
608 lp = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
609 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
610 if (np->next == new) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
611 sp = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
612 else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
613 sp = np->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
614 if (lp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
615 lp->status |= (np->status & FM_SUSPECT_FAULTY); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
616 if (add_pct) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
617 lp->pct += np->pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
618 lp->count += np->count; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
619 } else if (np->pct > lp->pct) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
620 lp->pct = np->pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
621 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
622 max_pct = np->max_pct; |
6002 | 623 if (np->label) |
624 free(np->label); | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
625 free(np->name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
626 free(np); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
627 np = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
628 if (max_pct > lp->max_pct) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
629 lp->max_pct = max_pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
630 if (lp->max_pct > lp->prev->max_pct && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
631 lp != *list) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
632 lp->prev->next = lp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
633 lp->next->prev = lp->prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
634 np = lp; |
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 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
637 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
638 if (np) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
639 lp = *list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
640 if (lp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
641 if (np->max_pct > lp->max_pct) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
642 np->next = lp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
643 np->prev = lp->prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
644 lp->prev->next = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
645 lp->prev = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
646 *list = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
647 rt = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
648 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
649 lp = lp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
650 while (lp != *list && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
651 np->max_pct < lp->max_pct) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
652 lp = lp->next; |
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 np->next = lp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
655 np->prev = lp->prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
656 lp->prev->next = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
657 lp->prev = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
658 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
659 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
660 *list = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
661 np->next = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
662 np->prev = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
663 rt = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
664 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
665 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
666 np = sp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
667 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
668 return (rt); |
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 |
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 * compare entries in two lists return true if the two lists have identical |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
673 * content. The two lists may not have entries in the same order, so we compare |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
674 * the size of the list as well as trying to find every entry from one list in |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
675 * the other. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
676 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
677 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
678 cmp_name_list(name_list_t *lxp1, name_list_t *lxp2) |
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 name_list_t *lp1, *lp2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
681 int l1 = 0, l2 = 0, common = 0; |
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 lp2 = lxp2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
684 while (lp2) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
685 l2++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
686 lp2 = lp2->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
687 if (lp2 == lxp2) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
688 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
689 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
690 lp1 = lxp1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
691 while (lp1) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
692 l1++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
693 lp2 = lxp2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
694 while (lp2) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
695 if (strcmp(lp2->name, lp1->name) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
696 common++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
697 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
698 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
699 lp2 = lp2->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
700 if (lp2 == lxp2) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
701 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
702 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
703 lp1 = lp1->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
704 if (lp1 == lxp1) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
705 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
706 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
707 if (l1 == l2 && l2 == common) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
708 return (0); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
709 else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
710 return (1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
711 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
712 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
713 static name_list_t * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
714 alloc_name_list(char *name, uint8_t pct) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
715 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
716 name_list_t *nlp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
717 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
718 nlp = malloc(sizeof (*nlp)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
719 nlp->name = strdup(name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
720 nlp->pct = pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
721 nlp->max_pct = pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
722 nlp->count = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
723 nlp->next = nlp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
724 nlp->prev = nlp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
725 nlp->status = 0; |
6002 | 726 nlp->label = NULL; |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
727 return (nlp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
728 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
729 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
730 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
731 free_name_list(name_list_t *list) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
732 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
733 name_list_t *next = list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
734 name_list_t *lp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
735 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
736 if (list) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
737 do { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
738 lp = next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
739 next = lp->next; |
6002 | 740 if (lp->label) |
741 free(lp->label); | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
742 free(lp->name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
743 free(lp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
744 } while (next != list); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
745 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
746 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
747 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
748 static status_record_t * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
749 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
|
750 name_list_t *fru, name_list_t *asru, name_list_t *resource, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
751 name_list_t *serial, const char *url, boolean_t not_suppressed, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
752 hostid_t *hostid) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
753 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
754 status_record_t *status_rec_p; |
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 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
|
757 status_rec_p->nrecs = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
758 status_rec_p->host = hostid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
759 status_rec_p->uurec = uurec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
760 uurec_p->next = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
761 uurec_p->prev = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
762 uurec_p->asru = asru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
763 status_rec_p->severity = get_dict_msg(msgid, "severity", 1, 0); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
764 status_rec_p->class = class; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
765 status_rec_p->fru = fru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
766 status_rec_p->asru = asru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
767 status_rec_p->resource = resource; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
768 status_rec_p->serial = serial; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
769 status_rec_p->url = url ? strdup(url) : NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
770 status_rec_p->msgid = strdup(msgid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
771 status_rec_p->not_suppressed = not_suppressed; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
772 return (status_rec_p); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
773 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
774 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
775 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
776 * 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
|
777 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
778 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
779 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
|
780 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
781 sr_list_t *tp, *np, *sp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
782 int order; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
783 uint64_t sec; |
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 np = malloc(sizeof (sr_list_t)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
786 np->status_record = status_rec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
787 sec = status_rec_p->uurec->sec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
788 if ((sp = *list_pp) == NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
789 *list_pp = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
790 np->next = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
791 np->prev = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
792 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
793 /* insert new record in front of lower priority */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
794 tp = sp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
795 order = cmp_priority(status_rec_p->severity, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
796 sp->status_record->severity, sec, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
797 tp->status_record->uurec->sec, 0, 0); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
798 if (order > 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
799 *list_pp = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
800 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
801 tp = sp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
802 while (tp != sp && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
803 cmp_priority(status_rec_p->severity, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
804 tp->status_record->severity, sec, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
805 tp->status_record->uurec->sec, 0, 0)) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
806 tp = tp->next; |
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 np->next = tp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
810 np->prev = tp->prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
811 tp->prev->next = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
812 tp->prev = np; |
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 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
815 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
816 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
817 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
|
818 resource_list_t *np) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
819 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
820 int order; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
821 uint64_t sec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
822 resource_list_t *sp, *tp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
823 status_record_t *srp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
824 char *severity = status_rec_p->severity; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
825 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
826 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
|
827 if ((sp = *rp) == NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
828 np->next = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
829 np->prev = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
830 *rp = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
831 } else { |
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 * insert new record in front of lower priority |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
834 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
835 tp = sp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
836 srp = sp->status_rec_list->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
837 sec = status_rec_p->uurec->sec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
838 order = cmp_priority(severity, srp->severity, sec, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
839 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
|
840 if (order > 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
841 *rp = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
842 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
843 srp = tp->status_rec_list->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
844 while (tp != sp && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
845 cmp_priority(severity, srp->severity, sec, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
846 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
|
847 tp = tp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
848 srp = tp->status_rec_list->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
849 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
850 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
851 np->next = tp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
852 np->prev = tp->prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
853 tp->prev->next = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
854 tp->prev = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
855 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
856 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
857 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
858 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
859 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
|
860 resource_list_t **rpp) |
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 int order; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
863 resource_list_t *np, *end; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
864 status_record_t *srp; |
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 np = *rpp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
867 end = np; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
868 while (np) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
869 if (strcmp(fp->name, np->resource) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
870 np->not_suppressed |= status_rec_p->not_suppressed; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
871 srp = np->status_rec_list->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
872 order = cmp_priority(status_rec_p->severity, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
873 srp->severity, status_rec_p->uurec->sec, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
874 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
|
875 if (order > 0 && np != end) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
876 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
877 * remove from list and add again using |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
878 * new priority |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
879 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
880 np->prev->next = np->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
881 np->next->prev = np->prev; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
882 add_resource(status_rec_p, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
883 rpp, np); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
884 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
885 add_rec_list(status_rec_p, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
886 &np->status_rec_list); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
887 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
888 break; |
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 np = np->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
891 if (np == end) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
892 np = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
893 break; |
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 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
896 if (np == NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
897 np = malloc(sizeof (resource_list_t)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
898 np->resource = fp->name; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
899 np->not_suppressed = status_rec_p->not_suppressed; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
900 np->status_rec_list = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
901 np->max_pct = fp->max_pct; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
902 add_resource(status_rec_p, rpp, np); |
0 | 903 } |
904 } | |
905 | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
906 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
907 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
|
908 resource_list_t **glistp) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
909 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
910 name_list_t *fp, *end; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
911 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
912 fp = listp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
913 end = fp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
914 while (fp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
915 add_resource_list(status_rec_p, fp, glistp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
916 fp = fp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
917 if (fp == end) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
918 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
919 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
920 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
921 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
922 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
923 * add record to rec, fru and asru lists. |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
924 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
925 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
926 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
|
927 name_list_t *fru, name_list_t *asru, name_list_t *resource, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
928 name_list_t *serial, const char *url, boolean_t not_suppressed, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
929 hostid_t *hostid) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
930 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
931 status_record_t *status_rec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
932 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
933 status_rec_p = new_record_init(uurec_p, msgid, class, fru, asru, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
934 resource, serial, url, not_suppressed, hostid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
935 add_rec_list(status_rec_p, &status_rec_list); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
936 if (status_rec_p->fru) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
937 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
|
938 if (status_rec_p->asru) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
939 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
|
940 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
941 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
942 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
943 * add uuid and diagnoses time to an existing record for similar fault on the |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
944 * same fru |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
945 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
946 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
947 catalog_merge_record(status_record_t *status_rec_p, uurec_t *uurec_p, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
948 name_list_t *asru, name_list_t *resource, name_list_t *serial, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
949 const char *url, boolean_t not_suppressed) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
950 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
951 uurec_t *uurec1_p; |
0 | 952 |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
953 status_rec_p->nrecs++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
954 /* add uurec in time order */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
955 if (status_rec_p->uurec->sec > uurec_p->sec) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
956 uurec_p->next = status_rec_p->uurec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
957 uurec_p->prev = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
958 status_rec_p->uurec = uurec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
959 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
960 uurec1_p = status_rec_p->uurec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
961 while (uurec1_p->next && uurec1_p->next->sec <= uurec_p->sec) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
962 uurec1_p = uurec1_p->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
963 if (uurec1_p->next) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
964 uurec1_p->next->prev = uurec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
965 uurec_p->next = uurec1_p->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
966 uurec_p->prev = uurec1_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
967 uurec1_p->next = uurec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
968 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
969 if (status_rec_p->url == NULL && url != NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
970 status_rec_p->url = strdup(url); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
971 status_rec_p->not_suppressed |= not_suppressed; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
972 uurec_p->asru = merge_name_list(&status_rec_p->asru, asru, 0); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
973 (void) merge_name_list(&status_rec_p->resource, resource, 0); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
974 (void) merge_name_list(&status_rec_p->serial, serial, 0); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
975 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
976 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
977 static status_record_t * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
978 record_in_catalog(name_list_t *class, name_list_t *fru, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
979 char *msgid, hostid_t *host) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
980 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
981 sr_list_t *status_rec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
982 status_record_t *srp = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
983 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
984 status_rec_p = status_rec_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
985 while (status_rec_p) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
986 srp = status_rec_p->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
987 if (host == srp->host && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
988 cmp_name_list(class, srp->class) == 0 && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
989 cmp_name_list(fru, srp->fru) == 0 && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
990 strcmp(msgid, srp->msgid) == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
991 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
992 if (status_rec_p->next == status_rec_list) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
993 srp = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
994 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
995 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
996 status_rec_p = status_rec_p->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
997 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
998 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
999 return (srp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1000 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1001 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1002 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1003 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
|
1004 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1005 char *name; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1006 char *serial = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1007 char **lserial = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1008 uint64_t serint; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1009 name_list_t *nlp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1010 int j; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1011 uint_t nelem; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1012 char buf[64]; |
0 | 1013 |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1014 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
|
1015 if (strcmp(name, FM_FMRI_SCHEME_CPU) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1016 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
|
1017 &serint) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1018 (void) snprintf(buf, sizeof (buf), "%llX", |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1019 serint); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1020 nlp = alloc_name_list(buf, pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1021 (void) merge_name_list(serial_p, nlp, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1022 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1023 } 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
|
1024 if (nvlist_lookup_string_array(nvl, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1025 FM_FMRI_MEM_SERIAL_ID, &lserial, &nelem) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1026 nlp = alloc_name_list(lserial[0], pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1027 for (j = 1; j < nelem; j++) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1028 name_list_t *n1lp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1029 n1lp = alloc_name_list(lserial[j], pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1030 (void) merge_name_list(&nlp, n1lp, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1031 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1032 (void) merge_name_list(serial_p, nlp, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1033 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1034 } 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
|
1035 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
|
1036 &serial) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1037 nlp = alloc_name_list(serial, pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1038 (void) merge_name_list(serial_p, nlp, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1039 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1040 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1041 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1042 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1043 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1044 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1045 extract_record_info(nvlist_t *nvl, name_list_t **class_p, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1046 name_list_t **fru_p, name_list_t **serial_p, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1047 name_list_t **resource_p, name_list_t **asru_p, uint8_t status) |
0 | 1048 { |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1049 nvlist_t *lfru, *lasru, *rsrc; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1050 name_list_t *nlp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1051 char *name; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1052 uint8_t lpct = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1053 char *lclass = NULL; |
6002 | 1054 char *label; |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1055 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1056 (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
|
1057 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
|
1058 nlp = alloc_name_list(lclass, lpct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1059 (void) merge_name_list(class_p, nlp, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1060 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1061 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
|
1062 name = get_nvl2str_topo(lfru); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1063 if (name != NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1064 nlp = alloc_name_list(name, lpct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1065 free(name); |
6002 | 1066 if (nvlist_lookup_string(nvl, FM_FAULT_LOCATION, |
1067 &label) == 0) | |
1068 nlp->label = strdup(label); | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1069 (void) merge_name_list(fru_p, nlp, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1070 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1071 get_serial_no(lfru, serial_p, lpct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1072 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1073 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
|
1074 name = get_nvl2str_topo(lasru); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1075 if (name != NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1076 nlp = alloc_name_list(name, lpct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1077 nlp->status = status & ~FM_SUSPECT_NOT_PRESENT; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1078 free(name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1079 (void) merge_name_list(asru_p, nlp, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1080 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1081 get_serial_no(lasru, serial_p, lpct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1082 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1083 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
|
1084 name = get_nvl2str_topo(rsrc); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1085 if (name != NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1086 nlp = alloc_name_list(name, lpct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1087 free(name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1088 (void) merge_name_list(resource_p, nlp, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1089 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1090 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1091 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1092 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1093 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1094 add_fault_record_to_catalog(nvlist_t *nvl, uint64_t sec, char *uuid, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1095 const char *url) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1096 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1097 char *msgid = "-"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1098 uint_t i, size = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1099 name_list_t *class = NULL, *resource = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1100 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
|
1101 nvlist_t **nva; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1102 uint8_t *ba; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1103 status_record_t *status_rec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1104 uurec_t *uurec_p; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1105 hostid_t *host; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1106 boolean_t not_suppressed = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1107 boolean_t any_present = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1108 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1109 (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
|
1110 (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
|
1111 (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
|
1112 ¬_suppressed); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1113 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1114 if (size != 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1115 (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
|
1116 &nva, &size); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1117 (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
|
1118 &ba, &size); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1119 for (i = 0; i < size; i++) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1120 extract_record_info(nva[i], &class, &fru, &serial, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1121 &resource, &asru, ba[i]); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1122 if (!(ba[i] & FM_SUSPECT_NOT_PRESENT) && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1123 (ba[i] & FM_SUSPECT_FAULTY)) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1124 any_present = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1125 } |
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 * also suppress if no resources present |
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 if (any_present == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1130 not_suppressed = 0; |
0 | 1131 } |
1132 | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1133 uurec_p = (uurec_t *)malloc(sizeof (uurec_t)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1134 uurec_p->uuid = strdup(uuid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1135 uurec_p->sec = sec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1136 uurec_p->ari_uuid_list = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1137 host = find_hostid(nvl); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1138 if (not_suppressed && !opt_g) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1139 status_rec_p = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1140 else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1141 status_rec_p = record_in_catalog(class, fru, msgid, host); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1142 if (status_rec_p) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1143 catalog_merge_record(status_rec_p, uurec_p, asru, resource, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1144 serial, url, not_suppressed); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1145 free_name_list(class); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1146 free_name_list(fru); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1147 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1148 catalog_new_record(uurec_p, msgid, class, fru, asru, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1149 resource, serial, url, not_suppressed, host); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1150 } |
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 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1153 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1154 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
|
1155 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1156 sr_list_t *srp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1157 uurec_t *uurp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1158 ari_list_t *ari_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1159 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1160 srp = status_rec_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1161 if (srp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1162 for (;;) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1163 uurp = srp->status_record->uurec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1164 while (uurp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1165 if (strcmp(uuid, uurp->uuid) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1166 ari_list = (ari_list_t *) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1167 malloc(sizeof (ari_list_t)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1168 ari_list->ari_uuid = strdup(ari_uuid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1169 ari_list->next = uurp->ari_uuid_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1170 uurp->ari_uuid_list = ari_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1171 return; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1172 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1173 uurp = uurp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1174 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1175 if (srp->next == status_rec_list) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1176 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1177 srp = srp->next; |
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 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1180 } |
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 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1183 print_line(char *label, char *buf) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1184 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1185 char *cp, *ep, *wp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1186 char c; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1187 int i; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1188 int lsz; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1189 char *padding; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1190 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1191 lsz = strlen(label); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1192 padding = malloc(lsz + 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1193 for (i = 0; i < lsz; i++) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1194 padding[i] = ' '; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1195 padding[i] = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1196 cp = buf; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1197 ep = buf; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1198 c = *ep; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1199 (void) printf("\n"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1200 while (c) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1201 i = lsz; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1202 wp = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1203 while ((c = *ep) != NULL && (wp == NULL || i < 80)) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1204 if (c == ' ') |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1205 wp = ep; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1206 else if (c == '\n') { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1207 i = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1208 *ep = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1209 do { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1210 ep++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1211 } while ((c = *ep) != NULL && c == ' '); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1212 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1213 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1214 ep++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1215 i++; |
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 if (i >= 80 && wp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1218 *wp = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1219 ep = wp + 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1220 c = *ep; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1221 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1222 (void) printf("%s%s\n", label, cp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1223 cp = ep; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1224 label = padding; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1225 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1226 free(padding); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1227 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1228 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1229 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1230 print_dict_info(char *msgid, char *url) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1231 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1232 const char *cp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1233 char *l_url; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1234 char *buf; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1235 int bufsz; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1236 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1237 cp = get_dict_msg(msgid, "description", 0, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1238 if (cp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1239 if (url) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1240 l_url = url; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1241 else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1242 l_url = get_dict_url(msgid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1243 bufsz = strlen(cp) + strlen(l_url) + 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1244 buf = malloc(bufsz); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1245 (void) snprintf(buf, bufsz, cp, l_url); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1246 print_line(dgettext("FMD", "Description : "), buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1247 free(buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1248 if (!url) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1249 free(l_url); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1250 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1251 cp = get_dict_msg(msgid, "response", 0, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1252 if (cp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1253 buf = strdup(cp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1254 print_line(dgettext("FMD", "Response : "), buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1255 free(buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1256 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1257 cp = get_dict_msg(msgid, "impact", 0, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1258 if (cp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1259 buf = strdup(cp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1260 print_line(dgettext("FMD", "Impact : "), buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1261 free(buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1262 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1263 cp = get_dict_msg(msgid, "action", 0, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1264 if (cp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1265 buf = strdup(cp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1266 print_line(dgettext("FMD", "Action : "), buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1267 free(buf); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1268 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1269 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1270 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1271 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1272 print_name(name_list_t *list, char *(func)(char *), char *padding, int *np, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1273 int pct, int full) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1274 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1275 char *name, *fru = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1276 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1277 name = list->name; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1278 if (func) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1279 fru = func(list->name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1280 if (fru) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1281 (void) printf("%s \"%s\" (%s)", padding, fru, name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1282 *np += 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1283 free(fru); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1284 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1285 (void) printf("%s %s", padding, name); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1286 *np += 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1287 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1288 if (list->pct && pct > 0 && pct < 100) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1289 if (list->count > 1) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1290 if (full) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1291 (void) printf(" %d @ %s %d%%\n", list->count, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1292 dgettext("FMD", "max"), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1293 list->max_pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1294 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1295 (void) printf(" %s %d%%\n", |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1296 dgettext("FMD", "max"), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1297 list->max_pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1298 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1299 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1300 (void) printf(" %d%%\n", list->pct); |
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 (void) printf("\n"); |
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 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1306 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1307 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1308 print_asru_status(int status, char *label) |
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 char *msg = NULL; |
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 switch (status) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1313 case 0: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1314 msg = dgettext("FMD", "ok and in service"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1315 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1316 case FM_SUSPECT_FAULTY: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1317 msg = dgettext("FMD", "degraded but still in service"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1318 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1319 case FM_SUSPECT_UNUSABLE: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1320 msg = dgettext("FMD", "unknown, not present or disabled"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1321 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1322 case FM_SUSPECT_FAULTY | FM_SUSPECT_UNUSABLE: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1323 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
|
1324 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1325 default: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1326 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1327 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1328 if (msg) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1329 (void) printf("%s %s\n", label, msg); |
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 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1332 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1333 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1334 print_name_list(name_list_t *list, char *label, char *(func)(char *), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1335 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
|
1336 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1337 char *name, *fru = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1338 char *padding; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1339 int i, j, l, n; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1340 name_list_t *end = list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1341 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1342 l = strlen(label); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1343 padding = malloc(l + 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1344 for (i = 0; i < l; i++) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1345 padding[i] = ' '; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1346 padding[l] = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1347 (void) printf("%s", label); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1348 name = list->name; |
6002 | 1349 if (func == NULL) |
1350 (void) printf(" %s", name); | |
1351 else if (list->label) | |
1352 (void) printf(" \"%s\" (%s)", list->label, name); | |
1353 else { | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1354 fru = func(list->name); |
6002 | 1355 if (fru) { |
1356 (void) printf(" \"%s\" (%s)", fru, name); | |
1357 free(fru); | |
1358 } else | |
1359 (void) printf(" %s", name); | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1360 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1361 if (list->pct && pct > 0 && pct < 100) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1362 if (list->count > 1) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1363 if (full) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1364 (void) printf(" %d @ %s %d%%\n", list->count, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1365 dgettext("FMD", "max"), list->max_pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1366 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1367 (void) printf(" %s %d%%\n", |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1368 dgettext("FMD", "max"), list->max_pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1369 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1370 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1371 (void) printf(" %d%%\n", list->pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1372 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1373 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1374 (void) printf("\n"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1375 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1376 if (func1) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1377 func1(list->status, padding); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1378 n = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1379 j = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1380 while ((list = list->next) != end) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1381 if (limit == 0 || n < limit) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1382 print_name(list, func, padding, &n, pct, full); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1383 if (func1) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1384 func1(list->status, padding); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1385 } else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1386 j++; |
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 if (j == 1) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1389 print_name(list->prev, func, padding, &n, pct, full); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1390 } else if (j > 1) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1391 (void) printf("%s... %d %s\n", padding, j, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1392 dgettext("FMD", "more entries suppressed," |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1393 " use -v option for full list")); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1394 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1395 free(padding); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1396 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1397 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1398 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1399 asru_same_status(name_list_t *list) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1400 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1401 name_list_t *end = list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1402 int status = list->status; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1403 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1404 while ((list = list->next) != end) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1405 if (status == -1) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1406 status = list->status; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1407 continue; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1408 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1409 if (list->status != -1 && status != list->status) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1410 status = -1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1411 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1412 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1413 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1414 return (status); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1415 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1416 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1417 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1418 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
|
1419 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1420 name_list_t *sp = serial; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1421 name_list_t *fp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1422 int nserial = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1423 int found = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1424 char buf[128]; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1425 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1426 while (sp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1427 fp = fru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1428 nserial++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1429 (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
|
1430 buf[sizeof (buf) - 1] = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1431 while (fp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1432 if (strstr(fp->name, buf) != NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1433 found++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1434 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1435 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1436 fp = fp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1437 if (fp == fru) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1438 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1439 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1440 sp = sp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1441 if (sp == serial) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1442 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1443 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1444 return (found == nserial ? 1 : 0); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1445 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1446 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1447 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1448 print_server_name(hostid_t *host, char *label) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1449 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1450 (void) printf("%s %s %s %s\n", label, host->server, host->platform, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1451 host->chassis ? host->chassis : ""); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1452 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1453 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1454 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1455 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
|
1456 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1457 char buf[32]; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1458 uurec_t *uurp = srp->uurec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1459 int n, j, k, max; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1460 int status; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1461 ari_list_t *ari_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1462 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1463 n = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1464 max = max_fault; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1465 if (max < 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1466 max = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1467 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1468 j = max / 2; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1469 max -= j; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1470 k = srp->nrecs - max; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1471 while ((uurp = uurp->next) != NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1472 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
|
1473 srp->nrecs == max_fault+1) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1474 if (opt_i) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1475 ari_list = uurp->ari_uuid_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1476 while (ari_list) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1477 (void) printf("%-15s %s\n", |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1478 format_date(buf, sizeof (buf), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1479 uurp->sec), ari_list->ari_uuid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1480 ari_list = ari_list->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1481 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1482 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1483 (void) printf("%-15s %s\n", |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1484 format_date(buf, sizeof (buf), uurp->sec), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1485 uurp->uuid); |
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 if (n == j) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1488 (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
|
1489 dgettext("FMD", "more entries suppressed")); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1490 n++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1491 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1492 (void) printf("\n"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1493 if (n_server > 1) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1494 print_server_name(srp->host, dgettext("FMD", "Host :")); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1495 if (srp->class) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1496 print_name_list(srp->class, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1497 dgettext("FMD", "Fault class :"), NULL, 0, srp->class->pct, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1498 NULL, full); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1499 if (srp->asru) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1500 status = asru_same_status(srp->asru); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1501 if (status != -1) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1502 print_name_list(srp->asru, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1503 dgettext("FMD", "Affects :"), NULL, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1504 full ? 0 : max_display, 0, NULL, full); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1505 print_asru_status(status, " "); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1506 } else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1507 print_name_list(srp->asru, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1508 dgettext("FMD", "Affects :"), NULL, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1509 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
|
1510 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1511 if (full || srp->fru == NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1512 if (srp->resource) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1513 print_name_list(srp->resource, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1514 dgettext("FMD", "Problem in :"), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1515 NULL, full ? 0 : max_display, 0, NULL, full); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1516 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1517 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1518 if (srp->fru) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1519 print_name_list(srp->fru, dgettext("FMD", "FRU :"), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1520 get_fmri_label, 0, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1521 srp->fru->pct == 100 ? 100 : srp->fru->max_pct, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1522 NULL, full); |
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 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
|
1525 !serial_in_fru(srp->asru, srp->serial)) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1526 print_name_list(srp->serial, dgettext("FMD", "Serial ID. :"), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1527 NULL, 0, 0, NULL, full); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1528 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1529 print_dict_info(srp->msgid, srp->url); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1530 (void) printf("\n"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1531 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1532 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1533 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1534 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
|
1535 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1536 char buf[32]; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1537 uurec_t *uurp = srp->uurec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1538 char *severity; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1539 static int header = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1540 char *head; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1541 ari_list_t *ari_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1542 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1543 if (nlspath) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1544 severity = get_dict_msg(srp->msgid, "severity", 1, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1545 else |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1546 severity = srp->severity; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1547 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1548 if (!summary || !header) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1549 if (opt_i) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1550 head = "--------------- " |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1551 "------------------------------------ " |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1552 "-------------- ---------\n" |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1553 "TIME CACHE-ID" |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1554 " MSG-ID" |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1555 " SEVERITY\n--------------- " |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1556 "------------------------------------ " |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1557 " -------------- ---------"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1558 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1559 head = "--------------- " |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1560 "------------------------------------ " |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1561 "-------------- ---------\n" |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1562 "TIME EVENT-ID" |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1563 " MSG-ID" |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1564 " SEVERITY\n--------------- " |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1565 "------------------------------------ " |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1566 " -------------- ---------"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1567 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1568 (void) printf("%s\n", dgettext("FMD", head)); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1569 header = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1570 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1571 if (opt_i) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1572 ari_list = uurp->ari_uuid_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1573 while (ari_list) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1574 (void) printf("%-15s %-37s %-14s %-9s\n", |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1575 format_date(buf, sizeof (buf), uurp->sec), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1576 ari_list->ari_uuid, srp->msgid, severity); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1577 ari_list = ari_list->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1578 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1579 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1580 (void) printf("%-15s %-37s %-14s %-9s\n", |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1581 format_date(buf, sizeof (buf), uurp->sec), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1582 uurp->uuid, srp->msgid, severity); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1583 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1584 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1585 if (!summary) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1586 print_sup_record(srp, opt_i, full); |
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 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1589 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1590 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
|
1591 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1592 status_record_t *srp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1593 sr_list_t *slp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1594 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1595 slp = status_rec_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1596 if (slp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1597 for (;;) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1598 srp = slp->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1599 if (opt_a || srp->not_suppressed) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1600 if (page_feed) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1601 (void) printf("\f\n"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1602 print_status_record(srp, summary, opt_i, full); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1603 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1604 if (slp->next == status_rec_list) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1605 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1606 slp = slp->next; |
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 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1609 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1610 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1611 static name_list_t * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1612 find_fru(status_record_t *srp, char *resource) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1613 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1614 name_list_t *rt = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1615 name_list_t *fru = srp->fru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1616 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1617 while (fru) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1618 if (strcmp(resource, fru->name) == 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1619 rt = fru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1620 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1621 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1622 fru = fru->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1623 if (fru == srp->fru) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1624 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1625 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1626 return (rt); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1627 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1628 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1629 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1630 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
|
1631 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1632 if (fru->pct == 100) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1633 (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
|
1634 dgettext("FMD", "suspects in this FRU total certainty"), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1635 100); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1636 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1637 (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
|
1638 dgettext("FMD", "suspects in this FRU max certainty"), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1639 fru->max_pct); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1640 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1641 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1642 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1643 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1644 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
|
1645 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1646 resource_list_t *tp = status_fru_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1647 status_record_t *srp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1648 sr_list_t *slp, *end; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1649 char *msgid, *fru_label; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1650 uurec_t *uurp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1651 name_list_t *fru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1652 ari_list_t *ari_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1653 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1654 while (tp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1655 if (opt_a || tp->not_suppressed) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1656 if (page_feed) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1657 (void) printf("\f\n"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1658 if (!summary) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1659 (void) printf("-----------------------------" |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1660 "---------------------------------------" |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1661 "----------\n"); |
6002 | 1662 slp = tp->status_rec_list; |
1663 end = slp; | |
1664 do { | |
1665 srp = slp->status_record; | |
1666 fru = find_fru(srp, tp->resource); | |
1667 if (fru) { | |
1668 if (fru->label) | |
1669 (void) printf("\"%s\" (%s)\n", | |
1670 fru->label, fru->name); | |
1671 else if (fru_label = | |
1672 get_fmri_label(fru->name)) { | |
1673 (void) printf("\"%s\" (%s)\n", | |
1674 fru_label, fru->name); | |
1675 free(fru_label); | |
1676 } else | |
1677 (void) printf("%s\n", | |
1678 fru->name); | |
1679 break; | |
1680 } | |
1681 slp = slp->next; | |
1682 } while (slp != end); | |
1683 | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1684 slp = tp->status_rec_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1685 end = slp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1686 do { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1687 srp = slp->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1688 uurp = srp->uurec; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1689 fru = find_fru(srp, tp->resource); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1690 if (fru) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1691 if (opt_i) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1692 ari_list = uurp->ari_uuid_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1693 while (ari_list) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1694 print_fru_line(fru, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1695 ari_list->ari_uuid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1696 ari_list = |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1697 ari_list->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1698 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1699 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1700 print_fru_line(fru, uurp->uuid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1701 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1702 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1703 slp = slp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1704 } while (slp != end); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1705 if (!summary) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1706 slp = tp->status_rec_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1707 end = slp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1708 srp = slp->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1709 if (srp->serial && |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1710 !serial_in_fru(srp->fru, srp->serial)) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1711 print_name_list(srp->serial, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1712 dgettext("FMD", "Serial ID. :"), |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1713 NULL, 0, 0, NULL, 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1714 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1715 msgid = NULL; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1716 do { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1717 if (msgid == NULL || |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1718 strcmp(msgid, srp->msgid) != 0) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1719 msgid = srp->msgid; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1720 print_dict_info(srp->msgid, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1721 srp->url); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1722 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1723 slp = slp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1724 } while (slp != end); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1725 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1726 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1727 tp = tp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1728 if (tp == status_fru_list) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1729 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1730 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1731 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1732 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1733 static void |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1734 print_asru(int opt_a) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1735 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1736 resource_list_t *tp = status_asru_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1737 status_record_t *srp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1738 sr_list_t *slp, *end; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1739 char *msg; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1740 int status; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1741 name_list_t *asru; |
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 while (tp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1744 if (opt_a || tp->not_suppressed) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1745 status = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1746 slp = tp->status_rec_list; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1747 end = slp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1748 do { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1749 srp = slp->status_record; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1750 asru = srp->asru; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1751 while (asru) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1752 if (strcmp(tp->resource, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1753 asru->name) == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1754 status |= asru->status; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1755 asru = asru->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1756 if (asru == srp->asru) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1757 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1758 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1759 slp = slp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1760 } while (slp != end); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1761 switch (status) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1762 case 0: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1763 msg = dgettext("FMD", "ok"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1764 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1765 case FM_SUSPECT_FAULTY: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1766 msg = dgettext("FMD", "degraded"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1767 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1768 case FM_SUSPECT_UNUSABLE: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1769 msg = dgettext("FMD", "unknown"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1770 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1771 case FM_SUSPECT_FAULTY | FM_SUSPECT_UNUSABLE: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1772 msg = dgettext("FMD", "faulted"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1773 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1774 default: |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1775 msg = ""; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1776 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1777 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1778 (void) printf("%-69s %s\n", tp->resource, msg); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1779 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1780 tp = tp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1781 if (tp == status_asru_list) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1782 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1783 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1784 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1785 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1786 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1787 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
|
1788 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1789 while (uurecp) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1790 if (strcmp(uuid, uurecp->uuid) == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1791 return (1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1792 uurecp = uurecp->next; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1793 } |
0 | 1794 return (0); |
1795 } | |
1796 | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1797 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1798 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
|
1799 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1800 int64_t *diag_time; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1801 uint_t nelem; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1802 int rt = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1803 char *uuid = "-"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1804 uurec_select_t *uurecp = (uurec_select_t *)arg; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1805 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1806 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
|
1807 &diag_time, &nelem) == 0 && nelem >= 2) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1808 (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
|
1809 &uuid); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1810 if (uurecp == NULL || uuid_in_list(uuid, uurecp)) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1811 add_fault_record_to_catalog(acp->aci_event, *diag_time, |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1812 uuid, acp->aci_url); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1813 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1814 rt = -1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1815 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1816 return (rt); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1817 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1818 |
0 | 1819 /*ARGSUSED*/ |
1820 static int | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1821 dstatus_rec(const fmd_adm_rsrcinfo_t *ari, void *unused) |
0 | 1822 { |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1823 update_asru_state_in_catalog(ari->ari_case, ari->ari_uuid); |
0 | 1824 return (0); |
1825 } | |
1826 | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1827 static int |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1828 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
|
1829 { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1830 int rt = FMADM_EXIT_SUCCESS; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1831 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1832 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1833 * These calls may fail with Protocol error if message payload is to big |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1834 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1835 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
|
1836 die("failed to get case list from fmd"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1837 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
|
1838 die("failed to get case status from fmd"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1839 return (rt); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1840 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1841 |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1842 /* |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1843 * fmadm faulty command |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1844 * |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1845 * -a show hidden fault records |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1846 * -f show faulty fru's |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1847 * -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
|
1848 * -n number of fault records to display |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1849 * -p pipe output through pager |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1850 * -r show faulty asru's |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1851 * -s print summary of first fault |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1852 * -u print listed uuid's only |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1853 * -v full output |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1854 */ |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1855 |
0 | 1856 int |
1857 cmd_faulty(fmd_adm_t *adm, int argc, char *argv[]) | |
1858 { | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1859 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
|
1860 int opt_i = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1861 char *pager; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1862 FILE *fp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1863 int rt, c, stat; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1864 uurec_select_t *tp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1865 uurec_select_t *uurecp = NULL; |
0 | 1866 |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1867 catalog_setup(); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1868 while ((c = getopt(argc, argv, "afgin:prsu:v")) != EOF) { |
0 | 1869 switch (c) { |
1870 case 'a': | |
1871 opt_a++; | |
1872 break; | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1873 case 'f': |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1874 opt_f++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1875 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1876 case 'g': |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1877 opt_g++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1878 break; |
0 | 1879 case 'i': |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1880 opt_i++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1881 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1882 case 'n': |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1883 max_fault = atoi(optarg); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1884 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1885 case 'p': |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1886 opt_p++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1887 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1888 case 'r': |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1889 opt_r++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1890 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1891 case 's': |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1892 opt_s++; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1893 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1894 case 'u': |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1895 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
|
1896 tp->uuid = optarg; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1897 tp->next = uurecp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1898 uurecp = tp; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1899 opt_a = 1; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1900 break; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1901 case 'v': |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1902 opt_v++; |
0 | 1903 break; |
1904 default: | |
1905 return (FMADM_EXIT_USAGE); | |
1906 } | |
1907 } | |
1908 if (optind < argc) | |
1909 return (FMADM_EXIT_USAGE); | |
1910 | |
5255
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1911 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
|
1912 if (opt_p) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1913 if ((pager = getenv("PAGER")) == NULL) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1914 pager = "/usr/bin/more"; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1915 fp = popen(pager, "w"); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1916 if (fp == NULL) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1917 rt = FMADM_EXIT_ERROR; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1918 opt_p = 0; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1919 } else { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1920 dup2(fileno(fp), 1); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1921 setbuf(stdout, NULL); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1922 (void) fclose(fp); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1923 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1924 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1925 max_display = max_fault; |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1926 if (opt_f) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1927 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
|
1928 if (opt_r) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1929 print_asru(opt_a); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1930 if (opt_f == 0 && opt_r == 0) |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1931 print_catalog(opt_s, opt_a, opt_v, opt_i, opt_p && !opt_s); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1932 label_release_topo(); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1933 if (opt_p) { |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1934 (void) fclose(stdout); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1935 (void) wait(&stat); |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1936 } |
8dc347a9bd70
PSARC 2007/460 fmadm faulty command new output and arguments
stephh
parents:
0
diff
changeset
|
1937 return (rt); |
0 | 1938 } |
1939 | |
1940 int | |
1941 cmd_flush(fmd_adm_t *adm, int argc, char *argv[]) | |
1942 { | |
1943 int i, status = FMADM_EXIT_SUCCESS; | |
1944 | |
1945 if (argc < 2 || (i = getopt(argc, argv, "")) != EOF) | |
1946 return (FMADM_EXIT_USAGE); | |
1947 | |
1948 for (i = 1; i < argc; i++) { | |
1949 if (fmd_adm_rsrc_flush(adm, argv[i]) != 0) { | |
1950 warn("failed to flush %s", argv[i]); | |
1951 status = FMADM_EXIT_ERROR; | |
1952 } else | |
1953 note("flushed resource history for %s\n", argv[i]); | |
1954 } | |
1955 | |
1956 return (status); | |
1957 } | |
1958 | |
1959 int | |
1960 cmd_repair(fmd_adm_t *adm, int argc, char *argv[]) | |
1961 { | |
1962 int err; | |
1963 | |
1964 if (getopt(argc, argv, "") != EOF) | |
1965 return (FMADM_EXIT_USAGE); | |
1966 | |
1967 if (argc - optind != 1) | |
1968 return (FMADM_EXIT_USAGE); | |
1969 | |
1970 /* | |
1971 * For now, we assume that if the input string contains a colon, it is | |
1972 * an FMRI and if it does not it is a UUID. If things get more complex | |
1973 * in the future with multiple UUID formats, an FMRI parser can be | |
1974 * added here to differentiate the input argument appropriately. | |
1975 */ | |
1976 if (strchr(argv[optind], ':') != NULL) | |
1977 err = fmd_adm_rsrc_repair(adm, argv[optind]); | |
1978 else | |
1979 err = fmd_adm_case_repair(adm, argv[optind]); | |
1980 | |
1981 if (err != 0) | |
1982 die("failed to record repair to %s", argv[optind]); | |
1983 | |
1984 note("recorded repair to %s\n", argv[optind]); | |
1985 return (FMADM_EXIT_SUCCESS); | |
1986 } |