Ignore recently-created temporary files (in the event that Ansible is doing shenanigans or something
This commit is contained in:
parent
edf1588c27
commit
8822bfad31
@ -11,6 +11,7 @@
|
||||
set -e
|
||||
|
||||
tmpdir="/tmp"
|
||||
minfileage="3600"
|
||||
|
||||
#
|
||||
# Compile a list of executables found in /tmp
|
||||
@ -23,6 +24,15 @@ tmpdir="/tmp"
|
||||
#
|
||||
executables=""
|
||||
while read line; do
|
||||
# Ignore recently-created files
|
||||
# This is so things like Ansible plays don't trigger us
|
||||
filetimestamp="$(stat -c %Y -- "$line")"
|
||||
now="$(date +%s)"
|
||||
age="$(( now - filetimestamp ))"
|
||||
if (( age <= minfileage )); then
|
||||
continue
|
||||
fi
|
||||
# Add it to the list
|
||||
if [ -z "$executables" ]; then
|
||||
executables="$line"
|
||||
else
|
||||
@ -36,6 +46,6 @@ if [ -n "$executables" ]; then
|
||||
echo "CRITICAL: Found executables in $tmpdir: $executables"
|
||||
exit 2
|
||||
else
|
||||
echo "OK: No executables in $tmpdir"
|
||||
echo "OK: No executables in $tmpdir older than ${minfileage}s"
|
||||
exit 0
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user