Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Iml Backup Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Iml Backup Server
Commits
fd4fc484
Commit
fd4fc484
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add param backupstatus
parent
57251e49
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage_helper.sh
+81
-8
81 additions, 8 deletions
storage_helper.sh
with
81 additions
and
8 deletions
storage_helper.sh
+
81
−
8
View file @
fd4fc484
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
#
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2019-11-01 hahn write more clear log messages
# 2019-11-01 hahn write more clear log messages
# 2021-06-xx hahn added setactive + setinactive
# 2021-06-16 hahn added backupstatus
# ======================================================================
# ======================================================================
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
...
@@ -37,17 +39,13 @@
...
@@ -37,17 +39,13 @@
# value is set in _showConnectionCount
# value is set in _showConnectionCount
iConnections
=
0
iConnections
=
0
# max age of last backup in h
iMaxbackupAge
=
36
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# FUNCTIONS
# FUNCTIONS
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# add a line into logfile
# param string message (date will be added as prefix)
function
_addLog
(){
# echo `date` $* >>${sLogDir}${sLogfile}
echo
`
date
"+%Y-%m-%d %H:%M:%S"
`
$*
>>
${
sLogfile
}
}
# ------------------------------------------------------------
# ------------------------------------------------------------
# color text
# color text
...
@@ -98,6 +96,42 @@
...
@@ -98,6 +96,42 @@
fi
fi
}
}
# ------------------------------------------------------------
# logging
# ------------------------------------------------------------
# add a line into logfile
# param string message (date will be added as prefix)
function
_addLog
(){
# echo `date` $* >>${sLogDir}${sLogfile}
echo
`
date "
+%Y-%m-%d %H:%M:%S
"
`
$*
>>
${
sLogfile
}
}
# get content of all logfiles
function
_getAllLogs
(){
zcat
$sLogdir
/
*
.gz
;
cat
$sLogfile
}
# get a list of all servers in the log
function
_getLoggedServers
(){
_getAllLogs |
cut
-f
2
-d
'['
|
cut
-f
1
-d
']'
|
sort
-u
}
# get timestamp of last backup start of a given server - see _getLoggedServers
# param string servername as fqdn
function
_getLastBackupstart
(){
local
_srv
=
$1
_getAllLogs |
sort
|
grep
"
\[
$_srv
\]
"
|
grep
ACCEPTED |
tail
-1
|
cut
-f
-2
-d
" "
}
# get timestamp of last backup end of a given server - see _getLoggedServers
# param string servername as fqdn
function
_getLastBackupend
(){
local
_srv
=
$1
_getAllLogs |
sort
|
grep
"
\[
$_srv
\]
"
|
grep
REMOVED |
tail
-1
|
cut
-f
-2
-d
" "
}
# ------------------------------------------------------------
# slot handling
# ------------------------------------------------------------
# show current connction count
# show current connction count
function
_showConnectionCount
(){
function
_showConnectionCount
(){
...
@@ -109,6 +143,7 @@
...
@@ -109,6 +143,7 @@
echo
STATUS:
$iConnections
existing connection
\(
s
\)
.
Allowed maximum is
$sMax
.
echo
STATUS:
$iConnections
existing connection
\(
s
\)
.
Allowed maximum is
$sMax
.
}
}
# helper: get filename for backup client connection
# helper: get filename for backup client connection
function
getConnFilename
(){
function
getConnFilename
(){
# sBackupClient=$1
# sBackupClient=$1
...
@@ -174,6 +209,43 @@
...
@@ -174,6 +209,43 @@
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
function
PUBLIC_backupstatus
(){
typeset
-i
local
ierrors
=
0
local
tbl
=
"%-45s | %-20s | %-20s | %-12s | %-10s
\n
"
printf
"
$tbl
"
"server"
"start"
"end"
"duration [s]"
"age [h]"
echo
"--------------------------------------------------------------------------------------------------------------"
for
myserver
in
$(
_getLoggedServers
)
do
# get data
local
tstart
=
"
$(
_getLastBackupstart
$myserver
)
"
local
tend
=
"
$(
_getLastBackupend
$myserver
)
"
typeset
-i
local
istart
=
$(
date
+%s
-d
"
$tstart
"
)
typeset
-i
local
iend
=
$(
date
+%s
-d
"
$tend
"
)
typeset
-i
local
iduration
=
$iend
-
$istart
typeset
-i
local
iage
=
$(
date
+%s
)
-
$iend
typeset
-i
local
iagehours
=
$iage
/60/60
# check values
local
statusAge
=
$(
color ok
)
if
[
$iagehours
-gt
$iMaxbackupAge
]
;
then
statusAge
=
$(
color error
)
ierrors
=
$ierrors
+1
fi
local
sduration
=
$iduration
test
$iduration
-lt
0
&&
sduration
=
"RUNNING"
# output
printf
"
$tbl
"
$myserver
"
$tstart
"
"
${
tend
}
"
"
${
sduration
}
"
"
${
iagehours
}
"
done
echo
echo
"total :
$(
_getLoggedServers
)
servers"
echo
"errors:
$ierrors
"
echo
echo
"rc=
$ierrors
"
exit
$ierrors
}
function
PUBLIC_setactive
(){
function
PUBLIC_setactive
(){
echo
---
list of inactive backup repositories
echo
---
list of inactive backup repositories
_listRepodirs |
grep
'\(inactive\)'
_listRepodirs |
grep
'\(inactive\)'
...
@@ -338,8 +410,6 @@
...
@@ -338,8 +410,6 @@
mkdir
-p
"
$sConncectionDir
"
||
exit
1
mkdir
-p
"
$sConncectionDir
"
||
exit
1
fi
fi
color
head
color
head
echo
echo
echo
"---------- :: STORAGE ::
`
hostname
`
:: ----------"
echo
"---------- :: STORAGE ::
`
hostname
`
:: ----------"
...
@@ -354,6 +424,9 @@
...
@@ -354,6 +424,9 @@
echo
SYNTAX:
echo
SYNTAX:
echo
"
`
basename
$0
`
[function]"
echo
"
`
basename
$0
`
[function]"
echo
echo
echo
" backupstatus"
echo
" show all servers and their backup times"
echo
echo
" register | unregister [hostname]"
echo
" register | unregister [hostname]"
echo
" add/ remove slot for a backup client"
echo
" add/ remove slot for a backup client"
echo
echo
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment