How it works

The idea is to write the function in a external python module and import it in the various dashboards and tables

step by step instructions

  • Create a filterHosts function that receive the Hosts list and a filter and return the filtered Hosts list

example:

def filterHosts(hostsList,filter): """ this function filters the hostsList depending of a filter type """ if filter=='Windows': #initialize bannedHosts List bannedHosts=[] for host in hostsList: if not (host.startswith('DRICORDEL')or host.startswith('VM-')): # host is not correct, we add it to the bannedHost list bannedHosts.append(host) #once we have go trough all the hostsList we can remove the banned ones for host in bannedHosts: hostsList.Remove(host) elif filter=='Linux': bannedHosts=[] for host in hostsList: if not (host.startswith('am012') or host.startswith('hi032')): bannedHosts.append(host) for host in bannedHosts: hostsList.Remove(host) elif filter=='AIX': bannedHosts=[] for host in hostsList: if not host.startswith('am011') or host.startswith('hi031'): bannedHosts.append(host) for host in bannedHosts: hostsList.Remove(host) elif filter=='i5': bannedHosts=[] for host in hostsList: if not host.startswith('am010'): bannedHosts.append(host) for host in bannedHosts: hostsList.Remove(host) else: #filter is not correct raise Exception('The filter "%s" is not defined'%filter, '') #we return the nes hostsList return hostsList 
  • Put this function in a hostsFilter.py file in %Program Files%\Tango04\Dashboards\t04custom
  • Put the following code into the python script in the dashboard configuration
import sys #we add the path where is our module and import it sys.path.append(r"C:\Program Files (x86)\Tango04\Dashboards\t04custom") from hostsFilter import * #we filter the Hosts list depending of the filter Hosts=filterHosts(Hosts,'Windows') 

That's it, you just have to modify the filterHosts function in the hostsfilters.py file and it is taken into account in all the dashboards or table that call this function.

Automatic version

It should be possible to create the list using the statistics database. More info later ;-)

SQL to get the info

SELECT LEFT(category,PATINDEX('%/%',category)-1), hostname FROM T04STATHOSTINFO, T04STATMONITORHOST, T04STATSCRIPTINFO, T04STATCHARTINFO WHERE T04STATHOSTINFO.HOSTID=T04STATMONITORHOST.HOSTID AND T04STATMONITORHOST.MONITORID=T04STATSCRIPTINFO.MONITORID AND T04STATSCRIPTINFO.SCRIPTID=T04STATCHARTINFO.SCRIPTID GROUP BY hostname,LEFT(category,PATINDEX('%/%',category)-1) 

Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: October 18, 2018