Index: include/common.h =================================================================== --- include/common.h (revision 53734) +++ include/common.h (working copy) @@ -397,6 +397,7 @@ MEDIA_TYPE_EXEC, MEDIA_TYPE_SMS, MEDIA_TYPE_JABBER, + MEDIA_TYPE_SYSLOG, MEDIA_TYPE_EZ_TEXTING = 100 } zbx_media_type_t; Index: include/db.h =================================================================== --- include/db.h (revision 53734) +++ include/db.h (working copy) @@ -347,6 +347,7 @@ char *message; zbx_alert_status_t status; int retries; + zbx_uint64_t eventid; } DB_ALERT; Index: src/zabbix_server/alerter/alerter.c =================================================================== --- src/zabbix_server/alerter/alerter.c (revision 53734) +++ src/zabbix_server/alerter/alerter.c (working copy) @@ -34,6 +34,7 @@ extern unsigned char process_type, daemon_type; extern int server_num, process_num; +const char syslog_alert_name[] = "zabbix_event"; /****************************************************************************** * * @@ -120,6 +121,70 @@ zbx_free(cmd); } + else if (MEDIA_TYPE_SYSLOG == mediatype->type) + { + DB_RESULT result; + DB_RESULT result_host; + DB_ROW row, row_host; + int sys_priority; + char messages[MAX_STRING_LEN], *trigger_value, *host; + zbx_uint64_t triggerid; + + result = DBselect( + "select a.eventid, b.description, b.priority, b.value, b.triggerid " + "from events a, triggers b " + "where a.objectid = b.triggerid and a.source=%d and a.eventid=" ZBX_FS_UI64, + EVENT_SOURCE_TRIGGERS, + alert->eventid); + if (NULL == (row = DBfetch(result)) || SUCCEED == DBis_null(row[0])) { + sys_priority = LOG_NOTICE; + zbx_snprintf(messages, sizeof(messages), "%s", alert->message); + } + else { + ZBX_STR2UINT64(triggerid, row[4]); + result_host = DBselect( + "select h.host" + " from hosts h,items i,functions f,triggers t" + " where h.hostid=i.hostid" + " and i.itemid=f.itemid" + " and f.triggerid=t.triggerid" + " and t.triggerid=" ZBX_FS_UI64, triggerid); + if (NULL == (row_host = DBfetch(result_host)) || SUCCEED == DBis_null(row_host[0])) { + host = zbx_dsprintf(NULL, "%s", "unknown"); + } + else { + host = zbx_strdup(host, row_host[0]); + } + + switch(atoi(row[2])) { + case 0: + case 1: + sys_priority = LOG_INFO; + break; + case 2: + sys_priority = LOG_WARNING; + break; + case 3: + sys_priority = LOG_ERR; + break; + case 4: + sys_priority = LOG_ALERT; + break; + case 5: + sys_priority = LOG_EMERG; + break; + } + trigger_value = zbx_strdup(trigger_value, zbx_trigger_value_string((unsigned char)atoi(row[3]))); + zbx_snprintf(messages, sizeof(messages), "%s %s: %s", host, trigger_value, row[1]); + } + openlog(syslog_alert_name, LOG_PID, LOG_DAEMON); + syslog(sys_priority, "%s", messages); + closelog(); + zbx_free(trigger_value); + zbx_free(host); + DBfree_result(result); + DBfree_result(result_host); + } else { zbx_snprintf(error, max_error_len, "unsupported media type [%d]", mediatype->type); @@ -172,7 +237,7 @@ result = DBselect( "select a.alertid,a.mediatypeid,a.sendto,a.subject,a.message,a.status,mt.mediatypeid," "mt.type,mt.description,mt.smtp_server,mt.smtp_helo,mt.smtp_email,mt.exec_path," - "mt.gsm_modem,mt.username,mt.passwd,a.retries" + "mt.gsm_modem,mt.username,mt.passwd,a.retries,a.eventid " " from alerts a,media_type mt" " where a.mediatypeid=mt.mediatypeid" " and a.status=%d" @@ -202,6 +267,7 @@ mediatype.passwd = row[15]; alert.retries = atoi(row[16]); + ZBX_STR2UINT64(alert.eventid, row[17]); *error = '\0'; res = execute_action(&alert, &mediatype, error, sizeof(error));