diff --git a/cluster/disk-watchdog.sh b/cluster/disk-watchdog.sh index d656376..558730c 100644 --- a/cluster/disk-watchdog.sh +++ b/cluster/disk-watchdog.sh @@ -3,17 +3,17 @@ # see https://bugzilla.ipr.univ-rennes1.fr/show_bug.cgi?id=3193 for details # test run: -# graffy@work:~/bug3193$ ./disk-watchdog.sh /mnt/work/graffy/workspaces/meniscus $HOME/var/run/ipr/cluster/disk-watchdog /opt/ipr/cluster/work.global 90 guillaume.raffy@univ-rennes1.fr "graffy (manual trigger)" 20 +# graffy@work:~/bug3193$ ./disk-watchdog.sh /mnt/work/graffy/workspaces/meniscus $HOME/var/run/ipr/cluster/disk-watchdog /opt/ipr/cluster/work.global 90 guillaume.raffy@univ-rennes1.fr "manual trigger" 20 # production run: -# graffy@work:~/bug3193$ sudo ./disk-watchdog.sh /mnt/work /var/run/ipr/cluster/disk-watchdog /opt/ipr/cluster/work.global 90 ipr-cluster@listes.univ-rennes1.fr "graffy (manual trigger)" 20 +# graffy@work:~/bug3193$ sudo ./disk-watchdog.sh /mnt/work /var/run/ipr/cluster/disk-watchdog /opt/ipr/cluster/work.global 90 ipr-cluster@listes.univ-rennes1.fr "cron" 20 SHARED_DISK_ROOT="$1" # eg '/mnt/work' REPORTS_ROOT_PATH="$2" # eg "$HOME/var/run/ipr/cluster/disk-watchdog" DISK_PUBLIC_PATH="$3" # 'eg /opt/ipr/cluster/work.global' FULLNESS_THRESHOLD="$4" # disk fullness percentage above which an e-mail is sent (eg. '90' for 90%) DEST_EMAIL="$5" # eg ipr-cluster@listes.univ-rennes1.fr -TRIGGERER="$6" # eg "daily cron" +TRIGGER_REASON="$6" # eg "daily cron" TOP_SIZE="$7" # # number of biggest directories reported (eg 20)" RETURNCODE_SUCCESS=0 @@ -130,12 +130,12 @@ function check_disk_usage() local disk_public_path="$3" # eg /opt/ipr/cluster/work.global local fullness_threshold="$4" # eg '90' for 90% local dest_email="$5" # eg ipr-cluster@listes.univ-rennes1.fr - local triggerer="$6" # eg "work.ipr.univ-rennes1.fr:/etc/cron.daily" + local trigger_reason="$6" # eg "cron.daily" local top_size="$7" # number of biggest directories reported (eg 20) local trigger_date="$(date)" disk_id=$(basename "${shared_disk_root}") - log "check of ${shared_disk_root} triggered by ${triggerer} with threshold ${fullness_threshold} %" + log "check of ${shared_disk_root} triggered by ${trigger_reason} with threshold ${fullness_threshold} %" mkdir -p "{$reports_root_path}" this_report_dir="${reports_root_path}/${disk_id}-$(date +'%Y-%m-%d-%H-%M-%S')" @@ -188,7 +188,7 @@ function check_disk_usage() fi html_content="${html_content}${localized_message}" done - html_content="${html_content}disk-watchdog.ipr.univ-rennes1.fr v1.0 - triggered from $(hostname --fqdn) by : ${triggerer} on ${trigger_date}" + html_content="${html_content}disk-watchdog.ipr.univ-rennes1.fr v1.0 - triggered from $(hostname --fqdn) by : $(whoami) (${trigger_reason}) on ${trigger_date}" local sendmail_stdin="To: ${to}\nFrom: ${from}\nSubject: ${subject}\nContent-Type: text/html; charset=\"UTF-8\"\n${html_content}\n" printf "$sendmail_stdin" | /usr/sbin/sendmail "${to}" @@ -200,7 +200,7 @@ set -o errexit if [ $# = 7 ] then - check_disk_usage "${SHARED_DISK_ROOT}" "${REPORTS_ROOT_PATH}" "${DISK_PUBLIC_PATH}" "${FULLNESS_THRESHOLD}" "${DEST_EMAIL}" "${TRIGGERER}" "${TOP_SIZE}" + check_disk_usage "${SHARED_DISK_ROOT}" "${REPORTS_ROOT_PATH}" "${DISK_PUBLIC_PATH}" "${FULLNESS_THRESHOLD}" "${DEST_EMAIL}" "${TRIGGER_REASON}" "${TOP_SIZE}" else error "wrong number of arguments" exit "${RETURNCODE_ERROR}"