mirror of
https://github.com/deajan/obackup.git
synced 2024-12-25 06:53:41 +01:00
Updated ofunctions
This commit is contained in:
parent
64c32bca07
commit
fbd5317010
@ -2,8 +2,8 @@
|
||||
#### OFUNCTIONS FULL SUBSET ####
|
||||
#### OFUNCTIONS MINI SUBSET ####
|
||||
|
||||
_OFUNCTIONS_VERSION=2.1.1
|
||||
_OFUNCTIONS_BUILD=2017041101
|
||||
_OFUNCTIONS_VERSION=2.1.4-dev
|
||||
_OFUNCTIONS_BUILD=2017052201
|
||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
||||
_OFUNCTIONS_BOOTSTRAP=true
|
||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
||||
@ -637,6 +637,22 @@ function Spinner {
|
||||
fi
|
||||
}
|
||||
|
||||
function _PerfProfiler { #__WITH_PARANOIA_DEBUG
|
||||
local perfString #__WITH_PARANOIA_DEBUG
|
||||
#__WITH_PARANOIA_DEBUG
|
||||
perfString=$(ps -p $$ -o args,pid,ppid,%cpu,%mem,time,etime,state,wchan) #__WITH_PARANOIA_DEBUG
|
||||
#__WITH_PARANOIA_DEBUG
|
||||
for i in $(pgrep -P $$); do #__WITH_PARANOIA_DEBUG
|
||||
perfString="$perfString\n"$(ps -p $i -o args,pid,ppid,%cpu,%mem,time,etime,state,wchan | tail -1) #__WITH_PARANOIA_DEBUG
|
||||
done #__WITH_PARANOIA_DEBUG
|
||||
#__WITH_PARANOIA_DEBUG
|
||||
if type iostat > /dev/null 2>&1; then #__WITH_PARANOIA_DEBUG
|
||||
perfString="$perfString\n"$(iostat) #__WITH_PARANOIA_DEBUG
|
||||
fi #__WITH_PARANOIA_DEBUG
|
||||
#__WITH_PARANOIA_DEBUG
|
||||
Logger "PerfProfiler:\n$perfString" "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
|
||||
} #__WITH_PARANOIA_DEBUG
|
||||
|
||||
|
||||
# Time control function for background processes, suitable for multiple synchronous processes
|
||||
# Fills a global variable called WAIT_FOR_TASK_COMPLETION_$callerName that contains list of failed pids in format pid1:result1;pid2:result2
|
||||
@ -769,6 +785,11 @@ function WaitForTaskCompletion {
|
||||
pidsArray=("${newPidsArray[@]}")
|
||||
# Trivial wait time for bash to not eat up all CPU
|
||||
sleep $sleepTime
|
||||
|
||||
if [ "$_PERF_PROFILER" == "yes" ]; then ##__WITH_PARANOIA_DEBUG
|
||||
_PerfProfiler ##__WITH_PARANOIA_DEBUG
|
||||
fi ##__WITH_PARANOIA_DEBUG
|
||||
|
||||
done
|
||||
|
||||
Logger "${FUNCNAME[0]} ended for [$callerName] using [$pidCount] subprocesses with [$errorcount] errors." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
|
||||
@ -934,6 +955,10 @@ function ParallelExec {
|
||||
|
||||
# Trivial wait time for bash to not eat up all CPU
|
||||
sleep $sleepTime
|
||||
|
||||
if [ "$_PERF_PROFILER" == "yes" ]; then ##__WITH_PARANOIA_DEBUG
|
||||
_PerfProfiler ##__WITH_PARANOIA_DEBUG
|
||||
fi ##__WITH_PARANOIA_DEBUG
|
||||
done
|
||||
|
||||
return $errorCount
|
||||
@ -1154,9 +1179,6 @@ function GetLocalOS {
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if [ "$_OFUNCTIONS_VERSION" != "" ]; then
|
||||
Logger "Local OS: [$localOsVar]." "DEBUG"
|
||||
fi
|
||||
|
||||
# Get linux versions
|
||||
if [ -f "/etc/os-release" ]; then
|
||||
@ -1166,6 +1188,10 @@ function GetLocalOS {
|
||||
|
||||
# Add a global variable for statistics in installer
|
||||
LOCAL_OS_FULL="$localOsVar ($localOsName $localOsVer)"
|
||||
|
||||
if [ "$_OFUNCTIONS_VERSION" != "" ]; then
|
||||
Logger "Local OS: [$LOCAL_OS_FULL]." "DEBUG"
|
||||
fi
|
||||
}
|
||||
#### GetLocalOS SUBSET END ####
|
||||
|
||||
@ -1238,11 +1264,14 @@ function GetRemoteOS {
|
||||
|
||||
$SSH_CMD env _REMOTE_TOKEN="$_REMOTE_TOKEN" bash -s << 'ENDSSH' >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1
|
||||
|
||||
|
||||
function GetOs {
|
||||
local localOsVar
|
||||
local localOsName
|
||||
local localOsVer
|
||||
|
||||
local osInfo="/etc/os-release"
|
||||
|
||||
# There's no good way to tell if currently running in BusyBox shell. Using sluggish way.
|
||||
if ls --help 2>&1 | grep -i "BusyBox" > /dev/null; then
|
||||
localOsVar="BusyBox"
|
||||
@ -1261,9 +1290,11 @@ function GetOs {
|
||||
fi
|
||||
fi
|
||||
# Get linux versions
|
||||
if [ -f "/etc/os-release" ]; then
|
||||
localOsName=$(GetConfFileValue "/etc/os-release" "NAME")
|
||||
localOsVer=$(GetConfFileValue "/etc/os-release" "VERSION")
|
||||
if [ -f "$osInfo" ]; then
|
||||
localOsName=$(grep "^NAME=" "$osInfo")
|
||||
localOsName="${localOsName##*=}"
|
||||
localOsVer=$(grep "^VERSION=" "$osInfo")
|
||||
localOsVer="${localOsVer##*=}"
|
||||
fi
|
||||
|
||||
echo "$localOsVar ($localOsName $localOsVer)"
|
||||
@ -1611,13 +1642,13 @@ function PostInit {
|
||||
|
||||
# Define remote commands
|
||||
if [ -f "$SSH_RSA_PRIVATE_KEY" ]; then
|
||||
SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
|
||||
SCP_CMD="$(type -p scp) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -P $REMOTE_PORT"
|
||||
RSYNC_SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS -p $REMOTE_PORT"
|
||||
SSH_CMD="$(type -p ssh) $SSH_COMP -q -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
|
||||
SCP_CMD="$(type -p scp) $SSH_COMP -q -i $SSH_RSA_PRIVATE_KEY -P $REMOTE_PORT"
|
||||
RSYNC_SSH_CMD="$(type -p ssh) $SSH_COMP -q -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS -p $REMOTE_PORT"
|
||||
elif [ -f "$SSH_PASSWORD_FILE" ]; then
|
||||
SSH_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p ssh) $SSH_COMP $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
|
||||
SCP_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p scp) $SSH_COMP -P $REMOTE_PORT"
|
||||
RSYNC_SSH_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p ssh) $SSH_COMP $SSH_OPTS -p $REMOTE_PORT"
|
||||
SSH_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p ssh) $SSH_COMP -q $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
|
||||
SCP_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p scp) $SSH_COMP -q -P $REMOTE_PORT"
|
||||
RSYNC_SSH_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p ssh) $SSH_COMP -q $SSH_OPTS -p $REMOTE_PORT"
|
||||
else
|
||||
SSH_PASSWORD=""
|
||||
SSH_CMD=""
|
||||
|
Loading…
Reference in New Issue
Block a user