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