0

我正在尝试使用Zabbix API实现一个功能,基本要求是:创建命令脚本(字符串或脚本文件都可以,无论保存在服务器还是代理上)->在代理上执行;

我找到了两种使用远程命令的方法:

1)全局脚本:我可以直接调用script.execute来使用,但是“远程命令限制为255个字符”,根据我们的需求创建一个脚本/命令是不够的;如果我们需要使用Python就更难了,如果Python脚本稍微复杂一点,#python -c "..." 就不能正常运行,并且使用shell命令在agent上创建*.py文件需要更多的字符;

全局脚本保存在脚本表中,但根据https://www.zabbix.com/forum/showthread.php?t=51869中的评论,通过将长度从 255 增加到 1024 来更改表结构并不是一个好主意;

2)自定义脚本:命令字符没有限制,但我必须在Action中配置它,并等待触发它。

另一方面,即使Remote Command也可以在agent上创建脚本文件,还是不方便,有没有办法通过Zabbix自带的函数将文件从Zabbix Server发送到Agent?

我想在 Zabbix 论坛上问它,但是我没有创建新帖子/线程的权限,所以我去这里。

有没有人可以给我一些帮助?

4

1 回答 1

1

That isn't really a feature of a monitoring system. You might be able to abuse the system.run key - have a script that splits your target script in ~200 byte blocks, then have them concatenated on the agent by running remote commands or zabbix_get like so (and be careful with newlines):

zabbix_get -s target.host -k "system.run[echo \"$script_part\" >> /script_location]"

That would be quite terrible and hackish, though.

While there is a feature request to introduce agent configuration management in Zabbix, have I already mentioned that it is not really a task for a monitoring system? You might want to look into system management tools like Puppet, Chef and others.

于 2016-12-16T07:13:45.330 回答