def test_xor_with_password(self): self.setServerBannerB64(""" unvxWHaOSEOA67AxsyjFCCOJ5i2d8pz5uHVA7A2ilccehh+UFWfXlVOIxwawjQ/UFvYBs +mdraET7o4gkCTnrqoHQsBvGlbDoh7KU6vZJ8HQKHW5xiJb2RDq+aAO4U+56ZJ5WKzQHE /u5qKZwMpbkPPQSrnzpZMDj42knW7zVlhNubCx """) notif = pynsca.NSCANotifier('127.0.0.1', self.port, password='******') notif.svc_result('linux-ix-slave10.build', 'buildbot-start', 0, 'hello!') self.assertGotB64(""" 0hmcMK4acQugOmHt20nECSyR9mGZ4tDnvHVb4V3/08QGhxKdfQa6/TLlr2fd5W65fpds24jwxcB+ hu9N+EWKxstqKqECcjeuyn+nO8q0LdXULHC2wTcbwgXm47VjiS7UgfMUMM29dC6DjsP0qKs2+JK9 ItiezfJu5+zJ9Q+ePjnXE5A1Hu8lK+GG2FDeQKRlS+iLRfyf9JjVHSGBZcP4r3/rd/V4D7b4O+mq btHgZ7V7nmDegfzAyXKD5kH9TIbDwmYvqA53PqLPdqs+w7gizN0pcvmrSjq0eIuUyG+MJ9iE+hg1 xLFxJ4+Lyvitojr9m7En0ZLI+2Li5cXwBpI7MNsWmTkb5iku6IrdWdJFrWlO4YdA9ZPxkdkYKI1g yvSqdudy/HQKv/Q+4KZr2OxivHebadKE9czMe4/jSPFJj8/HbyOtB3s7q8NzojLGsUasuEkY0adP M7h9gpjNZoAi0Yj/ETnBuH0ihofP8aGnM/GeuCvUm8T+a+7gzPwDmzc10hqcMBfjICLtg9Fc20mo YELkjkzwmv2U0BQthGzP/aZz7n75fQa6/TLlr2fd5W65fpds24jwxcB+hu9N+EWKxstqKqECcjeu yn+nO8q0T6C9QBTUrkM2sXGHkcFjiS7UgfMUMM29dC6DjsP0qKs2+JK9ItiezfJu5+zJ9Q+ePjnX E5A1Hu8lK+GG2FDeQKRlS+iLRfyf9JjVHSGBZcP4r3/rd/V4D7b4O+mqbtHgZ7V7nmDegfzAyXKD 5kH9TIbDwmYvqA53PqLPdqs+w7hKqbFFHdirSjq0eIuUyG+MJ9iE+hg1xLFxJ4+Lyvitojr9m7En 0ZLI+2Li5cXwBpI7MNsWmTkb5iku6IrdWdJFrWlO4YdA9ZPxkdkYKI1gyvSqdudy/HQKv/Q+4KZr 2OxivHebadKE9czMe4/jSPFJj8/HbyOtB3s7q8NzojLGsUas """)
def test_xor(self): self.setServerBannerB64(""" unvxWHaOSEOA67AxsyjFCCOJ5i2d8pz5uHVA7A2ilccehh+UFWfXlVOIxwawjQ/UFvYBs +mdraET7o4gkCTnrqoHQsBvGlbDoh7KU6vZJ8HQKHW5xiJb2RDq+aAO4U+56ZJ5WKzQHE /u5qKZwMpbkPPQSrnzpZMDj42knW7zVlhNubCx """) notif = pynsca.NSCANotifier('127.0.0.1', self.port) notif.svc_result('linux-ix-slave10.build', 'buildbot-start', 0, 'hello!') self.assertGotB64(""" unjxWM93GWrNUgCAsyipYU38ngD0irGK1BQ2iTySu6Vr73PwFWfXlVOIxwawjQ/UFvYBs +mdraET7o4gkCTnrqoHQsBvGlbDoh7KU6vZRbS5RBHbqVZ2qmSLi9QO4U+56ZJ5WKzQHE /u5qKZwMpbkPPQSrnzpZMDj42knW7zVli6e/FYdo5IQ4DrsDGzKMUII4nmLZ3ynPm4dUD sDaKVxx6GH5QVZ9eVU4jHBrCND9QW9gGz6Z2toRPujiCQJOeuqgdCwG8aVsOiHspTq9lP pLxEGpjGIlvZEOr5oA7hT7npknlYrNAcT+7mopnAyluQ89BKufOlkwOPjaSdbvNWWLp78 Vh2jkhDgOuwMbMoxQgjieYtnfKc+bh1QOwNopXHHoYflBVn15VTiMcGsI0P1Bb2AbPpna 2hE+6OIJAk566qB0LAbxpWw6IeylOr2SfB0Ch1ucYiW9kQ6vmgDuFPuemSeVis0BxP7ua imcDKW5Dz0Eq586WTA4+NpJ1u81ZYunvxWHaOSEOA67AxsyjFCCOJ5i2d8pz5uHVA7A2i lccehh+UFWfXlVOIxwawjQ/UFvYBs+mdraET7o4gkCTnrqoHQsBvGlbDoh7KU6vZJ8HQK HW5xiJb2RDq+aAO4U+56ZJ5WKzQHE/u5qKZwMpbkPPQSrnzpZMDj42knW7zVli6e/FYdo 5IQ4DrsDGzKMUII4nmLZ3ynPm4dUDsDaKVxx6GH5QVZ9eVU4jHBrCND9QW9gGz6Z2toRP ujiCQJOeuqgdCwG8aVsOiHspTq9knwdAodbnGIlvZEOr5oA7hT7npknlYrNAcT+7mopnA yluQ89BKufOlkwOPjaSdbvNWWLp78Vh2jkhDgOuwMbMoxQgjieYtnfKc+bh1QOwNopXHH oYflBVn15VTiMcGsI0P1Bb2AbPpna2hE+6OIJAk566qB0LAbxpWw6IeylOr2SfB """)
def __init__(self, localIP, nagiosIP, logfilename, interval,\ pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): daemon.Daemon.__init__(self, pidfile, stdin, stdout, stderr) self.localIP = localIP self.interval = interval self.logfilename = logfilename self.nscaSender = pynsca.NSCANotifier(nagiosIP) self.label_result_map = {}
def __init__(self, localIP=None, nagiosIP=None, logfileName=None, interval=None): self.latencyRatio = 0.95 self.label_result_map = {} self.localIP = localIP self.nscaSender = pynsca.NSCANotifier(nagiosIP) self.interval = interval self.warning_map = {"latency": 0, "failrate": 0} self.critical_map = {"latency": 0, "failrate": 0} self.logfileName = logfileName threading.Thread.__init__(self) self._stop = threading.Event()
def transmitResult(self, context): ''' Here we send the result to the Icinga / Nagios server using NSCA Overload this method if you want ot submit your changes on a different way ''' DebugMessage(context, 100, "Submitting check result to host %s, encryption: %d, Port: %d\n" \ %(self.monitorHost,self.encryption, self.monitorPort)) try: notif = pynsca.NSCANotifier(self.monitorHost, self.monitorPort, self.encryption) notif.svc_result(self.checkHost, self.checkService, self.nagiosResult, self.nagiosMessage + self.perfstring) except: JobMessage(context, bJobMessageType['M_WARNING'], "Plugin %s could not transmit check result to host %s, port %d\n"\ %(self.__class__, self.monitorHost, self.monitorPort))
cmd_parser.add_option("-c", "--critical", type="int", action="store", dest="critical_per", help="Exit with CRITICAL status if higher than the PERCENT of Disk Usage", metavar="Critical Percentage") (cmd_options, cmd_args) = cmd_parser.parse_args() if not (cmd_options.local_address and cmd_options.mount_point and cmd_options.warning_per and cmd_options.critical_per): cmd_parser.print_help() sys.exit(3) # get disk status disk_status = commands.getstatusoutput("df -h " + cmd_options.mount_point) usage_per= disk_status[1].split()[11] usage_per_number = int(usage_per[:-1]) # Check if CPU Usage is Critical/Warning/OK if usage_per_number >= cmd_options.critical_per: return_code = pynsca.CRITICAL plugin_output = 'STATISTICS CRITICAL : ' elif usage_per_number >= cmd_options.warning_per: return_code = pynsca.WARNING plugin_output = 'STATISTICS WARNING : ' else: return_code = pynsca.OK plugin_output = 'STATISTICS OK : ' plugin_output += '"MOUNT' + cmd_options.mount_point + '"Usage=' + usage_per + ' | "MOUNT' + cmd_options.mount_point + '"Usage=' + usage_per + ';' + str(cmd_options.warning_per) + ';' + str(cmd_options.critical_per) +';;' #print plugin_output nscaClient = pynsca.NSCANotifier(nagios_address) nscaClient.svc_result(cmd_options.local_address, service_description, return_code, plugin_output)
def setUp(self): self.notif = pynsca.NSCANotifier("host", 1234)