Last active
June 27, 2024 13:18
-
-
Save jduckles/65f4c741bec7ace4a39f to your computer and use it in GitHub Desktop.
This is a little script to check a phenocam site and determine if it has enough photos.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PHENOCAM_DIR=/data/eomfftp/phenocam | |
SITES="Marena Elreno_iGOS_East Elreno" | |
[email protected] | |
check_phenocam() { | |
SITE=$1 | |
COUNT_DATE=$(ls $PHENOCAM_DIR/$SITE | cut -f 2,3 -d "-" | sort -r | uniq -c | head -1 | sed 's/^ *//g') | |
COUNT=$(echo $COUNT_DATE | cut -f1 -d" ") # Extract count | |
DATE=$(echo $COUNT_DATE | cut -f2 -d" ") # Extract date | |
# Test that the top date is today | |
TODAY=$(date +%Y-%m%d) | |
MESSAGE="This is an error about site: ${SITE}. " | |
if [ $DATE != $TODAY ]; then | |
MESSAGE=${MESSAGE}"There don't seem to be any photos at $SITE today." | |
# Test that the count is 8 | |
if [ $COUNT -ne 8 ]; then | |
MESSAGE=${MESSAGE}" We don't have enough images, there are only $COUNT" | |
fi | |
ERROR=1 | |
fi | |
if [ $ERROR ]; then | |
echo $MESSAGE | mail -s "${SITE} Phenocam Problem" ${CONTACT} | |
fi | |
} | |
check_all() { | |
for site in $SITES; do | |
check_phenocam $site | |
done | |
} | |
check_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment