From 749892338bfb171eba0c8d10fa905f0e68ed8ca2 Mon Sep 17 00:00:00 2001 From: Florian Hines Date: Wed, 27 Jul 2011 22:29:23 -0500 Subject: [PATCH] few fixes to temp cronjob --- bin/swift-recon-cron | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/bin/swift-recon-cron b/bin/swift-recon-cron index a8d1c05353..3e4d3928c7 100755 --- a/bin/swift-recon-cron +++ b/bin/swift-recon-cron @@ -6,19 +6,20 @@ # of high async pendings when the find takes a while. #todo: everything. -SYSLOG_FACILITY="local0.error" +SYSLOG_FACILITY="local2" ASYNC_PATH="/srv/node/sd[a-z]/async_pending/" -RECON_CACHE_PATH="/var/cache/swift/object.recon" +RECON_CACHE_PATH="/var/cache/swift" LOCKFILE="/var/lock/swift-recon-object.lock" if [ -e $LOCKFILE ]; then echo "NOTICE - $0 lock present - cron jobs overlapping ?" - echo "$0 lock file present" | /usr/bin/logger -p $SYSLOG_FACILITY + echo "$0 lock file present" | /usr/bin/logger -p $SYSLOG_FACILITY.err exit 1 else touch $LOCKFILE fi + if [ -z "$1" ]; then LOGFILE="/var/log/swift/storage.log" else @@ -26,11 +27,15 @@ else fi if [ ! -r "$LOGFILE" ]; then - echo "$0: error $LOGFILE not readable" | /usr/bin/logger -p $SYSLOG_FACILITY + echo "$0: error $LOGFILE not readable" | /usr/bin/logger -p $SYSLOG_FACILITY.err rm $LOCKFILE exit 1 fi +if [ ! -d "$RECON_CACHE_PATH" ]; then + mkdir $RECON_CACHE_PATH +fi + TMPF=`/bin/mktemp` asyncs=$(find $ASYNC_PATH -type f 2> /dev/null| wc -l) @@ -41,6 +46,11 @@ objincoming=$(netstat -aln | egrep "tcp.*:6000.*:.*ESTABLISHED" -c) echo "{\"async_pending\":$asyncs, \"object_replication_time\":$objrep, \"object_established_conns\":$objincoming}" > $TMPF -mv $TMPF $RECON_CACHE_PATH +mv $TMPF $RECON_CACHE_PATH/object.recon +if [ $? -ne 0 ]; then + echo "$0: $TMPF rename failed" | /usr/bin/logger -p $SYSLOG_FACILITY.err + rm -f $TMPF $LOCKFILE + exit 1 +fi rm -f $TMPF $LOCKFILE exit 0