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 121
121
Export metrics to zabbix server
122
122
Command: --send-data-zabbix
123
123
Example:
124
- {prog} --send-data-zabbix --zabbix-file=localhost.log --zabbix-addres=licalhost
124
+ {prog} --send-data-zabbix --zabbix-file=localhost.log --zabbix-address=localhost
125
125
Options:
126
126
--zabbix-address <name of the Zabbix host to send metrics>
127
127
--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):
73
73
while True :
74
74
lines = list (islice (f , 100 ))
75
75
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 ,))
83
89
84
90
data = json .dumps ({
85
91
'request' : 'sender data' ,
You can’t perform that action at this time.
0 commit comments