diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-08-29 07:20:50 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-08-29 07:20:50 +0000 |
| commit | e051f8e9cbe4475ef1e18a888100054575268d63 (patch) | |
| tree | 51c2f8bf137bf340ee52b351d34291678320ab67 /frontends/php/include/items.inc.php | |
| parent | c447c7bdc5033fd351706a16ceddda7f0c505c3e (diff) | |
- group functions for item manipulations (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@2005 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/items.inc.php')
| -rw-r--r-- | frontends/php/include/items.inc.php | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index 796bb2b2..e44c66e1 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -19,6 +19,56 @@ **/ ?> <?php + # Update Item definition for selected group + + function update_item_in_group($groupid,$itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends) + { + $sql="select i.itemid,i.hostid from hosts_groups hg,items i where hg.groupid=$groupid and i.key_=\"$key\" and hg.hostid=i.hostid"; + $result=DBexecute($sql); + while($row=DBfetch($result)) + { + update_item($row["itemid"],$description,$key,$row["hostid"],$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends); + } + return 1; + } + + # Delete Item definition from selected group + + function delete_item_from_group($groupid,$itemid) + { + if(!isset($itemid)) + { + return 0; + } + + $item=get_item_by_itemid($itemid); + if(!$item) + { + return 0; + } + + $sql="select i.itemid from hosts_groups hg,items i where hg.groupid=$groupid and i.key_=\"".$item["key_"]."\" and hg.hostid=i.hostid"; + $result=DBexecute($sql); + while($row=DBfetch($result)) + { + delete_item($row["itemid"]); + } + return 1; + } + + # Add Item definition to selected group + + function add_item_to_group($groupid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends) + { + $sql="select hostid from hosts_groups where groupid=$groupid"; + $result=DBexecute($sql); + while($row=DBfetch($result)) + { + add_item($description,$key,$row["hostid"],$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends); + } + return 1; + } + # Add Item definition function add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends) @@ -29,11 +79,13 @@ return 0; } + $host=get_host_by_hostid($hostid); + $sql="select count(*) from items where hostid=$hostid and key_='$key'"; $result=DBexecute($sql); if(DBget_field($result,0,0)>0) { - error("An item with the same Key already exists for this host. The key must be unique."); + error("An item with the same Key already exists for host ".$host["host"].". The key must be unique."); return 0; } @@ -125,7 +177,8 @@ $result=DBexecute($sql); if($result) { - info("Item $key updated"); + $host=get_host_by_hostid($hostid); + info("Item ".$host["host"].":$key updated"); } return $result; } @@ -264,11 +317,13 @@ { return $result; } + $item=get_item_by_itemid($itemid); + $host=get_host_by_hostid($item["hostid"]); $sql="delete from items where itemid=$itemid"; $result=DBexecute($sql); if($result) { - info("Item $key deleted"); + info("Item ".$host["host"].":".$item["key_"]." deleted"); } return $result; } |
