X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=system-status;h=3513c90863631bcc2bf20e93e6f9afaa30e7e646;hb=3c7dab4936f011bb91f42f7ccb1f8432b94ea040;hp=c11024bc5ba2c125615beb78c285f6193755c201;hpb=802e885e3e7fa3857f8bc4f54c261d5ca76f2454;p=distro-setup diff --git a/system-status b/system-status index c11024b..3513c90 100755 --- a/system-status +++ b/system-status @@ -46,6 +46,12 @@ loday() { /usr/local/bin/log-once "$@" | ifne mail -s "$HOSTNAME: system-status $2" daylert@iankelling.org fi } +# rm glob +rmg() { + if (( $# )); then + rm -f "$@" + fi +} # todo, consider migrating some of these alerts into prometheus write-status() { @@ -94,6 +100,24 @@ write-status() { esac + # this section copied from servicepid() + unit=exim4 + pid=$(systemctl show --property MainPID --value $unit ||:) + case $pid in + [1-9]*) : ;; + *) + dir=/sys/fs/cgroup/system.slice + if [[ ! -d $dir ]]; then + dir=/sys/fs/cgroup/systemd/system.slice + fi; + pid=$(head -n1 $dir/${unit%.service}.service/cgroup.procs ||:) + ;; + esac + if [[ ! $pid ]]; then + chars+=(EXIM) + fi + + if [[ -e /a/bin/bash_unpublished/source-state ]]; then # /a gets remounted due to btrbk, ignore error code for file doesnt exist source /a/bin/bash_unpublished/source-state || [[ $? == 1 ]] @@ -137,13 +161,13 @@ write-status() { # allow failure in case there are no snapshots yet. # shellcheck disable=SC2012 shopt -u nullglob - files=(/mnt/root/btrbk/$vol.20*) + files=(/mnt/o/btrbk/$vol.20*) shopt -s nullglob snaps=() if (( ${#files[@]} )); then snaps=($(ls -1avdr "${files[@]}" 2>/dev/null |head -n1 || : )) fi - now=$(date +%s) + now=$EPOCHSECONDS maxtime=0 for s in ${snaps[@]}; do file=${s##*/} @@ -177,7 +201,10 @@ write-status() { # fi # fi # fi - + else # end if $MAIL_HOST + rmg /home/iank/cron-errors/bounce* \ + /home/iank/cron-errors/btrbk.timer* \ + /home/iank/cron-errors/old-snapshot* fi if ip l show tunfsf &>/dev/null; then @@ -194,14 +221,21 @@ write-status() { esac fi - - if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then - emacsfiles="$(emacsclient --eval "$(cat /usr/local/bin/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')" - if [[ $emacsfiles ]]; then - chars+=("$emacsfiles") + # We do this once every 5 minutes, since this is not a grave problem. + # For formatted elisp, see /b/ds/unsaved-buffers.el + elisp='(format "%s" (-reduce-from (lambda (acc buf) (let ((bpath (buffer-file-name buf))) (if (and bpath (buffer-modified-p buf)) (cons bpath acc ) acc))) nil (buffer-list)))' + if [[ ! $last_emacs_check || $emacsfiles ]] || (( last_emacs_check < EPOCHSECONDS - 300 )); then + if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then + # i dun care if this fails + emacsfiles="$(timeout 1 emacsclient -a /usr/bin/true --eval "$elisp" 2>/dev/null | sed '/^"nil"$/d;s/^"(/E: /;s/)"$//' ||:)" + if [[ $emacsfiles ]]; then + chars+=("$emacsfiles") + fi fi + last_emacs_check=$EPOCHSECONDS fi + glob=(/nocow/btrfs-stale/*) if [[ -e ${glob[0]} ]]; then chars+=(STALE) @@ -212,16 +246,6 @@ write-status() { fi p $var_mail_msg | loday -1 var_mail - - tmp=(/var/local/cron-errors/mailtest-check*) - if (( ${#tmp[@]} )); then - chars+=(MAILPING) - fi - tmp=(/var/local/cron-errors/mailtest-slow*) - if (( ${#tmp[@]} )); then - chars+=(SPAMD) - fi - # early in install process, we dont have permission yet for exiqgrep. # 1100 helps allow for system restarts qlen=$(/usr/sbin/exiqgrep -o 1100 -c -b | awk '{print $1}') ||: @@ -236,6 +260,9 @@ write-status() { $MAIL_HOST) p $qmsg | loday -120 qlen ;; + *) + rmg /home/iank/cron-errors/qlen* + ;; esac begin=false @@ -261,7 +288,7 @@ write-status() { # shellcheck disable=SC2043 for _ in 1; do if [[ -e $f ]]; then - now=$(date +%s) + now=$EPOCHSECONDS fsec=$(stat -c%Y $f) # the / 60 makes it 0-59 seconds less strict, +1 to help make sure we # dont have any false positives. @@ -354,6 +381,9 @@ main-loop() { fi wait=15 if ! $power; then + if systemctl -q is-active bitcoind; then + bitcoinoff + fi wait=60 fi