Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 May 2024 14:19:44 +0900
From:      Tatsuki Makino <tatsuki_makino@hotmail.com>
To:        freebsd-ports@FreeBSD.org
Subject:   Re: I've started collecting tmpfs usage figures from a poudriere-devel bulk -a for later publishing some of the top ones (handy for TMPFS_BLACKLIST judgments)
Message-ID:  <SI2PR01MB50364BC5D47D11707836AB67FAE92@SI2PR01MB5036.apcprd01.prod.exchangelabs.com>
In-Reply-To: <SI2PR01MB50366DD399A573CB7224AC2EFA192@SI2PR01MB5036.apcprd01.prod.exchangelabs.com>
References:  <97E1D1BA-CBA1-42C6-8202-B6D654941C28.ref@yahoo.com> <97E1D1BA-CBA1-42C6-8202-B6D654941C28@yahoo.com> <SI2PR01MB50366DD399A573CB7224AC2EFA192@SI2PR01MB5036.apcprd01.prod.exchangelabs.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello, especially those who add some kind of tweaks to poudriere :)

In my case, I try to make it a hook script first, so it is not affected by errexit of shell.
However, when modifying poudriere to incorporate the codes, some tmpfs are not mounted depending on USE_TMPFS value, so poudriere exits with an error when trying to handle them.

So I will post a revised version of the hook script that includes ideas to counteract that, including this one.
The file should be placed in a location that will be erased by poudriere-logclean. That would require another step to collect the results...
I don't know if multiple concurrent executions of it will occur, but even if it does, it has been changed to work exclusively.
And I am trying to use jq to get and add numbers.

If you see a point that you think is an interesting idea, cut it out and use it :)

Regards.

Below is the script.

#!/bin/sh
case "${0##*/}" in
pkgbuild.sh)
	case "${1}" in	# (
	success|failed)
		if ! [ ${LOCKF_HOOK_TMPFS:+1} ] ; then
			shopt="${-}"
			LOCKF_HOOK_TMPFS=1 lockf -k "${LOG}/.tmpfs.log" /bin/sh ${shopt:+"-${-}"} "${0}" ${1+"${@}"}
		elif [ ${MY_JOBID:+1} ] ; then
			# jq was installed by package textproc/jq
			if JQ=$(which jq 2>&${OUTPUT_REDIRECTED_STDERR:-2}) ; then
				realpath=$(realpath "${MASTERMNT}/../${MY_JOBID}/")
				pour_xo_sauce_on_df=$(
					mount -t tmpfs -p |
					cut -f 2 -w |
					grep -e "^${realpath}" |
					xargs df -b --libxo json |
					${JQ} -c -r '[.["storage-system-information"].filesystem[].["used-blocks"]]|add//-0'
					)
				tmpfs_at_end=$(
					echo "${pour_xo_sauce_on_df}" |
					awk '{ x += $0; } END { printf "%s %.2f %s", "TMPFS:", x*512/(1024**3), "GiB" }'
					)
			elif ! tmpfs_at_end="$(env BLOCKSIZE=512 df -t tmpfs \
					${MASTERMNT}/../${MY_JOBID}/ \
					${MASTERMNT}/../${MY_JOBID}/.p/ \
					${MASTERMNT}/../${MY_JOBID}/usr/local/ \
					2>/dev/null | tail -3 \
					| awk '{ tmpfs_use += $3; } END { printf "%s %.2f %s", "TMPFS:", tmpfs_use*512/(1024**3), "GiB" }')" ; then
				tmpfs_at_end="TMPFS: -0. GiB"
			fi
			if true ; then
				# output to stdout
				echo "${2} | ${3}: ${tmpfs_at_end}" >&${OUTPUT_REDIRECTED_STDOUT:-1}
			fi
			if false ; then
				# output to stderr
				echo "${2} | ${3}: ${tmpfs_at_end}" >&${OUTPUT_REDIRECTED_STDERR:-2}
			fi
			if true && [ ${OUTPUT_REDIRECTED:-0} -eq 1 ] ; then
				# output to ${LOG}/logs/${3}.log file
				echo "${tmpfs_at_end}" >&2
			fi
			if true ; then
				# append to file
				echo "${2} | ${3}: ${tmpfs_at_end}" >>"${LOG}/.tmpfs.log"
			fi
		fi
		;;	# (
	*)
	esac
	;;	# (
*)
esac
return 0
# end of script




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?SI2PR01MB50364BC5D47D11707836AB67FAE92>