X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=system-status;h=fc04445f02a067717b13a917ecf0ec6e187e9875;hb=8fc333f8c2d69d0792f3742d4f4351e7acb07d9e;hp=c11024bc5ba2c125615beb78c285f6193755c201;hpb=802e885e3e7fa3857f8bc4f54c261d5ca76f2454;p=distro-setup diff --git a/system-status b/system-status index c11024b..fc04445 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() { @@ -143,7 +149,7 @@ write-status() { 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 +183,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 +203,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 +228,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 +242,9 @@ write-status() { $MAIL_HOST) p $qmsg | loday -120 qlen ;; + *) + rmg /home/iank/cron-errors/qlen* + ;; esac begin=false @@ -261,7 +270,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.