Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

How to Set Up a Hardware RAID Monitoring Script on RHEL

Hardware RAID controllers can hide disk failures from the operating system until a logical volume becomes degraded. A small monitoring script gives administrators an early warning when a physical disk, battery, cache module, or virtual drive changes state.

This guide uses RHEL-compatible commands and LSI MegaRAID tools, including storcli64. The same approach generally applies to CentOS Stream and Fedora systems, although package paths and service names can differ. It suits servers in Sydney, Melbourne, Brisbane, Perth, and smaller regional data centres.

Tool Best use Typical output
storcli64 Modern LSI/Broadcom controllers Detailed controller and drive status
perccli64 Dell PERC hardware RAID, battery, and physical disk health
ssacli HPE Smart Array controllers Logical and physical drive state
megacli Older MegaRAID cards Legacy controller diagnostics

Identify The RAID Controller

Begin by identifying the PCI device and installed management utility. Root privileges are required for most controller queries.

lspci -nn | grep -Ei 'raid|sas|scsi'
command -v storcli64 perccli64 megacli ssacli 2>/dev/null

LSI and Broadcom cards commonly appear as MegaRAID SAS controllers. Dell servers may use PERC branding while exposing similar hardware internally. If the utility is missing, obtain the vendor-supported RPM or archive rather than downloading an unverified binary. Hardware sold through the Australian refurbished server market often includes older MegaRAID cards, so matching the utility version to the controller firmware matters.

For a StorCLI installation, place the executable in a controlled location and restrict its permissions:

install -o root -g root -m 0750 storcli64 /usr/local/sbin/storcli64
/usr/local/sbin/storcli64 show

Establish A Healthy Baseline

Capture a known-good report before creating alert logic. This gives you the normal controller count, virtual drives, physical disks, and battery state.

/usr/local/sbin/storcli64 /call show
/usr/local/sbin/storcli64 /call/vall show
/usr/local/sbin/storcli64 /call/eall/sall show
/usr/local/sbin/storcli64 /call show battery

For repeatable parsing, JSON output is preferable when supported:

/usr/local/sbin/storcli64 /call show J > /var/lib/raid-monitor/baseline.json

Create the directory with root ownership. A baseline is particularly useful before maintenance windows aligned with Australian Eastern Time, when teams in Sydney and Melbourne may coordinate changes with Brisbane or Perth operations staff across different time zones.

Create The Monitoring Script

The script below checks the controller summary and searches for common failure indicators. It writes to syslog, which allows RHEL administrators to use journalctl without building a separate log collector.

#!/usr/bin/env bash
set -u

CLI=/usr/local/sbin/storcli64
HOST=$(hostname -s)
TMP=$(mktemp)
trap 'rm -f "$TMP"' EXIT

if [[ ! -x "$CLI" ]]; then
    logger -p daemon.err -t raid-monitor \
      "[$HOST] RAID utility is missing: $CLI"
    exit 2
fi

"$CLI" /call show >"$TMP" 2>&1
status=$?

if (( status != 0 )); then
    logger -p daemon.err -t raid-monitor \
      "[$HOST] RAID query failed with exit code $status"
    exit 2
fi

if grep -Eiq 'critical|failed|degraded|offline|missing|foreign' "$TMP"; then
    logger -p daemon.alert -t raid-monitor \
      "[$HOST] RAID warning detected: $(tr '\n' ' ' < "$TMP")"
    exit 1
fi

logger -p daemon.info -t raid-monitor "[$HOST] RAID status is healthy"
exit 0

Save it as /usr/local/sbin/raid-monitor, then apply secure permissions:

chmod 0750 /usr/local/sbin/raid-monitor
chown root:root /usr/local/sbin/raid-monitor
/usr/local/sbin/raid-monitor
journalctl -t raid-monitor -n 20

Controller output varies between firmware releases, so inspect real healthy and failed-state output before relying on a simple keyword match. A production script may also parse JSON with jq and check rebuild progress, predictive failure flags, temperature, and cache protection.

Schedule Reliable Alerts

A systemd service and timer are more dependable than an interactive cron entry. Create /etc/systemd/system/raid-monitor.service:

[Unit]
Description=Hardware RAID health check

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/raid-monitor

Then create /etc/systemd/system/raid-monitor.timer:

[Unit]
Description=Run hardware RAID health check

[Timer]
OnBootSec=5min
OnUnitActiveSec=15min
Persistent=true

[Install]
WantedBy=timers.target

Enable the timer and verify its next run:

systemctl daemon-reload
systemctl enable --now raid-monitor.timer
systemctl list-timers raid-monitor.timer

Send alerts from a central monitoring platform, local rsyslog, or a mail relay approved by your organisation. Avoid depending on an untested local mail configuration. For related storage protection, the guide on efficient file synchronisation explains how to maintain separate copies of important data.

Test Failure Paths Safely

A monitoring script is incomplete until its alert path has been tested. Run it with a temporary test string or add a controlled test mode rather than pulling a live disk from a production array. Confirm that a non-zero exit code is recorded and that the monitoring platform receives the event.

Test service recovery after reboots and confirm that Persistent=true causes missed timer runs to execute after the system returns. If the server sends alerts through a remote host, investigate network delivery with TCPdump troubleshooting when messages do not arrive.

A staging server can validate the script against several controller outputs. Browser-based checks such as web test automation may help verify an operations dashboard, but hardware state should still be checked directly through StorCLI or the vendor utility.

Practical Deployment Recommendations

Keep the monitoring design simple, observable, and suited to the hardware installed in each host. A script that reports every normal detail can bury the single line that indicates a failed drive. Record controller model, firmware, enclosure slot, serial number, and replacement procedure in the server documentation.

Use these operational practices:

The script should complement backups, SMART information, vendor support, and full monitoring rather than replace them. A healthy RAID status does not protect against accidental deletion, filesystem corruption, theft, or a failed controller that destroys access to the array.

Start with one known-good report, automate a conservative status check, and verify the alert path before deploying it widely. The practical takeaway is simple: make every RAID state change visible, logged, and actionable before a degraded array becomes lost data.