-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetDedupJobStatus.ps1
72 lines (61 loc) · 1.86 KB
/
GetDedupJobStatus.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
$s = New-PSSession -ComputerName $args[0]
try {
$nodes = Invoke-Command -Session $s -ScriptBlock {
$nodes = [pscustomobject]@()
Get-ClusterNode | ForEach-Object {
$nodes += $_.Name
}
return $nodes
}
$volumes = Invoke-Command -Session $s -ScriptBlock {
$volumes = [pscustomobject]@()
Get-Volume | Where-Object -Property FileSystem -EQ "CSVFS" | ForEach-Object {
$volumes += $_.FileSystemLabel
}
return $volumes
}
}
finally {
Remove-PSSession $s
}
$dedupJobs = [pscustomobject]@()
$nodes | ForEach-Object {
$s = New-PSSession -ComputerName $_
try {
$jobs = Invoke-Command -Session $s -ScriptBlock {
return Get-DedupJob
}
$dedupJobs += $jobs
}
finally {
Remove-PSSession $s
}
}
$prtg = [pscustomobject]@{
prtg = [pscustomobject]@{
result = [pscustomobject]@()
}
}
$volumePrefix = "c:\ClusterStorage\"
$i = 0
$volumes | ForEach-Object {
$volumeName = [string]$_
$fullVolumeName = $volumePrefix + $volumeName
$filteredDedupJobs = [pscustomobject]@()
$filteredDedupJobs += $dedupJobs | Where-Object -Property Volume -Contains $fullVolumeName
if ($filteredDedupJobs.Count -gt 0) {
$measure = $filteredDedupJobs | Measure-Object -Property Progress -Average
$percentComplete = $measure.Average
}
else {
$percentComplete = -2 - $i++
}
$channel = [pscustomobject]@{
channel = $volumeName;
value = $percentComplete;
float = 1;
Unit = "Percent";
}
$prtg.prtg.result += $channel
}
$prtg | ConvertTo-Json -Depth 3