source: trunk/DataCheck/Monitoring/CheckDU.sh@ 19846

Last change on this file since 19846 was 18857, checked in by Daniela Dorner, 8 years ago
added newdata, improved handling of limits
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/bin/bash
2#
3# Script to check whether disk is full
4#
5
6source `dirname $0`/../Sourcefile.sh
7printprocesslog "INFO starting $0"
8
9# possible limits
10limits=( 10485760 52428800 104857600 209715200 524288000 1073741824 2147483648 )
11texts=( "10 GB" "50 GB" "100 GB" "200 GB" "500 GB" "1 TB" "2 TB" )
12
13# get paths depending on host
14case $HOSTNAME in
15# data) dirs=( "/loc_data" "/daq" "/newdaq" )
16 data) dirs=( "/loc_data" )
17 lowlimits=( 4 )
18 highlimits=( 5 )
19 ;;
20 daq) dirs=( "/raid10" )
21 lowlimits=( 4 )
22 highlimits=( 5 )
23 ;;
24 newdaq) dirs=( "/fact" )
25 lowlimits=( 5 )
26 highlimits=( 6 )
27 ;;
28 newdata) dirs=( "/scratch" "/data1" "/data2" )
29 lowlimits=( 1 4 4 )
30 highlimits=( 2 5 5 )
31 lowlimits=( 0 4 4 )
32 highlimits=( 1 5 5 )
33 ;;
34 isdc-dl00) dirs=( "/gpfs" "/scratch" )
35 lowlimits=( 4 )
36 highlimits=( 4 )
37 ;;
38 *) echo "no valid host "$HOSTNAME
39 exit
40 ;;
41esac
42
43# get current hour
44hour=`date +%k`
45
46for (( i=0 ; i< ${#dirs[@]} ; i++ ))
47do
48 dir=${dirs[$i]}
49 # define disk space limit for check depending on the time
50 if [ $hour -lt 8 ] || [ $hour -gt 15 ]
51 then
52 # during night
53 dulimit=${limits[${lowlimits[$i]}]}
54 dutext=${texts[${lowlimits[$i]}]}
55 else
56 # during day
57 dulimit=${limits[${highlimits[$i]}]}
58 dutext=${texts[${highlimits[$i]}]}
59 fi
60
61 # check if directory is mounted (check if empty)
62 printprocesslog "INFO check "$dir" with limit "$dutext"."
63 if [ "$(ls -A $dir)" ]
64 then
65 # get available disk space
66 diskusage=( `df -P $dir | grep $dir ` )
67 # check if more than X GB are left on /loc_data
68 if [ ${diskusage[3]} -lt $dulimit ]
69 then
70 echo "WARN less than "$dutext" left on "$dir" on node "$HOSTNAME" ("${diskusage[3]}")"
71 printprocesslog "DISK less than "$dutext" left on "$dir" on node "$HOSTNAME" ("${diskusage[3]}")"
72 df -h $dir
73 echo ""
74 fi
75 else
76 echo "ERROR "$dir" seems to be not mounted."
77 printprocesslog "ERROR "$dir" seems to be not mounted."
78 fi
79done
80
81finish
82
Note: See TracBrowser for help on using the repository browser.