Skip to content

Commit

Permalink
Merge pull request #43 from xeliuqa/develop
Browse files Browse the repository at this point in the history
v4.04
  • Loading branch information
xeliuqa authored Apr 29, 2024
2 parents df94b61 + 8ba6d0d commit f43f913
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
5 changes: 3 additions & 2 deletions sm-configs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ $DefaultBackgroundColor = "Black" # Set to the colour of your console if 'Black'

$emailEnable = "False" # "True" to enable email notification, "True" or "False"
$myEmail = "[email protected]" #Set your Email for notifications

$ShowPorts = "False" # True to show node's ports. "True" or "False"

$showFullID = "False" # Set to True to see a full ID intead of short one. "True" or "False"
$showPorts = "False" # True to show node's ports. "True" or "False"
$queryHighestAtx = "False" # "True" to request for Highest ATX. "True" or "False"
$checkIfBanned = "False" # "True" if you want to check if the node is banned. "True" or "False"
$showELG = "True" # "True" if you want to show the number of Epoch when the node will be eligible for rewards. "True" or "False"
Expand Down
22 changes: 12 additions & 10 deletions sm-monitor.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Requires -Version 7.0
<# -----------------------------------------------------------------------------------------------
<#PSScriptInfo
.VERSION 4.03
.VERSION 4.04
.GUID 98d4b6b6-00e1-4632-a836-33767fe196cd
.AUTHOR
.PROJECTURI https://github.com/xeliuqa/SM-Monitor
Expand All @@ -15,7 +15,7 @@ With Thanks To: == S A K K I == Stizerg == PlainLazy == Shanyaa == Miguell
Get grpcurl here: https://github.com/fullstorydev/grpcurl/releases
-------------------------------------------------------------------------------------------- #>
$version = "4.03"
$version = "4.04"
$host.ui.RawUI.WindowTitle = $MyInvocation.MyCommand.Name

function main {
Expand All @@ -37,6 +37,7 @@ function main {
$nodeList = @()
foreach ($line in $nodeListContent) {
if ($line.Trim() -ne "" -and $line[0] -ne "#") {
$line = $line -split "#"[0]
$nodeInfo = $line -split ","
$node = @{
name = $nodeInfo[0].Trim()
Expand Down Expand Up @@ -315,11 +316,12 @@ function main {

foreach ($key in $waitProofs.Keys) {
if ($key -eq $node.publicKey) {
if ($node.atx) {
$node.atx = $node.atx + ', ' + $waitProofs[$key]
$waitProof = $waitProofs[$key]
if ($node.atx -and ($node.atx -ne $waitProof)) {
$node.atx = $node.atx + ', ' + $waitProof
}
else {
$node.atx = $waitProofs[$key]
$node.atx = $waitProof
}
}
}
Expand Down Expand Up @@ -397,7 +399,7 @@ function main {

$o = [PSCustomObject]@{
Name = $node.name
NodeID = $node.shortKey
NodeID = if (($null -eq $showFullID) -or ($showFullID -eq "False")) {$node.shortKey} else {$node.fullkey}
Host = $node.host
Port = $node.port
Port2 = $node.port2
Expand Down Expand Up @@ -477,7 +479,7 @@ function main {
Clear-Host
$object | ForEach-Object {
$props = 'Name', 'Host'
if ($ShowPorts -eq "True") { $props += 'Port', 'Port2', 'Port3' }
if ($showPorts -eq "True") { $props += 'Port', 'Port2', 'Port3' }
$props += 'Peers', 'Synced', 'Layer', 'Verified', 'Version', 'Status', 'NodeID', 'SU', 'SizeTiB', 'RWD'
if ($showELG -eq "True") { $props += 'ELG' }
if ($checkIfBanned -eq "True") { $props += 'BAN' }
Expand Down Expand Up @@ -567,7 +569,7 @@ function main {
$Body = "Warning, some nodes are offline!"

foreach ($node in $syncNodes.Values) {
if (!$node.online) {
if (!$node.online -and ($_.port -ne 0)) {
$Body = $body + $newLine + $node.name + " " + $node.Host + " " + $node.status
if (!$node.emailsent) {
$OKtoSend = "True"
Expand Down Expand Up @@ -620,7 +622,7 @@ function main {
if ($stage -ne 2) {
$currentDate = Get-Date -Format HH:mm:ss
# Refresh
Write-Host "Press SPACE to refresh" -ForegroundColor DarkGray
Write-Host "Press SPACE to refresh, R to reload" -ForegroundColor DarkGray
Write-Host "Last refresh: " -ForegroundColor Yellow -nonewline; Write-Host "$currentDate" -ForegroundColor Green
}

Expand Down Expand Up @@ -931,4 +933,4 @@ function applyColumnRules {
)
}

main
main

0 comments on commit f43f913

Please sign in to comment.