Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Chart Support #54

Merged
merged 2 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# :arrows_clockwise: Veeam VBR As Built Report Changelog

## [0.5.4] - 2022-09-16
## [0.5.4] - 2022-09-17

### Added

- Added support for File Share Backup Job information
- Added support for Backup Jobs GFS Policy information
- Added Simple Chart support

### Fixed

- Fixes [#49](https://github.com/AsBuiltReport/AsBuiltReport.Veeam.VBR/issues/49)
Expand Down
240 changes: 144 additions & 96 deletions Src/Private/Get-AbrVbrBackupRepository.ps1

Large diffs are not rendered by default.

125 changes: 92 additions & 33 deletions Src/Private/Get-AbrVbrBackupjob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function Get-AbrVbrBackupjob {
.DESCRIPTION
Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo.
.NOTES
Version: 0.5.3
Version: 0.5.4
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand All @@ -27,44 +27,103 @@ function Get-AbrVbrBackupjob {
process {
try {
if ((Get-VBRJob -WarningAction SilentlyContinue).count -gt 0) {
Section -Style Heading3 'Backup Jobs' {
Paragraph "The following section list backup jobs created in Veeam Backup & Replication."
BlankLine
$OutObj = @()
$Bkjobs = Get-VBRJob -WarningAction SilentlyContinue | Where-object {$_.TypeToString -ne 'Windows Agent Backup' -and $_.TypeToString -ne 'Hyper-V Replication' -and $_.TypeToString -ne 'VMware Replication'}
foreach ($Bkjob in $Bkjobs) {
try {
Write-PscriboMessage "Discovered $($Bkjob.Name) backup job."
$inObj = [ordered] @{
'Name' = $Bkjob.Name
'Type' = $Bkjob.TypeToString
'Status' = Switch ($Bkjob.IsScheduleEnabled) {
'False' {'Disabled'}
'True' {'Enabled'}
}
'Latest Result' = $Bkjob.info.LatestStatus
'Target Repository' = Switch ($Bkjob.info.TargetRepositoryId) {
'00000000-0000-0000-0000-000000000000' {$Bkjob.TargetDir}
{$Null -eq (Get-VBRBackupRepository | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name} {(Get-VBRBackupRepository -ScaleOut | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name}
default {(Get-VBRBackupRepository | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name}
}
$OutObj = @()
$Bkjobs = Get-VBRJob -WarningAction SilentlyContinue | Where-object {$_.TypeToString -ne 'Windows Agent Backup' -and $_.TypeToString -ne 'Hyper-V Replication' -and $_.TypeToString -ne 'VMware Replication'}
foreach ($Bkjob in $Bkjobs) {
try {
Write-PscriboMessage "Discovered $($Bkjob.Name) backup job."
$inObj = [ordered] @{
'Name' = $Bkjob.Name
'Type' = $Bkjob.TypeToString
'Status' = Switch ($Bkjob.IsScheduleEnabled) {
'False' {'Disabled'}
'True' {'Enabled'}
}
'Latest Result' = $Bkjob.info.LatestStatus
'Target Repository' = Switch ($Bkjob.info.TargetRepositoryId) {
'00000000-0000-0000-0000-000000000000' {$Bkjob.TargetDir}
{$Null -eq (Get-VBRBackupRepository | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name} {(Get-VBRBackupRepository -ScaleOut | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name}
default {(Get-VBRBackupRepository | Where-Object {$_.Id -eq $Bkjob.info.TargetRepositoryId}).Name}
}
$OutObj += [pscustomobject]$inobj
}
catch {
Write-PscriboMessage -IsWarning $_.Exception.Message
}
$OutObj += [pscustomobject]$inobj
}
catch {
Write-PscriboMessage -IsWarning $_.Exception.Message
}
}

$TableParams = @{
Name = "Backup Jobs - $VeeamBackupServer"
List = $false
ColumnWidths = 25, 20, 15, 15, 25
}
if ($Report.ShowTableCaptions) {
$TableParams['Caption'] = "- $($TableParams.Name)"
}
try {
$Alljobs = @()
if ($Bkjobs.info.LatestStatus) {
$Alljobs += $Bkjobs.info.LatestStatus
}
if ((Get-VBRTapeJob -ErrorAction SilentlyContinue).LastResult) {
$Alljobs += (Get-VBRTapeJob).LastResult
}
if ((Get-VSBJob -ErrorAction SilentlyContinue).GetLastResult()) {
$Alljobs += (Get-VSBJob).GetLastResult()
}
$sampleData = $Alljobs | Group-Object
$exampleChart = New-Chart -Name BackupJobs -Width 600 -Height 400

$TableParams = @{
Name = "Backup Jobs - $VeeamBackupServer"
List = $false
ColumnWidths = 25, 20, 15, 15, 25
$addChartAreaParams = @{
Chart = $exampleChart
Name = 'BackupJobs'
AxisXTitle = 'Status'
AxisYTitle = 'Count'
NoAxisXMajorGridLines = $true
NoAxisYMajorGridLines = $true
}
$exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru

$addChartSeriesParams = @{
Chart = $exampleChart
ChartArea = $exampleChartArea
Name = 'exampleChartSeries'
XField = 'Name'
YField = 'Count'
Palette = 'Green'
ColorPerDataPoint = $true
}
$sampleData | Add-ColumnChartSeries @addChartSeriesParams

$addChartTitleParams = @{
Chart = $exampleChart
ChartArea = $exampleChartArea
Name = 'BackupJob'
Text = 'Jobs Latest Result'
Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold)
}
Add-ChartTitle @addChartTitleParams

$chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru

if ($PassThru)
{
Write-Output -InputObject $chartFileItem
}
}
catch {
Write-PscriboMessage -IsWarning "$($_.Exception.Message) (Account Security Assessment Table)"
}
if ($OutObj) {
if ($chartFileItem) {
Image -Text 'Backup Repository - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem
}
if ($Report.ShowTableCaptions) {
$TableParams['Caption'] = "- $($TableParams.Name)"
Section -Style Heading3 'Backup Jobs' {
Paragraph "The following section list backup jobs created in Veeam Backup & Replication."
BlankLine
$OutObj | Sort-Object -Property Name |Table @TableParams
}
$OutObj | Sort-Object -Property Name |Table @TableParams
}
}
}
Expand Down
79 changes: 65 additions & 14 deletions Src/Private/Get-AbrVbrInfrastructureSummary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function Get-AbrVbrInfrastructureSummary {
.DESCRIPTION
Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo.
.NOTES
Version: 0.5.3
Version: 0.5.4
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand All @@ -26,7 +26,6 @@ function Get-AbrVbrInfrastructureSummary {

process {
try {
Section -Style NOTOCHeading3 -ExcludeFromTOC 'Backup Infrastructure' {
$OutObj = @()
try {
$BackupServers = (Get-VBRServer).Count
Expand All @@ -48,16 +47,16 @@ function Get-AbrVbrInfrastructureSummary {
Write-PscriboMessage -IsWarning $_.Exception.Message
}
$inObj = [ordered] @{
'Number of Backup Proxies' = $BackupProxies
'Number of Managed Servers' = $BackupServers
'Number of Backup Repositories' = $BackupRepo
'Number of SOBR Repositories' = $SOBRRepo
'Number of Object Repository' = $ObjectStorageRepo
'Number of WAN Accelerator' = $WANAccels
'Number of Cloud Service Providers' = $ServiceProviders
'Number of SureBackup Application Group' = $SureBackupAGs
'Number of SureBackup Virtual Lab' = $SureBackupVLs
'Number of Locations' = $Locations
'Backup Proxies' = $BackupProxies
'Managed Servers' = $BackupServers
'Backup Repositories' = $BackupRepo
'SOBR Repositories' = $SOBRRepo
'Object Repository' = $ObjectStorageRepo
'WAN Accelerator' = $WANAccels
'Cloud Service Providers' = $ServiceProviders
'SureBackup Application Group' = $SureBackupAGs
'SureBackup Virtual Lab' = $SureBackupVLs
'Locations' = $Locations
'Instance Licenses (Total/Used)' = "$($InstanceLicenses.LicensedInstancesNumber)/$($InstanceLicenses.UsedInstancesNumber)"
'Socket Licenses (Total/Used)' = "$($SocketLicenses.LicensedSocketsNumber)/$($SocketLicenses.UsedSocketsNumber)"
'Capacity Licenses (Total/Used)' = "$($CapacityLicenses.LicensedCapacityTb)TB/$($CapacityLicenses.UsedCapacityTb)TB"
Expand All @@ -69,14 +68,66 @@ function Get-AbrVbrInfrastructureSummary {
}

$TableParams = @{
Name = "Backup Infrastructure Summary - $VeeamBackupServer"
Name = "Backup Infrastructure Inventory - $VeeamBackupServer"
List = $true
ColumnWidths = 50, 50
}
if ($Report.ShowTableCaptions) {
$TableParams['Caption'] = "- $($TableParams.Name)"
}
$OutObj | Table @TableParams
try {
$inObj.Remove('Instance Licenses (Total/Used)')
$inObj.Remove('Socket Licenses (Total/Used)')
$inObj.Remove('Capacity Licenses (Total/Used)')
$sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category'

$exampleChart = New-Chart -Name BackupInfrastructure -Width 600 -Height 400

$addChartAreaParams = @{
Chart = $exampleChart
Name = 'exampleChartArea'
}
$exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru

$addChartSeriesParams = @{
Chart = $exampleChart
ChartArea = $exampleChartArea
Name = 'exampleChartSeries'
XField = 'Category'
YField = 'Value'
Palette = 'Green'
ColorPerDataPoint = $true
}
$exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru

$addChartLegendParams = @{
Chart = $exampleChart
Name = 'Infrastructure'
TitleAlignment = 'Center'
}
Add-ChartLegend @addChartLegendParams

$addChartTitleParams = @{
Chart = $exampleChart
ChartArea = $exampleChartArea
Name = ' '
Text = ' '
Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold)
}
Add-ChartTitle @addChartTitleParams

$chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru
}
catch {
Write-PscriboMessage -IsWarning $($_.Exception.Message)
}
if ($OutObj) {
Section -Style NOTOCHeading3 -ExcludeFromTOC 'Backup Infrastructure Inventory' {
if ($chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) {
Image -Text 'Backup Infrastructure - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem
}
$OutObj | Table @TableParams
}
}
}
catch {
Expand Down
Loading