In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Falcon is combined with script redis-monitor.py to monitor redis* python / usr/local/openfalcon-0.2/mymon/redis-monitor.py & > / usr/local/openfalcon-0.2/mymon/redis-monitor.logcat redis-monitor.py# Note to modify the configuration item: _ redis_cli,def _ _ init__,insts_list Ipipflowers binmax Env python#-*- coding:utf-8-*-import jsonimport timeimport socketimport osimport reimport sysimport commandsimport urllib2, base64class RedisStats: # if you compile and deploy to redis yourself Please replace the following value with your path to redis-cli _ redis_cli ='/ usr/local/bin/redis-cli' _ stat_regex = re.compile (ur' (\ w +): ([0-9] +\.? [0-9] *)\ r') def _ _ init__ (self, port='6379', passwd=None) Host='127.0.0.1'): self._cmd ='% s-h% s-p% s info'% (self._redis_cli, host, port) if passwd not in [', None]: self._cmd ='% s-h% s-p% s-a% s info'% (self._redis_cli, host, port) Passwd) def stats (self): 'Return a dict containing redis stats' info = commands.getoutput (self._cmd) # print info return dict (self._stat_regex.findall (info)) def main (): ip = '192.168.1.1' # ip = socket.gethostname () timestamp = int (time.time ()) step = 60 # inst_list saved redis profile list The program will read port and password from these configurations, and it is recommended that you use dynamic discovery to get For example: # inst_list = [i for i in commands.getoutput ("find / etc/-name 'redis*.conf'"). Split ('\ n')] insts_list = ['/ etc/redis/redis.conf'] p = [] monit_keys = [('connected_clients','GAUGE'), (' blocked_clients','GAUGE'), ('used_memory','GAUGE') ('used_memory_rss','GAUGE'), (' mem_fragmentation_ratio','GAUGE'), ('total_commands_processed','COUNTER'), (' rejected_connections','COUNTER'), ('expired_keys','COUNTER'), (' evicted_keys','COUNTER'), ('keyspace_hits','COUNTER'), (' keyspace_misses' 'COUNTER'), (' keyspace_hit_ratio','GAUGE') ] for inst in insts_list: port = commands.getoutput ("sed-n's / ^ port *\ ([0-9]\ {4jue 5\}\) /\\ 1compp'% s"% inst) passwd = commands.getoutput ("sed-n's / ^ postpass *\ ([^] *\) /\\ 1lapp's"% inst) metric = "redis" endpoint = ip Tags = 'port=%s'% port try: conn = RedisStats (port Passwd) stats = conn.stats () except Exception,e: continue for key,vtype in monit_keys: # there is very little information output from info in some older versions of redis If there is no key we need to collect, skip if key not in stats.keys (): continue # calculate the hit rate if key = 'keyspace_hit_ratio': try: value = float (stats [' keyspace_hits']) / (int (stats ['keyspace_hits']) + int ( Stats ['keyspace_misses']) except ZeroDivisionError: value = 0 # fragment rate is floating point elif key = =' mem_fragmentation_ratio': value = float (stats [key]) else: # everything else is collected into counter Int try: value = int (stats [key]) except: continue I = {'Metric':'% s% s'% (metric, key), 'Endpoint': endpoint,' Timestamp': timestamp, 'Step': step 'Value': value,' CounterType': vtype, 'TAGS': tags} p.append (I) print json.dumps (p, sort_keys=True Indent=4) method = "POST" handler = urllib2.HTTPHandler () opener = urllib2.build_opener (handler) url = 'http://127.0.0.1:1998/v1/push' request = urllib2.Request (url, data=json.dumps (p) request.add_header ("Content-Type",' application/json') request.get_method = lambda: method try: connection = opener.open (request) except urllib2.HTTPError E: connection = e # check. Substitute with appropriate HTTP code. If connection.code = = 200: print connection.read () else: print'{"err": 1, "msg": "% s"}'% connectionif _ name__ = ='_ _ main__': proc = commands.getoutput ('ps-ef | grep% s | grep-v grep | wc-l'% os.path.basename (sys.argv [0])) sys.stdout.flush () if int (proc) < 5: main ()
Redis process monitoring
Redis status monitoring
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.