151
152 nvlist_free(in);
153
154 /*
155 * Check for faults and post ereport(s) if needed
156 */
157 if (nvlist_lookup_nvlist(result, "faults", &faults) == 0 &&
158 nvlist_lookup_string(result, "protocol", &protocol) == 0) {
159 elem = NULL;
160 while ((elem = nvlist_next_nvpair(faults, elem)) != NULL) {
161 if (nvpair_type(elem) != DATA_TYPE_BOOLEAN_VALUE)
162 continue;
163
164 (void) nvpair_value_boolean_value(elem, &fault);
165 if (!fault ||
166 nvlist_lookup_nvlist(result, nvpair_name(elem),
167 &details) != 0)
168 continue;
169
170 if (strcmp(nvpair_name(elem),
171 FM_EREPORT_SCSI_SSMWEAROUT) == 0 &&
172 fmd_prop_get_int32(dmp->dm_hdl,
173 "ignore-ssm-wearout") == FMD_B_TRUE)
174 continue;
175
176 dt_post_ereport(dmp->dm_hdl, dmp->dm_xprt, protocol,
177 nvpair_name(elem),
178 fmd_event_ena_create(dmp->dm_hdl), fmri, details);
179 }
180 }
181
182 nvlist_free(result);
183 nvlist_free(fmri);
184
185 return (TOPO_WALK_NEXT);
186 }
187
188 /*
189 * Periodic timeout. Iterates over all hc:// topo nodes, calling
190 * dt_analyze_disk() for each one.
235 */
236 /*ARGSUSED*/
237 static void
238 dt_topo_change(fmd_hdl_t *hdl, topo_hdl_t *thp)
239 {
240 disk_monitor_t *dmp = fmd_hdl_getspecific(hdl);
241
242 if (dmp->dm_timer_istopo)
243 return;
244
245 fmd_timer_remove(hdl, dmp->dm_timer);
246 dmp->dm_timer = fmd_timer_install(hdl, NULL, NULL,
247 fmd_prop_get_int64(hdl, "min-interval"));
248 dmp->dm_timer_istopo = B_TRUE;
249 }
250
251 static const fmd_prop_t fmd_props[] = {
252 { "interval", FMD_TYPE_TIME, "1h" },
253 { "min-interval", FMD_TYPE_TIME, "1min" },
254 { "simulate", FMD_TYPE_STRING, "" },
255 { "ignore-ssm-wearout", FMD_TYPE_BOOL, "false"},
256 { NULL, 0, NULL }
257 };
258
259 static const fmd_hdl_ops_t fmd_ops = {
260 NULL, /* fmdo_recv */
261 dt_timeout, /* fmdo_timeout */
262 NULL, /* fmdo_close */
263 NULL, /* fmdo_stats */
264 NULL, /* fmdo_gc */
265 NULL, /* fmdo_send */
266 dt_topo_change, /* fmdo_topo_change */
267 };
268
269 static const fmd_hdl_info_t fmd_info = {
270 "Disk Transport Agent", "1.1", &fmd_ops, fmd_props
271 };
272
273 void
274 _fmd_init(fmd_hdl_t *hdl)
|
151
152 nvlist_free(in);
153
154 /*
155 * Check for faults and post ereport(s) if needed
156 */
157 if (nvlist_lookup_nvlist(result, "faults", &faults) == 0 &&
158 nvlist_lookup_string(result, "protocol", &protocol) == 0) {
159 elem = NULL;
160 while ((elem = nvlist_next_nvpair(faults, elem)) != NULL) {
161 if (nvpair_type(elem) != DATA_TYPE_BOOLEAN_VALUE)
162 continue;
163
164 (void) nvpair_value_boolean_value(elem, &fault);
165 if (!fault ||
166 nvlist_lookup_nvlist(result, nvpair_name(elem),
167 &details) != 0)
168 continue;
169
170 if (strcmp(nvpair_name(elem),
171 FM_EREPORT_SCSI_OVERTEMP) == 0 &&
172 fmd_prop_get_int32(dmp->dm_hdl,
173 "ignore-overtemp") == FMD_B_TRUE)
174 continue;
175
176 if (strcmp(nvpair_name(elem),
177 FM_EREPORT_SCSI_SSMWEAROUT) == 0 &&
178 fmd_prop_get_int32(dmp->dm_hdl,
179 "ignore-ssm-wearout") == FMD_B_TRUE)
180 continue;
181
182 dt_post_ereport(dmp->dm_hdl, dmp->dm_xprt, protocol,
183 nvpair_name(elem),
184 fmd_event_ena_create(dmp->dm_hdl), fmri, details);
185 }
186 }
187
188 nvlist_free(result);
189 nvlist_free(fmri);
190
191 return (TOPO_WALK_NEXT);
192 }
193
194 /*
195 * Periodic timeout. Iterates over all hc:// topo nodes, calling
196 * dt_analyze_disk() for each one.
241 */
242 /*ARGSUSED*/
243 static void
244 dt_topo_change(fmd_hdl_t *hdl, topo_hdl_t *thp)
245 {
246 disk_monitor_t *dmp = fmd_hdl_getspecific(hdl);
247
248 if (dmp->dm_timer_istopo)
249 return;
250
251 fmd_timer_remove(hdl, dmp->dm_timer);
252 dmp->dm_timer = fmd_timer_install(hdl, NULL, NULL,
253 fmd_prop_get_int64(hdl, "min-interval"));
254 dmp->dm_timer_istopo = B_TRUE;
255 }
256
257 static const fmd_prop_t fmd_props[] = {
258 { "interval", FMD_TYPE_TIME, "1h" },
259 { "min-interval", FMD_TYPE_TIME, "1min" },
260 { "simulate", FMD_TYPE_STRING, "" },
261 { "ignore-overtemp", FMD_TYPE_BOOL, "true"},
262 { "ignore-ssm-wearout", FMD_TYPE_BOOL, "false"},
263 { NULL, 0, NULL }
264 };
265
266 static const fmd_hdl_ops_t fmd_ops = {
267 NULL, /* fmdo_recv */
268 dt_timeout, /* fmdo_timeout */
269 NULL, /* fmdo_close */
270 NULL, /* fmdo_stats */
271 NULL, /* fmdo_gc */
272 NULL, /* fmdo_send */
273 dt_topo_change, /* fmdo_topo_change */
274 };
275
276 static const fmd_hdl_info_t fmd_info = {
277 "Disk Transport Agent", "1.1", &fmd_ops, fmd_props
278 };
279
280 void
281 _fmd_init(fmd_hdl_t *hdl)
|