icinga2-checks/check_file_exists.sh

25 lines
481 B
Bash
Raw Normal View History

2024-09-16 15:44:53 -06:00
#!/bin/bash
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--file) file="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
if [[ -z "$file" ]]; then
echo "No file provided. Please provide a file with --file."
exit 3
fi
# Check if file exists
if [[ -f "$file" ]]; then
2024-09-16 16:02:30 -06:00
echo "OK - file exists: \"$file\""
2024-09-16 15:44:53 -06:00
exit 0
else
2024-09-16 16:02:30 -06:00
echo "CRITICAL - file does not exist: \"$file\""
2024-09-16 15:44:53 -06:00
exit 2
fi