diff options
| author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-02-27 08:56:45 +0000 |
|---|---|---|
| committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-02-27 08:56:45 +0000 |
| commit | 30840f8e68b889140cf951f73032e36e8844c465 (patch) | |
| tree | 22879c6d6aaf4e45e6c753972014afbffeb768a2 /src/zabbix_proxy | |
| parent | c228c7b2c9ea0b4d0e65295e47992b1e559447fc (diff) | |
| download | zabbix-30840f8e68b889140cf951f73032e36e8844c465.tar.gz zabbix-30840f8e68b889140cf951f73032e36e8844c465.tar.xz zabbix-30840f8e68b889140cf951f73032e36e8844c465.zip | |
- [DEV-110] Proxy changes
git-svn-id: svn://svn.zabbix.com/trunk@5407 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_proxy')
| -rw-r--r-- | src/zabbix_proxy/housekeeper/housekeeper.c | 214 |
1 files changed, 6 insertions, 208 deletions
diff --git a/src/zabbix_proxy/housekeeper/housekeeper.c b/src/zabbix_proxy/housekeeper/housekeeper.c index 3e0c66ec..f523da31 100644 --- a/src/zabbix_proxy/housekeeper/housekeeper.c +++ b/src/zabbix_proxy/housekeeper/housekeeper.c @@ -26,176 +26,6 @@ /****************************************************************************** * * - * Function: housekeeping_process_log * - * * - * Purpose: process table 'housekeeper' and remove data if required * - * * - * Parameters: * - * * - * Return value: SUCCEED - information removed succesfully * - * FAIL - otherwise * - * * - * Author: Alexei Vladishev * - * * - * Comments: * - * * - ******************************************************************************/ -/* -static int housekeeping_process_log() -{ - DB_HOUSEKEEPER housekeeper; - - DB_RESULT result; - DB_ROW row; - int res = SUCCEED; - - long records; - - zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_process_log()"); - -*/ /* order by tablename to effectively use DB cache *//* - result = DBselect("select housekeeperid, tablename, field, value from housekeeper order by tablename"); - - while((row=DBfetch(result))) - { - ZBX_STR2UINT64(housekeeper.housekeeperid,row[0]); - housekeeper.tablename=row[1]; - housekeeper.field=row[2]; - ZBX_STR2UINT64(housekeeper.value,row[3]); - -#ifdef HAVE_ORACLE - records = DBexecute("delete from %s where %s=" ZBX_FS_UI64 " and rownum<500", - housekeeper.tablename, - housekeeper.field, - housekeeper.value); -#elif defined(HAVE_POSTGRESQL) - records = DBexecute("delete from %s where oid in (select oid from %s where %s=" ZBX_FS_UI64 " limit 500)", - housekeeper.tablename, - housekeeper.tablename, - housekeeper.field, - housekeeper.value); -#else - records = DBexecute("delete from %s where %s=" ZBX_FS_UI64 " limit 500", - housekeeper.tablename, - housekeeper.field, - housekeeper.value); -#endif - if(records == 0) - { - DBexecute("delete from housekeeper where housekeeperid=" ZBX_FS_UI64, - housekeeper.housekeeperid); - } - else - { - zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [%s]", - records, - housekeeper.tablename); - } - } - DBfree_result(result); - - return res; -} - - -static int housekeeping_sessions(int now) -{ - int records; - - zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_sessions(%d)", - now); - - records = DBexecute("delete from sessions where lastaccess<%d", - now-24*3600); - - zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [sessions]", - records); - - return SUCCEED; -} - -static int housekeeping_alerts(int now) -{ - int alert_history; - DB_RESULT result; - DB_ROW row; - int res = SUCCEED; - int records; - - zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_alerts(%d)", - now); - - result = DBselect("select alert_history from config"); - - row=DBfetch(result); - - if(!row || DBis_null(row[0])==SUCCEED) - { - zabbix_log( LOG_LEVEL_ERR, "No records in table 'config'."); - res = FAIL; - } - else - { - alert_history=atoi(row[0]); - - records = DBexecute("delete from alerts where clock<%d", - now-24*3600*alert_history); - zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [alerts]", - records); - } - - DBfree_result(result); - return res; -} - -static int housekeeping_events(int now) -{ - int event_history; - DB_RESULT result; - DB_RESULT result2; - DB_ROW row1; - DB_ROW row2; - zbx_uint64_t eventid; - int res = SUCCEED; - - zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_events(%d)", - now); - - result = DBselect("select event_history from config"); - - row1=DBfetch(result); - - if(!row1 || DBis_null(row1[0])==SUCCEED) - { - zabbix_log( LOG_LEVEL_ERR, "No records in table 'config'."); - res = FAIL; - } - else - { - event_history=atoi(row1[0]); - - result2 = DBselect("select eventid from events where clock<%d", - now-24*3600*event_history); - while((row2=DBfetch(result2))) - { - ZBX_STR2UINT64(eventid,row2[0]); - - DBexecute("delete from acknowledges where eventid=" ZBX_FS_UI64, - eventid); - - DBexecute("delete from events where eventid=" ZBX_FS_UI64, - eventid); - } - DBfree_result(result2); - - } - - DBfree_result(result); - return res; -} -*/ -/****************************************************************************** - * * * Function: delete_history * * * * Purpose: remove outdated information from historical table * @@ -215,14 +45,11 @@ static int delete_history(const char *table, const char *fieldname, int now) DB_ROW row; int minclock, records = 0; zbx_uint64_t lastid; -/* double sec;*/ zabbix_log(LOG_LEVEL_DEBUG, "In delete_history() [table:%s] [now:%d]", table, now); -/* sec = zbx_time();*/ - DBbegin(); result = DBselect("select %s from proxies", @@ -249,17 +76,6 @@ static int delete_history(const char *table, const char *fieldname, int now) lastid, MIN(now - CONFIG_PROXY_LOCAL_BUFFER * 3600, minclock + 4 * CONFIG_HOUSEKEEPING_FREQUENCY * 3600)); -/* zabbix_log(LOG_LEVEL_DEBUG, "----- [table:%s] [now:%d] [lastid:" ZBX_FS_UI64 "] [minclock:%d] [offline:%d] [24h:%d] [maxdeleted:%d] [%d] [seconds:%f]", - table, - now, - lastid, - minclock, - now - CONFIG_PROXY_OFFLINE_BUFFER * 3600, - now - CONFIG_PROXY_LOCAL_BUFFER * 3600, - minclock + 4 * CONFIG_HOUSEKEEPING_FREQUENCY * 3600, - records, - zbx_time() - sec);*/ - DBcommit(); return records; @@ -306,6 +122,7 @@ int main_housekeeper_loop() { int records; int start, sleeptime; + double sec; if (CONFIG_DISABLE_HOUSEKEEPING == 1) { zbx_setproctitle("housekeeper [disabled]"); @@ -325,33 +142,14 @@ int main_housekeeper_loop() zbx_setproctitle("housekeeper [removing old history]"); - records = housekeeping_history(start); - - zabbix_log(LOG_LEVEL_WARNING, "Deleted %d records from history", - records); - -/* zbx_setproctitle("housekeeper [removing old history]"); - - housekeeping_process_log(start); + sec = zbx_time(); - zbx_setproctitle("housekeeper [removing old events]"); - - housekeeping_events(start); - - zbx_setproctitle("housekeeper [removing old alerts]"); - - housekeeping_alerts(start); - - zbx_setproctitle("housekeeper [removing old sessions]"); - - housekeeping_sessions(start);*/ - - zbx_setproctitle("housekeeper [vacuuming database]"); + records = housekeeping_history(start); -/* Transaction is not required here. It causes timeouts under MySQL */ -/* DBcommit();*/ + zabbix_log(LOG_LEVEL_WARNING, "Deleted %d records from history [%f seconds]", + records, + zbx_time() - sec); - DBvacuum(); DBclose(); sleeptime = CONFIG_HOUSEKEEPING_FREQUENCY * 3600 - (time(NULL) - start); |
