summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-12-05 14:33:41 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-12-05 14:33:41 +0000
commitec83538f501f0bf482f5780528fda833bdfd48f8 (patch)
treec80cc950b28b08ab7393ce6411b3defa2fa47846 /src/libs
parentb7884e618a8004342df1fc553008eca710e1855c (diff)
downloadzabbix-ec83538f501f0bf482f5780528fda833bdfd48f8.tar.gz
zabbix-ec83538f501f0bf482f5780528fda833bdfd48f8.tar.xz
zabbix-ec83538f501f0bf482f5780528fda833bdfd48f8.zip
- [ZBX-195,DEV-52] fixes for sysmaps on server side(Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5136 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/zbxdbhigh/db.c37
-rw-r--r--src/libs/zbxdbhigh/host.c38
2 files changed, 38 insertions, 37 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index e58869e3..4487d3b8 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -733,10 +733,8 @@ void DBdelete_trigger(zbx_uint64_t triggerid)
DBdelete_services_by_triggerid(triggerid);
- DBexecute("update sysmaps_links set triggerid=NULL where triggerid=" ZBX_FS_UI64,
- triggerid);
- DBexecute("delete from triggers where triggerid=" ZBX_FS_UI64,
- triggerid);
+ DBexecute("delete sysmaps_link_triggers where triggerid=" ZBX_FS_UI64,triggerid);
+ DBexecute("delete from triggers where triggerid=" ZBX_FS_UI64,triggerid);
}
void DBdelete_triggers_by_itemid(zbx_uint64_t itemid)
@@ -779,35 +777,6 @@ void DBdelete_history_by_itemid(zbx_uint64_t itemid)
itemid);
}
-void DBdelete_sysmaps_links_by_shostid(zbx_uint64_t shostid)
-{
- DBexecute("delete from sysmaps_links where shostid1=" ZBX_FS_UI64 " or shostid2=" ZBX_FS_UI64,
- shostid, shostid);
-}
-
-void DBdelete_sysmaps_hosts_by_hostid(zbx_uint64_t hostid)
-{
- zbx_uint64_t shostid;
- DB_RESULT result;
- DB_ROW row;
-
- zabbix_log(LOG_LEVEL_DEBUG,"In DBdelete_sysmaps_hosts(" ZBX_FS_UI64 ")",
- hostid);
- result = DBselect("select shostid from sysmaps_elements where elementid=" ZBX_FS_UI64,
- hostid);
-
- while((row=DBfetch(result)))
- {
- ZBX_STR2UINT64(shostid, row[0]);
-/* shostid=atoi(row[0]);*/
- DBdelete_sysmaps_links_by_shostid(shostid);
- }
- DBfree_result(result);
-
- DBexecute("delete from sysmaps_elements where elementid=" ZBX_FS_UI64,
- hostid);
-}
-
void DBupdate_triggers_status_after_restart(void)
{
int lastchange;
@@ -1531,7 +1500,7 @@ void DBvacuum(void)
{
#ifdef HAVE_POSTGRESQL
char *table_for_housekeeping[]={"services", "services_links", "graphs_items", "graphs", "sysmaps_links",
- "sysmaps_elements", "sysmaps", "config", "groups", "hosts_groups", "alerts",
+ "sysmaps_elements", "sysmaps_link_triggers","sysmaps", "config", "groups", "hosts_groups", "alerts",
"actions", "events", "functions", "history", "history_str", "hosts", "trends",
"items", "media", "media_type", "triggers", "trigger_depends", "users",
"sessions", "rights", "service_alarms", "profiles", "screens", "screens_items",
diff --git a/src/libs/zbxdbhigh/host.c b/src/libs/zbxdbhigh/host.c
index 4a761d65..0c21c43c 100644
--- a/src/libs/zbxdbhigh/host.c
+++ b/src/libs/zbxdbhigh/host.c
@@ -576,7 +576,7 @@ static int DBdelete_services_by_triggerid(
* *
* Parameters: selementid - map element identificator from database *
* *
- * Return value: always SUCCEED *
+ * Return value: always return SUCCEED *
* *
* Author: Eugene Grigorjev *
* *
@@ -587,9 +587,19 @@ static int DBdelete_sysmaps_element(
zbx_uint64_t selementid
)
{
- DBexecute("delete from sysmaps_links"
+ DB_RESULT db_links;
+ DB_ROW link;
+ zbx_uint64_t linkid;
+
+ db_links = DBselect("select linkid from sysmaps_links where "
" where selementid1=" ZBX_FS_UI64 " or selementid2=" ZBX_FS_UI64,
selementid, selementid);
+ while(link = DBfetch(db_links)){
+ ZBX_STR2UINT64(linkid, link[0]);
+ DBdelete_link(linkid);
+ }
+
+ DBfree_result(db_links);
DBexecute("delete from sysmaps_elements where selementid=" ZBX_FS_UI64, selementid);
@@ -641,6 +651,28 @@ static int DBdelete_sysmaps_elements_with_triggerid(
/******************************************************************************
* *
+ * Function: DBdelete_link *
+ * *
+ * Purpose: delete sysmap links from sysmap element *
+ * *
+ * Parameters: linkid - link idientificator from database *
+ * *
+ * Return value: always return SUCCEED *
+ * *
+ * Author: Aly *
+ * *
+ * Comments: !!! Don't forget sync code with PHP !!! *
+ * *
+ ******************************************************************************/
+static int DBdelete_link(zbx_uint64_t linkid){
+
+ DBexecute("DELETE FROM sysmaps_links WHERE linkid=" ZBX_FS_UI64 ,linkid);
+ DBexecute("DELETE FROM sysmaps_link_triggers WHERE linkid=" ZBX_FS_UI64 ,linkid);
+return SUCCEED;
+}
+
+/******************************************************************************
+ * *
* Function: DBdelete_trigger *
* *
* Purpose: delete trigger from database *
@@ -697,7 +729,7 @@ static int DBdelete_trigger(
DBexecute("delete from events where objectid=" ZBX_FS_UI64 " and object=%i", triggerid, EVENT_OBJECT_TRIGGER);
DBexecute("delete from alerts where triggerid=" ZBX_FS_UI64, triggerid);
- DBexecute("update sysmaps_links set triggerid=NULL where triggerid=" ZBX_FS_UI64, triggerid);
+ DBexecute("delete from sysmaps_link_triggers where triggerid=" ZBX_FS_UI64, triggerid);
/* disable actions */
db_elements = DBselect("select distinct actionid from conditions "