Zabbix integration for Selenium test monitoring via Mocha - Debian package https://github.com/VitexSoftware/multiflexi-zabbix-selenium
Find a file
CyberVitexus ab51cbc14f chore(debian): enable debian:forky and backport chown fix
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVPQmZBdyuxFj1rTiJe9p6
2026-09-11 11:51:14 +02:00
debian chore(debian): enable debian:forky and backport chown fix 2026-09-11 11:51:14 +02:00
test Fix EnvironmentFile path, add repo.vitexsoftware.com install docs, add missing driver.js 2026-02-25 22:53:10 +01:00
.gitignore Initial commit 2026-01-27 19:10:05 +01:00
AGENTS.md Fix EnvironmentFile path, add repo.vitexsoftware.com install docs, add missing driver.js 2026-02-25 22:53:10 +01:00
INSTALL.md Update docs: add node-mochawesome-report-generator and node-selenium-webdriver to requirements 2026-02-26 00:14:47 +01:00
mocha-selenium-tests.service Refactor test configuration and service setup for multiflexi-mocha integration 2026-02-02 12:29:30 +01:00
mocha-selenium-tests.timer Initial commit 2026-01-27 19:10:05 +01:00
multiflexi-mocha Fix EnvironmentFile path, add repo.vitexsoftware.com install docs, add missing driver.js 2026-02-25 22:53:10 +01:00
multiflexi-mocha-test.sh Refactor test configuration and service setup for multiflexi-mocha integration 2026-02-02 12:29:30 +01:00
multiflexi-mocha.conf Refactor test configuration and service setup for multiflexi-mocha integration 2026-02-02 12:29:30 +01:00
multiflexi-zabbix-selenium.svg Add AppStream stock icon and install metainfo/icon 2026-05-05 22:07:12 +02:00
README.md docs(README): add packaging badge 2026-07-29 16:03:21 +02:00
run-tests-foreground.sh Fix run-tests-foreground.sh: use json-only output (no dist/ needed) 2026-02-25 23:16:22 +01:00
zabbix-mocha-stats.sh Initial commit 2026-01-27 19:10:05 +01:00
zabbix-template-mocha.yaml Updates UUIDs for Zabbix Mocha template elements 2026-01-29 12:03:20 +01:00

MultiFlexi Zabbix Selenium Integration

Packaging: deb

Production-ready integration of Mocha/Selenium test results into Zabbix monitoring.

Architecture

Mocha tests → JSON report → Zabbix agent → Zabbix server
  • Tests run externally via systemd timer (not by Zabbix)
  • Zabbix only reads results and evaluates health
  • No browser execution on Zabbix server

Installation

# Import GPG key
sudo curl -fsSL http://repo.vitexsoftware.com/KEY.gpg \
  -o /usr/share/keyrings/vitexsoftware-archive-keyring.gpg

# Add repository (replace DISTRO with your distribution codename, e.g. trixie, forky, bookworm)
sudo tee /etc/apt/sources.list.d/vitexsoftware.sources <<EOF
Types: deb
URIs: http://repo.vitexsoftware.com
Suites: DISTRO
Components: main
Signed-By: /usr/share/keyrings/vitexsoftware-archive-keyring.gpg
EOF

# Install
sudo apt update
sudo apt install multiflexi-zabbix-selenium

From Local Debian Package

sudo dpkg -i multiflexi-zabbix-selenium_*.deb
sudo apt-get install -f  # Install dependencies

Enable Automated Tests

sudo systemctl enable --now mocha-selenium-tests.timer
systemctl status mocha-selenium-tests.timer

Configure Test Location

Set where your Mocha *.spec.js tests live. Edit /etc/default/multiflexi-mocha and set TESTS_DIR:

sudo sed -i 's#^TESTS_DIR=.*#TESTS_DIR=/path/to/your/tests#' /etc/default/multiflexi-mocha
sudo systemctl daemon-reload
sudo systemctl restart mocha-selenium-tests.timer

Configure Zabbix

  1. Import template: /usr/share/zabbix/templates/zabbix-template-mocha.yaml
  2. Assign template to monitored host
  3. Wait for data collection (5-15 minutes)

Manual Testing

# Test UserParameter
zabbix_agent2 -t mocha.tests[total]
zabbix_agent2 -t mocha.tests[failed]

# Run tests manually via service
sudo systemctl start mocha-selenium-tests.service

# Or run script directly (override TESTS_DIR as needed)
sudo -u zabbix TESTS_DIR=/path/to/your/tests /usr/bin/multiflexi-mocha-test.sh

# Check report
cat /var/lib/zabbix/mocha/test-results.json | jq .stats

Monitoring Metrics

  • mocha.tests[total] - Total test count
  • mocha.tests[passed] - Passed tests
  • mocha.tests[failed] - Failed tests
  • mocha.tests[pending] - Skipped tests
  • mocha.tests[duration] - Execution time (ms)
  • mocha.tests[age] - Report timestamp
  • mocha.success_rate - Calculated success percentage

Triggers

  • Warning: Any test failures
  • Average: Results older than 1 hour
  • High: Results older than 2 hours or success rate < 90%
  • Disaster: Success rate < 50%

Customization

Change Test Interval

Edit /etc/systemd/system/mocha-selenium-tests.timer:

[Timer]
OnUnitActiveSec=30min  # Change from 15min to 30min

Then reload:

sudo systemctl daemon-reload
sudo systemctl restart mocha-selenium-tests.timer

Custom Test Directory

Edit /etc/default/multiflexi-mocha and set:

TESTS_DIR=/path/to/your/tests

Troubleshooting

No Data in Zabbix

# Check agent configuration
zabbix_agent2 -t mocha.tests[total]

# Check test execution
systemctl status mocha-selenium-tests.service
journalctl -u mocha-selenium-tests.service -n 50

# Check timer
systemctl list-timers mocha-selenium-tests.timer

Permission Errors

sudo chown -R zabbix:zabbix /var/lib/zabbix/mocha
sudo chmod 755 /var/lib/zabbix/mocha

Stale Results

Check if timer is active:

systemctl is-active mocha-selenium-tests.timer
systemctl start mocha-selenium-tests.timer

Files

  • /usr/bin/zabbix-mocha-stats.sh - Metrics extraction script
  • /usr/bin/multiflexi-mocha-test.sh - Test runner used by the service
  • /etc/zabbix/zabbix_agent2.d/multiflexi-mocha.conf - Zabbix UserParameters
  • /etc/default/multiflexi-mocha - Environment file (e.g., TESTS_DIR)
  • /etc/systemd/system/mocha-selenium-tests.service - Test execution service
  • /etc/systemd/system/mocha-selenium-tests.timer - Periodic execution timer
  • /usr/share/zabbix/templates/zabbix-template-mocha.yaml - Zabbix template
  • /var/lib/zabbix/mocha/ - Test results directory

Requirements

  • Debian/Ubuntu Linux
  • Zabbix agent2
  • Node.js with Mocha
  • node-mochawesome and node-mochawesome-report-generator
  • node-selenium-webdriver
  • jq for JSON parsing

License

See debian/copyright