iankelling.org
/
git
/
distro-setup
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
avoid sudo resolv alert on rerun
[distro-setup]
/
system-status
diff --git
a/system-status
b/system-status
index 460d63be5c33385e03f580d03ecb41e5e9687132..e137d06f3b4b15c44b884e6dc04e8eb17d0a3759 100755
(executable)
--- a/
system-status
+++ b/
system-status
@@
-2,7
+2,8
@@
# Copyright (C) 2019 Ian Kelling
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (C) 2019 Ian Kelling
# SPDX-License-Identifier: AGPL-3.0-or-later
-# usage: runs 4 times every 15 seconds unless any args are passed, then just runs once
+# usage: runs 4 times every 15 seconds unless any args are passed, or we
+# are on battery power, then just runs once.
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
@@
-15,7
+16,7
@@
shopt -s dotglob
lo() { /usr/local/bin/log-once "$@"; }
write-status() {
lo() { /usr/local/bin/log-once "$@"; }
write-status() {
- chars=()
+ chars=(
"${first_chars[@]}"
)
glob=(/nocow/btrfs-stale/*)
if [[ -e ${glob[0]} ]]; then
glob=(/nocow/btrfs-stale/*)
if [[ -e ${glob[0]} ]]; then
@@
-35,7
+36,12
@@
write-status() {
chars+=("MAILPING!")
fi
chars+=("MAILPING!")
fi
+ qlen=$(/usr/sbin/exiqgrep -o 60 -c -b | awk '{print $1}')
+ if ((qlen)); then
+ chars+=("q $qlen")
+ fi
+ cd /b/ds
if ! make -q ~/.local/distro-begin || [[ $(<~/.local/distro-begin) != 0 ]]; then
chars+=("DISTRO-BEGIN!")
fi
if ! make -q ~/.local/distro-begin || [[ $(<~/.local/distro-begin) != 0 ]]; then
chars+=("DISTRO-BEGIN!")
fi
@@
-46,7
+52,6
@@
write-status() {
f=~/.local/conflink
if [[ -e $f ]]; then
f=~/.local/conflink
if [[ -e $f ]]; then
- cd /b/ds
now=$(date +%s)
fsec=$(stat -c%Y $f)
fmin=$(( (fsec - now ) / 60 + 1 ))
now=$(date +%s)
fsec=$(stat -c%Y $f)
fmin=$(( (fsec - now ) / 60 + 1 ))
@@
-77,7
+82,7
@@
write-status() {
spamcount=0
fi
if (( spamcount <= 4 )); then
spamcount=0
fi
if (( spamcount <= 4 )); then
- if grep -q 'spam acl condition' /var/log/exim4/paniclog; then
+ if grep -q 'spam acl condition' /var/log/exim4/paniclog
&>/dev/null
; then
printf . >>$loglog
fi
/a/bin/distro-setup/epanic-clean
printf . >>$loglog
fi
/a/bin/distro-setup/epanic-clean
@@
-92,6
+97,7
@@
write-status() {
source /a/bin/bash_unpublished/source-state
if [[ $MAIL_HOST == "$HOSTNAME" ]]; then
source /a/bin/bash_unpublished/source-state
if [[ $MAIL_HOST == "$HOSTNAME" ]]; then
+ bbkmsg=
if [[ $(systemctl is-active btrbk.timer) != active ]]; then
chars+=("BTRBK.TIMER!")
bbkmsg="btrbk.timer not enabled"
if [[ $(systemctl is-active btrbk.timer) != active ]]; then
chars+=("BTRBK.TIMER!")
bbkmsg="btrbk.timer not enabled"
@@
-130,11
+136,23
@@
write-status() {
fi
}
fi
}
+# use this if we want to do something just once per minute
+first_chars=()
+
+power=true
+if [[ -e /sys/class/power_supply/AC/online && $(</sys/class/power_supply/AC/online) == 0 ]]; then
+ power=false
+fi
+
write-status
if [[ $1 ]]; then
cat $status_file
exit 0
fi
write-status
if [[ $1 ]]; then
cat $status_file
exit 0
fi
+
+if ! $power; then
+ exit 0
+fi
for ((i=1; i<=3; i++)); do
sleep 15
write-status
for ((i=1; i<=3; i++)); do
sleep 15
write-status