Skip to content

Commit

Permalink
Convert runlogwatch.sh to use inotifywait
Browse files Browse the repository at this point in the history
This aligns with metal3 runlogwatch.sh[1] which is possible now that
inotify-tools package is available[2].

[1] https://github.com/metal3-io/ironic-image/pull/548/files
[2] openstack-k8s-operators/tcib@0795bb9

Jira: OSPRH-10240
  • Loading branch information
steveb committed Nov 6, 2024
1 parent 0391795 commit 3c4aeab
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions templates/common/bin/runlogwatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
# Ramdisk logs path
LOG_DIR=${LOG_DIR:-/var/lib/ironic/ramdisk-logs}

while :; do
sleep 5

while read -r fn; do
echo
echo "************ Contents of $fn ramdisk log file bundle **************"
tar -xOzvvf "$fn" | sed -e "s/^/$(basename "$fn"): /"
rm -f "$fn"
# find all *.tar.gz files which are older than six seconds
done < <(find "${LOG_DIR}" -mmin +0.1 -type f -name "*.tar.gz")

done
inotifywait -m "${LOG_DIR}" -e close_write |
while read -r path _action file; do
echo "************ Contents of ${path}${file} ramdisk log file bundle **************"
tar -xOzvvf "${path}${file}" | sed -e "s/^/${file}: /"
rm -f "${path}/${file}"
done

0 comments on commit 3c4aeab

Please sign in to comment.