Skip to content

Commit

Permalink
Merge pull request #136 from atc0005/i134-update-func-args-order
Browse files Browse the repository at this point in the history
Update summary/report function arguments order
  • Loading branch information
atc0005 authored Feb 9, 2021
2 parents 2eb8ad5 + f817d0f commit af40b3c
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 36 deletions.
6 changes: 3 additions & 3 deletions cmd/check_vmware_datastore/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ func main() {

nagiosExitState.LongServiceOutput = vsphere.DatastoreUsageReport(
c.Client,
dsUsage,
dsVMs,
dsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateCRITICALExitCode
Expand All @@ -239,8 +239,8 @@ func main() {

nagiosExitState.LongServiceOutput = vsphere.DatastoreUsageReport(
c.Client,
dsUsage,
dsVMs,
dsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateWARNINGExitCode
Expand All @@ -258,8 +258,8 @@ func main() {

nagiosExitState.LongServiceOutput = vsphere.DatastoreUsageReport(
c.Client,
dsUsage,
dsVMs,
dsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateOKExitCode
Expand Down
12 changes: 6 additions & 6 deletions cmd/check_vmware_host_cpu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.HostSystemCPUUsageOneLineCheckSummary(
nagios.StateCRITICALLabel,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.LongServiceOutput = vsphere.HostSystemCPUUsageReport(
c.Client,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateCRITICALExitCode
Expand All @@ -231,14 +231,14 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.HostSystemCPUUsageOneLineCheckSummary(
nagios.StateWARNINGLabel,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.LongServiceOutput = vsphere.HostSystemCPUUsageReport(
c.Client,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateWARNINGExitCode
Expand All @@ -253,14 +253,14 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.HostSystemCPUUsageOneLineCheckSummary(
nagios.StateOKLabel,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.LongServiceOutput = vsphere.HostSystemCPUUsageReport(
c.Client,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateOKExitCode
Expand Down
12 changes: 6 additions & 6 deletions cmd/check_vmware_host_memory/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.HostSystemMemoryUsageOneLineCheckSummary(
nagios.StateCRITICALLabel,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.LongServiceOutput = vsphere.HostSystemMemoryUsageReport(
c.Client,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateCRITICALExitCode
Expand All @@ -232,14 +232,14 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.HostSystemMemoryUsageOneLineCheckSummary(
nagios.StateWARNINGLabel,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.LongServiceOutput = vsphere.HostSystemMemoryUsageReport(
c.Client,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateWARNINGExitCode
Expand All @@ -254,14 +254,14 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.HostSystemMemoryUsageOneLineCheckSummary(
nagios.StateOKLabel,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.LongServiceOutput = vsphere.HostSystemMemoryUsageReport(
c.Client,
hsUsage,
hsVMs,
hsUsage,
)

nagiosExitState.ExitStatusCode = nagios.StateOKExitCode
Expand Down
4 changes: 2 additions & 2 deletions cmd/check_vmware_hs2ds2vms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.H2D2VMsOneLineCheckSummary(
nagios.StateCRITICALLabel,
vmDatastoresPairingIssues,
filteredVMs,
vmDatastoresPairingIssues,
resourcePools,
)

Expand Down Expand Up @@ -610,8 +610,8 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.H2D2VMsOneLineCheckSummary(
nagios.StateOKLabel,
vmDatastoresPairingIssues,
filteredVMs,
vmDatastoresPairingIssues,
resourcePools,
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/check_vmware_tools/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.VMToolsOneLineCheckSummary(
stateLabel,
vmsWithIssues,
filteredVMs,
vmsWithIssues,
resourcePools,
)

Expand Down Expand Up @@ -261,8 +261,8 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.VMToolsOneLineCheckSummary(
nagios.StateOKLabel,
vmsWithIssues,
filteredVMs,
vmsWithIssues,
resourcePools,
)

Expand Down
9 changes: 6 additions & 3 deletions cmd/check_vmware_vcpus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ func main() {
nagios.StateCRITICALLabel,
vCPUsAllocated,
cfg.VCPUsMaxAllowed,
filteredVMs, resourcePools,
filteredVMs,
resourcePools,
)

nagiosExitState.LongServiceOutput = vsphere.VirtualCPUsReport(
Expand Down Expand Up @@ -294,7 +295,8 @@ func main() {
nagios.StateWARNINGLabel,
vCPUsAllocated,
cfg.VCPUsMaxAllowed,
filteredVMs, resourcePools,
filteredVMs,
resourcePools,
)

nagiosExitState.LongServiceOutput = vsphere.VirtualCPUsReport(
Expand Down Expand Up @@ -322,7 +324,8 @@ func main() {
nagios.StateOKLabel,
vCPUsAllocated,
cfg.VCPUsMaxAllowed,
filteredVMs, resourcePools,
filteredVMs,
resourcePools,
)

nagiosExitState.LongServiceOutput = vsphere.VirtualCPUsReport(
Expand Down
4 changes: 2 additions & 2 deletions cmd/check_vmware_vhw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ func main() {
nagiosExitState.ServiceOutput = vsphere.VirtualHardwareOneLineCheckSummary(
nagios.StateWARNINGLabel,
hardwareVersionsIdx,
vmsWithOldHardware,
filteredVMs,
vmsWithOldHardware,
resourcePools,
)

Expand Down Expand Up @@ -272,8 +272,8 @@ func main() {
nagiosExitState.ServiceOutput = vsphere.VirtualHardwareOneLineCheckSummary(
nagios.StateOKLabel,
hardwareVersionsIdx,
vmsWithOldHardware,
filteredVMs,
vmsWithOldHardware,
resourcePools,
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/check_vmware_vm_power_uptime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.VMPowerCycleUptimeOneLineCheckSummary(
nagios.StateCRITICALLabel,
uptimeSummary,
filteredVMs,
uptimeSummary,
resourcePools,
)

Expand Down Expand Up @@ -268,8 +268,8 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.VMPowerCycleUptimeOneLineCheckSummary(
nagios.StateWARNINGLabel,
uptimeSummary,
filteredVMs,
uptimeSummary,
resourcePools,
)

Expand Down Expand Up @@ -299,8 +299,8 @@ func main() {

nagiosExitState.ServiceOutput = vsphere.VMPowerCycleUptimeOneLineCheckSummary(
nagios.StateOKLabel,
uptimeSummary,
filteredVMs,
uptimeSummary,
resourcePools,
)

Expand Down
2 changes: 1 addition & 1 deletion internal/vsphere/datastores.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ func DatastoreUsageOneLineCheckSummary(
// the web UI or in the body of many notifications.
func DatastoreUsageReport(
c *vim25.Client,
dsUsageSummary DatastoreUsageSummary,
dsVMs []mo.VirtualMachine,
dsUsageSummary DatastoreUsageSummary,
) string {

funcTimeStart := time.Now()
Expand Down
2 changes: 1 addition & 1 deletion internal/vsphere/hardware.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ func FilterVMsWithOldHardware(vms []mo.VirtualMachine, hwIndex HardwareVersionsI
func VirtualHardwareOneLineCheckSummary(
stateLabel string,
hwvIndex HardwareVersionsIndex,
vmsWithIssues []mo.VirtualMachine,
evaluatedVMs []mo.VirtualMachine,
vmsWithIssues []mo.VirtualMachine,
rps []mo.ResourcePool,
) string {

Expand Down
2 changes: 1 addition & 1 deletion internal/vsphere/host-to-datastores.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ func (hdi HostToDatastoreIndex) ValidateVirtualMachinePairings(
// check results summary. This is the line most prominent in notifications.
func H2D2VMsOneLineCheckSummary(
stateLabel string,
vmDatastoresPairingIssues VMToMismatchedDatastoreNames,
evaluatedVMs []mo.VirtualMachine,
vmDatastoresPairingIssues VMToMismatchedDatastoreNames,
rps []mo.ResourcePool,
) string {

Expand Down
8 changes: 4 additions & 4 deletions internal/vsphere/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ func GetHostSystemsTotalMemory(ctx context.Context, c *vim25.Client, excludeOffl
// notifications.
func HostSystemMemoryUsageOneLineCheckSummary(
stateLabel string,
hsUsageSummary HostSystemMemorySummary,
hsVMs []mo.VirtualMachine,
hsUsageSummary HostSystemMemorySummary,
) string {

funcTimeStart := time.Now()
Expand Down Expand Up @@ -422,8 +422,8 @@ func HostSystemMemoryUsageOneLineCheckSummary(
// results display in the web UI or in the body of many notifications.
func HostSystemMemoryUsageReport(
c *vim25.Client,
hsUsageSummary HostSystemMemorySummary,
hsVMs []mo.VirtualMachine,
hsUsageSummary HostSystemMemorySummary,
) string {

funcTimeStart := time.Now()
Expand Down Expand Up @@ -580,8 +580,8 @@ func HostSystemMemoryUsageReport(
// notifications.
func HostSystemCPUUsageOneLineCheckSummary(
stateLabel string,
hsUsageSummary HostSystemCPUSummary,
hsVMs []mo.VirtualMachine,
hsUsageSummary HostSystemCPUSummary,
) string {

funcTimeStart := time.Now()
Expand Down Expand Up @@ -630,8 +630,8 @@ func HostSystemCPUUsageOneLineCheckSummary(
// results display in the web UI or in the body of many notifications.
func HostSystemCPUUsageReport(
c *vim25.Client,
hsUsageSummary HostSystemCPUSummary,
hsVMs []mo.VirtualMachine,
hsUsageSummary HostSystemCPUSummary,
) string {

funcTimeStart := time.Now()
Expand Down
7 changes: 6 additions & 1 deletion internal/vsphere/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ func FilterVMsWithToolsIssues(vms []mo.VirtualMachine) []mo.VirtualMachine {

// VMToolsOneLineCheckSummary is used to generate a one-line Nagios service
// check results summary. This is the line most prominent in notifications.
func VMToolsOneLineCheckSummary(stateLabel string, vmsWithIssues []mo.VirtualMachine, evaluatedVMs []mo.VirtualMachine, rps []mo.ResourcePool) string {
func VMToolsOneLineCheckSummary(
stateLabel string,
evaluatedVMs []mo.VirtualMachine,
vmsWithIssues []mo.VirtualMachine,
rps []mo.ResourcePool,
) string {

funcTimeStart := time.Now()

Expand Down
2 changes: 1 addition & 1 deletion internal/vsphere/vms.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ func GetVMPowerCycleUptimeStatusSummary(
// notifications.
func VMPowerCycleUptimeOneLineCheckSummary(
stateLabel string,
uptimeSummary VirtualMachinePowerCycleUptimeStatus,
evaluatedVMs []mo.VirtualMachine,
uptimeSummary VirtualMachinePowerCycleUptimeStatus,
rps []mo.ResourcePool,
) string {

Expand Down

0 comments on commit af40b3c

Please sign in to comment.