Skip to content
Xi Software Request an evaluation

Monitoring the Xi-Batch Licence

Checking it from cron, systemd, Nagios, Zabbix or Prometheus: what to run, what it prints, and the exit statuses

Xi-BatchXi-Batchintegrationlicensingmonitoringxb-checklic

This article shows how to check the state of the Xi-Batch licence from a monitoring system: the command to run, what it prints, its exit statuses, and a check script for cron, a systemd timer, Nagios-compatible tools, Zabbix and Prometheus. Xi-Batch and Xi-Text each have their own licence and their own article; on a host that runs both, set up the check for each.

The command that reports the licence

xb-checklic

It takes no options and changes nothing. It is installed in /usr/local/bin, it can be run by any user, and it runs while Xi-Batch is running. A valid licence prints its details on standard output:

Licensed to:    Example Corporation
Serial is:  87654321
Start time: 01/01/2026
End time:   31/12/2026

The label and the value are separated by a tab. Dates are dd/mm/yyyy in the machine's local time. A licence with no end date prints "No limit" on the End time line. One of three further lines can follow:

"*** NOTE: Licence about to expire ***"
Printed in the last four days before the end date. The exit status is still 0.

"Validated for networks"
A networked licence.

"***Emergency licence***"
A seven-day emergency licence.

The exit statuses

A licence that fails prints a single message on standard error and nothing on standard output:

Status Message on standard error Meaning
0 (none) The licence is valid, including in its last four days
10 "Licence file does not exist no licence yet?" or "Unable to read licence file (is it running?)" There is no licence file, or it cannot be opened
11 "Could not read serial from file" The file is too short to be a licence
107 "Licence is not valid" The licence is not valid on this machine
110 "Licence expired, expiry date was dd/mm/yyyy" The end date has passed

Treat any non-zero status as urgent, including while Xi-Batch is still running.

Deciding when to alert

Alert from the end date: the exit status stays 0 until the licence has expired. The check script below works out the whole days remaining from the End time line and raises a warning at 30 days and a critical alert at 7. Set both to fit how long a renewal takes at your organisation.

An emergency licence lasts seven days, so it is critical as soon as it is installed. The script names it in its message.

The check script

The script runs xb-checklic, prints one line and exits with the status monitoring tools expect from a check: 0 OK, 1 warning, 2 critical, 3 unknown. The text after the "|" is the days remaining, in the form Nagios-compatible tools read as performance data; tools that do not read it ignore it.

Save it as /usr/local/sbin/check-xibatch-licence and make it executable:

#!/bin/sh
# check-xibatch-licence - report the Xi-Batch licence in one line.
# Exit status: 0 OK, 1 warning, 2 critical, 3 unknown.

WARN_DAYS=${WARN_DAYS:-30}
CRIT_DAYS=${CRIT_DAYS:-7}
CHECKLIC=/usr/local/bin/xb-checklic

out=$("$CHECKLIC" 2>&1)
rc=$?

case $rc in
    0)   ;;
    107) echo "CRITICAL - Xi-Batch licence is not valid on this machine"; exit 2 ;;
    110) echo "CRITICAL - Xi-Batch: $out"; exit 2 ;;
    10|11) echo "CRITICAL - Xi-Batch licence file: $out"; exit 2 ;;
    *)   echo "UNKNOWN - xb-checklic exited $rc: $out"; exit 3 ;;
esac

serial=$(printf '%s\n' "$out" | sed -n 's/^Serial is:[[:space:]]*//p')
end=$(printf '%s\n' "$out" | sed -n 's/^End time:[[:space:]]*//p')
note=""
printf '%s\n' "$out" | grep -q 'Emergency licence' && note=" (emergency licence)"

if [ "$end" = "No limit" ]; then
    echo "OK - Xi-Batch serial $serial has no end date$note"
    exit 0
fi

# dd/mm/yyyy to seconds; date -d is GNU date, as on Linux
d=${end%%/*}; rest=${end#*/}; m=${rest%%/*}; y=${rest#*/}
end_s=$(date -d "$y-$m-$d" +%s 2>/dev/null) || {
    echo "UNKNOWN - cannot read the end date '$end'"; exit 3; }
days=$(( (end_s - $(date +%s)) / 86400 ))

msg="Xi-Batch serial $serial ends $end, $days days$note | days=$days"
if   [ "$days" -lt "$CRIT_DAYS" ]; then echo "CRITICAL - $msg"; exit 2
elif [ "$days" -lt "$WARN_DAYS" ]; then echo "WARNING - $msg";  exit 1
fi
echo "OK - $msg"
exit 0
chmod 755 /usr/local/sbin/check-xibatch-licence

It prints one of:

OK - Xi-Batch serial 87654321 ends 31/12/2026, 36 days | days=36
WARNING - Xi-Batch serial 87654321 ends 31/12/2026, 21 days | days=21
CRITICAL - Xi-Batch licence is not valid on this machine
CRITICAL - Xi-Batch: Licence expired, expiry date was 31/12/2026

The thresholds can be changed for one run without editing the script:

WARN_DAYS=60 CRIT_DAYS=14 /usr/local/sbin/check-xibatch-licence

Running the check

Each of these runs the same script. Use the one your organisation already watches.

From cron, with an email

Cron sends any output a job prints to the address in MAILTO. This prints only when the check is not OK:

