diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-02-22 16:08:35 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-02-22 16:08:35 +0000 |
| commit | cfdccc6dd4f9d313f6cdc34f62f6453a1f5a1a0b (patch) | |
| tree | f1c9d0192496011e899f91dd9575db73d5cfc77a /frontends/php | |
| parent | 1e241634d9beb1dc6368d270f8be45d158c66a18 (diff) | |
| download | zabbix-cfdccc6dd4f9d313f6cdc34f62f6453a1f5a1a0b.tar.gz zabbix-cfdccc6dd4f9d313f6cdc34f62f6453a1f5a1a0b.tar.xz zabbix-cfdccc6dd4f9d313f6cdc34f62f6453a1f5a1a0b.zip | |
- added hosekeeper support for frontend (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2675 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/hosts.php | 3 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 42 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 121 | ||||
| -rw-r--r-- | frontends/php/include/graphs.inc.php | 10 | ||||
| -rw-r--r-- | frontends/php/include/hosts.inc.php | 36 | ||||
| -rw-r--r-- | frontends/php/include/items.inc.php | 12 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/maps.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/items.php | 29 |
10 files changed, 125 insertions, 136 deletions
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index 43bba517..ff9cbef6 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -167,11 +167,12 @@ $db_hosts=DBselect("select hostid from hosts"); while($db_host=DBfetch($db_hosts)) { + $host=get_host_by_hostid($db_host["hostid"]); + if(!in_array($db_host["hostid"],$hosts)) continue; if(!delete_host($db_host["hostid"])) continue; $result = 1; - $host=get_host_by_hostid($db_host["hostid"]); add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST, "Host [".$host["host"]."]"); } diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 94d8c77f..8d82fefe 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -1553,20 +1553,39 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!! # Delete from History - function delete_history_by_itemid( $itemid ) + function delete_history_by_itemid($itemid, $use_housekeeper=0) { - $sql="delete from history_str where itemid=$itemid"; - DBexecute($sql); - $sql="delete from history where itemid=$itemid"; - return DBexecute($sql); + $result = delete_trends_by_itemid($itemid,$use_housekeeper); + if(!$result) return $result; + + if($use_housekeeper) + { + DBexecute("insert into housekeeper (tablename,field,value)". + " values ('history_uint','itemid',$itemid)"); + DBexecute("insert into housekeeper (tablename,field,value)". + " values ('history_str','itemid',$itemid)"); + DBexecute("insert into housekeeper (tablename,field,value)". + " values ('history','itemid',$itemid)"); + return TRUE; + } + + DBexecute("delete from history_uint where itemid=$itemid"); + DBexecute("delete from history_str where itemid=$itemid"); + DBexecute("delete from history where itemid=$itemid"); + return TRUE; } # Delete from Trends - function delete_trends_by_itemid( $itemid ) + function delete_trends_by_itemid($itemid, $use_housekeeper=0) { - $sql="delete from trends where itemid=$itemid"; - return DBexecute($sql); + if($use_housekeeper) + { + DBexecute("insert into housekeeper (tablename,field,value)". + " values ('trends','itemid',$itemid)"); + return TRUE; + } + return DBexecute("delete from trends where itemid=$itemid"); } # Add alarm @@ -2961,4 +2980,11 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!! } return $value; } + + function Alert($msg) + { + echo "<script language=\"JavaScript\" type=\"text/javascript\">"; + echo "alert('$msg');"; + echo "</script>"; + } ?> diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 058a2a73..b32e5338 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -25,8 +25,8 @@ // $DB_TYPE ="POSTGRESQL"; $DB_TYPE ="MYSQL"; $DB_SERVER ="localhost"; - $DB_DATABASE ="zabbix"; -// $DB_DATABASE ="osmiy"; +// $DB_DATABASE ="zabbix"; + $DB_DATABASE ="osmiy"; $DB_USER ="root"; $DB_PASSWORD =""; // END OF DATABASE CONFIGURATION diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 8f680673..7b6b05f0 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -23,101 +23,6 @@ include_once "include/db.inc.php"; // include_once "include/local_en.inc.php"; - # Insert host template form - function insert_template_form() - { - global $_REQUEST; - - $frmTemplate = new CFormTable(S_TEMPLATE,'hosts.php'); - $frmTemplate->SetHelp('web.hosts.php'); - $frmTemplate->AddVar('config',$_REQUEST["config"]); - - if(isset($_REQUEST["hosttemplateid"])) - { - $frmTemplate->AddVar('hosttemplateid',$_REQUEST["hosttemplateid"]); - } - - if(isset($_REQUEST["hosttemplateid"]) && !isset($_REQUEST["form_refresh"])) - { - $result=DBselect("select * from hosts_templates". - " where hosttemplateid=".$_REQUEST["hosttemplateid"]); - $row=DBfetch($result); - - $hostid = $row["hostid"]; - $templateid = $row["templateid"]; - - $items = array(); - if(1 & $row["items"]) array_push($items,1); - if(2 & $row["items"]) array_push($items,2); - if(4 & $row["items"]) array_push($items,4); - - $triggers= array(); - if(1 & $row["triggers"]) array_push($triggers,1); - if(2 & $row["triggers"]) array_push($triggers,2); - if(4 & $row["triggers"]) array_push($triggers,4); - - $graphs= array(); - if(1 & $row["graphs"]) array_push($graphs,1); - if(2 & $row["graphs"]) array_push($graphs,2); - if(4 & $row["graphs"]) array_push($graphs,4); - } - else - { - $hostid = get_request("hostid",0); - $templateid = get_request("templateid",0); - - $items = get_request("items",array(1,2,4)); - $triggers = get_request("triggers",array(1,2,4)); - $graphs = get_request("graphs",array(1,2,4)); - } - if($hostid!=0){ - $host = get_host_by_hostid($hostid); - $frmTemplate->AddVar('hostid',$hostid); - } - - if($templateid!=0) - $template= get_host_by_hostid($templateid); - - $cmbTemplate = new CComboBox('templateid',$templateid); - $hosts=DBselect("select hostid,host from hosts order by host"); - while($host=DBfetch($hosts)) - $cmbTemplate->AddItem($host["hostid"],$host["host"]); - - $frmTemplate->AddRow(S_TEMPLATE,$cmbTemplate); - - $frmTemplate->AddRow(S_ITEMS,array( - new CCheckBox('items[]', in_array(1,$items)?'yes':'no', S_ADD, NULL, 1), - new CCheckBox('items[]', in_array(2,$items)?'yes':'no', S_UPDATE,NULL, 2), - new CCheckBox('items[]', in_array(4,$items)?'yes':'no', S_DELETE,NULL, 4) - )); - - $frmTemplate->AddRow(S_TRIGGERS,array( - new CCheckBox('triggers[]', in_array(1,$triggers)?'yes':'no',S_ADD, NULL, 1), - new CCheckBox('triggers[]', in_array(2,$triggers)?'yes':'no',S_UPDATE,NULL, 2), - new CCheckBox('triggers[]', in_array(4,$triggers)?'yes':'no',S_DELETE,NULL, 4), - )); - - $frmTemplate->AddRow(S_GRAPHS,array( - new CCheckBox('graphs[]', in_array(1,$graphs)?'yes':'no', S_ADD, NULL, 1), - new CCheckBox('graphs[]', in_array(2,$graphs)?'yes':'no', S_UPDATE,NULL, 2), - new CCheckBox('graphs[]', in_array(4,$graphs)?'yes':'no', S_DELETE,NULL, 4), - )); - - $frmTemplate->AddItemToBottomRow(new CButton('save',S_SAVE)); - if(isset($_REQUEST["hosttemplateid"])) - { - $frmTemplate->AddItemToBottomRow(SPACE); - $frmTemplate->AddItemToBottomRow(new CButtonDelete('Delete selected linkage?', - url_param("form").url_param("config").url_param("hostid"). - url_param("hosttemplateid"))); - } else { - } - $frmTemplate->AddItemToBottomRow(SPACE); - $frmTemplate->AddItemToBottomRow(new CButtonCancel(url_param("config").url_param("hostid"))); - - $frmTemplate->Show(); - } - # Insert form for User function insert_user_form($userid,$profile=0) { @@ -330,7 +235,7 @@ $snmp_community = get_request("snmp_community" ,"public"); $snmp_oid = get_request("snmp_oid" ,"interfaces.ifTable.ifEntry.ifInOctets.1"); $snmp_port = get_request("snmp_port" ,161); - $value_type = get_request("value_type" ,0); + $value_type = get_request("value_type" ,ITEM_VALUE_TYPE_UINT64); $trapper_hosts = get_request("trapper_hosts" ,""); $units = get_request("units" ,''); $valuemapid = get_request("valuemapid" ,0); @@ -461,6 +366,13 @@ $frmItem->AddRow(S_KEY, new CTextBox("key",$key,40)); + $cmbValType = new CComboBox("value_type",$value_type,"submit()"); + $cmbValType->AddItem(ITEM_VALUE_TYPE_UINT64, S_NUMERIC_UINT64); + $cmbValType->AddItem(ITEM_VALUE_TYPE_FLOAT, S_NUMERIC_FLOAT); + $cmbValType->AddItem(ITEM_VALUE_TYPE_STR, S_CHARACTER); + $cmbValType->AddItem(ITEM_VALUE_TYPE_LOG, S_LOG); + $frmItem->AddRow(S_TYPE_OF_INFORMATION,$cmbValType); + if( ($value_type==ITEM_VALUE_TYPE_FLOAT) || ($value_type==ITEM_VALUE_TYPE_UINT64)) { $frmItem->AddRow(S_UNITS, new CTextBox("units",$units,40)); @@ -493,7 +405,13 @@ $frmItem->AddVar("delay",$delay); } - $frmItem->AddRow(S_KEEP_HISTORY_IN_DAYS, new CTextBox("history",$history,8)); + $frmItem->AddRow(S_KEEP_HISTORY_IN_DAYS, array( + new CTextBox("history",$history,8), + (!isset($_REQUEST["itemid"])) ? NULL : + new CButton("del_history", + "Clean history", + "return Confirm('History cleaning can take a long time. Continue?');") + )); $frmItem->AddRow(S_KEEP_TRENDS_IN_DAYS, new CTextBox("trends",$trends,8)); $cmbStatus = new CComboBox("status",$status); @@ -503,13 +421,6 @@ $cmbStatus->AddItem(3,S_NOT_SUPPORTED); $frmItem->AddRow(S_STATUS,$cmbStatus); - $cmbValType = new CComboBox("value_type",$value_type,"submit()"); - $cmbValType->AddItem(ITEM_VALUE_TYPE_FLOAT, S_NUMERIC_FLOAT); - $cmbValType->AddItem(ITEM_VALUE_TYPE_UINT64, S_NUMERIC_UINT64); - $cmbValType->AddItem(ITEM_VALUE_TYPE_STR, S_CHARACTER); - $cmbValType->AddItem(ITEM_VALUE_TYPE_LOG, S_LOG); - $frmItem->AddRow(S_TYPE_OF_INFORMATION,$cmbValType); - if($value_type==ITEM_VALUE_TYPE_LOG) { $frmItem->AddRow(S_LOG_TIME_FORMAT, new CTextBox("logtimefmt",$logtimefmt,16)); @@ -2070,7 +1981,7 @@ $cmbStatus = new CComboBox("status",$status); $cmbStatus->AddItem(HOST_STATUS_MONITORED, S_MONITORED); - $cmbStatus->AddItem(HOST_STATUS_TEMPLATE, S_TEMPLATE); +// $cmbStatus->AddItem(HOST_STATUS_TEMPLATE, S_TEMPLATE); $cmbStatus->AddItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED); $frmHost->AddRow(S_STATUS,$cmbStatus); } diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index fffeee25..a27402ae 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -65,6 +65,16 @@ return $result; } + function get_graphitem_by_itemid($itemid) + { + $result=DBselect("select * from graphs_items where itemid=$itemid"); + if(DBnum_rows($result) == 1) + { + return DBfetch($result); + } + return $result; + } + function get_graph_by_graphid($graphid) { diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index 83b84ed4..1763b364 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -278,22 +278,32 @@ $ret = FALSE; - for($i=0;$i<100;$i++) + // delete items -> triggers -> graphs + $db_items = get_items_by_hostid($hostid); + while($db_item = DBfetch($db_items)) { - if($DB_TYPE=="MYSQL") - { - $sql="update hosts set status=".HOST_STATUS_DELETED.",host=concat(host,\" [DEL$i]\") where hostid=$hostid"; - } - else - { - $sql="update hosts set status=".HOST_STATUS_DELETED.",host=host||' [DEL$i]' where hostid=$hostid"; - } - if($ret = DBexecute($sql,1)) break; + delete_item($db_item["itemid"]); } - if($ret){ - delete_host_profile($hostid); + + // delete host from maps + delete_sysmaps_host_by_hostid($hostid); + + // delete host from group + DBexecute("delete from hosts_groups where hostid=$hostid"); + + // unlink child hosts + $db_childs = get_hosts_by_templateid($hostid); + while($db_child = DBfetch($db_childs)) + { + DBexecute("update hosts set templateid=0 where hostid=".$db_child["hostid"]); + sync_host_with_templates($hostid); } - return $ret; + + // delete host profile + delete_host_profile($hostid); + + // delete host + return DBexecute("delete from hosts where hostid=$hostid"); } function delete_host_group($groupid) diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index 3cf7dfc7..2d080f4c 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -378,14 +378,16 @@ $result = delete_triggers_by_itemid($itemid); if(!$result) return $result; - $result = delete_trends_by_itemid($itemid); - if(!$result) return $result; + $db_gitems = get_graphitem_by_itemid($itemid); + while($db_gitem = DBfetch($db_gitems)) + { + $result = delete_graph_by_itemid($db_gitem["graphid"]); + if(!$result) return $result; + } - $result = delete_history_by_itemid($itemid); + $result = delete_history_by_itemid($itemid, 1 /* use housekeeper */); if(!$result) return $result; - $result = DBexecute("delete from graphs_items where itemid=$itemid"); - if(!$result) return $result; $result = DBexecute("delete from items where itemid=$itemid"); if($result) diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index a7f320bd..303c3979 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -403,6 +403,8 @@ "S_HOSTS"=> "Hosts", // items.php + "S_HISTORY_CLEANED"=> "History cleaned", + "S_CANNOT_CLEAN_HISTORY"=> "Cannot clean history", "S_CONFIGURATION_OF_ITEMS"=> "Configuration of items", "S_CONFIGURATION_OF_ITEMS_BIG"=> "CONFIGURATION OF ITEMS", "S_CANNOT_UPDATE_ITEM"=> "Cannot update item", diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php index 5937d35f..c35bc044 100644 --- a/frontends/php/include/maps.inc.php +++ b/frontends/php/include/maps.inc.php @@ -136,7 +136,7 @@ $result=DBselect($sql); while($row=DBfetch($result)) { - $sql="delete from sysmaps_links where shostid1=".$row["shostid"]." or shostid2".$row["shostid"]; + $sql="delete from sysmaps_links where shostid1=".$row["shostid"]." or shostid2=".$row["shostid"]; DBexecute($sql); } $sql="delete from sysmaps_hosts where hostid=$hostid"; diff --git a/frontends/php/items.php b/frontends/php/items.php index b8c54ca6..2b6b8672 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -78,6 +78,8 @@ "group_itemid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), + "del_history"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + "register"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), "group_task"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), @@ -144,6 +146,17 @@ unset($_REQUEST["form"]); } } + elseif(isset($_REQUEST["del_history"])&&isset($_REQUEST["itemid"])) + { + $result = delete_history_by_itemid($_REQUEST["itemid"]); + if($result) + { + DBexecute("update items set nextcheck=null,lastvalue=null,". + "lastclock=null,prevvalue=null where itemid=".$_REQUEST["itemid"]); + } + show_messages($result, S_HISTORY_CLEANED, S_CANNOT_CLEAN_HISTORY); + + } elseif(isset($_REQUEST["register"])) { if($_REQUEST["register"]=="do") @@ -249,7 +262,7 @@ } show_messages(TRUE, S_ITEMS_ACTIVATED, S_CANNOT_ACTIVATE_ITEMS); } - if($_REQUEST["group_task"]=="Disable selected") + elseif($_REQUEST["group_task"]=="Disable selected") { $group_itemid = $_REQUEST["group_itemid"]; foreach($group_itemid as $id) @@ -258,6 +271,17 @@ } show_messages(TRUE, S_ITEMS_DISABLED, S_CANNOT_DISABLE_ITEMS); } + elseif($_REQUEST["group_task"]=="Clean history") + { + $group_itemid = $_REQUEST["group_itemid"]; + foreach($group_itemid as $id) + { + delete_history_by_itemid($id); + DBexecute("update items set nextcheck=null,lastvalue=null,". + "lastclock=null,prevvalue=null where itemid=$id"); + } + show_messages(TRUE, S_HISTORY_CLEANED, S_CANNOT_CLEAN_HISTORY); + } } ?> @@ -433,6 +457,9 @@ array_push($footerButtons, new CButton('group_task','Disable selected', "return Confirm('".S_DISABLE_SELECTED_ITEMS_Q."');")); array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('group_task','Clean history', + "return Confirm('History cleaning can take a long time. Continue?');")); + array_push($footerButtons, SPACE); array_push($footerButtons, new CButton('group_task','Delete selected', "return Confirm('".S_DELETE_SELECTED_ITEMS_Q."');")); $table->SetFooter(new CCol($footerButtons),'table_footer'); |
