Zabbix remote commands for automatic remediation

Zabbix remote commands can restart services or run fixes from an action, but they are disabled by default and need deliberate scoping. This page covers how to enable them safely.

On this page

When Zabbix remote commands for automatic remediation fit your operations

Remote commands make sense when an on-call engineer fixes the same well-understood fault the same way every time, such as restarting a hung service, clearing a full temporary directory or recycling a stuck worker process. In Zabbix, a remote command is an operation inside an action that runs a script or command on a target when a problem fires. The fit question is whether the fix is safe to repeat without a human judging the context. If the right answer depends on what else is happening on the host, the fault belongs in a runbook or an escalation, not in an automated action.

Where the command runs matters as much as what it does. Commands can run on the Zabbix server, on a proxy or on an agent. Remote commands are disabled by default on agents and proxies, so nothing executes until you deliberately enable it: agents need an AllowKey entry for system.run[*] or for each specific command, and proxies need EnableRemoteCommands set to 1. Confirm which component will execute each action, because a command that works on the server may fail silently on a proxy-monitored host. From agent 7.0, commands can also reach agents in active mode, which matters for hosts behind firewalls. Check the current Zabbix remote commands documentation against the agent version you run before you design around it.

Two behaviors deserve a decision before rollout. Remote commands run even when the target host is in maintenance, so a patch window that suppresses alerts will not stop an automated restart. Decide whether that is intended, and if not, build the condition into the action or the script. Also plan the blast radius: a single action can fire across many hosts at once. Ask your team to list the faults that qualify, the hosts they apply to, and who reviews the commands before they go live.

Which configuration options control remote command execution

This table compares the settings that decide whether a Zabbix remote command runs, where it runs and what the host user can do. Read each row as a separate control: a command runs only when every layer that applies to its execution target allows it. The main takeaway is that a broad wildcard key is simpler to deploy but gives Zabbix far more reach on the host than a list of narrow, named commands.

SettingWhat it controlsWhen it fitsTrade-off to weigh
AllowKey=system.run[*]Lets the agent execute any command Zabbix sends through system.run, with any parametersShort-lived lab or test hosts where you want to prove the workflow before narrowing itAny action with command access can run arbitrary commands on the host, so it is hard to defend in an assessment
Per-command AllowKey entriesPermits only the exact system.run keys you list, each with its own parameters patternProduction hosts where a small, known set of restarts or fixes is neededEvery new remediation needs a config change and an agent restart, which adds change work
EnableRemoteCommands=1 on proxiesAllows a proxy to pass remote commands to the agents it monitorsHosts that sit behind a proxy and need the same actions as directly monitored hostsLeaving it enabled on a proxy widens the path to every agent that proxy serves, so set it only where needed
Execution target: server, proxy or agentWhere the command runs: on the Zabbix server, on a proxy or on the monitored host through its agentAgent execution for host-local fixes such as restarting a service; server execution for checks that only need Zabbix-side toolsCommands on the server run with the server's privileges and reach, which is usually a larger trust boundary than a single host
Active-mode agent execution (agent 7.0 and later)Lets remote commands reach agents that connect to Zabbix in active modeHosts behind firewalls that only allow outbound connections from the agentConfirm your agent version supports it before relying on it, and test the path end to end
Sudo scope on the hostLimits which privileged operations the agent's OS user can perform through sudoRestarts of named services that need root, with sudoers entries for those exact commandsBroad sudo rules such as unrestricted command access undo the narrowing done in AllowKey, so keep both tight

How to set up remote commands without opening the host to anything

