RainbowMiner / RainbowMiner

GPU/CPU Mining script with intelligent profit-switching between miningpools, algorithms, miners, using all possible combinations of devices (NVIDIA, AMD, CPU). Features: actively maintained, uses the top actual miner programs (Bminer, Ccminer, Claymore, Dstm, EnemyZ, Sgminer, T-rex and more) easy setup wizard, webinterface, auto update.
GNU General Public License v3.0
571 stars 169 forks source link

Powershell is filling up my syslog. Is there a way to reduce this logging? #2442

Open username-rand opened 11 months ago

username-rand commented 11 months ago

Might want to skip to near the end. There is a solution and a enhancement request.

My syslog is getting very large because of Powershell logging and my rigs only have 35Gb and RainbowMiner is warning of low disk space. Is there a way to turn Powershell logging off or reduce the amount of logging?

For example: Start:PowershellConsoleStartup.WinStart.Informational] PowerShell console is sta rting up Aug 21 07:20:54 miner4 powershell[1725]: (7.2.13:B:80) [NamedPipeIPC_ServerListe nerStarted:NamedPipe.Open.Informational] PowerShell has started an IPC listening thread on process: 1725 in AppDomain: None. Aug 21 07:20:54 miner4 powershell[1725]: (7.2.13:1:80) [Perftrack_ConsoleStartup Stop:PowershellConsoleStartup.WinStop.Informational] PowerShell console is ready for user input Aug 21 07:20:54 miner4 powershell[1725]: (7.2.13:E:80) [ScriptBlock_Compile_Deta il:ExecuteCommand.Create.Warning] Creating Scriptblock text (1 of 28):#012⏎⏎func tion Initialize-Session {⏎⏎⏎⏎ Set-OsFlags⏎⏎⏎⏎ if (-not (Test-Path Variable :Global:Session)) {⏎⏎ $Global:Session = [hashtable]::Synchronized(@{})⏎⏎⏎ ⏎ if ($IsWindows) {⏎⏎ $Session.WindowsVersion = [System.Enviro nment]::OSVersion.Version⏎⏎ $Session.IsWin10 = [System.Environ ment]::OSVersion.Version -ge (Get-Version "10.0")⏎⏎ } elseif ($IsLinux) { ⏎⏎ try {⏎⏎ Get-ChildItem ".\IncludesLinux\bin\libcver sion" -File -ErrorAction Stop | Foreach-Object {⏎⏎ & chmod +x "$($.FullName)" > $null⏎⏎ $Session.LibCVersion = Get-Versio n "$(& $_.FullName)"⏎⏎ }⏎⏎ } catch {⏎⏎
if ($Error.Count){$Error.RemoveAt(0)}⏎⏎ }⏎⏎ }⏎⏎ $Sessio n.IsAdmin = Test-IsElevated⏎⏎ $Session.IsCore = $P SVersionTable.PSVersion -ge (Get-Version "6.1")⏎⏎ $Session.IsPS7
= $PSVersionTable.PSVersion -ge (Get-Version "7.0")⏎⏎ $Session.Mac

Thanks

Rand

P. S. I'm on ubuntu Linux. Don't know if there is a way in RainbowMiner to configure the logging but I think this might work:

  1. Create a directory ~/.config/powershell
  2. In .bashrc or .profile or both add the line: export PSHOME=~/.config/powershell
  3. In $PSHOME directory create a file called: powershell.config.json
  4. In the file powershell.config.json add the following json: { "ScriptBlockLogging": { "EnableScriptBlockInvocationLogging": true, "EnableScriptBlockLogging": true }, "ModuleLogging": { "EnableModuleLogging": false, "ModuleNames": [ "PSReadLine", "PowerShellGet" ] }, "LogLevel": "verbose" }

Change the "LogLevel": "verbose" to something that will produce less data such as "warning" or "error".

Stop RainbowMiner. Log out and log back in. Make sure that PSHOME is defined as an environment variable and then start RainbowMiner. If you use a cron job to start on boot you will have to setup PSHOME before you start RainbowMiner or other alternatives is to use systemctl or rc.local I guess.

If there is a way to do this RainbowMiner's configuration, I would like to know. Might be a bit easier.
(Didn't work for me. I don't remember if a bash shell inherits the environment that it is started from. Will try putting the environment variable in start-nohup.sh instead of .bashrc).

Putting the PSHOME in script-nohup.sh does appear to work. The problem now is that I set the LogLevel to "warning" and there are a lot of warnings. For example:

Aug 24 09:45:22 miner4 powershell[422531]: (7.2.13:E:80) [ScriptBlock_CompileDetail:ExecuteCommand.Create.Warning] Creating Scriptblock text (1 of 1):#012{⏎⏎ $Balance = $⏎⏎ $Balance | Add-Member "Value in $Currency" $(if ($RatesAPI.$($Balance.Currency).$Currency -ne $null) {$Balance.Total * $RatesAPI.$($Balance.Currency).$Currency}elseif($RatesAPI.$Currency.$($Balance.Currency)) {$Balance.Total / $RatesAPI.$Currency.$($Balance.Currency)}else{"-"}) -Force⏎⏎ }#012#012ScriptBlock ID: 22de13d2-8b2d-46c6-b29d-fc9430ac2d30#012Path: /home/rainbow/RainbowMiner/Modules/Core.psm1 Aug 24 09:45:22 miner4 powershell[422531]: (7.2.13:E:80) [ScriptBlock_CompileDetail:ExecuteCommand.Create.Warning] Creating Scriptblock text (1 of 1):#012{$.BaseName -ne "Wallet" -and $_."Value in $Currency"}#012#012ScriptBlock ID: 7ddf21bb-04e8-4435-91f9-7de776259990#012Path: /home/rainbow/RainbowMiner/Modules/Core.psm1 Aug 24 09:45:22 miner4 powershell[422531]: (7.2.13:E:80) [ScriptBlock_CompileDetail:ExecuteCommand.Create.Warning] Creating Scriptblock text (1 of 1):#012{⏎⏎ $Balance = $⏎⏎ $Balance.PSObject.Properties.Name | Where-Object {$ -match "^(Value in |Balance (|Pending ()(\w+)"} | Foreach-Object {if ($Balance.$ -eq "" -or $Balance.$ -eq $null) {$Balance.$=0};$Balance.$ = "{0:N$($n = if ($Balance.$ -ge 10 -and $Digits[$Matches[2]] -eq 8) {[Math]::Min([Math]::Ceiling([Math]::Log10($Balance.$)),8)} else {1};$Digits[$Matches[2]]-$n+1)}" -f $Balance.$}⏎⏎ }#012#012ScriptBlock ID: fd8f2473-ca40-40fe-9495-9136352748d0#012Path: /home/rainbow/RainbowMiner/Modules/Core.psm1

So setting the LogLevel to "error" should get rid of the warning and maybe save a lot of space in syslog. (Well that doesn't appear to work either. Still getting warnings in syslog. Will have to continue investigating).

I could never get the PSHOME environment variable to work with pwsh. I even put the export in the start.sh script. Still logged verbose to /var/log/syslog. I was finally able to get pwsh not to log so much by using its -settings argument in the start.sh script to point to my powershell.config.json file. The dev doesn't want the us to modify the start.sh script, so maybe the dev will add this as an enhancement to RainbowMiner to allow configuration of pwsh logging through config.txt and deliver a powershell.config.json file for us Linux users.

Here is the reference I was using:

[]https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logging_non-windows?view=powershell-7.2(url)

Thanks Rand

RainbowMiner commented 11 months ago

Nice! Thank you for that in-depth analysis. I'll try to figure something out.