diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-10-31 09:06:54 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-10-31 09:06:54 +0000 |
| commit | c9e0727ceb4a9299507a189affaff6d04ce5c3a5 (patch) | |
| tree | 792fd7e8abe212494a3a95ea4dece24694c8cecf /frontends/php/include | |
| parent | 3eea91a6fdd3ae1c667e25de6ffdf5546774f915 (diff) | |
- added availability of template triggers changing directly on host (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3417 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/config.inc.php | 12 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 51 | ||||
| -rw-r--r-- | frontends/php/include/triggers.inc.php | 14 |
3 files changed, 46 insertions, 31 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 75ce2fb2..c0bc4a70 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -694,6 +694,8 @@ else // Does expression match server:key.function(param) ? function validate_simple_expression($expression) { + global $ZBX_CURNODEID; + // echo "Validating simple:$expression<br>"; // Before str() // if (eregi('^\{([0-9a-zA-Z[.-.]\_\.]+)\:([]\[0-9a-zA-Z\_\/\.\,]+)\.((diff)|(min)|(max)|(last)|(prev))\(([0-9\.]+)\)\}$', $expression, $arr)) @@ -712,14 +714,20 @@ else //SDI($parameter); $sql="select count(*) as cnt from hosts h,items i where h.host=".zbx_dbstr($host). - " and i.key_=".zbx_dbstr($key)." and h.hostid=i.hostid"; + " and i.key_=".zbx_dbstr($key)." and h.hostid=i.hostid ". + " and ".DBid2nodeid('h.hostid').'='.$ZBX_CURNODEID; //SDI($sql); $row=DBfetch(DBselect($sql)); - if($row["cnt"]!=1) + if($row["cnt"]==0) { error("No such host ($host) or monitored parameter ($key)"); return -1; } + elseif($row["cnt"]!=1) + { + error("Too many hosts ($host) with parameter ($key)"); + return -1; + } if( ($function!="last")&& ($function!="diff")&& diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index e3ce16d4..0077bbad 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -1198,6 +1198,8 @@ $dep_el=array(); $dependences = get_request("dependences",array()); + $limited = null; + if(isset($_REQUEST["triggerid"])) { $frmTrig->AddVar("triggerid",$_REQUEST["triggerid"]); @@ -1205,36 +1207,41 @@ $description = htmlspecialchars(stripslashes($trigger["description"])); $frmTrig->SetTitle(S_TRIGGER." \"".$description."\""); + + $limited = $trigger['templateid'] ? 'yes' : null; } - if(isset($_REQUEST["triggerid"]) && !isset($_REQUEST["form_refresh"])) + $expression = get_request("expression" ,""); + $description = get_request("description" ,""); + $priority = get_request("priority" ,0); + $status = get_request("status" ,0); + $comments = get_request("comments" ,""); + $url = get_request("url" ,""); + + if((isset($_REQUEST["triggerid"]) && !isset($_REQUEST["form_refresh"])) || isset($limited)) { + $description = htmlspecialchars(stripslashes($trigger["description"])); $expression = explode_exp($trigger["expression"],0); - $priority = $trigger["priority"]; - $status = $trigger["status"]; - $comments = $trigger["comments"]; - $url = $trigger["url"]; - - $trigs=DBselect("select t.triggerid,t.description from triggers t,trigger_depends d". - " where t.triggerid=d.triggerid_up and d.triggerid_down=".$_REQUEST["triggerid"]); - while($trig=DBfetch($trigs)) + + if(!isset($limited) || !isset($_REQUEST["form_refresh"])) { - if(in_array($trig["triggerid"],$dependences)) continue; - array_push($dependences,$trig["triggerid"]); + $priority = $trigger["priority"]; + $status = $trigger["status"]; + $comments = $trigger["comments"]; + $url = $trigger["url"]; + + $trigs=DBselect("select t.triggerid,t.description from triggers t,trigger_depends d". + " where t.triggerid=d.triggerid_up and d.triggerid_down=".$_REQUEST["triggerid"]); + while($trig=DBfetch($trigs)) + { + if(in_array($trig["triggerid"],$dependences)) continue; + array_push($dependences,$trig["triggerid"]); + } } } - else - { - $expression = get_request("expression" ,""); - $description = get_request("description" ,""); - $priority = get_request("priority" ,0); - $status = get_request("status" ,0); - $comments = get_request("comments" ,""); - $url = get_request("url" ,""); - } - $frmTrig->AddRow(S_NAME, new CTextBox("description",$description,70)); - $frmTrig->AddRow(S_EXPRESSION,new CTextBox("expression",$expression,70)); + $frmTrig->AddRow(S_NAME, new CTextBox("description",$description,70, $limited)); + $frmTrig->AddRow(S_EXPRESSION,new CTextBox("expression",$expression,70, $limited)); /* dependences */ foreach($dependences as $val){ diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 5d8b1109..ed85afbd 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -109,6 +109,8 @@ function get_hosts_by_expression($expression) { + global $ZBX_CURNODEID; + $state=""; $host=""; $hosts=array(); @@ -124,7 +126,7 @@ if($expression[$i] == '}' && $state=="") { $state=''; - $hosts[$host] = $host; + $hosts[$host] = '\''.$host.'\''; continue; } @@ -161,12 +163,10 @@ continue; } - $sql = "select distinct * from hosts where hostid=0"; - foreach($hosts as $host) - { - $sql .= " or host=".zbx_dbstr($host); - } - return DBselect($sql); + if(count($hosts) == 0) $hosts = array(''); + + return DBselect('select distinct * from hosts where '.DBid2nodeid('hostid').'='.$ZBX_CURNODEID. + ' and host in ('.implode(',',$hosts).')'); } function validate_expression($expression) |
