-
Notifications
You must be signed in to change notification settings - Fork 1
/
GUI-HealthChecking.ps1
164 lines (149 loc) · 7.14 KB
/
GUI-HealthChecking.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
Param (
$Path
)
if (-not $Path) {$Path = '~\AppData\Roaming\Storj Share'}
Get-Item (Join-Path $Path *.log) |%{
$file = $_;
Write-Host "====================="
Write-Host $file.Name;
Write-Host
$isPrivate = $null
sls 'you are not publicly reachable' $file | select -Last 1 | %{Write-Host ('```'+$_.Line+'```')}
sls 'no public' $file | select -Last 1 | %{Write-Warning ('```'+$_.Line+'``` <-- *bad*')}
$isPrivate = sls 'private ' $file | select -Last 1 | %{('```'+$_.Line+'``` <-- *bad*')}
$opcode1 = $null
$opcode2 = $null
$opcode3 = $null
$opcode1 = sls 'subscribing to topic \\"0f01020202\\"' $file | select -Last 1
$opcode2 = sls 'subscribing to topic \\"0f02020202\\"' $file | select -Last 1
$opcode3 = sls 'subscribing to topic \\"0f03020202\\"' $file | select -Last 1
$upnp = $null
$address = $null
$port = $null
$delta = $null
$upnp = sls '] (.* upnp.*)' $file | select -last 1 | % {$_.Line}
if (-not $upnp) {
sls '] (.* public.*)' $file | select -last 1 | % {$_.Matches.Groups[1].Value}
} else {
if (($upnp | sls 'successful').Matches.Success) {
Write-Host ('```'+$upnp+'``` <-- *not optimal*')
} else {
Write-Warning ('```'+$upnp+'``` <-- *bad*')
}
($address, $port) = sls "upnp: (.*):(.*)" $file |
select -last 1 | %{$_.matches.Groups[1].value, $_.Matches.Groups[2].value}
Write-Host
}
sls "sharddata.kfs" $file | select -last 1 | % {Write-Warning ('```' + $_.Line + '``` <-- *bad*')}
sls "usedspace" $file | select -last 1 | % {Write-Warning ('```' + $_.Line + '``` <-- *bad*')}
sls "System clock is not syncronized with NTP" $file | select -last 1 | % {Write-Warning ('`' + $_.Line + '` <-- *bad*')}
sls "Timeout waiting for NTP response." $file | select -last 1 | % {Write-Warning ('`' + $_.Line + '` <-- *bad*')}
$delta = $null
sls "delta: (.*) ms" $file | select -last 1 | % {
$delta = $_.matches.Groups[1].value.ToDecimal([System.Globalization.CultureInfo]::CurrentCulture);
if ($delta -ge 500.0 -or $delta -le -500.0) {
Write-Warning ('clock delta: `' + $delta + '` <-- *bad*')
} else {
write-host ('clock delta: `' + $delta + '` <-- *ok*')
}
Write-Host
}
$nodeid = $null
$nodeid = sls 'created .* nodeid (.*)' $file | select -last 1 | %{$_.Matches.Groups[1].Value}
if ($nodeid) {
$contact = $null
$contact = (Invoke-WebRequest ("https://api.storj.io/contacts/" + $nodeid) -UseBasicParsing).Content;
$port = $contact | sls '"port":(\d*),' | % {$_.Matches.Groups[1].Value}
$address = $contact | sls '"address":"(.*?)",' | % {$_.Matches.Groups[1].Value}
$isTunneling = $false
$isTunneling = ($address | sls "storj\.dk").Matches.Success
Write-Host "https://api.storj.io/contacts/$nodeid"
if ($contact) {
Write-Host ('```' + $contact.ToString() + '```')
}
$address | % {Write-Host (' rpcAddress : `' + $_ + '`')}
$port | % {Write-Host (' rpcPort : `' + $_ + '`')}
$contact | sls '"lastSeen":"(.*?)",' | % {Write-Host (' last seen : `' + $_.Matches.Groups[1].Value + '`')}
$contact | sls '"responseTime":(.*?),' | % {Write-Host ('response time : `' + $_.Matches.Groups[1].Value + '`')}
$contact | sls '"lastTimeout":"(.*?)",' | % {Write-Host (' last timeout : `' + $_.Matches.Groups[1].Value + '`')}
$contact | sls '"timeoutRate":(.*?),' | % {Write-Host (' timeout rate : `' + $_.Matches.Groups[1].Value + '`')}
Write-Host
}
$isPortOpen = $null
if ($address -and $port -and -not $isTunneling) {
$isPortOpen = try {
Invoke-WebRequest ('http://' + $address + ':' + $port) -UseBasicParsing
} catch [System.Net.WebException] {
($_ | sls "get").matches.success
}
if ($isPortOpen) {
Write-Host ('`port ' + $port + ' is open on ' + $address + '`')
} else {
Write-Warning ('`port ' + $port + ' is CLOSED on ' + $address + '` <-- *bad*')
}
Write-Host
}
sls "\[(.*)\].* publish" $file | select -last 1 | % {
write-host (' last publish: `' + $_.matches.Groups[1].value + '` (' + (sls "publish" $file).Matches.Count + ')')
}
sls "\[(.*)\].* offer" $file | select -last 1 | % {
write-host (' last offer: `' + $_.matches.Groups[1].value + '` (' + (sls "offer" $file).Matches.Count + ')')
}
sls "\[(.*)\].* consign" $file | select -last 1 | % {
write-host ('last consigned: `' + $_.matches.Groups[1].value + '` (' + (sls "consign" $file).Matches.Count + ')')
}
sls '\[(.*)\].* download' $file | select -last 1 | % {
write-host (' last download: `' + $_.matches.groups[1].value + '` (' + (sls 'download' $_.Path).Matches.Count + ')')
};
sls '\[(.*)\].* upload' $file | select -last 1 | % {
write-host (' last upload: `' + $_.matches.groups[1].value + '` (' + (sls 'upload' $_.Path).Matches.Count + ')')
}
Write-Host "--------------"
if (-not $opcode1) {Write-Host '`Opcode "0f01020202" not found!` <-- *bad*'}
if (-not $opcode2) {Write-Host '`Opcode "0f02020202" not found!` <-- *bad*'}
if (-not $opcode3) {Write-Host '`Opcode "0f03020202" not found!` <-- *bad*'}
if (-not $opcode1 -or -not $opcode2 -or -not $opcode3) {
Write-Host 'You should specify only that opcodes:
"0f01020202"
"0f02020202"
"0f03020202"
Please, check it in your config!'
Write-Host
}
if ($delta -and ($delta -ge 500.0 -or $delta -le -500.0)) {
Write-Warning ('clock delta: `' + $delta + '` <-- *bad*')
Write-Host " Your clock is out of sync
https://docs.storj.io/docs/storjshare-troubleshooting-guide#section-4-synchronize-your-clock
"
}
if ($isPrivate) {
Write-Host $isPrivate
Write-Host ' Please, check your `"rpcAddress"` option in configuration of node.'
if ($address) {Write-Host (' It is should be like this: `"rpcAddress": "' + $address + '",`')}
Write-Host
}
if ($upnp) {
if (($upnp | sls 'successful').Matches.Success) {
Write-Host ('```'+$upnp+'``` <-- *not optimal*')
} else {
Write-Warning ('```'+$upnp+'``` <-- *bad*')
}
}
if (-not $isPortOpen -and $port -and $address -and -not $isTunneling) {
Write-Warning ('`port ' + $port + ' is CLOSED on ' + $address +'` <-- *bad*')
Write-Host 'Please, check it:' http://www.yougetsignal.com/tools/open-ports/
Write-Host
Write-Host 'Please, read this manual to fix this:
GUI: https://docs.storj.io/docs/storj-share-gui#section-5-storj-share-troubleshooting
'
}
if ($isTunneling) {
Write-Host '`You are using tunneling` <-- *not optimal*'
}
if ($upnp -or $isTunneling) {
Write-Host 'Please, read this manual to fix this:
GUI: https://docs.storj.io/docs/storj-share-gui#section--3-3-2-advanced-configuration-
'
}
}
Pause