File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ modules {
44 language = "python"
55 param host { value = "127.0.0.1" }
66 param port { value = 6379 }
7+ /* param auth { value = "passwordhere" } */
78 }
89}
910collection_group {
Original file line number Diff line number Diff line change @@ -11,7 +11,12 @@ def metric_handler(name):
1111 if 15 < time .time () - metric_handler .timestamp :
1212 s = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
1313 s .connect ((metric_handler .host , metric_handler .port ))
14- s .send ("INFO\r \n " )
14+ if metric_handler .auth is not None :
15+ s .send ("*2\r \n $4\r \n AUTH\r \n $%d\r \n %s\r \n " % (len (metric_handler .auth ), metric_handler .auth ));
16+ result = s .recv (100 )
17+ if not 'OK' in result :
18+ return 0
19+ s .send ("*1\r \n $4\r \n INFO\r \n " )
1520 #logging.debug("sent INFO")
1621 info = s .recv (4096 )
1722 #logging.debug("rcvd INFO")
@@ -70,6 +75,7 @@ def metric_handler(name):
7075def metric_init (params = {}):
7176 metric_handler .host = params .get ("host" , "127.0.0.1" )
7277 metric_handler .port = int (params .get ("port" , 6379 ))
78+ metric_handler .auth = params .get ("auth" , None )
7379 metric_handler .timestamp = 0
7480 metric_handler .prev_total_commands = 0
7581 metric_handler .prev_total_connections = 0
You can’t perform that action at this time.
0 commit comments