MAILTO=ops@example.com
0 7 * * * /usr/local/sbin/check-xibatch-licence >/var/tmp/xibatch-licence.out || cat /var/tmp/xibatch-licence.out

The check runs at 07:00 each day. A once-a-day check is enough for an end date measured in days.

From cron, into the system log

Where the system log is already collected centrally, send the result there, with the priority raised when the check is not OK:

0 7 * * * /usr/local/sbin/check-xibatch-licence >/var/tmp/xibatch-licence.out && logger -t xibatch-licence -p user.info -f /var/tmp/xibatch-licence.out || logger -t xibatch-licence -p user.warning -f /var/tmp/xibatch-licence.out

Alert on messages tagged xibatch-licence at warning priority.

From a systemd timer

A non-zero exit marks the service failed, so the check shows in systemctl --failed and in any monitoring that already watches for failed units. The output goes to the journal.

/etc/systemd/system/xibatch-licence-check.service:

[Unit]
Description=Check the Xi-Batch licence

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/check-xibatch-licence

/etc/systemd/system/xibatch-licence-check.timer:

[Unit]
Description=Check the Xi-Batch licence daily

[Timer]
OnCalendar=*-*-* 07:00:00
Persistent=true

[Install]
WantedBy=timers.target
systemctl daemon-reload
systemctl enable --now xibatch-licence-check.timer
journalctl -u xibatch-licence-check.service

From Nagios, Icinga, Naemon or Checkmk

The script follows the monitoring-plugin convention, so these tools run it as a check with no changes. Through NRPE on the Xi-Batch host, add to nrpe.cfg:

command[check_xibatch_licence]=/usr/local/sbin/check-xibatch-licence

and define a service on the monitoring server that calls check_nrpe with the command check_xibatch_licence. Checkmk runs it through MRPE, with one line in mrpe.cfg on the host:

Xi-Batch_licence /usr/local/sbin/check-xibatch-licence

From Zabbix

Two user parameters on the agent: the status for the trigger, and the line for the alert text. Add them to the agent's configuration, for example /etc/zabbix/zabbix_agent2.d/xibatch-licence.conf, and restart the agent:

UserParameter=xibatch.licence.status,/usr/local/sbin/check-xibatch-licence >/dev/null; echo $?
UserParameter=xibatch.licence.text,/usr/local/sbin/check-xibatch-licence

On the server, create items for both keys polled daily, and a trigger on the status item where the last value is greater than 0. The value is 1 for a warning, 2 for critical and 3 for unknown.

From Prometheus

Run the check from cron and write its result to node_exporter's textfile collector directory. Set the directory to the one node_exporter's --collector.textfile.directory option names:

#!/bin/sh
# xibatch-licence-metrics - write the licence check as Prometheus metrics.
DIR=/var/lib/node_exporter/textfile_collector

line=$(/usr/local/sbin/check-xibatch-licence)
status=$?
days=${line##*days=}

{
    echo "# HELP xi_licence_status 0 OK, 1 warning, 2 critical, 3 unknown"
    echo "# TYPE xi_licence_status gauge"
    echo "xi_licence_status{product=\"xibatch\"} $status"
    case $days in
        ''|*[!0-9-]*) ;;
        *) echo "# HELP xi_licence_days_remaining Whole days to the licence end date"
           echo "# TYPE xi_licence_days_remaining gauge"
           echo "xi_licence_days_remaining{product=\"xibatch\"} $days" ;;
    esac
} > "$DIR/xibatch_licence.prom.$$" && mv "$DIR/xibatch_licence.prom.$$" "$DIR/xibatch_licence.prom"
15 * * * * /usr/local/sbin/xibatch-licence-metrics

Writing to a temporary name and renaming it means node_exporter never reads a half-written file. Alert on xi_licence_status > 0, or on xi_licence_days_remaining < 30 to choose the threshold in Prometheus. A licence with no end date has no days-remaining metric.

From anything else

Any scheduler, agent or script that can run a command and read its exit status can use the check script as it stands: 0 means no action, and the one line it prints is the alert text. To read the licence directly, run xb-checklic, treat any non-zero status as a failure, and take the end date from the line that begins "End time:".

Checking the check works

Run the script by hand and confirm the serial and the end date match the licence you hold:

/usr/local/sbin/check-xibatch-licence; echo "exit $?"

To see an alert arrive, run it once with a warning threshold beyond the end date. The status becomes 1, and the alert should reach whoever it is meant to:

WARN_DAYS=10000 /usr/local/sbin/check-xibatch-licence; echo "exit $?"

Where the tool runs the check as its own user, such as the Zabbix or NRPE agent, run it once as that user too. "UNKNOWN - xb-checklic exited 127" means /usr/local/bin/xb-checklic is not installed at that path on this host; set CHECKLIC in the script to where it is.

Renewing an Xi-Batch Licence Without an Operator

Scheduling the stop, running xb-vwrite non-interactively, reading xb-checklic, and what the exit statuses mean

Installing an Emergency Seven-Day Licence on Xi-Batch

Recovering a system whose licence has been lost or damaged with xb-emerglic, and replacing it with a permanent licence

Migrating Xi-Batch to Another System

Exporting the schedule, variables, interpreters and users, the restore order, and the holidays gap

All articles · Release notes · Contact support