-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlast-runs-check.sh
29 lines (28 loc) · 1005 Bytes
/
last-runs-check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
cd "$(dirname "$0")"
# Manually execute to perform a lookup of a host's last runs on the network. Must be executed from the NAS device.
if [ ! -d "../damo_net_last-runs" ]
then
echo "'damo_net_last-runs' folder not found or command was not executed from the NAS device.. exiting."
exit 1
else
printf "\n"
echo "HOST - Last Run Date - Days Since Last Run - Exceeded 21 Days (X)"
echo "-----------------------------------------------------------------"
for filename in ../damo_net_last-runs/*.txt
do
exdays=""
basefile=$filename
host=$(basename $basefile | tr -d .txt)
filedate=$(cat $filename)
filedatelap=$(cat $filename | cut -d_ -f1 | cut -c 4-14 | sed 's/-//g' | sed 's/\(.*\)\(.\{4\}\)/\2\1/')
currentdate=$(date '+%Y%m%d')
let subtractdays=(`date +%s -d $currentdate`-`date +%s -d $filedatelap`)/86400
if [ $subtractdays -ge 21 ]
then
exdays="X"
fi
echo "$host - $filedate - $subtractdays $exdays"
done
printf "\n"
fi