Esempio n. 1
0
 def ssdb_info(self):
     try:
         ssdb_cli = SSDB(host=self.addr, port=self.port)
         ssdb_info_list = ssdb_cli.execute_command("info")[2:-2]
         ssdb_info = self.process_ssdb_info_simple(ssdb_info_list)
     except Exception as e:
         self.logger.error(e)
         ssdb_info = {}
     return ssdb_info
Esempio n. 2
0
    def ping_ssdb(self):
        ssdb_is_alive = 0
        try:
            ssdb_cli = SSDB(host=self.addr, port=self.port)
            ping_res = ssdb_cli.execute_command("ping")
            if ping_res:
                ssdb_is_alive = 1
        except Exception as e:
            self.logger.error(e)
        if ssdb_is_alive == 0:  # If ssdb is dead, update the alive metrice here.
            ssdb_alive_data = [{
                "endpoint": self.addr,
                "metric": "ssdb_alive",
                "tags": self.tags,
                "timestamp": upload_ts,
                "value": ssdb_is_alive,
                "step": 60,
                "counterType": "GAUGE"
            }]

            r = requests.post(falcon_client, data=json.dumps(ssdb_alive_data))
            self.logger.debug(r.text)
        return ssdb_is_alive
Esempio n. 3
0
import redis
from ssdb import SSDB

rclient = redis.Redis(host="*", port=36379, password='******')
rpipeline = rclient.pipeline()

pipe_time = time.time()
for x in range(10000):
    rpipeline.lpop('task_list_test01')
#rpipeline.lrange('task_list_test01',0,10000)
records = rpipeline.execute()
print('redis total time:', time.time() - pipe_time)

sclient = SSDB('*', port=46379)
# sclient = SSDB(host='18.196.*.*',port=46379,)
sclient.execute_command('auth xxxxxxx')
i = 1
begin_time = time.time()
sclient.qpush_front('task_list_sorted', records)
print(time.time() - begin_time)

exit(0)
for record in records:
    # sclient.zset('task_list_sorted',record,i)
    sclient.qpush_front('task_list_sorted', record)
    i += 1
print(time.time() - begin_time)
#------------------------------------
#postgresql连接代码
import psycopg2