static void sp_post_sysevent(fmd_hdl_t *hdl) { sp_monitor_t *smp = fmd_hdl_getspecific(hdl); sysevent_id_t eid; fmd_hdl_debug(hdl, "SP reset detected, posting sysevent"); if (sysevent_post_event(EC_PLATFORM, ESC_PLATFORM_SP_RESET, SUNW_VENDOR, "fmd", NULL, &eid) != 0) { fmd_hdl_debug(hdl, "failed to send sysevent: %s", strerror(errno)); /* * We reset the seconds and generation so that the next time * through we will try to post the sysevent again. */ smp->sm_seconds = -1U; smp->sm_generation = -1U; } }
/* --- tapealert_sysevent - send a tapealert sysevent to n event handlers */ static int /* 0 successful */ tapealert_sysevent( char *src_fn, /* source filename */ int src_ln, /* source file line number */ dev_ent_t *un, /* device */ int flags_len, /* num valid tapealert flags */ uint64_t flags, /* tapealert flags */ uint64_t *seq_no) /* sysevent sequence number */ { int rtn = 1; time_t tm; nvlist_t *attr_list = NULL; sysevent_id_t eid; boolean_t free_attr_list = B_FALSE; char *str; *seq_no = 0; /* * build and send sysevent with active tapealert flags */ if (nvlist_alloc(&attr_list, 0, 0)) { DevLog(DL_DEBUG(12008), "alloc", strerror(errno)); goto done; } free_attr_list = B_TRUE; #ifdef DEBUG if (nvlist_add_string(attr_list, TAPEALERT_SRC_FILE, src_fn)) { DevLog(DL_DEBUG(12008), TAPEALERT_SRC_FILE, strerror(errno)); goto done; } if (nvlist_add_int32(attr_list, TAPEALERT_SRC_LINE, src_ln)) { DevLog(DL_DEBUG(12008), TAPEALERT_SRC_LINE, strerror(errno)); goto done; } #endif /* DEBUG */ if (nvlist_add_string(attr_list, TAPEALERT_VENDOR, (char *)un->vendor_id)) { DevLog(DL_DEBUG(12008), TAPEALERT_VENDOR, strerror(errno)); goto done; } if (nvlist_add_string(attr_list, TAPEALERT_PRODUCT, (char *)un->product_id)) { DevLog(DL_DEBUG(12008), TAPEALERT_PRODUCT, strerror(errno)); goto done; } if (nvlist_add_string(attr_list, TAPEALERT_USN, (char *)un->serial)) { DevLog(DL_DEBUG(12008), TAPEALERT_USN, strerror(errno)); goto done; } if (nvlist_add_string(attr_list, TAPEALERT_REV, (char *)un->revision)) { DevLog(DL_DEBUG(12008), TAPEALERT_REV, strerror(errno)); goto done; } time(&tm); if (nvlist_add_int32(attr_list, TAPEALERT_TOD, tm)) { DevLog(DL_DEBUG(12008), TAPEALERT_TOD, strerror(errno)); goto done; } if (nvlist_add_int16(attr_list, TAPEALERT_EQ_ORD, un->eq)) { DevLog(DL_DEBUG(12008), TAPEALERT_EQ_ORD, strerror(errno)); goto done; } if (nvlist_add_string(attr_list, TAPEALERT_NAME, un->name)) { DevLog(DL_DEBUG(12008), TAPEALERT_NAME, strerror(errno)); goto done; } if (nvlist_add_byte(attr_list, TAPEALERT_VERSION, un->version)) { DevLog(DL_DEBUG(12008), TAPEALERT_VERSION, strerror(errno)); goto done; } if (nvlist_add_byte(attr_list, TAPEALERT_INQ_TYPE, un->scsi_type)) { DevLog(DL_DEBUG(12008), TAPEALERT_INQ_TYPE, strerror(errno)); goto done; } if (strlen(str = (char *)un->set) < 1) { str = TAPEALERT_EMPTY_STR; } if (nvlist_add_string(attr_list, TAPEALERT_SET, str)) { DevLog(DL_DEBUG(12008), TAPEALERT_SET, strerror(errno)); goto done; } if (nvlist_add_int16(attr_list, TAPEALERT_FSEQ, un->fseq)) { DevLog(DL_DEBUG(12008), TAPEALERT_FSEQ, strerror(errno)); goto done; } if (strlen(str = (char *)un->vsn) < 1) { str = TAPEALERT_EMPTY_STR; } if (nvlist_add_string(attr_list, TAPEALERT_VSN, str)) { DevLog(DL_DEBUG(12008), TAPEALERT_VSN, strerror(errno)); goto done; } if (nvlist_add_int16(attr_list, TAPEALERT_FLAGS_LEN, flags_len)) { DevLog(DL_DEBUG(12008), TAPEALERT_FLAGS_LEN, strerror(errno)); goto done; } if (nvlist_add_uint64(attr_list, TAPEALERT_FLAGS, flags)) { DevLog(DL_DEBUG(12008), TAPEALERT_FLAGS, strerror(errno)); goto done; } /* class, subclass, vendor, publisher, attribute list, event id */ if (sysevent_post_event(TAPEALERT_SE_CLASS, TAPEALERT_SE_SUBCLASS, TAPEALERT_SE_VENDOR, TAPEALERT_SE_PUBLISHER, attr_list, &eid) != 0) { DevLog(DL_DEBUG(12008), TAPEALERT_SE_PUBLISHER, strerror(errno)); goto done; } *seq_no = eid.eid_seq; /* * tapealert sysevent successfully sent. */ rtn = 0; done: if (free_attr_list == B_TRUE) { nvlist_free(attr_list); } return (rtn); }