Skip to content

janu-software/munin-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

munin-test

A small Bash utility script to validate all installed Munin plugins on a host and capture basic diagnostics when a plugin fails. The script iterates through /etc/munin/plugins, runs each plugin with munin-run, logs success/failure, and, when failures reference systemd-run, appends recent munin-node journal entries for easier troubleshooting.

Note: This repository is intentionally minimal and contains a single script file: munin-test.sh

Stack and entry points

  • Language: Bash (POSIX shell with Bash-specific features)
  • Frameworks/Libraries: None
  • Package manager: None
  • Entry point: ./munin-test.sh

Requirements

  • Operating system: Linux (tested with systemd-based distros)
  • Installed tools:
    • bash
    • munin-run (typically provided by munin-node package)
    • journalctl (from systemd; used only for additional diagnostics)
    • tee, grep, date (coreutils)
  • Access/permissions:
    • Read access to /etc/munin/plugins (default Munin plugin symlink directory)
    • Ability to execute munin-run for each plugin
    • Write access to /var/log/munin/plugin_test.log (default log path)
    • journalctl access for the munin-node unit (usually requires root or membership in the systemd-journal group)

If your environment differs (custom plugin directory, different log path, or a non-systemd init system), you may need to adjust the script or run it with appropriate privileges.

Setup

  1. Clone or copy this repository onto the target machine where Munin plugins are installed.

    wget https://raw.githubusercontent.com/janu-software/munin-test/refs/heads/master/munin-test.sh -O munin-test.sh
    
  2. Ensure the script is executable:

    chmod +x munin-test.sh
    
  3. Consider running as root (sudo) so that:

    • munin-run can access all plugins as needed
    • The script can write to /var/log/munin/plugin_test.log
    • journalctl can read the munin-node logs

Usage

Run the script from the repository directory:

./munin-test.sh

What it does:

  • Logs start/end timestamps
  • Iterates all entries in /etc/munin/plugins
  • For each plugin NAME, invokes: munin-run NAME
  • On success (exit code 0): prints and logs a ✅ NAME OK line
  • On failure (non-zero exit): prints/logs ❌ NAME FAILED and the command output
  • If the failure output mentions systemd-run, the script appends the last 10 journal lines for the munin-node unit to the log for context

Where the log goes:

  • Default log file: /var/log/munin/plugin_test.log

Sample output snippet:

  === Munin plugin test started at 2025-10-22 13:02 ===
  --- Testing plugin: cpu ---
  ✅ cpu OK
  --- Testing plugin: df ---
  ❌ df FAILED (exit code: 1)
  ...
  --- systemd-run journal details ---
  Oct 22 13:00:00 host munin-node[...]: ...
  --- end of journal ---
  === Munin plugin test finished at 2025-10-22 13:05 ===

Configuration and environment variables

The script currently uses hard-coded defaults inside the file:

  • LOGFILE="/var/log/munin/plugin_test.log"
  • PLUGINDIR="/etc/munin/plugins"

Environment overrides are not implemented in the script at this time.

  • TODO: Add support for overriding LOGFILE and PLUGINDIR via environment variables or CLI flags (e.g., LOGFILE=/path/to/log ./munin-test.sh).

Scripts

  • munin-test.sh: main and only script. No additional helper scripts.

Tests

There are no automated tests in this repository.

  • Manual verification procedure:

    1. Ensure munin-node and munin-run are installed; verify a couple of plugins exist in /etc/munin/plugins
    2. Run: sudo ./munin-test.sh
    3. Confirm exit messages for each plugin and check the log at /var/log/munin/plugin_test.log
    4. Intentionally break a plugin (or simulate failure) to see diagnostic behavior and journal excerpt collection
  • TODO: Add a simple test harness that mocks munin-run and journalctl to simulate success/failure cases without requiring system services.

License

Free to use and modify. No warranty. Use at your own risk.

Notes

  • This utility does not modify plugin configuration; it only runs munin-run for each plugin and records outcomes.
  • The presence of emojis in log output is primarily cosmetic; logs will still be readable in plain text.

About

Test all munin monitorings.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages