NAME
monitor_nvme.sh - check NVMe health log pages and device wear level
SYNOPSIS
/opt/omnicube/sbin/monitor_nvme.sh
monitor_nvme.sh
DESCRIPTION
monitor_nvme.sh inspects every NVMe device in the host and raises an alert when a device reports health-log anomalies or has consumed too much of its rated write endurance. It only reports; it never touches a device. The script takes no options and no operands and is intended for unattended periodic execution from root's crontab, alongside the other periodic jobs whose sample entries are shipped in /opt/omnicube/share/README. Running it by hand is equally valid and has no side effects beyond the log and mail it may produce.
The script sets PATH to /usr/sbin:/sbin:/opt/ooce/sbin:/usr/bin:/opt/ooce/bin before sourcing /opt/omnicube/lib/common/utils.sh, because utils.sh runs svcprop, mkdir and hostname at source time. GNU grep is called by absolute path as /usr/gnu/bin/grep, since the option -A is not available in the Illumos grep.
Run-level guard
abort_if_shutting_down is called before the first device is examined and again at the top of every device iteration, so the script exits 0 silently when the host is at run level 0, 1, 5, 6, S or s, or when /etc/nologin exists, and a run-level change part way through stops it before the next device. OC_IGNORE_RUNLEVEL set to a non-empty value overrides the guard.
Locking
This command takes no lock and does not enforce single-instance execution. Concurrent runs are harmless: the script keeps no state and issues only read-only nvmeadm queries. It does, however, create and normalise /var/run/omnicube and the mail-throttle directories as a side effect of sourcing utils.sh.
Checks performed
Devices are enumerated from pfexec nvmeadm list, taking the device name from every line that starts with nvme. For each device:
Alerting
warning() from utils.sh writes to stdout, logs to syslog as user.warn under the tag <site>monitor_nvme, which /etc/rsyslog.d/omnicube.conf routes to /var/log/misc.log, and mails oc-warn from $HOSTNAME@<config/mail_domain>. The verbose health dump is deliberately routed through warning() rather than left on stdout, so that it reaches syslog and the alert mail instead of only the cron mail. Mail is throttled per (severity, message) pair to one message per config/mail_throttle_window seconds, default 3600. monitor_nvme.sh never calls error(), so it never mails oc-alert.
OPERANDS
This command takes no options and no operands. Any argument given is ignored.
SMF PROPERTIES
monitor_nvme.sh reads no properties of its own. Through utils.sh it consumes, from svc:/omnicube/sysadm:default unless OC_SMF_INSTANCE selects another instance:
EXAMPLES
Example 1: hourly cron entry
11 * * * * /opt/omnicube/sbin/monitor_nvme.sh >/dev/null
Example 2: run one pass by hand
Every warning is also printed on stdout, prefixed [w].
pfexec /opt/omnicube/sbin/monitor_nvme.sh
Example 3: review past NVMe alerts
grep monitor_nvme /var/log/misc.log
EXIT STATUS
monitor_nvme.sh does not set an explicit exit status on its normal path; it returns the status left by the last wear-level comparison. Callers must therefore not read the exit status as a health verdict, and the status must not be used to gate anything.
FILES
ENVIRONMENT
SECURITY
nvmeadm is run through pfexec, which requires the OmniCube Administration profile from /etc/security/prof_attr.d/omnicube and the /usr/sbin/nvmeadm entry in /etc/security/exec_attr.d/omnicube. That profile is root-equivalent as a whole and must only be assigned to accounts trusted with root. ${PFEXEC} is not used here; the pfexec calls are unconditional and are harmless no-ops for a caller who is already root.
SEE ALSO
pool_monitor.sh(8), sys_monitor(8), zone_monitor.sh(8), zones_srv_monitor.sh(8), oc_log(3), oc_runlevel(3), omnicube_utils(3), omnicube(7).
NOTES
The alert-mail throttle keys on the exact message text, and the anomaly warning embeds the whole health page. Counters and temperatures in that page drift from run to run, so consecutive anomaly reports hash to different throttle keys and may produce more than one mail per window. This is deliberate: the branch is only reached for a device that is already misbehaving and an operator wants to see the progression rather than have it silenced.
The wear-level alarm fires from 90 percent of rated life used and keeps firing on every run; there is no acknowledgement mechanism. A device that has crossed the threshold should be replaced or excluded from monitoring by disabling the cron entry, since the script has no exclusion property.