Merge branch '10-Tech_Blocked' into 104-integration
Former-commit-id:272ba87883
[formerly 14c8ac5618aa04da5408a1d75297f3f9fa19d023] Former-commit-id:c1129dbd00
This commit is contained in:
commit
ad402655f4
3 changed files with 193 additions and 0 deletions
BIN
rpms/awips2.core/Installer.ldm/patch/bin/edexBridge
Executable file
BIN
rpms/awips2.core/Installer.ldm/patch/bin/edexBridge
Executable file
Binary file not shown.
17
rpms/awips2.core/Installer.ldm/patch/bin/monitor_data_store.sh
Executable file
17
rpms/awips2.core/Installer.ldm/patch/bin/monitor_data_store.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
myPID=$$
|
||||
echo -e "`date +%Y%m%d`\t`date +%H:%M:%S`\tStarting Script (pid = $myPID, parent = $PPID)" >> ~/logs/`basename $0 .sh`
|
||||
if ps -wef|grep `basename $0` | grep -v grep | grep -v $myPID | grep -v $PPID
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd /data_store
|
||||
while true
|
||||
do
|
||||
for _dir in `ls`
|
||||
do
|
||||
echo -e "`date +%Y%m%d`\t`date +%H:%M:%S`\t\tfind ${_dir} -mtime +0 -type f -exec rm -f {} \;" >> ~/logs/`basename $0 .sh`
|
||||
find ${_dir} -mtime +0 -type f -exec rm -f {} \;
|
||||
done
|
||||
done
|
176
rpms/awips2.core/Installer.ldm/patch/bin/scour
Normal file
176
rpms/awips2.core/Installer.ldm/patch/bin/scour
Normal file
|
@ -0,0 +1,176 @@
|
|||
|
||||
# $Id: scour.in,v 1.1.16.6.2.7 2009/07/16 19:27:13 steve Exp $
|
||||
# Deletes old data files.
|
||||
#
|
||||
# Recursively deletes files older than a specified number of days from a
|
||||
# specified set of directories. The directories, retention time in days,
|
||||
# and an optional shell filename pattern appear, separated by tab characters
|
||||
# one directory per line, in a configuration file named on the command line.
|
||||
#
|
||||
# If no files have been written under a directory since the last time scour was
|
||||
# run, it will skip deleting old files and log an error message instead.
|
||||
#
|
||||
# WARNING: scour follows symbolic links, so don't put symbolic links to
|
||||
# directories you don't want scoured under data directories.
|
||||
|
||||
PATH=/bin:/usr/bin
|
||||
CONFFILE=/usr/local/ldm/etc/scour.conf # default, if no args
|
||||
VERBOSEFLAG=
|
||||
DEBUGFLAG=
|
||||
ERRS=
|
||||
PROG=`basename $0`
|
||||
LOGGER="echo $PROG: "
|
||||
TZ=UTC0 export TZ
|
||||
LOG_LDM=local0
|
||||
|
||||
while [ "$1" != "" ]
|
||||
do
|
||||
case "$1" in
|
||||
-v)
|
||||
VERBOSEFLAG=1
|
||||
;;
|
||||
-x)
|
||||
DEBUGFLAG=1
|
||||
;;
|
||||
-l) # logs to syslogd
|
||||
LOGGER="logger -t $PROG -p $LOG_LDM.notice"
|
||||
;;
|
||||
-*)
|
||||
$LOGGER "unrecognized flag ($1)"
|
||||
ERRS=1
|
||||
;;
|
||||
*)
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
$LOGGER "only 1 conf file argument permitted"
|
||||
ERRS=1
|
||||
fi
|
||||
CONFFILE=$1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$ERRS" != "" ]
|
||||
then
|
||||
$LOGGER "usage: $PROG [-l] [-v] [-x] [config-file]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$VERBOSEFLAG" != "" ]
|
||||
then
|
||||
$LOGGER "Starting Up"
|
||||
fi
|
||||
|
||||
# Different find(1) utilities have different meanings for the "-mtime" argument.
|
||||
# Discover the meaning for the find(1) utility that will be used.
|
||||
#
|
||||
dayOffsetName=scour_$$
|
||||
trap 'rm -f /tmp/$dayOffsetName' EXIT
|
||||
if touch /tmp/$dayOffsetName; then
|
||||
sleep 2
|
||||
#
|
||||
# NOTE: OSF/1's find(1) utility doesn't conform to the Standard
|
||||
# because the CWD must be changed in order to get this test to work.
|
||||
#
|
||||
dir=`pwd`
|
||||
cd /tmp
|
||||
if find $dayOffsetName -mtime 0 |
|
||||
grep $dayOffsetName >/dev/null; then
|
||||
DAY_OFFSET=1
|
||||
elif find $dayOffsetName -mtime 1 |
|
||||
grep $dayOffsetName >/dev/null; then
|
||||
DAY_OFFSET=0
|
||||
else
|
||||
$LOGGER "Couldn't discover meaning of '-mtime' argument of find(1)"
|
||||
exit 1
|
||||
fi
|
||||
cd $dir
|
||||
rm /tmp/$dayOffsetName
|
||||
else
|
||||
$LOGGER "Couldn't create '-mtime' discovery-file /tmp/$dayOffsetName"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while read dir age pattern; do
|
||||
if [ x$dir = x ] # ignore blank lines
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
case $dir in
|
||||
\#*) # ignore comments
|
||||
continue
|
||||
;;
|
||||
*)
|
||||
if [ x$pattern = x ]
|
||||
then
|
||||
pattern="*"
|
||||
fi
|
||||
|
||||
# Convert directory specification to absolute pathname: follow symbolic
|
||||
# links (because find(1) doesn't) and perform tilde-expansion.
|
||||
#
|
||||
# NB: The statement
|
||||
# edir=`csh -f -c "cd $dir && /bin/pwd"`
|
||||
# causes the read(1) of the enclosing while-loop to return EOF if the
|
||||
# directory doesn't exist.
|
||||
#
|
||||
if edir=`echo "cd $dir && /bin/pwd" | csh -f`; then
|
||||
: true
|
||||
else
|
||||
$LOGGER "directory $dir does not exist, skipping"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$DEBUGFLAG" != "" ]
|
||||
then
|
||||
echo "dir=$dir age=$age pattern=$pattern edir=$edir"
|
||||
fi
|
||||
|
||||
(
|
||||
if cd $edir
|
||||
then
|
||||
# if either "$edir/.scour$pattern" doesn't exist yet OR
|
||||
# there are files newer than "$edir/.scour$pattern"
|
||||
# then
|
||||
# delete old files and create "$edir/.scour$pattern"
|
||||
# else
|
||||
# skip deletions and log message
|
||||
if [ ! -f ".scour$pattern" ] || \
|
||||
[ -n "`find . -newer \".scour$pattern\" 2>/dev/null | \
|
||||
head -1`" ]
|
||||
then
|
||||
FINDAGE=`echo $age $DAY_OFFSET - p|dc`
|
||||
if [ "$VERBOSEFLAG" != "" ]
|
||||
then
|
||||
BEFORE=`du -s . 2>/dev/null | \
|
||||
sed 's/^ *\([0-9]*\).*/\1/'`
|
||||
fi
|
||||
find . -type f -mtime +$FINDAGE -name "$pattern" -print \
|
||||
| sed 's/\([^\n]\)/\\\1/g' \
|
||||
| xargs rm -f && touch ".scour$pattern"
|
||||
if [ "$VERBOSEFLAG" != "" ]
|
||||
then
|
||||
AFTER=`du -s . 2>/dev/null | \
|
||||
sed 's/^ *\([0-9]*\).*/\1/'`
|
||||
# set DELETED to max(0, BEFORE - AFTER)
|
||||
DELETED=`echo $BEFORE $AFTER|\
|
||||
sed 's/\([0-9]*\) \([0-9]*\).*/b=\1;a=\2;d=0;if(a<b)d=b-a;d/'|\
|
||||
bc`
|
||||
$LOGGER "$DELETED blocks from $edir/$pattern (>" \
|
||||
"$age days old)"
|
||||
fi
|
||||
else
|
||||
$LOGGER "skipping, no recent files in $edir/$pattern"
|
||||
fi
|
||||
fi
|
||||
)
|
||||
;;
|
||||
esac
|
||||
done < $CONFFILE
|
||||
|
||||
if [ "$VERBOSEFLAG" != "" ]
|
||||
then
|
||||
$LOGGER exiting ...
|
||||
fi
|
Loading…
Add table
Reference in a new issue