Monitoring the Xi-Text Licence
Checking it from cron, systemd, Nagios, Zabbix or Prometheus: what to run, what it prints, and the exit statuses
This article shows how to check the state of the Xi-Text 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
xt-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-Text 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-Text 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 xt-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-xitext-licence and make it executable:
#!/bin/sh
# check-xitext-licence - report the Xi-Text 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/xt-checklic
out=$("$CHECKLIC" 2>&1)
rc=$?
case $rc in
0) ;;
107) echo "CRITICAL - Xi-Text licence is not valid on this machine"; exit 2 ;;
110) echo "CRITICAL - Xi-Text: $out"; exit 2 ;;
10|11) echo "CRITICAL - Xi-Text licence file: $out"; exit 2 ;;
*) echo "UNKNOWN - xt-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-Text 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-Text 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-xitext-licence
It prints one of:
OK - Xi-Text serial 87654321 ends 31/12/2026, 36 days | days=36
WARNING - Xi-Text serial 87654321 ends 31/12/2026, 21 days | days=21
CRITICAL - Xi-Text licence is not valid on this machine
CRITICAL - Xi-Text: 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-xitext-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-xitext-licence >/var/tmp/xitext-licence.out || cat /var/tmp/xitext-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-xitext-licence >/var/tmp/xitext-licence.out && logger -t xitext-licence -p user.info -f /var/tmp/xitext-licence.out || logger -t xitext-licence -p user.warning -f /var/tmp/xitext-licence.out
Alert on messages tagged xitext-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/xitext-licence-check.service:
[Unit]
Description=Check the Xi-Text licence
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/check-xitext-licence
/etc/systemd/system/xitext-licence-check.timer:
[Unit]
Description=Check the Xi-Text licence daily
[Timer]
OnCalendar=*-*-* 07:00:00
Persistent=true
[Install]
WantedBy=timers.target
systemctl daemon-reload
systemctl enable --now xitext-licence-check.timer
journalctl -u xitext-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-Text host, add to nrpe.cfg:
command[check_xitext_licence]=/usr/local/sbin/check-xitext-licence
and define a service on the monitoring server that calls check_nrpe with the command check_xitext_licence. Checkmk runs it through MRPE, with one line in mrpe.cfg on the host:
Xi-Text_licence /usr/local/sbin/check-xitext-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/xitext-licence.conf, and restart the agent:
UserParameter=xitext.licence.status,/usr/local/sbin/check-xitext-licence >/dev/null; echo $?
UserParameter=xitext.licence.text,/usr/local/sbin/check-xitext-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
# xitext-licence-metrics - write the licence check as Prometheus metrics.
DIR=/var/lib/node_exporter/textfile_collector
line=$(/usr/local/sbin/check-xitext-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=\"xitext\"} $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=\"xitext\"} $days" ;;
esac
} > "$DIR/xitext_licence.prom.$$" && mv "$DIR/xitext_licence.prom.$$" "$DIR/xitext_licence.prom"
15 * * * * /usr/local/sbin/xitext-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 xt-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-xitext-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-xitext-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 - xt-checklic exited 127" means /usr/local/bin/xt-checklic is not installed at that path on this host; set CHECKLIC in the script to where it is.
Related articles
Renewing an Xi-Text Licence Without an Operator
Scheduling the stop, running xt-vwrite non-interactively, reading xt-checklic, and what the exit statuses mean
Installing an Emergency Seven-Day Licence on Xi-Text
Recovering a system whose licence has been lost or damaged with xt-emerglic, and replacing it with a permanent licence
Migrating Xi-Text to Another System
Exporting the print queue, printers and users with xt-backup, and restoring them on a newly licensed machine