This sequence turns remote commands from an open door into a narrow, audited path: a short list of named fixes, explicit agent and proxy permissions, scoped sudo, and an action that only fires under conditions you have tested.

  1. Define the specific fixes you want to allow

    Before touching any configuration, write down each automated fix as an exact command with fixed arguments, such as restarting one named service. Keep the list short and owned by the platform team, and record who approves each entry. Done means you have a written list where every item is a single command you could read aloud to an auditor, with no free-form input from alerts or users.

  2. Decide the execution target for each fix

    For each command, choose whether it runs on the Zabbix server, a proxy or the monitored agent. Agent execution is usually the right fit for restarting a local service, while server or proxy execution suits checks that do not need the host itself. Confirm in the Zabbix remote commands documentation which target and mode (passive or active agent, agent 7.0 or later for active mode) your version supports. Done means each fix has one named target written next to it.

  3. Set AllowKey entries on the agent

    Remote commands are disabled by default on agents, so the agent must be told which keys it may execute. Add a specific AllowKey entry for each approved command in the agent configuration file, avoiding a broad wildcard such as system.run[*] unless you have a documented reason. Restart or reload the agent under your change process. Check by running a remote command test for an approved key and confirming the agent accepts it, then testing an unlisted command and confirming the agent refuses it.

  4. Enable remote commands on the proxy where needed

    If commands must run through a proxy, set EnableRemoteCommands=1 in the proxy configuration file and restart the proxy. Leave this off on proxies that do not need it. Confirm the setting by checking the proxy log after restart and by running one approved test command that reaches the target host through that proxy. Done means the proxy accepts the command path you designed and no other proxy has the setting enabled by accident.

  5. Scope sudo to the named commands only

    If the approved command needs elevated rights, grant sudo only for the exact binary and arguments in a dedicated file under sudoers.d, for example allowing the zabbix service account to run one specific systemctl restart. Avoid granting ALL, shell access or wildcards that accept arbitrary arguments. Validate the file with the visudo syntax check. Verify by running the command as the zabbix account and confirming that a different service or a shell command is refused.

  6. Create the action with conditions and maintenance behavior

    Create a Zabbix action that runs the remote command only for matching problems, using conditions such as host group, trigger severity or a specific trigger tag, and limit it to the operation step you intend. Decide deliberately whether it should run when the target host is in maintenance, since remote commands do run during maintenance by default. Record that decision with the maintenance owner. Done means the action conditions, target and maintenance decision are written down and reviewed by the people who will answer for them.

  7. Test on a non-production host and review the action log

    Trigger a controlled problem on a non-production host that matches the action conditions and confirm the command runs exactly once with the expected result. Then open the action log and confirm it records the executed command, the target and the outcome. Repeat the test for a non-approved key to confirm refusal. Only after these checks pass should the action be enabled for production hosts, with the test evidence stored alongside the change record.

Guardrails auditors expect around automated fixes

Automated fixes run with real privileges on production hosts, so reviewers look first at who can change what runs, how narrowly it is allowed, and whether every run leaves a trail. The cards below cover the controls that connect those questions to Zabbix remote commands for automatic remediation.

Least-privilege sudo rules

When a remote command runs through the agent, it inherits the rights of the agent's service account, and any sudo rule you add extends those rights. Write sudo rules for the exact binaries and arguments the fix needs, such as one restart command for one service, rather than granting broad shell access. Review each rule with the team that owns the service, and confirm that the rule is limited to the hosts where the fix applies.

Remote commands docs

Narrow AllowKey entries

Remote commands are disabled by default on agents, and the AllowKey setting decides which system.run items the agent accepts. A wildcard such as system.run[*] allows any command the agent is asked to run, so it is hard to defend in a review. Prefer one entry per approved command with the parameters fixed or tightly matched, and keep the list in version control so changes are visible.

Change records for each automated fix

Each automated fix should trace back to an approved change record that names the problem it addresses, the command, the target host group, and the owner who accepted the risk. Auditors often ask how a fix was authorized before it ran, not only what it did. Link the Zabbix action or script name to the change ticket so a reviewer can follow the chain from the approval to the execution.

Action logging and audit trails

Confirm what Zabbix records when an action runs a remote command, where those records are kept, and how long they stay available. Forward the Zabbix audit and server logs to a store that the Zabbix administrators cannot edit, and test that a sample run can be reconstructed from the log alone. Ask your team to confirm the retention period that your policy requires, since the logs are only useful if they still exist when someone asks.

Limiting who can edit actions and scripts

An attacker or a careless editor who can change an action or a script can run any command the agent accepts. Restrict edit rights on actions, scripts and host configuration to a small administrator group, and separate those rights from the rights to view problems and acknowledge alerts. Review membership of that group on a schedule and after staff changes, and confirm that the Zabbix authentication source, such as LDAP or SAML, enforces the same control.

Separating remediation from alerting

Keep the action that notifies people separate from the action that changes a system. A notification action should page the on-call engineer, while a remediation action should run only a fixed, approved command with a defined scope. Mixing them makes it unclear whether a human decided to act, and it makes maintenance periods harder to reason about, because remote commands still run when a host is in maintenance.

Why remote commands run during maintenance and what to do about it

