Ad Widget

Collapse

PATCH: allow inclusion of triggers status in screens

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vince2
    Member
    • Oct 2006
    • 40

    #1

    PATCH: allow inclusion of triggers status in screens

    Hi !

    Here is a patch allowing to include trigger status (for a group or a host) into a screen. This is a rather big patch because tr_status.php is not modularized. And some fullscreen functionality is lost when applying it. The patch is fuzzy because I do not apply it on pristine sources but it applies without further modifications anyway.

    First part of the patch :

    Code:
    From: Vincent Bernat <[email protected]>
    Date: Tue, 27 Feb 2007 11:36:59 +0000 (+0100)
    Subject: Allow trigger inclusion into screens
    X-Git-Url: http://localhost/cgi-bin/gitweb.cgi?p=zabbix-wallix-1.1.6.git;a=commitdiff_plain;h=6ecbab87db630abfc85fc7fc831c8a9237fdc311
    
    Allow trigger inclusion into screens
    ---
    
    diff --git a/frontends/php/css.css b/frontends/php/css.css
    index f83d616..d20f5bb 100644
    --- a/frontends/php/css.css
    +++ b/frontends/php/css.css
    @@ -376,6 +376,8 @@ table.header
     }
     table.header td.header_l
     {
    +	background: #5C7099 url(images/gradients/table_head2.gif) repeat-x top left;
    +	background-color: #6d88ad;
             font-family:verdana, arial, helvetica, sans-serif;
             font-size:10px;
     	text-align: left;
    @@ -383,6 +385,8 @@ table.header td.header_l
     }
     table.header td.header_r
     {
    +	background: #5C7099 url(images/gradients/table_head2.gif) repeat-x top left;
    +	background-color: #6d88ad;
             font-family:verdana, arial, helvetica, sans-serif;
             font-size:10px;
     	text-align: right;
    diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
    index bf65d7f..cf28ec3 100644
    --- a/frontends/php/include/defines.inc.php
    +++ b/frontends/php/include/defines.inc.php
    @@ -188,5 +188,7 @@
     	define("SCREEN_RESOURCE_ACTIONS", 12);
     	define("SCREEN_RESOURCE_EVENTS",13);
    +	define("SCREEN_RESOURCE_TRIGGERS_HOST",15);
    +	define("SCREEN_RESOURCE_TRIGGERS_GROUP",16);
     
     /* alignes */
     	define("HALIGN_DEFAULT",0);
    diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
    index c72c4d5..372af6c 100644
    --- a/frontends/php/include/forms.inc.php
    +++ b/frontends/php/include/forms.inc.php
    @@ -1709,5 +1709,7 @@
     		$cmbRes->AddItem(SCREEN_RESOURCE_ACTIONS,	S_HISTORY_OF_ACTIONS);
                     $cmbRes->AddItem(SCREEN_RESOURCE_EVENTS,       S_HISTORY_OF_EVENTS);
    +                $cmbRes->AddItem(SCREEN_RESOURCE_TRIGGERS_HOST,   S_TRIGGERS_HOST);
    +                $cmbRes->AddItem(SCREEN_RESOURCE_TRIGGERS_GROUP,   S_TRIGGERS_GROUP);
     		$form->AddRow(S_RESOURCE,$cmbRes);
     
     		if($resourcetype == SCREEN_RESOURCE_GRAPH)
    @@ -1773,6 +1775,16 @@
     				  expand_trigger_description($row["triggerid"]));
     		  $form->AddRow(S_PARAMETER, $cmb);
     		}
    +		elseif($resourcetype == SCREEN_RESOURCE_TRIGGERS_HOST)
    +		{
    +	// Triggers for host
    +		  $result=DBselect("select h.host, h.hostid from hosts h order by h.host");
    +
    +		  $cmb = new CComboBox("resourceid",$resourceid);
    +		  while($row=DBfetch($result))
    +		    $cmb->AddItem($row["hostid"],$row["host"]);
    +		  $form->AddRow(S_PARAMETER, $cmb);
    +		}
     		elseif($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT)
     		{
     	// Plain text
    @@ -1804,7 +1816,7 @@
                             $form->AddRow(S_SHOW_LINES, new CTextBox("elements",$elements,2));
                             $form->AddVar("resourceid",0);
                     }
    -		elseif(in_array($resourcetype,array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW,SCREEN_RESOURCE_DATA_OVERVIEW)))
    +		elseif(in_array($resourcetype,array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW,SCREEN_RESOURCE_DATA_OVERVIEW,SCREEN_RESOURCE_TRIGGERS_GROUP)))
     		{
     	// Overiews
     			$cmbGroup = new CComboBox("resourceid",$resourceid);
    diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
    index 0239d37..136c079 100644
    --- a/frontends/php/include/locales/en_gb.inc.php
    +++ b/frontends/php/include/locales/en_gb.inc.php
    @@ -75,8 +75,8 @@
     	"S_WHEN_TRIGGER"=>			"When trigger",
     	"S_DELAY"=>				"Delay",
     	"S_SUBJECT"=>				"Subject",
    -	"S_ON"=>				"ON",
    -	"S_OFF"=>				"OFF",
    +	"S_ON"=>				"Problem",
    +	"S_OFF"=>				"OK",
     	"S_NO_ACTIONS_DEFINED"=>		"No actions defined",
     	"S_SINGLE_USER"=>			"Single user",
     	"S_USER_GROUP"=>			"User group",
    @@ -738,2 +738,4 @@
     	"S_EDIT"=>				"Edit",
     	"S_DIMENSION_COLS_ROWS"=>		"Dimension (cols x rows)",
    +	"S_TRIGGERS_HOST"=>			"Host triggers",
    +	"S_TRIGGERS_GROUP"=>			"Group triggers",
    
    diff --git a/frontends/php/include/locales/fr_fr.inc.php b/frontends/php/include/locales/fr_fr.inc.php
    index 55e93ca..1f1938b 100644
    --- a/frontends/php/include/locales/fr_fr.inc.php
    +++ b/frontends/php/include/locales/fr_fr.inc.php
    @@ -40,8 +40,8 @@
     	"S_WHEN_TRIGGER"=>					"Lorsque déclencheur",
     	"S_DELAY"=>							"Délai",
     	"S_SUBJECT"=>						"Sujet",
    -	"S_ON"=>							"OUVERT",
    -	"S_OFF"=>							"FERMÉ",
    +	"S_ON"=>							"Problème",
    +	"S_OFF"=>							"OK",
     	"S_NO_ACTIONS_DEFINED"=>			"Aucune action de définie",
     	"S_NEW_ACTION"=>					"Nouvelle action",
     	"S_SINGLE_USER"=>					"Simple utilisateur",
    @@ -522,2 +522,4 @@
     	"S_HEIGHT"=>						"Hauteur",
     	"S_EMPTY"=>							"Vide",
    + 	"S_TRIGGERS_HOST"=>			"État des déclencheurs d'un hôte",
    + 	"S_TRIGGERS_GROUP"=>			"État des déclencheurs d'un groupe",
    
    diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php
    index 3236d93..5328956 100644
    --- a/frontends/php/include/screens.inc.php
    +++ b/frontends/php/include/screens.inc.php
    @@ -257,6 +257,24 @@
     					$item = array(get_screen_icone($resourceid));
     					if($editmode == 1)	array_push($item,new CLink(S_CHANGE,$action));
     				}
    +				elseif( ($screenitemid!=0) && (($resourcetype==SCREEN_RESOURCE_TRIGGERS_HOST) ||
    +							       ($resourcetype==SCREEN_RESOURCE_TRIGGERS_GROUP)))
    +				{
    +				  if ($resourcetype==SCREEN_RESOURCE_TRIGGERS_GROUP)
    +				    $request="groupid=$resourceid&hostid=0";
    +				  else
    +				    $request="hostid=$resourceid&groupid=0";
    +
    +				  ob_start();
    +				  show_status_of_triggers('true', 'true', 'true', '', '', "like '%'", 'priority',
    +							  ($resourcetype==SCREEN_RESOURCE_TRIGGERS_GROUP)?0:$resourceid,
    +							  ($resourcetype==SCREEN_RESOURCE_TRIGGERS_GROUP)?$resourceid:0,
    +							  1);
    +				  array_push($item, ob_get_contents());
    +				  ob_end_clean();
    +
    +				  if($editmode == 1)	array_push($item,new CLink(S_CHANGE,$action));
    +				}
     				elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_HOSTS_INFO) )
     				{
     					$item = array(new CHostsInfo($style));
  • Vince2
    Member
    • Oct 2006
    • 40

    #2
    Well, I cannot post the patch here. You can grab it here :
    I apologize for the inconvenience but the page you attempted to access does not exist. You may have followed a bad external link, or mis-typed a...

    Comment

    • Marie
      Member
      • Mar 2007
      • 30

      #3
      Very nice one ! Works like a charm, thanks so much

      Comment

      Working...