X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=check-remote-mailqs;h=bb0f8b1defdaed131dab1f17623053d5baed933e;hb=HEAD;hp=3caaa61be67db995ba291b24038937cd299e7c8b;hpb=0249e646cbed14fc191827f95a05044287d419ad;p=distro-setup diff --git a/check-remote-mailqs b/check-remote-mailqs index 3caaa61..bb0f8b1 100755 --- a/check-remote-mailqs +++ b/check-remote-mailqs @@ -1,16 +1,36 @@ #!/bin/bash -# Copyright (C) 2019 Ian Kelling -# SPDX-License-Identifier: AGPL-3.0-or-later +# I, Ian Kelling, follow the GNU license recommendations at +# https://www.gnu.org/licenses/license-recommendations.en.html. They +# recommend that small programs, < 300 lines, be licensed under the +# Apache License 2.0. This file contains or is part of one or more small +# programs. If a small program grows beyond 300 lines, I plan to switch +# its license to GPL. + +# Copyright 2024 Ian Kelling + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi -source /a/bin/errhandle/err +source /a/bin/bash-bear-trap/bash-bear shopt -s nullglob shopt -s dotglob +# temp disabled: x2wg kwwg # this list duplicated in brc2 ralerts -for h in bk je li frodo kwwg x3wg x2wg kdwg sywg; do +for h in bk je li x3wg kdwg sywg; do statedir=/b/bash_unpublished/mailq-state statefile=$statedir/$h [[ -d $statedir ]] || continue @@ -26,9 +46,16 @@ for h in bk je li frodo kwwg x3wg x2wg kdwg sywg; do else if [[ -s $statefile ]]; then logsec=$(date +%s -d "$(head -n1 $statefile | awk '{print $1,$2}')") - nowsec=$(date +%s) - if (( logsec < nowsec - 60*60*48 )); then - echo $0: host $h ssh /usr/local/bin/check-mailq fail for over 48 hours + case $h in + frodo) + hours=200 + ;; + *) + hours=20 + ;; + esac + if (( logsec < EPOCHSECONDS - 60*60*hours )); then + echo $0: host $h ssh /usr/local/bin/check-mailq fail for over $hours hours fi fi printf "%s\n" "$c" | ts "%F %T" >> $statefile