Hi folks, I have python script which is downloading and parsing some files. In these files I am looking for some string. I would like to ask if there is any way how to connect it to zabbix. I would like to run trigger in case that script will find string which I am looking for. Is there any solution how to do it? Thank you in advance.
Ad Widget
Collapse
Is possible to run trigger using python script?
Collapse
X
-
Hi, you can create an item of type Zabbix trapper, and send data to it with for example https://github.com/markkuleinio/zbxsend. Then you can define suitable trigger in Zabbix.
Alternatively, if your script can do its thing fast (like in two seconds or faster), then you can use UserParameters and call your script directly in a Zabbix agent item.
Markku -
Great, thank you for your answer, but I have problem with sending data using zbxsend. I always get error message
Here is line from scriptERROR:zbxsender:Wrong zabbix response
192.168.0.100 zabbix serverHTML Code:send_to_zabbix([Metric('192.168.1.77', 'trapx', 1)], '192.168.0.100', 10050)
192.168.1.77 my pc
Screen of settings
I have checked zabbix_server.log, but I didn't find any information about possible problem. I wanted to try zabbix_sender to send some test data, but I don't know how to get it. In documentation, there is written that is located in bin folder, but I don't have it, and I didn't find any more information about this tool. Could someone help me, where could be a problem or how to debug it?Last edited by lkip912; 07-02-2020, 15:38.Comment
-
Thank you very much, you are great! The port was problem. In the list of hosts there is interface 127.0.0.1:10050, this is why I put there wrong port. I have also found zabbix-sender, I was looking for zabbix_sender according to documentation.
However I have one more problem. I can successfully send data by zabbix-sender with this command:
but with this line in script it doesn't work (0 processed)Code:zabbix_sender -z 192.168.0.100 -s "Zabbix server" -k "trapx" -o "asdf"
Code:send_to_zabbix([Metric('Zabbix server', 'trapx', 'asdf')], '192.168.0.100', 10051)Could you help me? I think it is again some small problem, but I am not able to find it. Thank you in advance.DEBUG:zbxsender:Got response from Zabbix: {'response': 'success', 'info': 'processed: 0; failed: 0; total: 0; seconds spent: 0.000024'}
INFO:zbxsender: processed: 0; failed: 0; total: 0; seconds spent: 0.000024Last edited by lkip912; 10-02-2020, 10:35.Comment
-
What is your Python version? I have modified the code with Python 3 in mind (and It works for me<tm>
), with legacy Python (2.x) I don't know how it actually works. (In the latter case you may want to try the original author's code in https://github.com/pistolero/zbxsend)
You may want to take some packet capture as well to see the actual content of the packets.
MarkkuComment
Comment