diff options
-rwxr-xr-x | create/data/change_nodeid.sh | 37 | ||||
-rw-r--r-- | create/data/data.sql | 30 | ||||
-rw-r--r-- | create/data/nodes.sql | 1 | ||||
-rw-r--r-- | frontends/php/css.css | 6 | ||||
-rw-r--r-- | frontends/php/include/classes/ctag.inc.php | 5 | ||||
-rw-r--r-- | frontends/php/include/classes/ctextbox.inc.php | 6 | ||||
-rw-r--r-- | frontends/php/include/classes/graph.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/db.inc.php | 8 | ||||
-rw-r--r-- | frontends/php/include/forms.inc.php | 280 | ||||
-rw-r--r-- | frontends/php/include/hosts.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/items.inc.php | 8 | ||||
-rw-r--r-- | frontends/php/include/validate.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/items.php | 68 | ||||
-rw-r--r-- | src/zabbix_server/server.c | 6 |
14 files changed, 189 insertions, 272 deletions
diff --git a/create/data/change_nodeid.sh b/create/data/change_nodeid.sh new file mode 100755 index 00000000..daa0d6e6 --- /dev/null +++ b/create/data/change_nodeid.sh @@ -0,0 +1,37 @@ +dbname="zabbix" +nodeid=$1 + +echo "update config set configid=configid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update media_type set mediatypeid=mediatypeid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update users set userid=userid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update usrgrp set usrgrpid=usrgrpid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update rights set rightid=rightid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update rights set groupid=groupid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update hosts set hostid=hostid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update groups set groupid=groupid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update hosts_groups set hostgroupid=hostgroupid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update hosts_groups set hostid=hostid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update hosts_groups set groupid=groupid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update items set itemid=itemid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update items set hostid=hostid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update functions set functionid=functionid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update functions set itemid=itemid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update functions set triggerid=triggerid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update triggers set triggerid=triggerid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update actions set actionid=actionid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update actions set userid=userid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update media set mediaid=mediaid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update media set userid=userid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update media set mediatypeid=mediatypeid+0000100000000000000*$nodeid"|mysql -uroot $dbname +echo "update images set imageid=imageid+0000100000000000000*$nodeid"|mysql -uroot $dbname + +echo "select concat(triggerid,'_',expression) from triggers"|mysql -uroot $dbname >tmp +for i in `cat tmp`; do + expression=`echo $i|cut -f2 -d"_"` + recid=`echo $i|cut -f1 -d"_"` + id=`echo $i|cut -f2 -d"{"|cut -f1 -d "}"` + newid=`echo "$id+0000100000000000000"|bc` + newexpression=`echo $expression|sed "s/{$id}/{$newid}/g"` + echo "update triggers set expression='$newexpression' where triggerid=$recid"|mysql -uroot $dbname +done +rm tmp diff --git a/create/data/data.sql b/create/data/data.sql index 7655f101..2bfcfdcf 100644 --- a/create/data/data.sql +++ b/create/data/data.sql @@ -61,34 +61,12 @@ INSERT INTO rights VALUES (3,2,'Default permission','R',0); -- Dumping data for table `hosts` -- -INSERT INTO hosts VALUES (10010,'a0',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10011,'a1',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10012,'a2',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10013,'a3',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10014,'a4',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10015,'a5',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10016,'a6',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10017,'a7',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10018,'a8',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10019,'a9',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10001,'Unix_t',0,'',10000,3,0,'',0,0); ---INSERT INTO hosts VALUES (10001,'Unix_t',1,'127.0.0.1',10050,0,0,'',0,0); -INSERT INTO hosts VALUES (10002,'Windows_t',0,'',10000,3,0,'',0,0); -INSERT INTO hosts VALUES (10004,'Standalone_t',0,'',10000,3,0,'',0,0); -INSERT INTO hosts VALUES (10003,'MySQL_t',0,'',10000,3,0,'',0,0); +INSERT INTO hosts VALUES (10001,'Unix_t',0,'',10050,3,0,'',0,0); +INSERT INTO hosts VALUES (10002,'Windows_t',0,'',10050,3,0,'',0,0); +INSERT INTO hosts VALUES (10004,'Standalone_t',0,'',10050,3,0,'',0,0); +INSERT INTO hosts VALUES (10003,'MySQL_t',0,'',10050,3,0,'',0,0); INSERT INTO hosts VALUES (10007,'SNMP_t',0,'',161,3,0,'',0,0); -INSERT INTO items VALUES (19020,0,'','',161,10010,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19021,0,'','',161,10011,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19022,0,'','',161,10012,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19023,0,'','',161,10013,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19024,0,'','',161,10014,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19025,0,'','',161,10015,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19026,0,'','',161,10016,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19027,0,'','',161,10017,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19028,0,'','',161,10018,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); -INSERT INTO items VALUES (19029,0,'','',161,10019,'Ping to the server (TCP)','agent.ping',001,7,365,0,NULL,NULL,NULL,0,3,'','',0,0,NULL,'',0,'','','0','',0,'',0,0,''); - -- -- Dumping data for table `groups` -- diff --git a/create/data/nodes.sql b/create/data/nodes.sql index 8d48980b..94c04464 100644 --- a/create/data/nodes.sql +++ b/create/data/nodes.sql @@ -7,6 +7,7 @@ insert into nodes values (4, "Zabbix", 2, "127.0.0.1", 15054, 30, 365, 0, 0, 0, insert into nodes values (3, "Latvia", 2, "127.0.0.1", 15053, 30, 365, 0, 0, 0, 4); insert into nodes values (2, "Riga", 2, "127.0.0.1", 15052, 30, 365, 0, 0, 0, 3); insert into nodes values (1, "Dpils", 2, "127.0.0.1", 15051, 30, 365, 0, 0, 0, 3); +insert into nodes values (1, "Dpils", 2, "127.0.0.1", 15051, 30, 365, 0, 0, 0, 3); insert into events values (700000000000001, 700000000000003, 123456789, 0, 0); insert into events values (700000000000002, 700000000000012, 123456789, 0, 0); insert into events values (700000000000003, 700000000000023, 123456789, 0, 0); diff --git a/frontends/php/css.css b/frontends/php/css.css index 5fe0d08a..b4372fe3 100644 --- a/frontends/php/css.css +++ b/frontends/php/css.css @@ -604,12 +604,6 @@ table.sub_menu tr td .biginput:focus { border-color: black; } .biginput:hover { border-color: black; } -.biginput[readonly] /* NOTE: Ignored by IE */ -{ - border-color: #D0D0D0; - background-color: #EEEEEE; -} - .button { font-family: Verdana, Helvetica, Geneva; diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php index c5cfc7c8..00f81eda 100644 --- a/frontends/php/include/classes/ctag.inc.php +++ b/frontends/php/include/classes/ctag.inc.php @@ -93,7 +93,10 @@ function ShowEnd() { echo $this->EndToString(); } function Show($destroy=true) { echo $this->ToString($destroy); } - function Destroy() { $this = null; } + function Destroy() { +### TODO Problem under PHP 5.0 "Fatal error: Cannot re-assign $this in ..." +# $this = null; + } function StartToString() { diff --git a/frontends/php/include/classes/ctextbox.inc.php b/frontends/php/include/classes/ctextbox.inc.php index 1f3ea4a5..97373a03 100644 --- a/frontends/php/include/classes/ctextbox.inc.php +++ b/frontends/php/include/classes/ctextbox.inc.php @@ -113,7 +113,11 @@ { $res = implode('.',$this->ip_parts); - if($destroy) $this = null; + if($destroy) + { +### TODO Problem under PHP 5.0 "Fatal error: Cannot re-assign $this in ..." +# $this = null; + } return $res; } diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php index 753ce648..e36f96c8 100644 --- a/frontends/php/include/classes/graph.inc.php +++ b/frontends/php/include/classes/graph.inc.php @@ -949,7 +949,7 @@ ); } - $curr_data = &$this->data[$this->items[$i]["itemid"]][$type]; + $curr_data = &$this->data[$this->items[$i]["itemid"]][$calc_type]; $curr_data->count = NULL; $curr_data->min = NULL; $curr_data->max = NULL; diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 15b5e27e..18097f31 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -26,7 +26,7 @@ // $DB_TYPE ="POSTGRESQL"; $DB_TYPE ="MYSQL"; $DB_SERVER ="localhost"; - $DB_DATABASE ="osmiy1"; + $DB_DATABASE ="zabbix"; $DB_USER ="root"; $DB_PASSWORD =""; // END OF DATABASE CONFIGURATION @@ -296,7 +296,7 @@ if($DB_TYPE == "ORACLE") { function id2nodeid($id_var) { - return (int)($id_var / 100000000000000); + return (int)bcdiv("$id_var","100000000000000"); } function get_dbid($table,$field) @@ -307,11 +307,11 @@ if($DB_TYPE == "ORACLE") { $row=DBfetch($result); if($row && !is_null($row["id"])) { - return ++$row["id"]; + return bcadd($row["id"],1); } else { - return $ZBX_CURNODEID*100000000000000+1; + return bcadd(bcmul($ZBX_CURNODEID,"100000000000000"),1); } } ?> diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index e3ce16d4..32a3e9f5 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -694,7 +694,6 @@ $add_groupid = get_request("add_groupid" ,get_request("groupid",0)); - $limited = null; if(is_null($host)){ $host_info = get_host_by_hostid($_REQUEST["hostid"]); @@ -705,63 +704,58 @@ { $frmItem->AddVar("itemid",$_REQUEST["itemid"]); - $item_data = DBfetch(DBselect("select i.*, h.host, h.hostid". + $result=DBselect("select i.*, h.host, h.hostid". " from items i,hosts h where i.itemid=".$_REQUEST["itemid"]. - " and h.hostid=i.hostid")); - - $limited = $item_data['templateid'] == 0 ? null : 'yes'; - } - - if((isset($_REQUEST["itemid"]) && !isset($_REQUEST["form_refresh"])) || isset($limited)) - { - $description = $item_data["description"]; - $key = $item_data["key_"]; - $host = $item_data["host"]; - $type = $item_data["type"]; - $snmp_community = $item_data["snmp_community"]; - $snmp_oid = $item_data["snmp_oid"]; - $snmp_port = $item_data["snmp_port"]; - $value_type = $item_data["value_type"]; - $trapper_hosts = $item_data["trapper_hosts"]; - $units = $item_data["units"]; - $valuemapid = $item_data["valuemapid"]; - $multiplier = $item_data["multiplier"]; - $hostid = $item_data["hostid"]; - - $snmpv3_securityname = $item_data["snmpv3_securityname"]; - $snmpv3_securitylevel = $item_data["snmpv3_securitylevel"]; - $snmpv3_authpassphrase = $item_data["snmpv3_authpassphrase"]; - $snmpv3_privpassphrase = $item_data["snmpv3_privpassphrase"]; + " and h.hostid=i.hostid"); + $row=DBfetch($result); + } + + if(isset($_REQUEST["itemid"]) && !isset($_REQUEST["form_refresh"])) + { + $description = $row["description"]; + $key = $row["key_"]; + $host = $row["host"]; + $delay = $row["delay"]; + $history = $row["history"]; + $status = $row["status"]; + $type = $row["type"]; + $snmp_community = $row["snmp_community"]; + $snmp_oid = $row["snmp_oid"]; + $snmp_port = $row["snmp_port"]; + $value_type = $row["value_type"]; + $trapper_hosts = $row["trapper_hosts"]; + $units = $row["units"]; + $valuemapid = $row["valuemapid"]; + $multiplier = $row["multiplier"]; + $hostid = $row["hostid"]; + $delta = $row["delta"]; + $trends = $row["trends"]; + $db_delay_flex = $row["delay_flex"]; + + $snmpv3_securityname = $row["snmpv3_securityname"]; + $snmpv3_securitylevel = $row["snmpv3_securitylevel"]; + $snmpv3_authpassphrase = $row["snmpv3_authpassphrase"]; + $snmpv3_privpassphrase = $row["snmpv3_privpassphrase"]; - $formula = $item_data["formula"]; - $logtimefmt = $item_data["logtimefmt"]; + $formula = $row["formula"]; + $logtimefmt = $row["logtimefmt"]; - if(!isset($limited) || !isset($_REQUEST["form_refresh"])) + $db_applications = get_applications_by_itemid($_REQUEST["itemid"]); + while($db_app = DBfetch($db_applications)) { - $delay = $item_data["delay"]; - $history = $item_data["history"]; - $status = $item_data["status"]; - $delta = $item_data["delta"]; - $trends = $item_data["trends"]; - $db_delay_flex = $item_data["delay_flex"]; - - if(isset($db_delay_flex)) - { - $arr_of_dellays = explode(";",$db_delay_flex); - foreach($arr_of_dellays as $one_db_delay) - { - @list($one_delay,$one_time_period) = explode("/",$one_db_delay); - if(!isset($one_delay) || !isset($one_time_period)) continue; + if(in_array($db_app["applicationid"],$applications)) continue; + array_push($applications,$db_app["applicationid"]); + } - array_push($delay_flex,array("delay"=>$one_delay,"period"=>$one_time_period)); - } - } - - $db_applications = get_applications_by_itemid($_REQUEST["itemid"]); - while($db_app = DBfetch($db_applications)) + if(isset($db_delay_flex)) + { + $arr_of_dellays = explode(";",$db_delay_flex); + foreach($arr_of_dellays as $one_db_delay) { - if(in_array($db_app["applicationid"],$applications)) continue; - array_push($applications,$db_app["applicationid"]); + @list($one_delay,$one_time_period) = explode("/",$one_db_delay); + if(!isset($one_delay) || !isset($one_time_period)) continue; + + array_push($delay_flex,array("delay"=>$one_delay,"period"=>$one_time_period)); } } } @@ -797,32 +791,26 @@ if(count($applications)==0) array_push($applications,0); if(isset($_REQUEST["itemid"])) { - $frmItem->SetTitle(S_ITEM." '$host:".$item_data["description"]."'"); + $frmItem->SetTitle(S_ITEM." '$host:".$row["description"]."'"); } else { $frmItem->SetTitle(S_ITEM." '$host:$description'"); } - $frmItem->AddRow(S_DESCRIPTION, new CTextBox("description",$description,40, $limited)); + $frmItem->AddRow(S_DESCRIPTION, new CTextBox("description",$description,40)); + + + $cmbType = new CComboBox("type",$type,"submit()"); + $cmbType->AddItem(ITEM_TYPE_ZABBIX,S_ZABBIX_AGENT); + $cmbType->AddItem(ITEM_TYPE_ZABBIX_ACTIVE,S_ZABBIX_AGENT_ACTIVE); + $cmbType->AddItem(ITEM_TYPE_SIMPLE,S_SIMPLE_CHECK); + $cmbType->AddItem(ITEM_TYPE_SNMPV1,S_SNMPV1_AGENT); + $cmbType->AddItem(ITEM_TYPE_SNMPV2C,S_SNMPV2_AGENT); + $cmbType->AddItem(ITEM_TYPE_SNMPV3,S_SNMPV3_AGENT); + $cmbType->AddItem(ITEM_TYPE_TRAPPER,S_ZABBIX_TRAPPER); + $cmbType->AddItem(ITEM_TYPE_INTERNAL,S_ZABBIX_INTERNAL); + $cmbType->AddItem(ITEM_TYPE_AGGREGATE,S_ZABBIX_AGGREGATE); + $frmItem->AddRow(S_TYPE, $cmbType); - if(isset($limited)) - { - $frmItem->AddRow(S_TYPE, new CTextBox("typename", item_type2str($type), 40, 'yes')); - $frmItem->AddVar('type', $type); - } - else - { - $cmbType = new CComboBox("type",$type,"submit()"); - $cmbType->AddItem(ITEM_TYPE_ZABBIX,S_ZABBIX_AGENT); - $cmbType->AddItem(ITEM_TYPE_ZABBIX_ACTIVE,S_ZABBIX_AGENT_ACTIVE); - $cmbType->AddItem(ITEM_TYPE_SIMPLE,S_SIMPLE_CHECK); - $cmbType->AddItem(ITEM_TYPE_SNMPV1,S_SNMPV1_AGENT); - $cmbType->AddItem(ITEM_TYPE_SNMPV2C,S_SNMPV2_AGENT); - $cmbType->AddItem(ITEM_TYPE_SNMPV3,S_SNMPV3_AGENT); - $cmbType->AddItem(ITEM_TYPE_TRAPPER,S_ZABBIX_TRAPPER); - $cmbType->AddItem(ITEM_TYPE_INTERNAL,S_ZABBIX_INTERNAL); - $cmbType->AddItem(ITEM_TYPE_AGGREGATE,S_ZABBIX_AGGREGATE); - $frmItem->AddRow(S_TYPE, $cmbType); - } if(($type==ITEM_TYPE_SNMPV1)||($type==ITEM_TYPE_SNMPV2C)) { @@ -831,46 +819,32 @@ $frmItem->AddVar("snmpv3_authpassphrase",$snmpv3_authpassphrase); $frmItem->AddVar("snmpv3_privpassphrase",$snmpv3_privpassphrase); - $frmItem->AddRow(S_SNMP_COMMUNITY, new CTextBox("snmp_community",$snmp_community,16,$limited)); - $frmItem->AddRow(S_SNMP_OID, new CTextBox("snmp_oid",$snmp_oid,40,$limited)); - $frmItem->AddRow(S_SNMP_PORT, new CNumericBox("snmp_port",$snmp_port,5,$limited)); + $frmItem->AddRow(S_SNMP_COMMUNITY, new CTextBox("snmp_community",$snmp_community,16)); + $frmItem->AddRow(S_SNMP_OID, new CTextBox("snmp_oid",$snmp_oid,40)); + $frmItem->AddRow(S_SNMP_PORT, new CTextBox("snmp_port",$snmp_port,5)); } else if($type==ITEM_TYPE_SNMPV3) { $frmItem->AddVar("snmp_community",$snmp_community); - $frmItem->AddRow(S_SNMP_OID, new CTextBox("snmp_oid",$snmp_oid,40,$limited)); + $frmItem->AddRow(S_SNMP_OID, new CTextBox("snmp_oid",$snmp_oid,40)); $frmItem->AddRow(S_SNMPV3_SECURITY_NAME, - new CTextBox("snmpv3_securityname",$snmpv3_securityname,64,$limited)); + new CTextBox("snmpv3_securityname",$snmpv3_securityname,64)); + + $cmbSecLevel = new CComboBox("snmpv3_securitylevel",$snmpv3_securitylevel); + $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV,"NoAuthPriv"); + $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV,"AuthNoPriv"); + $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV,"AuthPriv"); + $frmItem->AddRow(S_SNMPV3_SECURITY_LEVEL, $cmbSecLevel); - if(isset($limited)) - { - $frmItem->AddVar("snmpv3_securitylevel", $snmpv3_securitylevel); - switch($snmpv3_securitylevel) - { - case ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV: $snmpv3_securitylevel="NoAuthPriv"; break; - case ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV: $snmpv3_securitylevel = "AuthNoPriv"; break; - case ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV: $snmpv3_securitylevel = "AuthPriv"; break; - } - $frmItem->AddRow(S_SNMPV3_SECURITY_LEVEL, new CTextBox("snmpv3_securitylevel_desc", - $snmpv3_securitylevel, $limited)); - } - else - { - $cmbSecLevel = new CComboBox("snmpv3_securitylevel",$snmpv3_securitylevel); - $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV,"NoAuthPriv"); - $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV,"AuthNoPriv"); - $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV,"AuthPriv"); - $frmItem->AddRow(S_SNMPV3_SECURITY_LEVEL, $cmbSecLevel); - } $frmItem->AddRow(S_SNMPV3_AUTH_PASSPHRASE, - new CTextBox("snmpv3_authpassphrase",$snmpv3_authpassphrase,64,$limited)); + new CTextBox("snmpv3_authpassphrase",$snmpv3_authpassphrase,64)); $frmItem->AddRow(S_SNMPV3_PRIV_PASSPHRASE, - new CTextBox("snmpv3_privpassphrase",$snmpv3_privpassphrase,64,$limited)); + new CTextBox("snmpv3_privpassphrase",$snmpv3_privpassphrase,64)); - $frmItem->AddRow(S_SNMP_PORT, new CNumericBox("snmp_port",$snmp_port,5,$limited)); + $frmItem->AddRow(S_SNMP_PORT, new CTextBox("snmp_port",$snmp_port,5)); } else { @@ -883,54 +857,30 @@ $frmItem->AddVar("snmpv3_privpassphrase",$snmpv3_privpassphrase); } - if(isset($limited)) - { - $btnSelect = null; - } - else - { - $btnSelect = new CButton('btn1',S_SELECT, - "return PopUp('popup.php?dstfrm=".$frmItem->GetName(). - "&dstfld1=key&srctbl=help_items&srcfld1=key_','new_win',". - "'width=650,height=450,resizable=1,scrollbars=1');"); - $btnSelect->SetAccessKey('T'); - } - - $frmItem->AddRow(S_KEY, array(new CTextBox("key",$key,40,$limited), $btnSelect)); + $btnSelect = new CButton('btn1',S_SELECT, + "return PopUp('popup.php?dstfrm=".$frmItem->GetName(). + "&dstfld1=key&srctbl=help_items&srcfld1=key_','new_win',". + "'width=650,height=450,resizable=1,scrollbars=1');"); + $btnSelect->SetAccessKey('T'); - if(isset($limited)) - { - $frmItem->AddVar("value_type", $value_type); - $cmbValType = new CTextBox('value_type_name', item_value_type2str($value_type), 40, 'yes'); - } - else - { - $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); - $cmbValType->AddItem(ITEM_VALUE_TYPE_TEXT, S_TEXT); - } + $frmItem->AddRow(S_KEY, array(new CTextBox("key",$key,40), $btnSelect)); + + $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); + $cmbValType->AddItem(ITEM_VALUE_TYPE_TEXT, S_TEXT); $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, $limited)); + $frmItem->AddRow(S_UNITS, new CTextBox("units",$units,40)); - if(isset($limited)) - { - $frmItem->AddVar("multiplier", $multiplier); - $cmbMultipler = new CTextBox('multiplier_name', $multiplier ? S_CUSTOM_MULTIPLIER : S_DO_NOT_USE, 20, 'yes'); - } - else - { - $cmbMultipler = new CComboBox("multiplier",$multiplier,"submit()"); - $cmbMultipler->AddItem(0,S_DO_NOT_USE); - $cmbMultipler->AddItem(1,S_CUSTOM_MULTIPLIER); - } + $cmbMultipler = new CComboBox("multiplier",$multiplier,"submit()"); + $cmbMultipler->AddItem(0,S_DO_NOT_USE); + $cmbMultipler->AddItem(1,S_CUSTOM_MULTIPLIER); $frmItem->AddRow(S_USE_MULTIPLIER, $cmbMultipler); - } else { @@ -940,7 +890,7 @@ if($multiplier == 1) { - $frmItem->AddRow(S_CUSTOM_MULTIPLIER, new CTextBox("formula",$formula,40,$limited)); + $frmItem->AddRow(S_CUSTOM_MULTIPLIER, new CTextBox("formula",$formula,40)); } else { @@ -948,12 +898,12 @@ } if($type != ITEM_TYPE_TRAPPER) { - $frmItem->AddRow(S_UPDATE_INTERVAL_IN_SEC, new CNumericBox("delay",$delay,5)); + $frmItem->AddRow(S_UPDATE_INTERVAL_IN_SEC, new CTextBox("delay",$delay,5)); $frmItem->AddRow("Flexible intervals (sec)", $delay_flex_el); $frmItem->AddRow("New flexible interval", array( S_DELAY, SPACE, - new CNumericBox("new_delay_flex[delay]","50",5), + new CTextBox("new_delay_flex[delay]","50",5), S_PERIOD, SPACE, new CTextBox("new_delay_flex[period]","1-7,00:00-23:59",27), BR, new CButton("add_delay_flex",S_ADD) @@ -966,23 +916,24 @@ } $frmItem->AddRow(S_KEEP_HISTORY_IN_DAYS, array( - new CNumericBox("history",$history,8), + 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 CNumericBox("trends",$trends,8)); + $frmItem->AddRow(S_KEEP_TRENDS_IN_DAYS, new CTextBox("trends",$trends,8)); $cmbStatus = new CComboBox("status",$status); $cmbStatus->AddItem(ITEM_STATUS_ACTIVE,S_MONITORED); $cmbStatus->AddItem(ITEM_STATUS_DISABLED,S_DISABLED); +# $cmbStatus->AddItem(2,"Trapper"); $cmbStatus->AddItem(ITEM_STATUS_NOTSUPPORTED,S_NOT_SUPPORTED); $frmItem->AddRow(S_STATUS,$cmbStatus); if($value_type==ITEM_VALUE_TYPE_LOG) { - $frmItem->AddRow(S_LOG_TIME_FORMAT, new CTextBox("logtimefmt",$logtimefmt,16,$limited)); + $frmItem->AddRow(S_LOG_TIME_FORMAT, new CTextBox("logtimefmt",$logtimefmt,16)); } else { @@ -1004,25 +955,12 @@ if(($value_type==ITEM_VALUE_TYPE_UINT64) || ($value_type == ITEM_VALUE_TYPE_STR)) { - if(isset($limited)) - { - $frmItem->AddVar("valuemapid", $valuemapid); - $map_name = S_AS_IS; - if($map_data = DBfetch(DBselect('select name from valuemaps where valuemapid='.$valuemapid))) - { - $map_name = $map_data['name']; - } - $cmbMap = new CTextBox("valuemap_name", $map_name, 20, 'yes'); - } - else - { - $cmbMap = new CComboBox("valuemapid",$valuemapid); - $cmbMap->AddItem(0,S_AS_IS); - $db_valuemaps = DBselect("select * from valuemaps where ".DBid2nodeid("valuemapid")."=".$ZBX_CURNODEID); - while($db_valuemap = DBfetch($db_valuemaps)) - $cmbMap->AddItem($db_valuemap["valuemapid"],$db_valuemap["name"]); - } - + $cmbMap = new CComboBox("valuemapid",$valuemapid); + $cmbMap->AddItem(0,S_AS_IS); + $db_valuemaps = DBselect("select * from valuemaps where ".DBid2nodeid("valuemapid")."=".$ZBX_CURNODEID); + while($db_valuemap = DBfetch($db_valuemaps)) + $cmbMap->AddItem($db_valuemap["valuemapid"],$db_valuemap["name"]); + $link = new CLink("throw map","config.php?config=6","action"); $link->AddOption("target","_blank"); $frmItem->AddRow(array(S_SHOW_VALUE.SPACE,$link),$cmbMap); @@ -1033,9 +971,9 @@ $frmItem->AddVar("valuemapid",0); } - if($type==ITEM_TYPE_TRAPPER) + if($type==2) { - $frmItem->AddRow(S_ALLOWED_HOSTS, new CTextBox("trapper_hosts",$trapper_hosts,40,$limited)); + $frmItem->AddRow(S_ALLOWED_HOSTS, new CTextBox("trapper_hosts",$trapper_hosts,40)); } else { @@ -1053,7 +991,7 @@ $frmItem->AddRow(S_APPLICATIONS,$cmbApps); $frmRow = array(new CButton("save",S_SAVE)); - if(isset($_REQUEST["itemid"]) && !isset($limited)) + if(isset($_REQUEST["itemid"])) { array_push($frmRow, SPACE, diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index f6ac11c4..834035cc 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -375,7 +375,7 @@ require_once "include/items.inc.php"; function get_hosts_by_templateid($templateid) { - return DBselect("select h.* from hosts h, hosts_templates ht where h.hostid=ht.hostid and ht.templateid=$templateid"); + return DBselect("select * from hosts where templateid=$templateid"); } # Update Host status diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index 98a25bba..271061f5 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -247,7 +247,7 @@ // add items to child hosts - $db_hosts = get_hosts_by_templateid($host["hostid"]); + $db_hosts = DBselect("select hostid from hosts where templateid=".$host["hostid"]); while($db_host = DBfetch($db_hosts)) { // recursion @@ -355,6 +355,10 @@ DBexecute("update items set lastlogsize=0 where itemid=$itemid and key_<>".zbx_dbstr($key)); + if($templateid==0){ + update_item_status($itemid, $status); + } + $result = DBexecute("delete from items_applications where itemid=$itemid"); foreach($applications as $appid) { @@ -364,7 +368,7 @@ $result=DBexecute( "update items set description=".zbx_dbstr($description).",key_=".zbx_dbstr($key).",". - "hostid=$hostid,delay=$delay,history=$history,nextcheck=0,type=$type,status=".$status.','. + "hostid=$hostid,delay=$delay,history=$history,nextcheck=0,type=$type,". "snmp_community=".zbx_dbstr($snmp_community).",snmp_oid=".zbx_dbstr($snmp_oid).",". "value_type=$value_type,trapper_hosts=".zbx_dbstr($trapper_hosts).",". "snmp_port=$snmp_port,units=".zbx_dbstr($units).",multiplier=$multiplier,delta=$delta,". diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php index b054e8ac..21882e47 100644 --- a/frontends/php/include/validate.inc.php +++ b/frontends/php/include/validate.inc.php @@ -49,7 +49,7 @@ } define("NOT_EMPTY","({}!='')&&"); - define("DB_ID","({}>=0&&{}<=10000000000000000000)&&"); + define("DB_ID","({}>=0&&bccomp('{}',\"10000000000000000000\")<0)&&"); // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION diff --git a/frontends/php/items.php b/frontends/php/items.php index 29ff36d2..5b8d8aea 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -148,40 +148,7 @@ include_once "include/page_header.php"; if(isset($_REQUEST["itemid"])) { - $item_data = get_item_by_itemid($_REQUEST["itemid"]); - if($item_data['templateid']) - { - foreach(array( - "description" => null, - "key" => "key_", - "hostid" => null, - //"delay" => null, - //"history" => null, - //"status" => null, - "type" => null, - "snmp_community" => null, - "snmp_oid" => null, - "value_type" => null, - "trapper_hosts" => null, - "snmp_port" => null, - "units" => null, - "multiplier" => null, - //"delta" => null, - "snmpv3_securityname" => null, - "snmpv3_securitylevel" => null, - "snmpv3_authpassphrase" => null, - "snmpv3_privpassphrase" => null, - "formula" => null, - //"trends" => null, - "logtimefmt" => null, - "valuemapid" => null - ) as $req_var_name => $db_varname) - { - if(!isset($db_varname)) $db_varname = $req_var_name; - $_REQUEST[$req_var_name] = $item_data[$db_varname]; - } - } - $result = update_item($_REQUEST["itemid"], + $result=update_item($_REQUEST["itemid"], $_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"], $_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"], $_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"], @@ -189,8 +156,7 @@ include_once "include/page_header.php"; $_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"], $_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"], $_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"], - $_REQUEST["logtimefmt"],$_REQUEST["valuemapid"],$db_delay_flex,$applications, - $item_data['templateid']); + $_REQUEST["logtimefmt"],$_REQUEST["valuemapid"],$db_delay_flex,$applications); $itemid = $_REQUEST["itemid"]; $action = AUDIT_ACTION_UPDATE; @@ -530,29 +496,27 @@ include_once "include/page_header.php"; $show_applications == 1 ? S_APPLICATIONS : NULL, S_ERROR)); - $db_items = DBselect('select i.*,th.host as template_host,th.hostid as template_hostid from items i '. - ' left join items ti on i.templateid=ti.itemid left join hosts th on ti.hostid=th.hostid '. - ' where i.hostid='.$_REQUEST['hostid']. - ' order by th.host,i.description, i.key_'); + $db_items = DBselect("select i.* from hosts h,items i where h.hostid=i.hostid and". + " h.hostid=".$_REQUEST["hostid"]." order by i.templateid,i.description, i.key_"); while($db_item = DBfetch($db_items)) { - $description = array(); - - if($db_item["templateid"]) + if($db_item["templateid"]==0) { + $description = new CLink( + item_description($db_item["description"],$db_item["key_"]), + "items.php?form=update&itemid=". + $db_item["itemid"].url_param("hostid").url_param("groupid"), + 'action'); + } else { $template_host = get_realhost_by_itemid($db_item["templateid"]); - array_push($description, + $description = array( new CLink($template_host["host"],"items.php?". "hostid=".$template_host["hostid"], - 'uncnown'), - ":"); + 'action'), + ":", + item_description($db_item["description"],$db_item["key_"]), + ); } - - array_push($description, new CLink( - item_description($db_item["description"],$db_item["key_"]), - "items.php?form=update&itemid=". - $db_item["itemid"].url_param("hostid").url_param("groupid"), - 'action')); $status=new CCol(new CLink(item_status2str($db_item["status"]), "items.php?group_itemid%5B%5D=".$db_item["itemid"]. diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c index 728dba8d..a53ce13d 100644 --- a/src/zabbix_server/server.c +++ b/src/zabbix_server/server.c @@ -339,12 +339,6 @@ int main(int argc, char **argv) { int ch; - printf("Sizeof ZBX [%d]", sizeof(zbx_uint64_t)); - printf("Sizeof Int [%d]", get_nodeid_by_id(100000000000000ULL)); - printf("Sizeof Int [%d]", get_nodeid_by_id(500000000000000ULL)); - printf("Sizeof Int [%d]", get_nodeid_by_id(5500000000000000ULL)); - return; - #ifdef HAVE_ZZZ DB_RESULT result; DB_ROW row; |