#!/bin/bash set -Ceuo pipefail PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin cd /var/www/html/rrd rrd=batch.rrd if ! test -f $rrd then rrdcreate $rrd \ DS:batch:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:512 RRA:AVERAGE:0.5:12:512 RRA:AVERAGE:0.5:288:512 \ DS:queued:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:512 RRA:AVERAGE:0.5:12:512 RRA:AVERAGE:0.5:288:512 fi batch=$( journalctl --since "10 minutes ago" --facility=news | grep -E 'batch\.sh\[[0-9]+\]:' | wc -l ) queued=$(atq 2>/dev/null | wc -l) [[ "$queued" =~ ^[0-9]+$ ]] || queued=0 logger -p news.info -t batchrrd "batch=<${batch}> queued=<${queued}>" rrdupdate "$rrd" "N:${batch}:${queued}" rrdtool graph batch.png \ -t batch \ DEF:batch=${rrd}:batch:AVERAGE \ DEF:queued=${rrd}:queued:AVERAGE \ LINE1:batch#00FF00 \ LINE1:queued#FF0000 \ > /dev/null rrdtool graph batchd10.png \ --end now --start now-864000s \ -t batch \ DEF:batch=${rrd}:batch:AVERAGE \ DEF:queued=${rrd}:queued:AVERAGE \ LINE1:batch#00FF00 \ LINE1:queued#FF0000 \ > /dev/null