#process data current_redis_memory_usage = (float(redis_memory_used)) / ( float(redis_maxmemory)) current_redis_memory_usage = Decimal( current_redis_memory_usage).quantize( Decimal('1.01'), rounding=ROUND_UP) if debug: print("current memory usage") print("--------------------") print("memory usage : {u}%".format(u=current_redis_memory_usage)) #Format perf data string con_perf_data_string = OutputFormatHelpers.perf_data_string( label="redis_memory_usage", value=current_redis_memory_usage, warn=s_warning, crit=s_critical, UOM='%') #check logic status = "OK" if current_redis_memory_usage >= s_warning: status = "Warning" if current_redis_memory_usage >= s_critical: status = "Critical" #output formating memory_usage_message = '{used}% of {max}'.format( used=current_redis_memory_usage, max=size(redis_maxmemory, alternative))
redis = redis.StrictRedis( port=port, password=password, host=hostname, db=database ) if redis.ping(): status = "OK" message = "Success to ping-pong" else: status = "Critial" message = "Failed to ping-pong" output = OutputFormatHelpers.check_output_string( status, message ) print(output) except Exception as e: if debug: print(e) the_type, value, tb = sys.exc_info() traceback.print_tb(tb) print("Error: {m}".format(m=e)) sys.exit(2) finally: if status == "Critical": sys.exit(2)
#get redis_info redis_info = RedisCheckHelpers.get_info(redis_con=redis, debug=debug) redis_blocked_clients = long(redis_info['blocked_clients']) if debug: print("blocked clients") print("-----------") print("blocked_clients: {m}".format( m=size(redis_blocked_clients, alternative))) #Format perf data string con_perf_data_string = OutputFormatHelpers.perf_data_string( label="blocked_clients", value=redis_blocked_clients, warn=s_warning, crit=s_critical) #check logic status = "OK" if redis_blocked_clients >= s_warning: status = "Warning" if redis_blocked_clients >= s_critical: status = "Critical" #output formating memory_usage_message = '{n} blocked clients'.format( n=redis_blocked_clients)
current_redis_memory_usage = (float(redis_memory_used))/(float(redis_maxmemory)) current_redis_memory_usage = Decimal(current_redis_memory_usage).quantize( Decimal('1.01'), rounding=ROUND_UP ) if debug: print("current memory usage") print("--------------------") print("memory usage : {u}%".format(u=current_redis_memory_usage)) #Format perf data string con_perf_data_string = OutputFormatHelpers.perf_data_string( label="redis_memory_usage", value=current_redis_memory_usage, warn=s_warning, crit=s_critical, UOM='%' ) #check logic status = "OK" if current_redis_memory_usage >= s_warning: status = "Warning" if current_redis_memory_usage >= s_critical: status = "Critical" #output formating memory_usage_message = '{used}% of {max}'.format( used=current_redis_memory_usage,
print("Echo Base64 string") print("------------------") print(test_string_echo_b64) print("Echo string") print("-----------") print(test_string_echo) #get request time stop_time = datetime.now() elapsed_time = (stop_time - start_time) elapsed_time_ms = int(ceil(elapsed_time.microseconds * 0.001)) #Format perf data string con_perf_data_string = OutputFormatHelpers.perf_data_string( label="connection_delay", value=elapsed_time_ms, warn=s_warning, crit=s_critical, UOM='ms') #check logic if test_string == test_string_echo: status = "OK" message = "Redis connection successful" if elapsed_time_ms > s_warning: status = "Warning" message = "Redis connection with too slow" if elapsed_time_ms > s_critical: status = "Critical" message = "Redis connection too slow" else: status = "Critical"
print( "used_memory_rss: {m}".format( m=size( redis_memory_used_rss, alternative ) ) ) #Format perf data string perfdata = [ OutputFormatHelpers.perf_data_string( label="used_memory", value=redis_memory_used, warn=s_warning, crit=s_critical, min=0, max=redis_maxmemory, UOM='B' ), #Format perf data string OutputFormatHelpers.perf_data_string( label="used_memory_rss", value=redis_memory_used_rss, UOM='B' ) ] #check logic status = "OK"
debug = opts.debug try: redis = redis.StrictRedis(port=port, password=password, host=hostname, db=database) if redis.ping(): status = "OK" message = "Success to ping-pong" else: status = "Critial" message = "Failed to ping-pong" output = OutputFormatHelpers.check_output_string(status, message) print(output) except Exception as e: if debug: print(e) the_type, value, tb = sys.exc_info() traceback.print_tb(tb) print("Error: {m}".format(m=e)) sys.exit(2) finally: if status == "Critical": sys.exit(2) if status == "Warning":
if debug: print("blocked clients") print("-----------") print( "blocked_clients: {m}".format( m=size( redis_blocked_clients, alternative ) ) ) #Format perf data string con_perf_data_string = OutputFormatHelpers.perf_data_string( label="blocked_clients", value=redis_blocked_clients, warn=s_warning, crit=s_critical ) #check logic status = "OK" if redis_blocked_clients >= s_warning: status = "Warning" if redis_blocked_clients >= s_critical: status = "Critical" #output formating memory_usage_message = '{n} blocked clients'.format( n=redis_blocked_clients )
print( "connected_clients: {m}".format( m=redis_connected_clients ) ) print( "maxclients: {m}".format( m=redis_maxclients ) ) #Format perf data string con_perf_data_string = OutputFormatHelpers.perf_data_string( label="connected_clients", value=redis_connected_clients, warn=s_warning, crit=s_critical, min=0, max=redis_maxclients ) #check logic status = "OK" if redis_connected_clients >= s_warning: status = "Warning" if redis_connected_clients >= s_critical: status = "Critical" #output formating memory_usage_message = '{n} connected clients'.format( n=redis_connected_clients
redis_info = RedisCheckHelpers.get_info(redis_con=redis, debug=debug) redis_connected_clients = long(redis_info['connected_clients']) redis_maxclients = RedisCheckHelpers.get_mmaxclients(redis_con=redis, debug=debug) if debug: print("connected clients") print("-----------") print("connected_clients: {m}".format(m=redis_connected_clients)) print("maxclients: {m}".format(m=redis_maxclients)) #Format perf data string con_perf_data_string = OutputFormatHelpers.perf_data_string( label="connected_clients", value=redis_connected_clients, warn=s_warning, crit=s_critical, min=0, max=redis_maxclients) #check logic status = "OK" if redis_connected_clients >= s_warning: status = "Warning" if redis_connected_clients >= s_critical: status = "Critical" #output formating memory_usage_message = '{n} connected clients'.format( n=redis_connected_clients)
redis_memory_used_rss = long(redis_info['used_memory_rss']) if debug: print("memory used") print("-----------") print("used_memory: {m}".format( m=size(redis_memory_used, alternative))) print("used_memory_rss: {m}".format( m=size(redis_memory_used_rss, alternative))) #Format perf data string perfdata = [ OutputFormatHelpers.perf_data_string(label="used_memory", value=redis_memory_used, warn=s_warning, crit=s_critical, min=0, max=redis_maxmemory, UOM='B'), #Format perf data string OutputFormatHelpers.perf_data_string(label="used_memory_rss", value=redis_memory_used_rss, UOM='B') ] #check logic status = "OK" if redis_memory_used >= s_warning: status = "Warning" if redis_memory_used >= s_critical:
print(test_string_echo) #get request time stop_time = datetime.now() elapsed_time = (stop_time - start_time) elapsed_time_ms = int( ceil( elapsed_time.microseconds * 0.001 ) ) #Format perf data string con_perf_data_string = OutputFormatHelpers.perf_data_string( label="connection_delay", value=elapsed_time_ms, warn=s_warning, crit=s_critical, UOM='ms' ) #check logic if test_string == test_string_echo: status = "OK" message = "Redis connection successful" if elapsed_time_ms > s_warning: status = "Warning" message = "Redis connection with too slow" if elapsed_time_ms > s_critical: status = "Critical" message = "Redis connection too slow" else: