diff --git a/check_executables_in_tmp b/check_executables_in_tmp index c4c7796..0fca90f 100755 --- a/check_executables_in_tmp +++ b/check_executables_in_tmp @@ -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