Skip to content

Commit

Permalink
merge v2 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
v-AdamC committed Aug 24, 2024
2 parents 6af246d + 1446cdb commit 834b0f8
Show file tree
Hide file tree
Showing 79 changed files with 3,766 additions and 1,063 deletions.
12 changes: 0 additions & 12 deletions vHC/HC_Reporting/AssemblyInfo.cs

This file was deleted.

5 changes: 5 additions & 0 deletions vHC/HC_Reporting/Common/CGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ internal class CGlobals
private static bool _runSecReport;
public static bool EXPORTINDIVIDUALJOBHTMLS = true;
public static bool CHECKFIXES = false;
public static bool EXPORTPDF = false;


// Security Values
public static bool IsMfaEnabled = false;

// B&R Server global values
//public static string isConsoleLocal = "Undetermined";
Expand Down
2 changes: 2 additions & 0 deletions vHC/HC_Reporting/Common/CMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ internal class CMessages
"\t/lite\t\t" + "Skips output of individual jobs to HTML files. Default is ON and adds extra processing time." +
"\n" +
"\t/scrub:\t\t" + "/scrub:true | /scrub:false; determines if sensitive data is removed. Default option creates both options" +
"\n"+
"\t/pdf\t\t" + "Exports the report as PDF in addition to HTML report."+
"\n\n" +
"HotFix Detection:\n"+
"Use the following syntax:\t\t.\\VeeamHealthCheck.exe /hotfix /path=D:\\ExamplePath"+
Expand Down
4 changes: 3 additions & 1 deletion vHC/HC_Reporting/Functions/Collection/CCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using VeeamHealthCheck.Functions.Collection.Security;
using VeeamHealthCheck.Shared;
using Microsoft.Management.Infrastructure;
using VeeamHealthCheck.Functions.Collection.PowerShell;
using VeeamHealthCheck.Functions.Collection.PSCollections;
using System.Web.Services.Description;
using System.Windows;

Expand Down Expand Up @@ -135,6 +135,8 @@ private void WeighSuccessContinuation()
}
private bool TestPsMFA(PSInvoker p)
{
CScripts scripts = new();

return p.TestMfa();
}
private void ExecVbrScripts(PSInvoker p)
Expand Down
26 changes: 14 additions & 12 deletions vHC/HC_Reporting/Functions/Collection/DB/CModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public enum EDbJobType
//ApplicationLevelRestore = 48,
//RemoteReplica = 50,
BackupSync = 51,
SqlLogBackup = 52,
//SqlLogBackup = 52,
//LicenseAutoUpdate = 53,
OracleLogBackup = 54,
//OracleLogBackup = 54,
//TapeMarkAsFree = 55,
//TapeDeleteFromLibrary = 56,
//TapeMoveToMediaPool = 57,
Expand All @@ -69,7 +69,7 @@ public enum EDbJobType
//SimpleOracleBackupCopyWorker = 69,
//SimpleBackupCopyParentWorker = 70,
//RepoCopyPolicy = 73,
ConfBackup = 100,
//ConfBackup = 100,
//ConfRestore = 101,
//ConfResynchronize = 102,
//WaGlobalDedupFill = 103,
Expand All @@ -90,12 +90,12 @@ public enum EDbJobType
//ViLabDeploy = 207,
//ViLabDelete = 208,
//ViLabStart = 209,
Cloud = 300,
//Cloud = 300,
//CloudApplDeploy = 301,
//HardwareQuotasProcessing = 302,
//ReconnectVpn = 303,
//DisconnectVpn = 304,
OrchestratedTask = 305,
//OrchestratedTask = 305,
//ViReplicaRescan = 306,
//ExternalRepositoryMaintenance = 307,
//DeleteBackup = 308,
Expand All @@ -106,14 +106,14 @@ public enum EDbJobType
//BackupCacheSync = 4010,
//EndpointSqlLogBackup = 4020,
//EndpointOracleLogBackup = 4021,
OracleRMANBackup = 4030,
SapBackintBackup = 4031,
//OracleRMANBackup = 4030,
//SapBackintBackup = 4031,
//OracleRMANRestore = 4032,
//SapBackintRestore = 4033,
//OracleRMANBackupCopyWorker = 4035,
//SapBackintBackupCopyWorker = 4037,
//PluginBackupCopyPolicy = 4038,
CloudBackup = 5000,
//CloudBackup = 5000,
//RestoreVirtualDisks = 6000,
//RestoreAgentVolumes = 6001,
//InfraItemSave = 7000,
Expand All @@ -126,10 +126,10 @@ public enum EDbJobType
//InfraStatistic = 10001,
//AzureVmRestore = 11000,

EpAgentManagement = 12000,
//EpAgentManagement = 12000,
//EpAgentDiscoveryObsolete = 12001, // Use EpAgentDiscovery
EpAgentPolicy = 12002, // Managed by agent (parent job type)
EpAgentBackup = 12003, // Managed by VBR (parent job type)
//EpAgentPolicy = 12002, // Managed by agent (parent job type)
//EpAgentBackup = 12003, // Managed by VBR (parent job type)
//EpAgentTestCreds = 12004,
//EpAgentDiscovery = 12005,
//EpAgentDeletedRetention = 12006,
Expand All @@ -153,7 +153,7 @@ public enum EDbJobType
//AmazonRestore = 16000,
//StagedRestore = 17000,

ArchiveBackup = 18000,
//ArchiveBackup = 18000,
//ArchiveRehydration = 18001,
//ArchiveDownload = 18002,
//ArchiveSync = 18003,
Expand All @@ -170,6 +170,8 @@ public enum EDbJobType
//AuditZip = 23000,

//CustomPlatformRestoreVm = 24000,
Kasten = 25000,
VB365 = 26000,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void ReadVmc()
private void ParseConfigDbInfo(string line)
{
DateTime dbLineDate = ParseLineDate(line);
if (_DbLineDate == null || dbLineDate.Ticks - _DbLineDate.Ticks == 0)
if ( dbLineDate.Ticks - _DbLineDate.Ticks == 0)
_DbLineDate = ParseLineDate(line);

}
Expand Down
59 changes: 59 additions & 0 deletions vHC/HC_Reporting/Functions/Collection/PSCollections/CScripts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;

namespace VeeamHealthCheck.Functions.Collection.PSCollections
{
internal class CScripts
{
public CScripts()
{
//RunPsScript(GetJobInfo());
//RunPsScript("Get-VBRJob");
//RunPsScript(File.ReadAllText(Environment.CurrentDirectory + @"\Tools\Scripts\Get-VBRConfig.ps1"));
}
//script to get vbr-job info
public string GetJobInfo()
{
string script = @"
Connect-VBRServer -Server localhost
$jobs = Get-VBRJob
$piJob = Get-VBRPluginJob
$jobInfo = @()
foreach ($job in $jobs)
{
$jobInfo += $job
}
$jobInfo
";
return script;
}

//script to get job information from Veeam PowerShell
//write a powershell script to save job information in a custom object containing members: jobName, jobType, sourceSizeUsedGB, sourceSizeProvisionedGb, Repository, daysOrPoints, retentionValue, GfsEnabled, GfsWeeklyCount, GfsMonthlyCount, GfsYearlyCount, SyntheticEnabled, ActiveFullEnabled, SyntheticDays, ActiveFullDays, compressionLevel, BlockSize, Encrypted, IndexingEnabled, schedule

//execute powershell script returned from GetJobInfo() method

private void RunPsScript(string script)
{
using (PowerShell ps = PowerShell.Create())
{
ps.AddScript(script);
ps.AddParameter("VBRServer", "localhost");//.AddParameter("localhost");
ps.AddParameter("VBRVersion", "12");//.AddParameter("12");
var results = ps.Invoke();
foreach (var result in results)
{
//do something with the results
Console.WriteLine(result);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
using VeeamHealthCheck.Shared;
using VeeamHealthCheck.Shared.Logging;

namespace VeeamHealthCheck.Functions.Collection.PowerShell
namespace VeeamHealthCheck.Functions.Collection.PSCollections
{
class PSInvoker
{
private readonly string _vb365Script = Environment.CurrentDirectory + @"\Tools\Scripts\Collect-VB365Data.ps1";
private readonly string _vbrConfigScript = Environment.CurrentDirectory + @"\Tools\Scripts\Get-VBRConfig.ps1";
private readonly string _vbrSessionScript = Environment.CurrentDirectory + @"\Tools\Scripts\Get-VeeamSessionReport.ps1";
private readonly string _exportLogsScript = Environment.CurrentDirectory + @"\Tools\Scripts\Collect-VBRLogs.ps1";
private readonly string _dumpServers = Environment.CurrentDirectory + @"\Tools\Scripts\DumpManagedServerToText.ps1";
private readonly string _vb365Script = Environment.CurrentDirectory + @"\Tools\Scripts\HealthCheck\VB365\Collect-VB365Data.ps1";

private readonly string _vbrConfigScript = Environment.CurrentDirectory + @"\Tools\Scripts\HealthCheck\VBR\Get-VBRConfig.ps1";
private readonly string _vbrSessionScript = Environment.CurrentDirectory + @"\Tools\Scripts\HealthCheck\VBR\Get-VeeamSessionReport.ps1";
private readonly string _nasScript = Environment.CurrentDirectory + @"\Tools\Scripts\HealthCheck\VBR\Get-NasInfo.ps1";

private readonly string _exportLogsScript = Environment.CurrentDirectory + @"\Tools\Scripts\HotfixDetection\Collect-VBRLogs.ps1";
private readonly string _dumpServers = Environment.CurrentDirectory + @"\Tools\Scripts\HotfixDetection\DumpManagedServerToText.ps1";

public static readonly string SERVERLISTFILE = "serverlist.txt";

private readonly CLogger log = CGlobals.Logger;
Expand All @@ -42,6 +46,7 @@ public void TryUnblockFiles()
{
UnblockFile(_vbrConfigScript);
UnblockFile(_vbrSessionScript);
UnblockFile(_nasScript);
UnblockFile(_exportLogsScript);
UnblockFile(_dumpServers);
UnblockFile(_vb365Script);
Expand Down Expand Up @@ -87,14 +92,24 @@ public bool TestMfa()
return failed;
}
public bool RunVbrConfigCollect()
{
bool success = true;
success = ExecutePsScript(VbrConfigStartInfo());
if (success)
success = ExecutePsScript(VbrNasStartInfo());
if (success)
success = ExecutePsScript(VbrSessionStartInfo());
return success;
}
public bool ExecutePsScript(ProcessStartInfo startInfo)
{
var res1 = new Process();
res1.StartInfo = VbrConfigStartInfo();
res1.StartInfo = startInfo;
res1.Start();

log.Info(CMessages.PsVbrConfigProcId + res1.Id.ToString(), false);
log.Info("[PS] Script execution started. PID: " + res1.Id.ToString(), false);

if(res1 != null && !res1.HasExited)
if (res1 != null && !res1.HasExited)
res1.WaitForExit();
List<string> errorarray = new();

Expand All @@ -113,7 +128,8 @@ public bool RunVbrConfigCollect()
}
errorarray.Add(errString);
}
PushPsErrorsToMainLog(errorarray);
if(errorarray.Count > 0)
PushPsErrorsToMainLog(errorarray);

log.Info(CMessages.PsVbrConfigProcIdDone, false);
if (failed)
Expand Down Expand Up @@ -147,6 +163,15 @@ private ProcessStartInfo VbrConfigStartInfo()
log.Info(CMessages.PsVbrConfigStart, false);
return ConfigStartInfo(_vbrConfigScript, 0, "");
}
private ProcessStartInfo VbrNasStartInfo()
{
log.Info("");
return ConfigStartInfo(_nasScript, 0, "");
}
private ProcessStartInfo VbrSessionStartInfo()
{
return ConfigStartInfo(_vbrSessionScript, CGlobals.ReportDays, "");
}

private ProcessStartInfo ExportLogsStartInfo(string path, string server)
{
Expand Down Expand Up @@ -198,7 +223,14 @@ private ProcessStartInfo LogCollectionInfo(string scriptLocation, string path, s
private ProcessStartInfo ServerDumpInfo(string scriptLocation)
{
string argString;
argString = $"-NoProfile -ExecutionPolicy unrestricted -file \"{scriptLocation}\"";
string server = "localhost";
if (CGlobals.REMOTEHOST == "")
server = "localhost";
else
{
server = CGlobals.REMOTEHOST;
}
argString = $"-NoProfile -ExecutionPolicy unrestricted -file \"{scriptLocation}\" -Server {server}";

//string argString = $"-NoProfile -ExecutionPolicy unrestricted -file \"{scriptLocation}\" -ReportPath \"{path}\"";
log.Debug(logStart + "PS ArgString = " + argString, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Text;
using System.Threading.Tasks;

namespace VeeamHealthCheck.Functions.Collection.PowerShell
namespace VeeamHealthCheck.Functions.Collection.PSCollections
{
public class PsErrorTypes
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class CCapTierCsv
[Index(1)]
public string Type { get; set; }
[Index(2)]
public string Immute { get; set; }
public bool Immute { get; set; }
[Index(3)]
public string ImmutePeriod { get; set; }
[Index(4)]
public string SizeLimitEnabled { get; set; }
public bool SizeLimitEnabled { get; set; }
[Index(5)]
public string SizeLimit { get; set; }
[Index(6)]
Expand Down
Loading

0 comments on commit 834b0f8

Please sign in to comment.