403Webshell
Server IP : 39.108.156.168  /  Your IP : 216.73.216.104
Web Server : nginx/1.24.0
System : Linux e2.ksyuki.com 6.11.0-25-generic #25~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 17:20:50 UTC 2 x86_64
User : root ( 0)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/dstat/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/dstat/dstat_redis.py
### Author: Jihyun Yu <yjh0502@gmail.com>

global redis_host 
redis_host = os.getenv('DSTAT_REDIS_HOST') or "127.0.0.1"

global redis_port
redis_port = os.getenv('DSTAT_REDIS_PORT') or "6379"

class dstat_plugin(dstat):
    def __init__(self):
        self.type = 'd'
        self.width = 7
        self.scale = 10000
        self.name = 'redis'
        self.nick = ('tps',)
        self.vars = ('tps',)
        self.cmdInfo = '*1\r\n$4\r\ninfo\r\n'

    def get_info(self):
        global socket
        import socket

        global redis_host
        global redis_port

        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            s.settimeout(0.1)
            s.connect((redis_host, int(redis_port)))
            s.send(self.cmdInfo)
            dict = {};
            for line in s.recv(1024*1024).split('\r\n'):
                if line == "" or line[0] == '#' or line[0] == '*' or line[0] == '$':
                    continue
                pair = line.split(':', 2)
                dict[pair[0]] = pair[1]
            return dict
        except:
            return {}
        finally:
            try:
                s.close()
            except:
                pass

    def extract(self):
        key = "instantaneous_ops_per_sec"
        dic = self.get_info()
        if key in dic:
            self.val['tps'] = int(dic[key])

# vim:ts=4:sw=4:et

Youez - 2016 - github.com/yon3zu
LinuXploit