diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-02-17 22:41:20 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-02-17 22:41:20 +0000 |
| commit | 33ca5f663dca2bb55a10c10aa45acedb5be130ab (patch) | |
| tree | 6485d246586d97c180d6ab2ab336206544d74b8a /frontends/php | |
| parent | 64783dd7e2037814b9e114dfebb001f0351d6878 (diff) | |
| download | zabbix-33ca5f663dca2bb55a10c10aa45acedb5be130ab.tar.gz zabbix-33ca5f663dca2bb55a10c10aa45acedb5be130ab.tar.xz zabbix-33ca5f663dca2bb55a10c10aa45acedb5be130ab.zip | |
Improvements for new algorithm for action handling.
git-svn-id: svn://svn.zabbix.com/trunk@1262 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/actions.php | 3 | ||||
| -rw-r--r-- | frontends/php/alerts.php | 23 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 27 |
3 files changed, 45 insertions, 8 deletions
diff --git a/frontends/php/actions.php b/frontends/php/actions.php index 3fdbfe3f..0921deab 100644 --- a/frontends/php/actions.php +++ b/frontends/php/actions.php @@ -146,7 +146,8 @@ $found=0; while($row2=DBfetch($result2)) { - $sql="select * from actions a,triggers t,hosts h,functions f,items i where a.triggerid=t.triggerid and f.triggerid=t.triggerid and h.hostid=a.triggerid and i.hostid=h.hostid and a.actionid=".$row["actionid"]." and a.scope=1 and h.hostid=".$row2["hostid"]; +// $sql="select * from actions a,triggers t,hosts h,functions f,items i where a.triggerid=t.triggerid and f.triggerid=t.triggerid and h.hostid=a.triggerid and i.hostid=h.hostid and a.actionid=".$row["actionid"]." and a.scope=1 and h.hostid=".$row2["hostid"]; + $sql="select * from actions a where a.actionid=".$row["actionid"]." and a.scope=1 and a.triggerid=".$row2["hostid"]; // echo "$sql<br>"; $result3=DBselect($sql); if(DBnum_rows($result3)>0) $found=1; diff --git a/frontends/php/alerts.php b/frontends/php/alerts.php index cced0641..e4dd6e4d 100644 --- a/frontends/php/alerts.php +++ b/frontends/php/alerts.php @@ -66,11 +66,11 @@ if(!isset($HTTP_GET_VARS["start"])) { - $sql="select a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,ac.triggerid,a.status,a.retries from alerts a,actions ac,media_type mt where a.actionid=ac.actionid and mt.mediatypeid=a.mediatypeid and a.alertid>$maxalertid-200 order by a.clock desc limit 200"; + $sql="select a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,ac.triggerid,a.status,a.retries,ac.scope from alerts a,actions ac,media_type mt where a.actionid=ac.actionid and mt.mediatypeid=a.mediatypeid and a.alertid>$maxalertid-200 order by a.clock desc limit 200"; } else { - $sql="select a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,ac.triggerid,a.status,a.retries from alerts a,actions ac,media_type mt where a.actionid=ac.actionid and mt.mediatypeid=a.mediatypeid and a.alertid>$maxalertid-200-".$HTTP_GET_VARS["start"]." order by a.clock desc limit ".($HTTP_GET_VARS["start"]+500); + $sql="select a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,ac.triggerid,a.status,a.retries,ac.scope from alerts a,actions ac,media_type mt where a.actionid=ac.actionid and mt.mediatypeid=a.mediatypeid and a.alertid>$maxalertid-200-".$HTTP_GET_VARS["start"]." order by a.clock desc limit ".($HTTP_GET_VARS["start"]+500); } $result=DBselect($sql); @@ -92,7 +92,15 @@ { continue; } - if(!check_right_on_trigger("R",$row["triggerid"])) + if(($row["scope"]==0)&&!check_right_on_trigger("R",$row["triggerid"])) + { + continue; + } + if(($row["scope"]==1)&&!check_right("Host","R",$row["triggerid"])) + { + continue; + } + if(($row["scope"]==2)&&!check_anyright("Default permission","R")) { continue; } @@ -102,7 +110,14 @@ if($col>100) break; - echo "<TD><a href=\"alarms.php?triggerid=".$row["triggerid"]."\">".date("Y.M.d H:i:s",$row["clock"])."</a></TD>"; + if($row["scope"]==0) + { + echo "<TD><a href=\"alarms.php?triggerid=".$row["triggerid"]."\">".date("Y.M.d H:i:s",$row["clock"])."</a></TD>"; + } + else + { + echo "<TD>".date("Y.M.d H:i:s",$row["clock"])."</TD>"; + } echo "<TD>".$row["description"]."</TD>"; if($row["status"] == 1) { diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index fbea7393..2348dee3 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -178,10 +178,31 @@ function get_action_count_by_triggerid($triggerid) { - $sql="select count(*) as cnt from actions where triggerid=$triggerid"; + $cnt=0; + + $sql="select count(*) as cnt from actions where triggerid=$triggerid and scope=0"; $result=DBselect($sql); $row=DBfetch($result); - return $row["cnt"]; + + $cnt=$cnt+$row["cnt"]; + + $sql="select count(*) as cnt from actions where scope=2"; + $result=DBselect($sql); + $row=DBfetch($result); + + $cnt=$cnt+$row["cnt"]; + + $sql="select distinct h.hostid from hosts h,items i,triggers t,functions f where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid=$triggerid"; + $result=DBselect($sql); + while($row=DBfetch($result)) + { + $sql="select count(*) as cnt from actions a,hosts h,items i,triggers t,functions f where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and a.triggerid=".$row["hostid"]." and a.scope=1 and t.triggerid"; + $result2=DBselect($sql); + $row2=DBfetch($result2); + $cnt=$cnt+$row2["cnt"]; + } + + return $cnt; } function check_anyright($right,$permission) @@ -2790,7 +2811,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; DBexecute($sql); } # Add actions - $sql="select actionid from actions where triggerid=".$row2["triggerid"]; + $sql="select actionid from actions where scope=0 and triggerid=".$row2["triggerid"]; $result3=DBselect($sql); while($row3=DBfetch($result3)) { |
