From 492394371b39fa562304b45e809e9cb944ee12fa Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 18 Sep 2019 13:38:00 +0200 Subject: bin/nit-picker: check for long-running builds --- bin/nit-picker | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'bin/nit-picker') diff --git a/bin/nit-picker b/bin/nit-picker index 9395ef4..44a3e62 100755 --- a/bin/nit-picker +++ b/bin/nit-picker @@ -119,6 +119,12 @@ while pgrep -x ii >/dev/null \ printf ' WHERE `repositories`.`is_on_master_mirror`' printf ';\n' + printf 'SELECT' + printf ' "build-duration",' + printf '`build_slaves`.`name`' + printf ' FROM `build_slaves`' + printf ';\n' + printf 'SELECT DISTINCT' printf ' "binary-dependencies",' mysql_package_name_query @@ -332,6 +338,60 @@ while pgrep -x ii >/dev/null \ "${tmp_dir}/${parameters}" \ "${tmp_dir}/${parameters}.sig" ;; + 'build-duration') + infos=$( + # shellcheck disable=SC2016 + { + printf 'SELECT' + printf '`persons`.`name`,' + printf '`build_slaves`.`name`,' + printf '`architectures`.`name`,' + printf '`package_sources`.`pkgbase`,' + printf 'UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(' + printf 'MAX(' + printf 'IF(' + printf '`ssh_log`.`action`="get-assignment",' + printf '`ssh_log`.`date`,' + printf 'NULL' + printf ')' + printf ')' + printf ')' + printf ' FROM `build_slaves`' + mysql_join_build_slaves_build_assignments + mysql_join_build_assignments_architectures + mysql_join_build_assignments_package_sources + mysql_join_build_slaves_ssh_keys + mysql_join_ssh_keys_persons + mysql_join_build_slaves_ssh_log + printf ' WHERE `ssh_log`.`date`>=ADDDATE(NOW(),"-7 00:00:00")' + printf ' AND `build_slaves`.`name`=from_base64("%s")' \ + "$( + printf '%s' "${parameters}" \ + | base64 -w0 + )" + printf ' GROUP BY `build_slaves`.`id`' + printf ';\n' + } \ + | mysql_run_query \ + | tr '\t' ' ' + ) + if [ -z "${infos}" ]; then + continue + fi + if [ "${infos##* }" -lt $((60*60*24)) ]; then + continue + fi + printf '%s %s\n' \ + "${infos% *}" \ + "$( + date -d"@${infos##* }" +'%-j %H:%M:%S' + )" \ + | awk '{print $1 ": your slave " $2 " builds " $3 "/" $4 " for more than a day, now (" ($5-1) " day(s) " $6 ")"}' \ + | irc_say + if [ $# -eq 0 ]; then + sleep 60 + fi + ;; *) >&2 printf 'action "%s" is not yet implemented ...\n' "${action}" ;; -- cgit v1.2.3-70-g09d2