Remote commands run even when the target host is in maintenance, so a remediation action can restart a service in the middle of a planned patch window. Zabbix maintenance suppresses problem recording and notifications for the hosts it covers, but it does not stop an action's remote command operation from executing. Treat this as the default behavior until you have proven otherwise in your own version. The practical consequence is that a systemctl restart step triggered by a trigger on a host you are patching can undo the work your change window depends on, such as a service held down deliberately while packages are replaced.

Put the guard in the action, not in the hope that maintenance will catch it. Use action-level conditions so the remote command operation only fires for problems you want automated, for example by matching host groups, tags or trigger names that belong to the remediation runbook. Where your environment already tags hosts by change state or owner, scope the action to exclude hosts carrying a maintenance or change tag. Also scope the trigger itself, so a restart is only attempted for a narrow, well-understood condition. Test each filter with a problem on a host in maintenance and confirm the command either does not run or runs only where you intended.

Verify the behavior in the Zabbix version you run, because the answer depends on the release and on your action and maintenance configuration. Build a lab check with a dummy service on an agent, put that host into maintenance with and without data collection, trigger the problem, and record whether the command executes, which is the approach the Zabbix remote commands documentation describes for the operation itself. Keep the results with your change records. Ask your own change management owner to decide whether automated restarts are allowed during declared patch windows at all, and write that decision into the action's conditions rather than leaving it to the on-call engineer's memory.

Limits to confirm in your environment before relying on automatic fixes

Automatic remediation from Zabbix depends on settings across the server, proxies, agents and your network, and on how each component behaves when a command fails. The cards below cover the checks to complete before any action runs unattended, in the order they usually surface problems.

Zabbix version and component settings

Remote command behavior differs by release and by component, so start by recording the exact Zabbix version on the server, proxies and agents. Confirm which agent settings and proxy settings apply to that version. Remote commands are disabled by default on agents and proxies, so the enabling settings must be verified on every node that will run them, not assumed from the server configuration. Keep a written record of the version and settings that were tested.

Default state
Disabled
Remote commands docs

Active-mode execution support

Confirm whether your agent version can run remote commands on agents monitored in active mode. Active checks are common when agents sit behind firewalls that block inbound connections from the server, so this affects which hosts can be remediated at all. Where support depends on agent version, plan the upgrade or use passive-mode paths for the hosts that need them. Test one active-mode host end to end before writing it into an automated action.

Earliest agent version
7.0

Wildcard key scope

An entry such as AllowKey=system.run[*] lets any command the server sends pass through the agent, which is far broader than a single named command. Decide whether each host needs a wildcard or only specific per-command entries, and test how your configuration matches the commands in your actions. Review the keys on each agent after every configuration change, since a wildcard entry added for one fix applies to every action that targets that host.

Failure handling for errored commands

Decide what happens when a remediation command exits with an error, times out or partially succeeds. Zabbix records the result, but it does not decide whether to retry, escalate or stop further actions. Define the expected exit codes, set the follow-up step (usually a notification to the on-call team), and make sure the fix is safe to run more than once. Test failure cases on a non-production host, not only success paths.

Network paths from server and proxies

Remote commands travel from the server or proxy to the agent over the Zabbix agent port, so firewall and routing rules must allow that traffic in the direction the mode requires. Confirm the path from each proxy to its agents, check any segmentation or intrusion prevention between them, and verify that the path stays open during maintenance and incidents. A remediation that cannot reach its host fails silently from the operator's point of view unless its failure is alerted.

Execution during maintenance

Remote commands run even when the target host is in maintenance, which is useful for planned work but risky if an automated fix fires during a patch window. Confirm which actions should be suppressed during maintenance and which should continue, and document the reason for each. Review your maintenance and action conditions together so a routine change does not trigger a restart on a host that is being patched by another team.

Questions teams ask before automating Zabbix remediation

What does automating Zabbix remediation cost and what drives the effort?

The cost is mostly the time to define, test and approve each fix, because Zabbix itself is released under the GNU Affero General Public License version 3 from version 7.0 onward and has no license fee, device limits or feature gates. Effort rises with the number of distinct fixes, the number of host groups that need them, how many approval steps each fix must pass, and how much testing each fix needs on non-production hosts. Ask any partner for a quote built from a written list of fixes, target hosts, approvers and test environments. Recurring costs usually come from reviewing the fix list after each change and from keeping sudo rules current as the platform changes.

How long does a first remediation deployment take?

Duration depends mainly on how many fixes are in scope and how long your change control process takes, not on the Zabbix configuration itself. A small set of low-risk service restarts moves faster than a catalogue of fixes that touch databases, network devices or shared hosts, because each one needs its own owner sign-off and test evidence. Confirm with your change board how long a standard change takes, and confirm the Zabbix release you run, since the support window for your version affects when upgrades must be planned. Any partner timeline should be stated in the written scope before work starts.

