How to increase length of remote command script or how to send file from server to agent for zabbix

829 views Asked by At

I'm trying to implement a function with Zabbix API, the basic requirement is: create command script(string or script file both are OK, no matter save on Server or Agent) -> execute on Agent;

I find 2 way to do it with Remote Command:

1) Global Script: I can use it by calling script.execute directly, but "Remote commands are limited to 255 characters", it's not enough to create a script/command as our demand; and it's harder if we need use Python, #python -c "..." cannot run ok if Python script is complex a little, and use shell command to create *.py file on agent need more characters;

Global Script are saved in scripts table, but changing table structure by increasing length from 255 to 1024 is not a good idea according to comments in https://www.zabbix.com/forum/showthread.php?t=51869;

2) Custom Script: there is no limitation on command characters, but I had to config it in a Action, and wait for triggering it.

On the another hand, even Remote Command can create script file on agent, it's still not convenient, is there any way to sent file from Zabbix Server to Agent by Zabbix own function?

I want to ask it on Zabbix Forums, but I have no permission to create new Post/Thread, so I go to here.

Is there any one can give me some help about this?

1

There are 1 answers

0
Richlv On

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.