Пример #1
0
    def print_test(self, outfile, prefix, test):
        """
	        Print external commands for device test
		@param output file to print to
	        @param prefix SZARP configuration prefix
	        @param test (device num, device daemon, parameter) tuple
	        """
        (num, daemon, param) = test
        service = "Device %d" % num
        code = False
        if param is None:
            code = 3
            output = "Test parameter not defined"
            d = None
        if not code:
            path = sn.param_to_path(param)
            d = sn.get_lad(prefix, path)
        if not code and d is None:
            code = 3
            output = "Data not found: " + path
        if not code:
            output = daemon + " " + path.replace("/", ":", 2)
            age = sn.get_age(d)
            if age > 40:
                code = 2
            elif age > 20:
                code = 1
            else:
                code = 0
        print >> outfile, ("[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s" %
                           (int(time.time()), prefix, service, code, output))
        return code
Пример #2
0
	def print_test(self, outfile, prefix, test):
	        """
	        Print external commands for device test
		@param output file to print to
	        @param prefix SZARP configuration prefix
	        @param test (device num, device daemon, parameter) tuple
	        """
	        (num, daemon, param) = test
	        service = "Device %d" % num
		code = False
		if param is None:
	                code = 3
	                output = "Test parameter not defined"
			d = None
		if not code:
			path = sn.param_to_path(param)
	        	d = sn.get_lad(prefix, path)
		if not code and d is None:
	                code = 3
			output = "Data not found: " + path
		if not code:
	                output = daemon + " " + path.replace("/", ":", 2)
	                age = sn.get_age(d)
	                if age > 40:
	                        code = 2
	                elif age > 20:
	                        code = 1
	                else:
	                        code = 0
	        print >> outfile, ("[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s" % (
	                        int(time.time()), prefix, service, code, output
	                        ))
		return code
Пример #3
0
    def print_lad(self, outfile, prefix, parameter_path, service_name):
        """
	        Print nagios external command for last-available-date for prefix and parameter
		@param output file to print to
	        @param prefix SZARP configuration prefix
	        @param parameter_path directory for parameter (for example: Status/Meaner3/program_uruchomiony)
	        @service_name name of service to print
	        @return status code, 0 for ok
	        """
        d = sn.get_lad(prefix, parameter_path)
        if d is None:
            code = 3
            output = "Status parameter not found"
        else:
            output = d.strftime("%Y-%m-%d %H:%M")
            age = sn.get_age(d)
            if age > self.reqs[prefix].max_delay:
                code = 2
            elif age > self.reqs[prefix].max_delay - 10:
                code = 1
            else:
                code = 0
        print >> outfile, (
            "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s" %
            (int(time.time()), prefix, service_name, code, output))
        if code == 2:
            self.reqs[prefix].failed += 1
        else:
            self.reqs[prefix].failed = 0
        return code
Пример #4
0
	def print_lad(self, outfile, prefix, parameter_path, service_name):
	        """
	        Print nagios external command for last-available-date for prefix and parameter
		@param output file to print to
	        @param prefix SZARP configuration prefix
	        @param parameter_path directory for parameter (for example: Status/Meaner3/program_uruchomiony)
	        @service_name name of service to print
	        @return status code, 0 for ok
	        """
	        d = sn.get_lad(prefix, parameter_path)
	        if d is None:
	                code = 3
	                output = "Status parameter not found"
	        else:
	                output = d.strftime("%Y-%m-%d %H:%M")
	                age = sn.get_age(d)
	                if age > self.reqs[prefix].max_delay:
	                        code = 2
	                elif age > self.reqs[prefix].max_delay - 10:
	                        code = 1
	                else:
	                        code = 0
	        print >> outfile, ("[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s" % (
	                        int(time.time()), prefix, service_name, code, output
	                        ))
		if code == 2:
			self.reqs[prefix].failed += 1 
		else:
			self.reqs[prefix].failed = 0
	        return code