def nagfromtestdata():
    return parse(buildtestnagconfig())
Beispiel #2
0
def nagfromtestdata():
    return parse(buildtestnagconfig())
Beispiel #3
0
import nagparser

#Setup the config options
basedir = './nagparser/test/data/'
files = [basedir + 'test_objects.cache', basedir + 'test_status.dat']

config = nagparser.NagConfig(files=files)

#Extra config options
config.APIKEYS = ['test', 'hi']
config.NAGIOS_CMD_FILE = '/home/ARBFUND/mkennedy/nagios.cmd'

#config.getpermissions = examplegetpermissionssoverridefunction

#get the nag object
nag = nagparser.parse(config)

#Do something interesting

servicegroupstatuses = [
    x.status for x in nag.getservicegroups(onlyimportant=False)
]
for status in list(set(servicegroupstatuses)):
    print(servicegroupstatuses.count(status))

#json = nag.genoutput('json', prittyprint = False)
#
#print nag.servicegroups[1].commands.scheduledowntime('user', 'now', '1h', 'Testing', apikey = 'hi', doappend = True)
#
##print json
#print json.keys()
Beispiel #4
0
import nagparser

#Setup the config options
basedir = './nagparser/test/data/'
files = [basedir + 'test_objects.cache', basedir + 'test_status.dat']

config = nagparser.NagConfig(files = files)

#Extra config options
config.APIKEYS = ['test', 'hi']
config.NAGIOS_CMD_FILE = '/home/ARBFUND/mkennedy/nagios.cmd'

#config.getpermissions = examplegetpermissionssoverridefunction

#get the nag object
nag = nagparser.parse(config)

#Do something interesting

servicegroupstatuses = [x.status for x in nag.getservicegroups(onlyimportant = False)]
for status in list(set(servicegroupstatuses)):
    print servicegroupstatuses.count(status)


#json = nag.genoutput('json', prittyprint = False)
#
#print nag.servicegroups[1].commands.scheduledowntime('user', 'now', '1h', 'Testing', apikey = 'hi', doappend = True)
#
##print json
#print json.keys()
#print json['hosts'][1]['attributes']['host_name']