--- watchdog.old 2016-12-21 09:08:40.000000000 +0100 +++ watchdog.c 2017-01-31 13:26:26.274896489 +0100 @@ -28,7 +28,9 @@ #include "../alerter/alerter.h" #include "watchdog.h" - +/* ZBXNEXT-970 */ +#include +/* ZBXNEXT-970 */ #define STR_REPLACE(str1, str2) if (NULL == str1 || 0 != strcmp(str1, str2)) str1 = zbx_strdup(str1, str2) #define ALERT_FREQUENCY (15 * SEC_PER_MIN) @@ -156,7 +158,30 @@ STR_REPLACE(recipient->alert.sendto, row[16]); if (NULL == recipient->alert.subject) - recipient->alert.message = recipient->alert.subject = zbx_strdup(NULL, "Zabbix database is down."); + { + /* ZBXNEXT-970 */ + struct utsname buffer; + char serverName[128] = "localhost"; + if (uname(&buffer) != 0) + { + zabbix_log(LOG_LEVEL_WARNING, "In %s() Recover uname ERROR", __function_name); + } + else + { + zbx_snprintf(serverName,128, "%s", buffer.nodename); + zabbix_log(LOG_LEVEL_DEBUG, "In %s() serverName=%s", __function_name,serverName); + } + char subject[256] = ""; + zbx_snprintf(subject, 256, "Zabbix on %s : database %s is not available.",serverName, CONFIG_DBNAME); + zabbix_log(LOG_LEVEL_DEBUG, "In %s() subject=%s", __function_name,subject); + recipient->alert.subject = zbx_strdup(NULL, subject); + + char message[1024] = ""; + zbx_snprintf(message, 1024, "Zabbix on %s : database %s is not available.\nDatabase host: %s\nDatabase port: %d\n",serverName,CONFIG_DBNAME,CONFIG_DBHOST,CONFIG_DBPORT); + zabbix_log(LOG_LEVEL_DEBUG, "In %s() message=%s", __function_name,message); + recipient->alert.message = zbx_strdup(NULL, message); + /* ZBXNEXT-970 */ + } count++; }