Compare commits
No commits in common. "master" and "v1.0" have entirely different histories.
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1 +0,0 @@
|
|||||||
* text=auto
|
|
21
LICENSE
21
LICENSE
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2015 6543
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice (including the next
|
|
||||||
paragraph) shall be included in all copies or substantial portions of the
|
|
||||||
Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
||||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
||||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,9 +1,3 @@
|
|||||||
[](https://opensource.org/licenses/MIT)
|
|
||||||
[](https://code.obermui.de/6543/LogWert/releases)
|
|
||||||
[](https://mh.obermui.de/publickey.gpg)
|
|
||||||
|
|
||||||
# LogWert
|
# LogWert
|
||||||
|
|
||||||
Summarizes the RoboCopy Log's
|
Fasst die RoboCopy Log's zusammen
|
||||||
|
|
||||||
exec: `./logwert.ps1 [path-log1] [path-log2] [path-log3] ... `
|
|
||||||
|
198
logwert.ps1
Executable file → Normal file
198
logwert.ps1
Executable file → Normal file
@ -1,16 +1,14 @@
|
|||||||
#!/usr/bin/pwsh
|
##############################################################
|
||||||
|
|
||||||
|
|
||||||
##############################################################
|
|
||||||
## ##
|
## ##
|
||||||
## logwert.ps1 version. 1.2 ##
|
## logwert.ps1 version. 1.0 ##
|
||||||
## ##
|
## ##
|
||||||
## This is a smal help script ##
|
## Dies ist ein Hilfsscript fuer _shares_spiegeln.bat ##
|
||||||
## It evaluates robocopy logs and summarizes them ##
|
## und der Nachfolger des CMD-Scriptes "logwert.cmd", ##
|
||||||
|
## Es wertet die Robologfile aus und fast diese zusammen. ##
|
||||||
## ##
|
## ##
|
||||||
## @parameter: [path-log1] [path-log2] [path-log3] ... ##
|
## @parameter: [Pfad-Log1] [Pfad-Log2] [Pfad-Log3] ... ##
|
||||||
## ##
|
## ##
|
||||||
## @author: 6543@obermui.de ##
|
## @author: Martin.Huber@stbaro.bayern.de ##
|
||||||
## ##
|
## ##
|
||||||
##############################################################
|
##############################################################
|
||||||
|
|
||||||
@ -18,13 +16,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################### Einstellungen ####################################################
|
################################### Variablen Declaration ###############################################
|
||||||
|
[String]$Global:Log_Copy_Size_Einheit = "GB"
|
||||||
# b (=Bytes), k (=Kilobytes), m (=Megabytes), g (=Gigabytes) und t (=Terabytes)
|
|
||||||
[String]$Global:Log_Copy_Size_Einheit = "g"
|
|
||||||
|
|
||||||
|
|
||||||
################################### Hilfsvariablen NICHT editieren #######################################
|
### Hilfsvariablen NICHT editieren ###
|
||||||
|
|
||||||
[Double]$Global:zLog_Copy_errors = 0
|
[Double]$Global:zLog_Copy_errors = 0
|
||||||
[Double]$Global:zLog_Copy_Size = 0
|
[Double]$Global:zLog_Copy_Size = 0
|
||||||
@ -34,146 +30,122 @@
|
|||||||
|
|
||||||
################################### Functionen ##########################################################
|
################################### Functionen ##########################################################
|
||||||
|
|
||||||
function Log_Start ([String]$sLogpath){
|
function Log_Start ([String]$sLogPfad){
|
||||||
If(Test-Path $sLogpath) { #test if file exists
|
If(Test-Path $sLogPfad) {
|
||||||
$tmp = ""
|
$tmp = ""
|
||||||
$tmp = Get-Content $sLogpath #copy file into list
|
$tmp = Get-Content $sLogPfad
|
||||||
$tmp | ForEach-Object { Log_Main $_ } #process each line
|
$tmp | ForEach-Object { Log_Main $_ }
|
||||||
}
|
}
|
||||||
} # start processing
|
}
|
||||||
|
|
||||||
function Log_Main ([String]$sLine){
|
function Log_Main ([String]$sLine){
|
||||||
# separate Set character
|
#Zeilenweise auswertung
|
||||||
|
|
||||||
|
while(" ".Equals($sLine.Substring(0,1))) {$sLine = $sLine.Substring(1, $sLine.Length - 1)}
|
||||||
|
while("`"".Equals($sLine.Substring(0,1))) {$sLine = $sLine.Substring(1, $sLine.Length - 1)}
|
||||||
|
while(" ".Equals($sLine.Substring($sLine.Length - 1,1))) {$sLine = $sLine.Substring(0, $sLine.Length - 1)}
|
||||||
|
|
||||||
|
#Trenn Zeichen Setzen
|
||||||
$sLine = $sLine.replace("`"", "#")
|
$sLine = $sLine.replace("`"", "#")
|
||||||
$sLine = $sLine.replace(",", "#")
|
$sLine = $sLine.replace(",", "#")
|
||||||
$sLine = $sLine.replace("Insgesamt:", "")
|
$sLine = $sLine.replace(":", "#")
|
||||||
|
|
||||||
if($sLine -match "[0-z]") {
|
#Entferne Problemeverursachende Zeichen
|
||||||
|
$sLine = $sLine.replace(")", "+")
|
||||||
|
$sLine = $sLine.replace("(", "+")
|
||||||
|
|
||||||
|
$sLine.Split("#") | ForEach-Object { WichCase $_ }
|
||||||
|
}
|
||||||
|
|
||||||
### rule out anomalies
|
function WichCase ([String]$sTocken) {
|
||||||
|
$aTocken = ""
|
||||||
|
while(" ".Equals($sTocken.Substring(0,1))) {$sTocken = $sTocken.Substring(1, $sTocken.Length - 1)} #Lehrzeichen vor werten entvernen
|
||||||
|
while(" ".Equals($sTocken.Substring($sTocken.Length - 1,1))) {$sTocken = $sTocken.Substring(0, $sTocken.Length - 1)} #Lehrzeichen nach werten entvernen
|
||||||
|
while($sTocken.IndexOf(" ") -gt -1 ) {$sTocken = $sTocken.Replace(" ", " ")} #Mehrere hintereinander volgende Lehrzeichen entvernen
|
||||||
|
|
||||||
while(" ".Equals($sLine.Substring(0,1))) {$sLine = $sLine.Substring(1, $sLine.Length - 1)}
|
$aTocken = $sTocken.Split(" ")
|
||||||
#Remove when String Begins with Lehrzeichen
|
|
||||||
while("#".Equals($sLine.Substring(0,1))) {$sLine = $sLine.Substring(1, $sLine.Length - 1)}
|
|
||||||
#If string begins with delimiter remove
|
|
||||||
while(" ".Equals($sLine.Substring($sLine.Length - 1,1))) {$sLine = $sLine.Substring(0, $sLine.Length - 1)}
|
|
||||||
#If String Ends with Lehrzeichen Remove String
|
|
||||||
while("#".Equals($sLine.Substring($sLine.Length - 1,1))) {$sLine = $sLine.Substring(0, $sLine.Length - 1)}
|
|
||||||
#Remove if string ends with delimiters
|
|
||||||
while($sLine.IndexOf("##") -gt -1 ) {$sLine = $sLine.Replace("##", "#")}
|
|
||||||
#Remove several following delimiters in a row
|
|
||||||
while($sLine.IndexOf(" ") -gt -1 ) {$sLine = $sLine.Replace(" ", " ")}
|
|
||||||
#Remove several following characters in a row
|
|
||||||
$sLine.Split("#") | ForEach-Object { WichCase $_ }
|
|
||||||
}
|
|
||||||
} #Line by line evaluation
|
|
||||||
|
|
||||||
function WichCase ([String]$sToken) {
|
# Count_Copy_errors
|
||||||
|
If("Fehler".Equals($aTocken[1])) {
|
||||||
if($sToken -match "[0-z]") {
|
[Double]$Global:zLog_Copy_errors = [Double]$Global:zLog_Copy_errors + $aTocken[0]
|
||||||
|
|
||||||
while(" ".Equals($sToken.Substring(0,1))) {$sToken = $sToken.Substring(1, $sToken.Length - 1)}
|
|
||||||
#remove blank before rating
|
|
||||||
while(" ".Equals($sToken.Substring($sToken.Length - 1,1))) {$sToken = $sToken.Substring(0, $sToken.Length - 1)}
|
|
||||||
#remove blank avter rating
|
|
||||||
|
|
||||||
$aToken = $sToken.Split(" ")
|
|
||||||
|
|
||||||
# Count_Copy_errors
|
|
||||||
If(("Fehler".Equals($aToken[1])) -and ($aToken[0] -notmatch "[a-z]")) {
|
|
||||||
[Double]$Global:zLog_Copy_errors = [Double]$Global:zLog_Copy_errors + $aToken[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Count_Items
|
|
||||||
If(("von".Equals($aToken[1])) -and ("Dateien".Equals($aToken[3])) -and ($aToken[0] -notmatch "[a-z]") -and ($aToken[2] -notmatch "[a-z]")) {
|
|
||||||
[Double]$Global:zLog_Copy_item += $aToken[2]
|
|
||||||
[Double]$Global:zLog_Copy_real_item += $aToken[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Count_Size
|
# Count_Items
|
||||||
If(("von".Equals($aToken[2])) -and ("kopiert".Equals($aToken[5])) -and ($aToken[0] -notmatch "[a-z]") -and ($aToken[3] -notmatch "[a-z]") ){# -and ($aToken[1] -match "[b,k,m,g,t]") -and ($aToken[4] -match "[b,k,m,g,t]")) {
|
If("von".Equals($aTocken[1]) -and ("Dateien".Equals($aTocken[3]))) {
|
||||||
[Double]$Global:zLog_Copy_Size += (Calc_Byte_Sice $aToken[3] $aToken[4] b)
|
[Double]$Global:zLog_Copy_item = [Double]$Global:zLog_Copy_item + $aTocken[2]
|
||||||
[Double]$Global:zLog_Copy_real_Size += (Calc_Byte_Sice $aToken[0] $aToken[1] b)
|
[Double]$Global:zLog_Copy_real_item = [Double]$Global:zLog_Copy_real_item + $aTocken[0]
|
||||||
}
|
}
|
||||||
} #Transfer of the line; evaluation; storage in global variables
|
|
||||||
|
|
||||||
function Calc_Byte_Sice ([Double]$Wert, [String]$EinheitEingabe, [String]$EinheitAusgabe ) {
|
# Count_Size
|
||||||
|
If("von".Equals($aTocken[2]) -and ("kopiert".Equals($aTocken[5])) ) {
|
||||||
|
[Double]$Global:zLog_Copy_Size = [Double]$Global:zLog_Copy_Size + (Calc_Bite_Sice $aTocken[3] $aTocken[4] b)
|
||||||
|
[Double]$Global:zLog_Copy_real_Size = [Double]$Global:zLog_Copy_real_Size + (Calc_Bite_Sice $aTocken[0] $aTocken[1] b)
|
||||||
|
}
|
||||||
|
|
||||||
#Calc_Byte_Sice: [value] [unit outpute] [unit input]
|
} #Übergabe der Zeile; Auswertung; Speicherung in Globale Variablen
|
||||||
# If you enter something other than KB,MB,GB,TB for unit, it is calculated with bytes.
|
|
||||||
|
|
||||||
#fertieren the different size specifications (conversion unit= 1024)
|
function Calc_Bite_Sice ([Double]$Wert, [String]$EinheitEingabe, [String]$EinheitAusgabe ) {
|
||||||
|
|
||||||
|
#Calc_Bite_Sice: [Wert] [Einheit-Ausgabe] [Einheit-Eingabe]
|
||||||
|
# Wenn bei Einheit etwas anderes als KB,MB,GB,TB eingebeben Wird, Wird mit Bites gerechnet
|
||||||
|
|
||||||
|
#fertieren der unterschiedlichen Groeßenangaben (umrechnungseinheit= 1024)
|
||||||
# b (=Bytes), k (=Kilobytes), m (=Megabytes), g (=Gigabytes) und t (=Terabytes)
|
# b (=Bytes), k (=Kilobytes), m (=Megabytes), g (=Gigabytes) und t (=Terabytes)
|
||||||
|
|
||||||
If("".Equals("$Wert") -and "0".Equals("$Wert")) {return 0} else {
|
If("".Equals("$sWert") -and "0".Equals("$sWert")) {return 0} else {
|
||||||
|
|
||||||
$EinheitEingabe = ($EinheitEingabe.substring(0,1)).replace("K","k")
|
$EinheitEingabe = ($EinheitEingabe.substring(0,1)).replace("K","k")
|
||||||
$EinheitEingabe = ($EinheitEingabe.substring(0,1)).replace("M","m")
|
$EinheitEingabe = ($EinheitEingabe.substring(0,1)).replace("M","g")
|
||||||
$EinheitEingabe = ($EinheitEingabe.substring(0,1)).replace("G","g")
|
$EinheitEingabe = ($EinheitEingabe.substring(0,1)).replace("G","g")
|
||||||
$EinheitEingabe = ($EinheitEingabe.substring(0,1)).replace("T","t")
|
$EinheitEingabe = ($EinheitEingabe.substring(0,1)).replace("T","g")
|
||||||
|
|
||||||
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("K","k")
|
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("K","k")
|
||||||
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("M","m")
|
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("M","g")
|
||||||
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("G","g")
|
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("G","g")
|
||||||
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("T","t")
|
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("T","g")
|
||||||
|
|
||||||
# Catching size information that does not exist/that are not handled
|
|
||||||
If ( -not ("b".Equals("$EinheitAusgabe") -or "k".Equals("$EinheitAusgabe") -or "m".Equals("$EinheitAusgabe") -or "g".Equals("$EinheitAusgabe") -or "t".Equals("$EinheitAusgabe"))) {$EinheitAusgabe = "else"}
|
|
||||||
If ( -not ("b".Equals("$EinheitEingabe") -or "k".Equals("$EinheitEingabe") -or "m".Equals("$EinheitEingabe") -or "g".Equals("$EinheitEingabe") -or "t".Equals("$EinheitEingabe"))) {$EinheitEingabe = "else"}
|
|
||||||
|
|
||||||
|
|
||||||
|
If ( -not ("k".Equals("$EinheitAusgabe") -or "m".Equals("$EinheitAusgabe") -or "g".Equals("$EinheitAusgabe") -or "t".Equals("$EinheitAusgabe"))) {$EinheitAusgabe = "b"}
|
||||||
|
If ( -not ("k".Equals("$EinheitEingabe") -or "m".Equals("$EinheitEingabe") -or "g".Equals("$EinheitEingabe") -or "t".Equals("$EinheitEingabe"))) {$EinheitEingabe = "b"}
|
||||||
|
|
||||||
switch("$EinheitEingabe") {
|
switch("$EinheitEingabe") {
|
||||||
|
|
||||||
"k" { $Wert = $Wert * 1024 }
|
"k" { $Wert = $Wert * 1024 }
|
||||||
|
|
||||||
"m" {$Wert = $Wert * 1048576}
|
"m" {$Wert = $Wert * 1048576}
|
||||||
|
|
||||||
"g" {$Wert = $Wert * 1073741824}
|
"g" {$Wert = $Wert * 1073741824}
|
||||||
|
|
||||||
"t" {$Wert = $Wert * 1099511627776}
|
"t" {$Wert = $Wert * 1099511627776}
|
||||||
|
|
||||||
"else" {$Wert = 0 }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch("$EinheitAusgabe") {
|
switch("$EinheitAusgabe") {
|
||||||
|
|
||||||
"b" {$Wert = [math]::round($Wert, 0)}
|
#"b" {$Wert = [math]::round($Wert, 0)}
|
||||||
|
|
||||||
"k" {$Wert = $Wert / 1024}
|
"k" {$Wert = $Wert / 1024}
|
||||||
|
|
||||||
"m" {$Wert = $Wert / 1048576}
|
"m" {$Wert = $Wert / 1048576}
|
||||||
|
|
||||||
"g" {$Wert = $Wert / 1073741824}
|
"g" {$Wert = $Wert / 1073741824}
|
||||||
|
|
||||||
"t" {$Wert = $Wert / 1099511627776}
|
"t" {$Wert = $Wert / 1099511627776}
|
||||||
|
|
||||||
"else" {$Wert = 0 }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return $Wert
|
return $Wert
|
||||||
}
|
}
|
||||||
} #[value] [unit outpute] [unit input]
|
} #[Wert] [Einheit-Ausgabe] [Einheit-Eingabe]
|
||||||
|
|
||||||
##########################################################################################################
|
###################################################################################
|
||||||
|
|
||||||
If ($args[0] -eq "--version") {
|
#for each param do start(param)
|
||||||
echo "Version: 1.2"
|
$args | ForEach-Object { Log_Start $_ }
|
||||||
} ElseIf ($args[0] -eq "--help") {
|
|
||||||
echo "./logwert.ps1 [log1] [log2] ..."
|
|
||||||
} Else {
|
|
||||||
|
|
||||||
#for each param do start(param)
|
[String]$sLog_Copy_errors = "$Global:zLog_Copy_errors"
|
||||||
$args | ForEach-Object { Log_Start $_ }
|
[String]$sLog_Copy_Size = [math]::round((Calc_Bite_Sice $Global:zLog_Copy_Size b $Global:Log_Copy_Size_Einheit), 2)
|
||||||
|
[String]$sLog_Copy_real_Size = [math]::round((Calc_Bite_Sice $Global:zLog_Copy_real_Size b $Global:Log_Copy_Size_Einheit), 2)
|
||||||
|
[String]$sLog_Copy_item = "$Global:zLog_Copy_item"
|
||||||
|
[String]$sLog_Copy_real_item = "$Global:zLog_Copy_real_item"
|
||||||
|
|
||||||
[String]$sLog_Copy_errors = "$Global:zLog_Copy_errors"
|
echo "Insgesamt: $sLog_Copy_real_item von $sLog_Copy_item Dateien kopiert, $sLog_Copy_errors Fehler, $sLog_Copy_real_Size g von $sLog_Copy_Size g kopiert"
|
||||||
[String]$sLog_Copy_Size = [math]::round((Calc_Byte_Sice $Global:zLog_Copy_Size b $Global:Log_Copy_Size_Einheit), 2)
|
|
||||||
[String]$sLog_Copy_real_Size = [math]::round((Calc_Byte_Sice $Global:zLog_Copy_real_Size b $Global:Log_Copy_Size_Einheit), 2)
|
|
||||||
[String]$sLog_Copy_item = "$Global:zLog_Copy_item"
|
|
||||||
[String]$sLog_Copy_real_item = "$Global:zLog_Copy_real_item"
|
|
||||||
[String]$sLog_Copy_Size_Einheit = "$Global:Log_Copy_Size_Einheit"
|
|
||||||
|
|
||||||
echo "Summary: $sLog_Copy_real_item of $sLog_Copy_item files copied, $sLog_Copy_errors errors, $sLog_Copy_real_Size $sLog_Copy_Size_Einheit of $sLog_Copy_Size $sLog_Copy_Size_Einheit copied"
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user