Skip to content

Add Zabbix agent rules - #15128

Open
israel-villar wants to merge 4 commits into
ComplianceAsCode:masterfrom
israel-villar:feat/zabbix-agent-rules
Open

israel-villar wants to merge 4 commits into
ComplianceAsCode:masterfrom
israel-villar:feat/zabbix-agent-rules

Conversation

@israel-villar

@israel-villar israel-villar commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Description:

  • Adds a new zabbix rule group under linux_os/guide/services/zabbix/ with four rules: package_zabbix_agent_installed and service_zabbix_agent_enabled (both using existing templates), and two custom-OVAL rules that each check one Zabbix agent directive in /etc/zabbix/zabbix_agentd.conf independently: zabbix_agent_server_configured (Server, passive checks) and zabbix_agent_serveractive_configured (ServerActive, active checks). Adds the zabbix component.

Rationale:

  • Zabbix is a widely used open-source network monitoring solution; the project already carries SELinux booleans referencing it (sebool_httpd_can_connect_zabbix, sebool_zabbix_can_network) but had no rules covering the monitoring agent itself.
  • Server and ServerActive are independent directives — Server controls which hosts may query the agent (passive checks), ServerActive controls which server the agent reports to (active checks). A site may legitimately use only one of the two (Zabbix itself recommends active-only for firewall-friendliness), so they are checked by two separate rules instead of one rule requiring both, as originally implemented. Neither rule ships with remediation, since the correct server address is site-specific.

Review Hints:

  • No product profile selects these rules yet; this PR only adds the rule definitions and component.
  • Tested all four rules with Automatus's libvirt backend against a real Debian 13 VM (systemd, not a container), with the official Zabbix 7.4 repository (repo.zabbix.com) configured so the remediation pulls the official package instead of Debian's:
    • package_zabbix_agent_installed: all 3 scenarios OK; confirmed by SSH that the official zabbix-agent/zabbix-release packages were actually installed, not Debian's own.
    • service_zabbix_agent_enabled: both scenarios OK.
    • zabbix_agent_server_configured / zabbix_agent_serveractive_configured: all scenarios OK, including cases that verify each rule ignores the other directive's value.
  • Key files: linux_os/guide/services/zabbix/*/rule.yml, the two oval/shared.xml files, components/zabbix.yml.

israel-villar and others added 2 commits September 16, 2026 21:55
Zabbix is a widely used open-source network monitoring solution; the
project already has SELinux booleans referencing it
(sebool_httpd_can_connect_zabbix, sebool_zabbix_can_network) but no
rules covering the monitoring agent itself.

Adds a new zabbix service group with three rules:

- package_zabbix_agent_installed and service_zabbix_agent_enabled
  (from templates).
- zabbix_agent_server_configured: check-only, verifies Server and
  ServerActive are set in zabbix_agentd.conf and not left at the
  packaged 127.0.0.1 default. No remediation is shipped, since the
  correct monitoring server address is site-specific.

Adds the zabbix component.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
zabbix_agent_server_configured has custom OVAL (not template-based),
so it isn't covered by any template's built-in test suite. Adds 5
scenarios covering the AND of the four OVAL criteria: both directives
configured (pass), both left at the packaged default, either directive
missing entirely, and either directive individually left at default
while the other is configured (fail).

Verified with Automatus against the debian13 test container: all 5
scenarios evaluate as expected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Sep 16, 2026

Copy link
Copy Markdown

Hi @israel-villar. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci Bot added the needs-ok-to-test Used by openshift-ci bot. label Sep 16, 2026
@macko1

macko1 commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Hello @israel-villar, thanks for the submission.

In order to consider this for a review, and to review this properly, please provide exact official Zabbix documentation sources for the decisions you made when creating these rules.

Also please provide full documentation (comments) into the test benches you provided (expected results)

Thanks.

Comment thread components/zabbix.yml
@@ -0,0 +1,7 @@
name: zabbix

@macko1 macko1 Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to #15128 (comment) please

@israel-villar israel-villar Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, @macko1. Here are the exact official Zabbix sources for the decisions in this PR:

Server / ServerActive directive names and semantics — Zabbix agent (UNIX) configuration parameter reference:
https://www.zabbix.com/documentation/current/en/manual/appendix/config/zabbix_agentd
This confirms Server governs passive checks (mandatory unless StartAgents=0) and ServerActive governs active checks, which is why the check requires both to be set.

The 127.0.0.1 "packaged default" — the official upstream Zabbix source repository ships zabbix_agentd.conf with these two directives uncommented and set to 127.0.0.1:
https://github.com/zabbix/zabbix/blob/master/conf/zabbix_agentd.conf#L132-L200
(see ### Option: Server and ### Option: ServerActive — the parameter reference page itself documents no default, but this reference template is the file that ships as-is in the zabbix-agent package, which is why an unmodified install ends up with both directives pointing at 127.0.0.1.)

Passive vs. active checks concept, explaining why both directives are relevant to a correctly-configured agent:
https://www.zabbix.com/documentation/current/en/manual/concepts/agent

I've also pushed a commit adding expected-result comments to each test scenario per your second request (587f3a8).

Add a comment to each Automatus test scenario explaining what it
exercises and the expected pass/fail outcome, as requested in review.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@macko1 macko1 self-assigned this Sep 18, 2026

@macko1 macko1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please provide a simple way how to review it on a product:

i.e. install zabbix agent or RHEL9 and run test X.
Thanks.

Comment on lines +17 to +20
template:
name: package_installed
vars:
pkgname: zabbix-agent

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zabbix recommends installing their own packages instead of distro-distributed ones, see https://www.zabbix.com/documentation/7.4/en/manual/installation/install_from_packages

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please, do the testing yourself and post the results - with i.e. automatus in a custom container implementing Zabbix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @macko1 for pointing that out. Zabbix's own recommendation to prefer their official packages over distro ones is a fair concern, so I tested the rules directly in a custom Debian 13 container configured with the official Zabbix 7.4 repository (repo.zabbix.com), as recommended in their documentation.

./build_product debian13 --rule-id package_zabbix_agent_installed
cd tests
./automatus.py rule --docker ssg_test_suite_debian13_zabbix --product debian13 \
    --datastream ../build/ssg-debian13-ds.xml package_zabbix_agent_installed
# -> Script package-installed-removed.fail.sh using profile (all) OK
# -> Script package-removed.fail.sh using profile (all) OK
# -> Script package-installed.pass.sh using profile (all) OK

package_zabbix_agent_installed only checks that the zabbix-agent package is installed, regardless of which repository it comes from. The official repo keeps the exact same package name, just at a newer version (7.4.15 vs. Debian's packaged 7.0.22). With the default APT priorities, the official Zabbix package is selected because it has a higher version. The remediation log confirms the install actually came from the Zabbix repo:

Get:2 https://repo.zabbix.com/zabbix/7.4/stable/debian trixie/main amd64 zabbix-agent amd64 1:7.4.15-1+debian13 [826 kB]
Setting up zabbix-agent (1:7.4.15-1+debian13) ...

zabbix_agent_server_configured also passes cleanly against this same container (5/5 scenarios, same as previously verified):

cd ..
./build_product debian13 --rule-id zabbix_agent_server_configured
./automatus.py rule --docker ssg_test_suite_debian13_zabbix --product debian13 \
    --datastream ../build/ssg-debian13-ds.xml zabbix_agent_server_configured
# -> Script both_configured.pass.sh using profile (all) OK
# -> Script default_values.fail.sh using profile (all) OK
# -> Script directives_missing.fail.sh using profile (all) OK
# -> Script server_default.fail.sh using profile (all) OK
# -> Script serveractive_default.fail.sh using profile (all) OK

service_zabbix_agent_enabled is the one rule I can't get a clean Automatus/Docker result for — but it's not specific to Zabbix or to this rule. The OVAL systemd-unit probe requires access to a running systemd instance through D-Bus. However, Automatus's Docker/Podman backend starts the container with /usr/sbin/sshd -D rather than systemd as PID 1, so the required systemd/D-Bus environment is unavailable. I reproduced the same failure using the project's existing Debian 13 test image, which suggests an environment limitation rather than an issue with the Zabbix rule itself (no Zabbix involved at all in that reproduction):

DBus connection failed, could not identify systemd units.

Happy to test service_zabbix_agent_enabled some other way if you can point me to how service_enabled-templated rules are normally exercised in CI/Automatus for other products.

@macko1 macko1 Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @israel-villar a lot for the effort.

I'd suggest testing with a VM, automatus supports that. Example:

./tests/automatus.py template --libvirt qemu:///session <domain_name> --datastream <datastream> <template>

Let us know if you encounter any issues.

Edit: the zabbix package needs to be installed in the VM.

Server (passive checks) and ServerActive (active checks) are
independent Zabbix agent directives; a site may legitimately only use
one of them. Narrow zabbix_agent_server_configured to only check
Server, and add zabbix_agent_serveractive_configured to check
ServerActive on its own. Test scenarios for each rule now also verify
the other directive's value doesn't affect the result.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@israel-villar

Copy link
Copy Markdown
Contributor Author

@macko1 Thanks for the suggestion! Tested all three rules with Automatus's libvirt backend against a real Debian 13 VM (systemd, not a container), with the official Zabbix 7.4 repository configured (repo.zabbix.com), so the remediation pulls the official package instead of Debian's.

cd tests
./automatus.py rule --libvirt qemu:///system debian13-bios --datastream ../build/ssg-debian13-ds.xml package_zabbix_agent_installed
# -> Script package-installed.pass.sh using profile (all) OK
# -> Script package-installed-removed.fail.sh using profile (all) OK
# -> Script package-removed.fail.sh using profile (all) OK

Confirmed by SSH after remediation that the official package actually got installed, not Debian's:

ii  zabbix-agent   1:7.4.15-1+debian13 amd64        Zabbix network monitoring solution - agent
ii  zabbix-release 1:7.4-4+debian13    all          Zabbix official repository configuration
./automatus.py rule --libvirt qemu:///system debian13-bios --datastream ../build/ssg-debian13-ds.xml zabbix_agent_server_configured
# -> Script both_configured.pass.sh using profile (all) OK
# -> Script default_values.fail.sh using profile (all) OK
# -> Script directives_missing.fail.sh using profile (all) OK
# -> Script server_default.fail.sh using profile (all) OK
# -> Script serveractive_default.fail.sh using profile (all) OK
./automatus.py rule --libvirt qemu:///system debian13-bios --datastream ../build/ssg-debian13-ds.xml service_zabbix_agent_enabled
# -> Script service_enabled.pass.sh using profile (all) OK
# -> Script service_disabled.fail.sh using profile (all) OK

Separately, while looking at zabbix_agent_server_configured again I realized it was ANDing two independent Zabbix agent directives together: Server (passive checks — which hosts may query the agent) and ServerActive (active checks — which server the agent reports to). A site may legitimately only use one of the two (active-only is actually what Zabbix recommends for firewall-friendliness), so a single rule requiring both penalizes anyone using just one mode. I split it:

  • zabbix_agent_server_configured now only checks Server.
  • New rule zabbix_agent_serveractive_configured checks ServerActive on its own.

Pushed as 413a7a8859. Re-ran Automatus against the same VM for both, including scenarios that explicitly verify each rule ignores the other directive's value:

./automatus.py rule --libvirt qemu:///system debian13-bios --datastream ../build/ssg-debian13-ds.xml zabbix_agent_server_configured
# -> Script server_default.fail.sh using profile (all) OK
# -> Script server_configured.pass.sh using profile (all) OK
# -> Script server_missing.fail.sh using profile (all) OK

./automatus.py rule --libvirt qemu:///system debian13-bios --datastream ../build/ssg-debian13-ds.xml zabbix_agent_serveractive_configured
# -> Script serveractive_configured.pass.sh using profile (all) OK
# -> Script serveractive_missing.fail.sh using profile (all) OK
# -> Script serveractive_default.fail.sh using profile (all) OK

@macko1

macko1 commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Perfect, glad that helped @israel-villar!
May I ask you to review the pr description and update it, please?

@israel-villar

Copy link
Copy Markdown
Contributor Author

@macko1 Done, PR description updated. Thanks for the feedback!

@israel-villar
israel-villar requested a review from macko1 October 14, 2026 22:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants