Skip to content

Commit

Permalink
Add Agent proxy servers to graph #16
Browse files Browse the repository at this point in the history
rebelinux committed Jan 10, 2024
1 parent da78090 commit f552f63
Showing 9 changed files with 492 additions and 20 deletions.
151 changes: 151 additions & 0 deletions Src/Private/Convert-TableToHTML.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
function Convert-TableToHTML
{
<#
.SYNOPSIS
Creates a html table object
.DESCRIPTION
Creates a table object that contains rows of data.
.PARAMETER Name
The table name for this record
.PARAMETER Label
The label to use for the headder of the table.
.PARAMETER FontName
The table shape based on: https://graphviz.org/doc/info/shapes.html.
.PARAMETER FontSize
The table font size.
.PARAMETER Style
The table drawing style based on: https://graphviz.org/docs/attr-types/style/.
.PARAMETER Penwidth
The table line width.
.PARAMETER FillColor
The table fill color.
.PARAMETER HeaderColor
The table header cell color.
.PARAMETER HeaderFontColor
The table header font color.
.PARAMETER BorderColor
The table border color.
.PARAMETER Row
An array of strings/objects to place in this record
.PARAMETER RowScript
A script to run on each row
.PARAMETER ScriptBlock
A sub expression that contains Row commands
.EXAMPLE
.NOTES
Early release version of this command.
A lot of stuff is hard coded that should be exposed as attributes
#>
[OutputType('System.String')]
[cmdletbinding(DefaultParameterSetName = 'Script')]
param(
[Parameter(
Mandatory,
Position = 0
)]
[alias('ID', 'Node')]
[string]
$Name,

[Parameter(
Position = 1,
ValueFromPipeline,
ParameterSetName = 'Strings'
)]
[alias('Rows')]
[Object[]]
$Row,

[Parameter(
Position = 1,
ParameterSetName = 'Script'
)]
[ScriptBlock]
$ScriptBlock,

[Parameter(
Position = 2
)]
[ScriptBlock]
$RowScript,

[string]
$Label,

[string]
$FontName = "Segoe UI",

[int]
$FontSize = 14,

[string]
$Style = "filled",

[string]
$Fillcolor = "white",

[string]
$HeaderColor = "black",

[string]
$HeaderFontColor="white",

[string]
$BorderColor="white"
)
begin
{
$tableData = [System.Collections.ArrayList]::new()
if ( [string]::IsNullOrEmpty($Label) )
{
$Label = $Name
}
}
process
{
if ( $null -ne $ScriptBlock )
{
$Row = $ScriptBlock.Invoke()
}

if ( $null -ne $RowScript )
{
$Row = foreach ( $node in $Row )
{
@($node).ForEach($RowScript)
}
}

$results = foreach ( $node in $Row )
{
Row -Label $node
}

foreach ( $node in $results )
{
[void]$tableData.Add($node)
}
}
end
{
$html = "<TABLE CELLBORDER='1' BORDER='0' CELLSPACING='0'><TR><TD bgcolor='$HeaderColor' align='center'><font color='$HeaderFontColor'><B>{0}</B></font></TD></TR>{1}</TABLE>" -f $Label, ($tableData -join '')
Node $Name @{label = $html; shape = 'none'; fontname = $Fontname; fontsize = $FontSize; style = $Style; penwidth = 1; fillcolor = $Fillcolor; color = $BorderColor}
}
}
230 changes: 230 additions & 0 deletions Src/Private/Get-DiagBackupToProtectedGroup.ps1

Large diffs are not rendered by default.

58 changes: 39 additions & 19 deletions Src/Private/Get-HtmlLabel.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Function Get-HTMLLabel {
param(
[string]$Label,
[string]$Type
[string]$Type,
[Switch]$SubgraphLabel
)

if ($Type -eq 'NoIcon') {
@@ -13,23 +14,42 @@ Function Get-HTMLLabel {
$ICON = $images[$Type]
} else {$ICON = "no_icon.png"}

if ($ICON -ne 'NoIcon') {
return "<TABLE border='0' cellborder='0' cellspacing='20' cellpadding='10'>
<TR>
<TD ALIGN='center' colspan='1'><img src='$($ICON)'/></TD>
</TR>
<TR>
<TD ALIGN='center'>$Label</TD>
</TR>
</TABLE>"
} else {
return "<TABLE border='0' cellborder='0' cellspacing='20' cellpadding='10'>
<TR>
<TD bgcolor='#FFCCCC' ALIGN='center' colspan='1'>Veeam Logo</TD>
</TR>
<TR>
<TD bgcolor='#FFCCCC' ALIGN='center'>$Label</TD></TR><TR><TD ALIGN='center'><font color='red'>Debug ON</font></TD>
</TR>
</TABLE>"
if (-Not $SubgraphLabel) {
if ($ICON -ne 'NoIcon') {
return "<TABLE border='0' cellborder='0' cellspacing='20' cellpadding='10'>
<TR>
<TD ALIGN='center' colspan='1'><img src='$($ICON)'/></TD>
</TR>
<TR>
<TD ALIGN='center'>$Label</TD>
</TR>
</TABLE>"
} else {
return "<TABLE border='0' cellborder='0' cellspacing='20' cellpadding='10'>
<TR>
<TD bgcolor='#FFCCCC' ALIGN='center' colspan='1'>Veeam Logo</TD>
</TR>
<TR>
<TD bgcolor='#FFCCCC' ALIGN='center'>$Label</TD></TR><TR><TD ALIGN='center'><font color='red'>Debug ON</font></TD>
</TR>
</TABLE>"
}
}
if ($SubgraphLabel) {
if ($ICON -ne 'NoIcon') {
return "<TABLE border='0' cellborder='0' cellspacing='5' cellpadding='5'>
<TR>
<TD ALIGN='center' colspan='1' fixedsize='true' width='60' height='60'><img src='$($ICON)'/></TD>
<TD ALIGN='center'>$Label</TD>
</TR>
</TABLE>"
} else {
return "<TABLE border='0' cellborder='0' cellspacing='20' cellpadding='10'>
<TR>
<TD bgcolor='#FFCCCC' ALIGN='center' colspan='1'>Subgraph Logo</TD>
<TD bgcolor='#FFCCCC' ALIGN='center'>$Label</TD>
</TR>
</TABLE>"
}
}
}
59 changes: 59 additions & 0 deletions Src/Private/Get-VbrBackupProtectedGroupInfo.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function Get-VbrBackupProtectedGroupInfo {
<#
.SYNOPSIS
Function to extract veeam backup & replication protected group information.
.DESCRIPTION
Build a diagram of the configuration of Veeam VBR in PDF/PNG/SVG formats using Psgraph.
.NOTES
Version: 0.5.7
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
.LINK
https://github.com/rebelinux/Veeam.Diagrammer
#>
[CmdletBinding()]
[OutputType([System.Object[]])]

Param (
)

process {
Write-Verbose -Message "Collecting Protected Group information from $($VBRServer.Name)."
try {
[Array]$ProtectedGroups = Get-VBRProtectionGroup

$ProtectedGroupInfo = @()
if ($ProtectedGroups) {
foreach ($ProtectedGroup in $ProtectedGroups) {

$Rows = @{
'Type' = $ProtectedGroup.Type
'Status' = Switch ($ProtectedGroup.Enabled) {
$true {'Enabled'}
$false {'Disabled'}
default {'Unknown'}
}
'Schedule' = $ProtectedGroup.ScheduleOptions.PolicyType
}

$Type = Get-IconType -String $ProtectedGroup.Container.Type

$TempProtectedGroupInfo = [PSCustomObject]@{
Name = "$((Remove-SpecialChar -String $ProtectedGroup.Name -SpecialChars '\').toUpper()) "
Label = Get-NodeIcon -Name "$((Remove-SpecialChar -String $ProtectedGroup.Name -SpecialChars '\').toUpper())" -Type $Type -Align "Center" -Rows $Rows
Container = $ProtectedGroup.Container.Type
}

$ProtectedGroupInfo += $TempProtectedGroupInfo
}
}

return $ProtectedGroupInfo
}
catch {
$_
}
}
end {}
}
8 changes: 8 additions & 0 deletions Src/Private/Images.ps1
Original file line number Diff line number Diff line change
@@ -21,4 +21,12 @@ $Images = @{
'VBR_Tape_Drive' = 'Tape_Drive.png'
"VBR_Server_DB_PG" = "PostGre_SQL_DB.png"
"VBR_LOGO_Footer" = "verified_recoverability.png"
"VBR_AGENT_Container" = "Folder.png"
"VBR_AGENT_AD" = "Server.png"
"VBR_AGENT_MC" = "Task list.png"
"VBR_AGENT_IC" = "Workstation.png"
"VBR_AGENT_CSV" = "CSV_Computers.png"
"VBR_AGENT_AD_Logo" = "Microsoft Active Directory.png"
"VBR_AGENT_CSV_Logo" = "File.png"

}
4 changes: 4 additions & 0 deletions Src/Private/SharedUtilsFunctions.ps1
Original file line number Diff line number Diff line change
@@ -55,6 +55,10 @@ function Get-IconType {
'Proxy' {'VBR_Repository'}
'ESXi' {'VBR_ESXi_Server'}
'HyperVHost' {'Hyper-V_host'}
'ManuallyDeployed' {'VBR_AGENT_MC'}
'IndividualComputers' {'VBR_AGENT_IC'}
'ActiveDirectory' {'VBR_AGENT_AD'}
'CSV' {'VBR_AGENT_CSV'}
default {'VBR_No_Icon'}
}

2 changes: 1 addition & 1 deletion Veeam.Diagrammer.psd1
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
RootModule = 'Veeam.Diagrammer.psm1'

# Version number of this module.
ModuleVersion = '0.5.6'
ModuleVersion = '0.5.7'

# Supported PSEditions
# CompatiblePSEditions = @()
Binary file modified icons/File.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/Task list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f552f63

Please sign in to comment.