From 2bc8e9fcdad98cfc5edea775de1d8860ecebf48e Mon Sep 17 00:00:00 2001 From: hugetoad Date: Thu, 18 Jul 2002 18:17:14 +0000 Subject: - empty result for DBselect is always checked (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@435 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- src/zabbix_sucker/zabbix_sucker.c | 70 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/zabbix_sucker/zabbix_sucker.c b/src/zabbix_sucker/zabbix_sucker.c index 78eff4cb..5d9320fd 100644 --- a/src/zabbix_sucker/zabbix_sucker.c +++ b/src/zabbix_sucker/zabbix_sucker.c @@ -813,6 +813,13 @@ int housekeeping_alerts(int now) sprintf(sql,"select alert_history from config"); result = DBselect(sql); + if(DBis_empty(result) == SUCCEED) + { + zabbix_log( LOG_LEVEL_ERR, "No records in table 'config'."); + DBfree_result(result); + exit (FAIL); + } + alert_history=atoi(DBget_field(result,0,0)); sprintf (sql,"delete from alerts where clock<%d",now-24*3600*alert_history); @@ -830,6 +837,12 @@ int housekeeping_alarms(int now) sprintf(sql,"select alarm_history from config"); result = DBselect(sql); + if(DBis_empty(result) == SUCCEED) + { + zabbix_log( LOG_LEVEL_ERR, "No records in table 'config'."); + DBfree_result(result); + exit (FAIL); + } alarm_history=atoi(DBget_field(result,0,0)); @@ -862,6 +875,12 @@ int main_alerter_loop() sprintf(sql,"select smtp_server,smtp_helo,smtp_email from config"); result = DBselect(sql); + if(DBis_empty(result) == SUCCEED) + { + zabbix_log( LOG_LEVEL_ERR, "No records in table 'config'."); + DBfree_result(result); + exit (FAIL); + } strncpy(smtp_server,DBget_field(result,0,0), MAX_STRING_LEN); strncpy(smtp_helo,DBget_field(result,0,1), MAX_STRING_LEN); strncpy(smtp_email,DBget_field(result,0,2), MAX_STRING_LEN); @@ -870,37 +889,40 @@ int main_alerter_loop() sprintf(sql,"select alertid,type,sendto,subject,message,status,retries from alerts where status=0 and retries<3 order by clock"); result = DBselect(sql); - for(i=0;i