mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
parent
6ef2cdb0eb
commit
3ce7262aa8
@ -48,14 +48,15 @@ for line in out.split("\n"):
|
|||||||
plugin = "".join([chr(int(ch)) for ch in plugin])
|
plugin = "".join([chr(int(ch)) for ch in plugin])
|
||||||
plugins.append(plugin)
|
plugins.append(plugin)
|
||||||
|
|
||||||
print("template Host \"snmp-extend:%s\" {" % (ipaddr))
|
|
||||||
print(" macros[\"community\"] = \"%s\"," % (community))
|
|
||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
print(" services[\"%s\"] = {" % (plugin))
|
print("apply Service \"%s\" {" % (plugin))
|
||||||
print(" templates = [ \"snmp-extend-service\" ],")
|
print(" import \"snmp-extend-service\",")
|
||||||
print(" check_command = \"snmp-extend\",")
|
print()
|
||||||
print(" macros[\"plugin\"] = \"%s\"" % (plugin))
|
print(" check_command = \"snmp-extend\",")
|
||||||
print(" },")
|
print(" macros[\"community\"] = \"%s\"," % (community))
|
||||||
print("}")
|
print()
|
||||||
|
print(" assign where host.macros.address == \"%s\"" % (ipaddr))
|
||||||
|
print("}")
|
||||||
|
print()
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -106,22 +106,23 @@ def process_host(host_element):
|
|||||||
hosts[name] = { "name": name, "address": address, "services": services }
|
hosts[name] = { "name": name, "address": address, "services": services }
|
||||||
|
|
||||||
def print_host(host):
|
def print_host(host):
|
||||||
print "object Host \"%s\" inherits \"discovered-host\" {" % (host["name"])
|
print "object Host \"%s\" {" % (host["name"])
|
||||||
print "\tmacros[\"address\"] = \"%s\"," % (host["address"])
|
print "\timport \"discovered-host\","
|
||||||
|
print ""
|
||||||
for serv, service in host["services"].iteritems():
|
print "\tmacros.address = \"%s\"," % (host["address"])
|
||||||
print ""
|
|
||||||
print "\tservices[\"%s\"] = {" % (serv)
|
|
||||||
print "\t\ttemplates = [ \"discovered-service\" ],"
|
|
||||||
print ""
|
|
||||||
print "\t\tcheck_command = \"%s\"," % (service["command"])
|
|
||||||
print ""
|
|
||||||
print "\t\tmacros[\"port\"] = %s" % (service["port"])
|
|
||||||
print "\t},"
|
|
||||||
|
|
||||||
print "}"
|
print "}"
|
||||||
print ""
|
print ""
|
||||||
|
|
||||||
|
for serv, service in host["services"].iteritems():
|
||||||
|
print "apply Service \"%s\" {" % (serv)
|
||||||
|
print "\timport \"discovered-service\","
|
||||||
|
print ""
|
||||||
|
print "\tcheck_command = \"%s\"," % (service["command"])
|
||||||
|
print ""
|
||||||
|
print "\tmacros.port = %s" % (service["port"])
|
||||||
|
print "}"
|
||||||
|
print ""
|
||||||
|
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
# Expects XML output from 'nmap -oX'
|
# Expects XML output from 'nmap -oX'
|
||||||
dom = parse(arg)
|
dom = parse(arg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user