File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 121121Export metrics to zabbix server
122122Command: --send-data-zabbix
123123Example:
124- {prog} --send-data-zabbix --zabbix-file=localhost.log --zabbix-addres=licalhost
124+ {prog} --send-data-zabbix --zabbix-file=localhost.log --zabbix-address=localhost
125125Options:
126126 --zabbix-address <name of the Zabbix host to send metrics>
127127 --zabbix-port <port of Zabbix server to send metrics> by default 10051
Original file line number Diff line number Diff line change @@ -73,13 +73,19 @@ def send_file_to_zabbix (self,path):
7373 while True :
7474 lines = list (islice (f , 100 ))
7575 for line in lines :
76- split_line = line .rstrip ('\n ' ).split ('\t ' )
77- metric = {
78- 'host' : zabbix_client ,
79- 'key' : split_line [2 ],
80- 'value' : split_line [1 ],
81- 'clock' : int (split_line [0 ])}
82- metrics .append (metric )
76+ try :
77+ split_line = line .rstrip ('\n ' ).split ('\t ' )
78+ if len (split_line ) == 3 :
79+ metric = {
80+ 'host' : zabbix_client ,
81+ 'key' : split_line [2 ],
82+ 'value' : split_line [1 ],
83+ 'clock' : int (split_line [0 ])}
84+ metrics .append (metric )
85+ else :
86+ self .log .error ('Can\' t load metric in line: "{0}". The line must have the format: time <tab> value <tab> metric\' s name.' .format (line .rstrip ('\n ' )))
87+ except Exception as e :
88+ self .log .error ('Can\' t load metric in line: "{0}". Error : {1} ' .format (line .rstrip ('\n ' ),e ,))
8389
8490 data = json .dumps ({
8591 'request' : 'sender data' ,
You can’t perform that action at this time.
0 commit comments