Skip to content

Instantly share code, notes, and snippets.

@btm
Created January 28, 2009 02:09
Show Gist options
  • Save btm/53771 to your computer and use it in GitHub Desktop.
Save btm/53771 to your computer and use it in GitHub Desktop.
<% require '/srv/icagent/lib/iclassify' -%>
<% ic = IClassify::Client.new("https://iclassify", iclassify_user, iclassify_password) -%>
<% nagios_nodes = ic.search(nagios_iclassify_search) -%>
<% all_hosts = Array.new -%>
<% vmware = Array.new -%>
<% kvm = Array.new -%>
<% test_hosts = Array.new -%>
<% windows_hosts = Array.new -%>
<% dell_hosts = Array.new -%>
<% ots_servers = Array.new -%>
<% ras_servers = Array.new -%>
<% was_servers = Array.new -%>
<% woputil_servers = Array.new -%>
<% rserve_servers = Array.new -%>
<% mssql_servers = Array.new -%>
<% msdns_servers = Array.new -%>
<% msldap_corp_servers = Array.new -%>
<% msldap_wmprod_servers = Array.new -%>
<% msldap_prod_servers = Array.new -%>
<% mssmtp_servers = Array.new -%>
<% msftp_servers = Array.new -%>
<% mshttp_servers = Array.new -%>
<% mshttp_401_servers = Array.new -%>
<% mshttp_403_servers = Array.new -%>
<% nagios_nodes.each do |node| -%>
<% hostname = node.attrib?("hostname") -%>
<% if node.attrib?("operatingsystem") == "windows" -%>
<% windows_hosts << hostname -%>
<% nagios_dyn_checks = Array.new -%>
<% if node.attrib?("nagios_checks") != nil -%>
<% nagios_dyn_checks = node.attrib?("nagios_checks") -%>
<% nagios_dyn_checks.each do |check| -%>
<% if check == "dns" -%>
<% msdns_servers << hostname -%>
<% elsif check == "mssql" -%>
<% mssql_servers << hostname -%>
<% elsif check == "ldap_corp" -%>
<% msldap_corp_servers << hostname -%>
<% elsif check == "ldap_wmprod" -%>
<% msldap_wmprod_servers << hostname -%>
<% elsif check == "ldap_prod" -%>
<% msldap_prod_servers << hostname -%>
<% elsif check == "smtp" -%>
<% mssmtp_servers << hostname -%>
<% elsif check == "ftp" -%>
<% msftp_servers << hostname -%>
<% elsif check == "http" -%>
<% mshttp_servers << hostname -%>
<% elsif check == "http_401" -%>
<% mshttp_401_servers << hostname -%>
<% elsif check == "http_403" -%>
<% mshttp_403_servers << hostname -%>
<% end -%>
<% end -%>
<% end -%>
<% else -%>
<% if node.tag?("vmware-server") -%>
<% vmware << hostname -%>
<% end -%>
<% if node.tag?("kvm") -%>
<% kvm << hostname -%>
<% end -%>
<% if node.attrib?("domain") == "test.widemile.com" -%>
<% test_hosts << hostname -%>
<% else -%>
<% all_hosts << hostname -%>
<% end -%>
<% if node.tag?("omsa") -%>
<% dell_hosts << hostname -%>
<% end -%>
<% if node.tag?("ots-server") && node.attrib?("domain") == "prod.widemile.com" -%>
<% ots_servers << hostname -%>
<% end -%>
<% if node.tag?("ras-server") && node.attrib?("domain") == "prod.widemile.com" -%>
<% ras_servers << hostname -%>
<% end -%>
<% if node.tag?("was-server") && node.attrib?("domain") == "prod.widemile.com" -%>
<% was_servers << hostname -%>
<% end -%>
<% if node.tag?("woputil-server") && node.attrib?("domain") == "prod.widemile.com" -%>
<% woputil_servers << hostname -%>
<% end -%>
<% if node.tag?("rserve") && node.attrib?("domain") == "prod.widemile.com" -%>
<% rserve_servers << hostname -%>
<% end -%>
<% end -%>
<% end -%>
define hostgroup {
hostgroup_name all
alias All Servers
members <%= all_hosts.join(",") %>
}
define hostgroup {
hostgroup_name vmware
alias VMWare Servers
members <%= vmware.join(",") %>
}
define hostgroup {
hostgroup_name kvm
alias KVM Servers
members <%= kvm.join(",") %>
}
define hostgroup {
hostgroup_name testhosts
alias Test Servers
members <%= test_hosts.join(",") %>
}
define hostgroup {
hostgroup_name sensors
alias EM Sensors
members sensor01,sensor02
}
define hostgroup {
hostgroup_name dellhosts
alias Dell Hosts
members <%= dell_hosts.join(",") %>
}
<% require '/srv/icagent/lib/iclassify' -%>
<% ic = IClassify::Client.new("https://iclassify", iclassify_user, iclassify_password) -%>
<% nagios_nodes = ic.search(nagios_iclassify_search) -%>
<% all_hosts = Array.new -%>
<% nagios_nodes.each do |node| -%>
<% hostname = node.attrib?("hostname") -%>
<% unless node.attrib?("domain") == "test.widemile.com" -%>
<% unless node.attrib?("operatingsystem") == "windows" -%>
<% all_hosts << hostname -%>
<% end -%>
<% end -%>
<% end -%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment