Ad Widget

Collapse

patch for all hosts in tr_status.php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Andreas Bollhalder
    Senior Member
    Zabbix Certified Specialist
    • Apr 2007
    • 144

    #1

    patch for all hosts in tr_status.php

    I solved my problem descriebed under

    Menu entry "all" for Host disapears when not using Group "all" in the filter

    with the following (hackish) patch:

    Code:
    file tr_status.php, line ~108:
    
    //	validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","always_select_first_host","monitored_hosts","with_monitored_items"),
    	validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","monitored_hosts","with_monitored_items"),
    
    
    file tr_status.php, line ~139:
    
    	$cmbHosts->AddItem(0,S_ALL_SMALL);
    
    
    file tr_status.php, line ~167:
    
    //		$cmbHosts->AddItem(0,S_ALL_SMALL);
    
    
    file tr_status.php, line ~30:
    
    	$join="";
    	if($_REQUEST["groupid"] > 0)
    	{
    		$join = " LEFT JOIN hosts_groups ON hosts_groups.hostid=h.hostid ";
    		$cond .= " and hosts_groups.groupid=".$_REQUEST["groupid"]." ";
    	}
    
    	$result = DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,".
    //		" t.lastchange,t.comments,t.url,t.value,h.host from triggers t,hosts h,items i,functions f".
    		" t.lastchange,t.comments,t.url,t.value,h.host from triggers t,items i,functions f,hosts h".
    		$join.
    		" where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.status=".TRIGGER_STATUS_ENABLED.
    		" and t.description $select_cond and i.status=".ITEM_STATUS_ACTIVE.
    		" and ".DBid2nodeid("t.triggerid")."=".$ZBX_CURNODEID.
    		" and h.hostid not in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT).") ".
    		" and h.status=".HOST_STATUS_MONITORED." $cond $sort");
    Now I can use a group with all hosts displaying there triggers. Sorry that I'm still not providing a diff...

    Andreas
    Zabbix statistics
    Total hosts: 380 - Total items: 12190 - Total triggers: 4530 - Required server performance: 224.2
  • Andreas Bollhalder
    Senior Member
    Zabbix Certified Specialist
    • Apr 2007
    • 144

    #2
    Will try to make the same for the latest data...
    Zabbix statistics
    Total hosts: 380 - Total items: 12190 - Total triggers: 4530 - Required server performance: 224.2

    Comment

    • Andreas Bollhalder
      Senior Member
      Zabbix Certified Specialist
      • Apr 2007
      • 144

      #3
      Here for the "latest.php":

      Code:
      file latest.php, line ~50:
      
      //	validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","always_select_first_host","monitored_hosts","with_monitored_items"));
      	validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","monitored_hosts","with_monitored_items"));
      
      file latest.php, line ~104:
      
      	$cmbHosts->AddItem(0,S_ALL_SMALL);
      
      file latest.php, line ~130:
      
      //		$cmbHosts->AddItem(0,S_ALL_SMALL);
      
      file latest.php, line ~184:
      
      //		$compare_host = " and h.hostid in (".$availiable_hosts.") ";
      		$compare_host = "";
      		$join = " LEFT JOIN hosts_groups ON hosts_groups.hostid=h.hostid ";
      		$cond = " and hosts_groups.groupid=".$_REQUEST["groupid"]." ";
      
      file latest.php, line ~275:
      
      //	$db_items = DBselect("select h.host,h.hostid,i.* from hosts h, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid".
      	$db_items = DBselect("select h.host,h.hostid,i.* from items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid, hosts h".
      		$join.
      		" where ia.itemid is NULL and h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE.
      		$cond.
      		$compare_description.$compare_host.' and h.hostid in ('.$availiable_hosts.") order by i.description,h.host");
      As before, this is a little bit hackish, but it works for me. It also empties the variable "$compare_host" in the case the "hostid" is greater then "0" as the " and h.hostid in (".$availiable_hosts.") " is already in the SQL query.

      Andreas
      Zabbix statistics
      Total hosts: 380 - Total items: 12190 - Total triggers: 4530 - Required server performance: 224.2

      Comment

      • Andreas Bollhalder
        Senior Member
        Zabbix Certified Specialist
        • Apr 2007
        • 144

        #4
        Updated version for "latest.php":

        WARNING !!!
        The version above didn't show any values if the host group has been set to "all" and a host has been selected.

        Code:
        file latest.php, line ~50:
        
        //	validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","always_select_first_host","monitored_hosts","with_monitored_items"));
        	validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","monitored_hosts","with_monitored_items"));
        
        file latest.php, line ~104:
        
        	$cmbHosts->AddItem(0,S_ALL_SMALL);
        
        file latest.php, line ~130:
        
        //		$cmbHosts->AddItem(0,S_ALL_SMALL);
        
        file latest.php, line ~179:
        
        	$join="";
        	$cond="";
        	$compare_host = "";
        	if($_REQUEST["hostid"] > 0)
        		$compare_host = " and h.hostid=".$_REQUEST["hostid"];
        //	else
        //		$compare_host = " and h.hostid in (".$availiable_hosts.") ";
        	if($_REQUEST["groupid"] > 0)
        	{
        //		$compare_host = "";
        		$join = " LEFT JOIN hosts_groups ON hosts_groups.hostid=h.hostid ";
        		$cond = " and hosts_groups.groupid=".$_REQUEST["groupid"]." ";
        	}
        
        file latest.php, line ~279:
        
        //	$db_items = DBselect("select h.host,h.hostid,i.* from hosts h, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid".
        	$db_items = DBselect("select h.host,h.hostid,i.* from items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid, hosts h".
        		$join.
        		" where ia.itemid is NULL and h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE.
        		$cond.
        		$compare_description.$compare_host.' and h.hostid in ('.$availiable_hosts.") order by i.description,h.host");
        Please tell me if there are other errors in the patches or if there exist a better way to do it.

        Andreas
        Zabbix statistics
        Total hosts: 380 - Total items: 12190 - Total triggers: 4530 - Required server performance: 224.2

        Comment

        Working...