Truncate SWD_DeploymentResults.log
Log In or Register to download the BES file, and more.

0 Votes


This fixlet takes the last 200 lines of SWD_DeploymentResults.log and discards the rest. It's relevant for logfiles with over 300 lines, giving 100 lines of wiggle room before it becomes relevant again.

Property Details

StatusQA - Ready for Production Level Testing
TitleTruncate SWD_DeploymentResults.log
Source Release Date3/12/2024 12:00:00 AM
KeywordsTruncate, log, SWD, SWD_DeploymentResults, reduce, logging, shorten, tail
Is TaskTrue
Added by on 3/13/2024 7:48:44 AM
Last Modified by on 3/13/2024 7:50:44 AM
Counters 133 Views / 0 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.


Used in 1 fixlet   * Results in a true/false
Show indented relevance
number of lines of file "SWD_DeploymentResults.log" of folder "SWDDeployData" of folder "__Global" of data folder of client > 300


Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
parameter "mainSWDLogFolder" = "{parent folder of client folder of current site}/__Global/SWDDeployData"
folder create "{parameter "mainSWDLogFolder"}"
parameter "logFile" = "SWD_DeploymentResults.log"
parameter "logFolder" = "{parameter "mainSWDLogFolder"}"

parameter "logPath" = "{pathname of file "SWD_DeploymentResults.log" of folder "SWDDeployData" of folder "__Global" of data folder of client}"
parameter "targetLength" = "200"

if {windows of operating system}
waithidden cmd.exe /C echo %DATE% %TIME% >> "{parameter "logFolder"}\{parameter "logFile"}"
waithidden cmd.exe /C echo Action ID: {id of active action} >> "{parameter "logFolder"}\{parameter "logFile"}"
delete prometheus.ps1
delete __createfile
createfile until _EOF_
$truncatedContent = Get-Content "{parameter "logPath"}" -tail {parameter "targetLength"}
Remove-Item -Path "{parameter "logPath"}"
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines("{parameter "logPath"}", $truncatedContent, $Utf8NoBomEncoding)
Copy-Item "SWD_DeploymentResults.log" -Destination "{parameter "logPath"}"
Remove-Item -Path "SWD_DeploymentResults.log"
copy "__createfile" "prometheus.ps1"
waithidden powershell.exe -executionpolicy bypass -File "prometheus.ps1"
parameter "error" = "{exit code of action}"
waithidden cmd.exe /C echo Log truncated to {parameter "targetLength"} lines >> "{parameter "logFolder"}\{parameter "logFile"}"
waithidden cmd.exe /C echo Return Code: {parameter "error"} >> "{parameter "logFolder"}\{parameter "logFile"}"
waithidden cmd.exe /C echo. >> "{parameter "logFolder"}\{parameter "logFile"}"
delete "prometheus.ps1"

wait sh -c "echo '' >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
wait sh -c "echo $(date +%Y_%m_%d' '%T) >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
wait sh -c "echo Action ID: {id of active action} >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
delete __createfile
createfile until _EOF_
tail -n {parameter "targetLength"} "{parameter "logPath"}" > SWD_DeploymentResults.log
rm -rf "{parameter "logPath"}"
mv -f SWD_DeploymentResults.log "{parameter "logPath"}"
rm -rf SWD_DeploymentResults.log
copy "__createfile" ""
wait chmod +x ""
wait /bin/sh ""
parameter "error" = "{exit code of action}"
wait sh -c "echo Log truncated to {parameter "targetLength"} lines >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
wait sh -c "echo Return Code: {parameter "error"} >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
delete ""

if {parameter "error" != "0"}
exit {parameter "error"}

exit {parameter "error"}
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Social Media:
Share this page on Yammer


Log In or Register to leave comments!