summaryrefslogtreecommitdiffstats
path: root/src/libs/zbxdbhigh/db.c
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-31 11:17:54 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-31 11:17:54 +0000
commitc606a0bad1b26b76bf7a061c329afbc49ff1cd97 (patch)
tree70ea31e3c754d9a91d531befd4ebd974c72abf63 /src/libs/zbxdbhigh/db.c
parented68e5fe0c92a2a620df0116f28c6ef7ceea8df4 (diff)
downloadzabbix-c606a0bad1b26b76bf7a061c329afbc49ff1cd97.tar.gz
zabbix-c606a0bad1b26b76bf7a061c329afbc49ff1cd97.tar.xz
zabbix-c606a0bad1b26b76bf7a061c329afbc49ff1cd97.zip
- improvements to services calculation algorithms (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5564 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxdbhigh/db.c')
-rw-r--r--src/libs/zbxdbhigh/db.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index 998764ad..edf328d9 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -417,40 +417,22 @@ void get_latest_event_status(zbx_uint64_t triggerid, int *prev_status, int *late
/* Rewrite required to simplify logic ?*/
int latest_service_alarm(zbx_uint64_t serviceid, int status)
{
- int clock;
+ int servicealarmid;
DB_RESULT result;
DB_ROW row;
int ret = FAIL;
+ char sql[MAX_STRING_LEN];
+ zbx_snprintf(sql,"select servicealarmid, value from service_alarms where serviceid=" ZBX_FS_UI64 " order by servicealarmid desc",serviceid);
zabbix_log(LOG_LEVEL_DEBUG,"In latest_service_alarm()");
- result = DBselect("select max(clock) from service_alarms where serviceid=" ZBX_FS_UI64,
- serviceid);
+ result = DBselectN(sql,1);
row = DBfetch(result);
- if(!row || DBis_null(row[0])==SUCCEED)
- {
- zabbix_log(LOG_LEVEL_DEBUG, "Result for MAX is empty" );
- ret = FAIL;
+ if(row && (DBis_null(row[1])==FAIL) && (atoi(row[1]) == status)){
+ ret = SUCCEED;
}
- else
- {
- clock=atoi(row[0]);
- DBfree_result(result);
-
- result = DBselect("select value from service_alarms where serviceid=" ZBX_FS_UI64 " and clock=%d",
- serviceid,
- clock);
- row = DBfetch(result);
- if(row && DBis_null(row[0]) != SUCCEED)
- {
- if(atoi(row[0]) == status)
- {
- ret = SUCCEED;
- }
- }
- }
DBfree_result(result);