PDA

View Full Version : Remote commands execution


dunedin
12-12-2005, 13:01
Hello,

Is it possible to execute remote commands from zabbix (say stopping/starting IIS or sql etc...) ?

ReefShark
29-03-2006, 15:24
It is now (beta8) ;)

ianh
30-03-2006, 00:21
what parameter does it take in the "remote command" field?

Also in zabbix_agentd.conf i found out that remote commands was disabled so i uncommented it and it should enabled it correct?

# Enable remote commands for ZABBIX agent. By default remote commands disabled.
EnableRemoteCommands=1

Cheers

kempkep
30-03-2006, 01:40
The remote command should be of the form:

<hostname>:<command>

Note: The hostname cannot be a fully qualified one, it doesn't match the reg expression in the code. So if you defined hosts fully qualified you need to change it.

Also make sure you update the agent on the host you want to run the command on. A system.run command is run on the agent and this is not supported prior to 1.1beta8.

ianh
30-03-2006, 06:01
Thanks for the tip kempkep ;)

I can successfully add a remote command action however i don't think the command is executing. FYI, I am using zabbix 1.1beta8 on all my test machines.

Here is my remote command "amon01:service sendmail start" -- starts my sendmail

First off, i stopped my sendmail service so when the action is fired it starts my service sendmail, thus i am able to check if the remote command works.

Assigning a trigger that when fired sends a email and remote command, i get the email but when i check my sendmail status it has not started.

One other thing is that if a remote command action is fired, does it show up in the "history of actions page"?

Has anyone got remote command working?

**any docs on remote command??

Cheers

kempkep
30-03-2006, 06:13
Check the agent log, increase the debug level to 4 and restart. You should see something like this...

015114:20060330:124941 Got line:system.run[/tmp/mycommand >/tmp/remcom.log]
015114:20060330:124941 Run remote command '/tmp/mycommand >/tmp/remcom.log'
015114:20060330:124941 Sending back:1

Also check that the agent is working and not saying ZBX_NOTSUPPORTED, ie: it should look like this...

akcux05:/etc/zabbix##### /usr/local/bin/zabbix_agentd -p
system.run[echo test] [u|1]

If it does not show you're probably running the wrong agent or the script/command is not executable.

You're right about it not showing in the actions history - even when it works :(

Just had another thought - what you are doing won't work as the script will run as zabbix and a service command will need to run as root. So unless you're doing a setuid on the service command, you'll need to use sudo or create a wrapper script that you setuid. Maybe do the wrapper first and direct output to a log somewhere.

ianh
30-03-2006, 06:37
Once again thanks for the quick response kempkep.

I'll keep working on it... :)

tuhl
03-04-2006, 14:10
Hi!

Remote command invocation works (user zabbix). There should be a log of the exit status and the output of stdout and stderr (up to 512 bytes)

Corsar
13-04-2006, 14:05
So ... can you help me?
How i can add remote command execution with web-frontend?

1. Put EnableRemoteCommands=1 in agentd.conf
2. Add some item and trigger with web-frontend
3. But when i'm trying to add action:
-------------------------------------
host.domain.ru:whoami | mail root@domain.ru
-------------------------------------
Web-frontend say me:
[ERROR:Cannot add action]
incorrect command: 'host.domain.ru:mail root@domain.ru'

Where is my mistake? :confused:

grabber
24-04-2006, 12:32
@Corsar

reading the above it would seem that you cannot use FQDN for the host. So you have to switch that off....

Corsar
24-04-2006, 13:03
Ooops ...
Sorry
I see this condition ...

But, i think what this is .... khm ... mistake developer's ...
FQDN != remote command execution :confused:
It's very uncomfortable ...

May i hope, for this condition (FQDN != remote command execution) eliminate?
:rolleyes: ;)

Borrie
28-06-2006, 13:30
-edited by me-