summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2003-08-24 10:04:51 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2003-08-24 10:04:51 +0000
commit0871955c1bbd573b3a5bd6ae9ce26a8c19c9b274 (patch)
tree2a150e6d3dd2213d82e8a99edbb595faf69301d1 /src
parent889dcc1108b7fe2df9cfdff25a03b26b8e882150 (diff)
downloadzabbix-0871955c1bbd573b3a5bd6ae9ce26a8c19c9b274.tar.gz
zabbix-0871955c1bbd573b3a5bd6ae9ce26a8c19c9b274.tar.xz
zabbix-0871955c1bbd573b3a5bd6ae9ce26a8c19c9b274.zip
Improvements for housekeeper (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@940 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/zabbix_sucker/housekeeper.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/zabbix_sucker/housekeeper.c b/src/zabbix_sucker/housekeeper.c
index 99f7307f..5a98fda4 100644
--- a/src/zabbix_sucker/housekeeper.c
+++ b/src/zabbix_sucker/housekeeper.c
@@ -50,6 +50,24 @@
#include "housekeeper.h"
+/* Remove hosts having status 'deleted' */
+int housekeeping_hosts(int now)
+{
+ char sql[MAX_STRING_LEN+1];
+ DB_RESULT *result;
+ int i,hostid;
+
+ sprintf(sql,"select hostid from hosts where status=%d", HOST_STATUS_DELETED);
+ result = DBselect(sql);
+ for(i=0;i<DBnum_rows(result);i++)
+ {
+ hostid=atoi(DBget_field(result,i,0));
+ DBdelete_host(hostid);
+ }
+ DBfree_result(result);
+ return SUCCEED;
+}
+
int housekeeping_history(int now)
{
char sql[MAX_STRING_LEN+1];
@@ -182,7 +200,10 @@ int main_housekeeper_loop()
#endif
DBconnect(CONFIG_DBHOST, CONFIG_DBNAME, CONFIG_DBUSER, CONFIG_DBPASSWORD, CONFIG_DBSOCKET);
- DBvacuum();
+#ifdef HAVE_FUNCTION_SETPROCTITLE
+ setproctitle("housekeeper [removing deleted hosts]");
+#endif
+ housekeeping_hosts(now);
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("housekeeper [removing old values]");
@@ -204,6 +225,11 @@ int main_housekeeper_loop()
#endif
housekeeping_sessions(now);
+#ifdef HAVE_FUNCTION_SETPROCTITLE
+ setproctitle("housekeeper [vacuuming database]");
+#endif
+ DBvacuum();
+
zabbix_log( LOG_LEVEL_DEBUG, "Sleeping for %d hours", CONFIG_HOUSEKEEPING_FREQUENCY);
#ifdef HAVE_FUNCTION_SETPROCTITLE