What must our team provide before a partner can build remediation actions?

Your team has to supply the decisions that a partner cannot make for you. These usually include:

  • A runbook for each fix, with the exact command, expected outcome and rollback step
  • A sudo policy that names the commands each agent account may run, and who approves changes to it
  • A named change owner for each host group and for the remote command configuration
  • The maintenance and out-of-hours rules that decide when a fix may run

Without these, the remote command settings will either be too narrow to be useful or too broad to pass review.

Can our own team set this up, and when does a partner help?

Your team can set this up if it already runs Zabbix agents, understands the agent configuration file and has someone who can write and test sudo rules. Remote commands are disabled by default on agents and proxies, so enabling them with an explicit AllowKey entry and, for proxies, EnableRemoteCommands is a small change that must be reviewed carefully. A partner helps when the scope is large, when auditors expect evidence you have not yet produced, or when several teams share one platform and need consistent guardrails. Confirm your own skills against the remote command documentation before deciding.

Do remote commands replace our existing runbooks?

No. Remote commands only execute the steps you have already written down, so the runbook remains the source of truth for what a fix does, who approves it and how it is reversed. A remote command is useful when the fix is short, safe to repeat and well understood, such as restarting a stuck service. Fixes that need judgment, data changes or coordination with other teams should stay as human-led procedures, with Zabbix providing the alert and context. Keep runbooks and remote command definitions under the same version control and review process.

Which guardrails do auditors usually expect for automated fixes?

Auditors generally look for least privilege, documented approval, a record of each execution and a way to stop automation quickly. In practice this means limiting AllowKey entries to specific commands, scoping sudo to named binaries rather than shells, logging who changed the configuration and what ran, and reviewing maintenance behavior, since remote commands run even when the target host is in maintenance. Confirm the exact control expectations with your auditor and map them to your own evidence. DeployOpen can prepare the configuration and evidence for a compliance assessment, but independent auditors and certification bodies issue any attestation.

What is the main technical risk when enabling system.run?

The main risk is that a broad key or a permissive sudo rule lets anyone able to trigger an action run commands the team did not intend. Each AllowKey entry should match one reviewed command pattern, not a general wildcard, and the agent account should have no more privileges than that command needs. Test each fix in a non-production host group first, and confirm that actions triggered during maintenance behave as your change policy requires, because remote commands do run on hosts in maintenance.

How a Zabbix action reaches the target and where the gates sit

The flow starts at a trigger on the Zabbix server, which runs an action with a remote command operation. The command travels to a proxy or directly to an agent, and each hop has its own gate: EnableRemoteCommands on the proxy and AllowKey on the agent. Even when the agent accepts the key, the command still runs as the agent's user, so sudo scope on the host decides what it can really change. Maintenance does not block this path, so check that before you trust a window to stop a fix.

Remote command path from trigger to host, with the three gates and the maintenance bypass.

How DeployOpen scopes and delivers remote command remediation

DeployOpen starts by agreeing a fixed list of remediation commands in writing before any setting changes. Each entry names the Zabbix action that triggers it, the exact command or script, the host groups it may touch, the account it runs under and the condition that must hold before it fires. Anything not on that list stays out of scope, and adding an entry is a change request with its own review. This list is the document auditors and your security team will read first, so it is worth agreeing with them before the build rather than after the first incident.

Configuration follows the list. On each agent, DeployOpen sets AllowKey entries for only the approved commands instead of a blanket system.run[*], and on each proxy it enables EnableRemoteCommands only where an approved action needs it. The sudo rule is written for the same commands and nothing broader, with the service account and its permitted arguments named explicitly. Each action is then exercised on a non-production host, including the case where the target is in maintenance, because remote commands run in that state. Your team confirms the agent and proxy versions it runs against, since the behavior for active-mode agents depends on the release. Every test result, configuration file and approval is stored with the change record so the trail can be reviewed later.

Operating the setup is where the guardrails either hold or drift. We recommend a quarterly review that compares the live AllowKey values, sudo rules and action definitions against the approved list, and a check that the Zabbix audit log captures who edited an action and when. Ask whether your own change process requires a second approver for any new remediation entry, and confirm who can edit Zabbix actions in your environment. Pricing and effort depend on how many actions are in scope and how many hosts and proxies they reach, so those are the figures to request in a written quote.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.