-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiphc_check_irods_irm.sh
executable file
·101 lines (87 loc) · 2.26 KB
/
iphc_check_irods_irm.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
##############################################################################
#
# Name : iphc_check_irods_irm.sh
# Author : Emmanuel Medernach
#
# Parameters: --help
# --version
##############################################################################
HELP="This script is used by Nagios to check deletion of IRODS files"
# Initialisation
NVERSION=0.1
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
PROGNAME=`basename $0`
PWARNING=$1
PCRITICAL=$2
DIR=/tmp
print_usage() {
echo "Usage: $PROGNAME --help"
echo "Usage: $PROGNAME --version"
}
print_help() {
echo "Command : $PROGNAME"
echo $HELP
echo
echo "Usage: $PROGNAME -R <resource> -d <destination>"
echo "<destination> is an IRODS directory"
}
delete_file() {
if [ -z $DESTINATION ]
then
FILE="DATE.$RESOURCE"
else
FILE="$DESTINATION/DATE.$RESOURCE"
fi
ils $FILE > /dev/null || exit $STATE_WARNING
irm -f $FILE 2>&1 || exit $STATE_CRITICAL
}
DESTINATION=""
RESOURCE=""
# Parse the arguments
while [ -n "$1" ]; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
--version)
echo "Version: $NVERSION"
exit $STATE_OK
;;
-V)
echo "Version: $NVERSION"
exit $STATE_OK
;;
-R)
RESOURCE=$2
shift
;;
-d)
DESTINATION=$2
shift
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
if [ -z $RESOURCE ]
then
echo "Resource option not set: -R <resource>"
exit $STATE_WARNING
fi
delete_file
echo Ok
exit $STATE_OK