X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tools%2Fnagiosobjects.py;fp=tools%2Fnagiosobjects.py;h=332fb4051785507ab72548c6b617e8a26f0241ea;hb=0ec02be43199c5fe414e3e9f24369eb1586ca3bc;hp=0000000000000000000000000000000000000000;hpb=82a17d43e5329fea99340b25dfda4ec646ea1095;p=monitor.git diff --git a/tools/nagiosobjects.py b/tools/nagiosobjects.py new file mode 100644 index 0000000..332fb40 --- /dev/null +++ b/tools/nagiosobjects.py @@ -0,0 +1,60 @@ + +class NagiosObject(object): + trans = {'d2_coords': '2d_coords'} + + def __init__(self, id, **kwargs): + self.id = id + self.kwords = kwargs.keys() + for key in self.kwords: + self.__setattr__(key, kwargs[key]) + + def toString(self): + ret = "" + ret += "define %s {\n" % self.id + for key in self.kwords: + if key in self.trans: + ret += " %s %s\n" % (self.trans[key], self.__getattribute__(key)) + else: + ret += " %s %s\n" % (key, self.__getattribute__(key)) + ret += "}\n" + return ret + +class Command(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "command", **kwargs) + +class Host(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "host", **kwargs) + +class HostGroup(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "hostgroup", **kwargs) + +class HostEscalation(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "hostescalation", **kwargs) + +class Contact(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "contact", **kwargs) + +class ContactGroup(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "contactgroup", **kwargs) + +class Service(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "service", **kwargs) + +class ServiceDependency(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "servicedependency", **kwargs) + +class ServiceEscalation(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "serviceescalation", **kwargs) + +class ServiceGroup(NagiosObject): + def __init__(self, **kwargs): + NagiosObject.__init__(self, "servicegroup", **kwargs)