682 return;
683
684 buf[j++] = msg[i++];
685 for (i = 1; i < strlen(msg); i++) {
686 if (!(msg[i] == '\n' && msg[i - 1] == '\n'))
687 buf[j++] = msg[i];
688 }
689 buf[j] = '\0';
690 (void) strncpy(msg, buf, j+1);
691 free(buf);
692 }
693
694 /*ARGSUSED*/
695 static void
696 listev_cb(fmev_t ev, const char *class, nvlist_t *nvl, void *arg)
697 {
698 char *body = NULL, *headers = NULL;
699 nd_ev_info_t *ev_info = NULL;
700 boolean_t domsg;
701 email_pref_t *eprefs;
702
703 nd_debug(nhdl, "Received event of class %s", class);
704
705 if (get_email_prefs(nhdl, ev, &eprefs) < 0)
706 return;
707
708 if (nd_get_event_info(nhdl, class, ev, &ev_info) != 0)
709 goto listcb_done;
710
711 /*
712 * If the message payload member is set to 0, then it's an event we
713 * typically suppress messaging on, so we won't send an email for it.
714 */
715 if (nvlist_lookup_boolean_value(ev_info->ei_payload, FM_SUSPECT_MESSAGE,
716 &domsg) == 0 && !domsg) {
717 nd_debug(nhdl, "Messaging suppressed for this event");
718 goto listcb_done;
719 }
720
721 /*
722 * If the user specified a template, then we pass it through a script,
723 * which post-processes any expansion macros. Then we attempt to read
724 * it in and then send the message. Otherwise we carry on with the rest
725 * of this function which will contruct the message body from one of the
726 * default templates.
727 */
728 if (eprefs->ep_template != NULL)
729 free(eprefs->ep_template);
730
731 if (eprefs->ep_template_path != NULL &&
732 process_template(ev_info, eprefs) == 0) {
733 send_email_template(nhdl, ev_info, eprefs);
734 goto listcb_done;
735 }
736
|
682 return;
683
684 buf[j++] = msg[i++];
685 for (i = 1; i < strlen(msg); i++) {
686 if (!(msg[i] == '\n' && msg[i - 1] == '\n'))
687 buf[j++] = msg[i];
688 }
689 buf[j] = '\0';
690 (void) strncpy(msg, buf, j+1);
691 free(buf);
692 }
693
694 /*ARGSUSED*/
695 static void
696 listev_cb(fmev_t ev, const char *class, nvlist_t *nvl, void *arg)
697 {
698 char *body = NULL, *headers = NULL;
699 nd_ev_info_t *ev_info = NULL;
700 boolean_t domsg;
701 email_pref_t *eprefs;
702 uint32_t size;
703
704 nd_debug(nhdl, "Received event of class %s", class);
705
706 if (get_email_prefs(nhdl, ev, &eprefs) < 0)
707 return;
708
709 if (nd_get_event_info(nhdl, class, ev, &ev_info) != 0)
710 goto listcb_done;
711
712 /*
713 * If the message payload member is set to 0, then it's an event we
714 * typically suppress messaging on, so we won't send an email for it.
715 */
716 if (nvlist_lookup_boolean_value(ev_info->ei_payload,
717 FM_SUSPECT_MESSAGE, &domsg) != 0)
718 domsg = 1;
719
720 if (nvlist_lookup_uint32(ev_info->ei_payload, FM_SUSPECT_FAULT_SZ,
721 &size) != 0)
722 size = 0;
723
724 if (domsg && size != 0) {
725 /*
726 * Only send mail if there are suspects believed to be faulty
727 * still present.
728 */
729 uint8_t *status;
730 if (nvlist_lookup_uint8_array(nvl, FM_SUSPECT_FAULT_STATUS,
731 &status, &size) == 0) {
732 boolean_t any_faulty = 0;
733 for (int i = 0; i < size; i++) {
734 if (status[i] & FM_SUSPECT_FAULTY) {
735 any_faulty = 1;
736 break;
737 }
738 }
739 if (!any_faulty)
740 domsg = 0;
741 }
742 }
743
744 if (!domsg) {
745 nd_debug(nhdl, "Messaging suppressed for this event");
746 goto listcb_done;
747 }
748
749 /*
750 * If the user specified a template, then we pass it through a script,
751 * which post-processes any expansion macros. Then we attempt to read
752 * it in and then send the message. Otherwise we carry on with the rest
753 * of this function which will contruct the message body from one of the
754 * default templates.
755 */
756 if (eprefs->ep_template != NULL)
757 free(eprefs->ep_template);
758
759 if (eprefs->ep_template_path != NULL &&
760 process_template(ev_info, eprefs) == 0) {
761 send_email_template(nhdl, ev_info, eprefs);
762 goto listcb_done;
763 }
764
|