Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
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
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ Global Flags:

```
$ check_cloud_aws ec2 instances
CRITICAL - 4 Instances found - 2 running - 2 stopped

[CRITICAL] i-0f38c870feae9c593 "(none)" stopped (no status)
[OK] i-06378c1b63a42384f "IcingaMaster" running instance=ok system=ok
[CRITICAL] i-0d5c0ad646be4610e "IcingaAgent" stopped (no status)
[OK] i-0a1b3143ae11565fc "IcingaSatellit" running instance=ok system=ok
CRITICAL - 4 Instances: 2 running - 2 stopped
\_[CRITICAL] i-0f38c870feae9c593 "(none)" stopped (no status)
\_[OK] i-06378c1b63a42384f "IcingaMaster" running instance=ok system=ok
\_[CRITICAL] i-0d5c0ad646be4610e "IcingaAgent" stopped (no status)
\_[OK] i-0a1b3143ae11565fc "IcingaSatellit" running instance=ok system=ok
```

#### ec2 instance
Expand All @@ -86,10 +85,9 @@ Global Flags:
```
$ check_cloud_aws ec2 instance --name IcingaMaster
OK - "IcingaMaster" running instance=ok system=ok

ID: i-06378c1b63a42384f
Type: t2.micro
AutoScaling: (none)
\_ID: i-06378c1b63a42384f
\_Type: t2.micro
\_AutoScaling: (none)
```

### S3
Expand Down Expand Up @@ -119,10 +117,10 @@ Global Flags:
````

```
$ check_cloud_aws s3 bucket -w 100mb -c 200mb
OK - Found 2 buckets - critical 0 - warning 0
[OK] my-aws-test-bucket1: 50MiB
[OK] my-aws-test-bucket2: 60MiB | my-aws-test-bucket1=50MB;100;200 my-aws-test-bucket2=60MB;100;200
$ check_cloud_aws s3 bucket -C ~/.aws/credentials -w 100mb -c 200mb
OK - 2 Buckets: 0 Critical - 0 Warning - 2 Ok
\_[OK] my-aws-test-bucket1 - value: 50MiB
\_[OK] my-aws-test-bucket2 - value: 20MiB | my-aws-test-bucket1=50MB;100;200 my-aws-test-bucket2=60MB;100;200
```

### s3 object
Expand Down Expand Up @@ -150,9 +148,14 @@ Global Flags:
````

````
$ check_cloud_aws s3 object --perfdata --prefix 'test' -b 'my-aws-testbucket1'
OK - Found 3 objects - critical 0 - warning 0 | test-file2.jpg=20MB;800;1024 test-file3.gif=10MB;800;1024 test-file5.rtf=10MB;800;1024

$ check_cloud_aws s3 object -C ~/.aws/credentials --perfdata --prefix 'test'
OK - 2 Objects: 0 Critical - 0 Warning - 3 Ok
\_[y-aws-testbucket1]:
\_[OK] test-file4.txt: 20MiB
\_[y-aws-testbucket2]:
\_[OK] test-file3.gif: 10MiB
\_[OK] test-file5.rtf: 20MiB
| test-file4.txt=20MB;800;1024 test-file3.gif=10MB;800;1024 test-file5.gif=20MB;800;1024
````

### Cloudfront
Expand All @@ -176,12 +179,10 @@ Global Flags:
````

````
$ check_cloud_aws cloudfront
CRITICAL - Found 2 Distributions - critical 1 - warning 1

[WARNING] E32127W2BLH4SR status=InProgress enabled=true
[CRITICAL] E16D3ZI1743SVJ status=Deployed enabled=false
| E32127W2BLH4SR=InProgress E16D3ZI1743SVJ=Deployed
$ check_cloud_aws cloudfront -C ~/.aws/credentials
WARNING - 1 Distributions: 0 Disabled - 1 InProgress - 0 Enabled
\_[WARNING] E2BD5GDFJZXKWC status=InProgress enabled=true
| E2BD5GDFJZXKWC=inprogress
````

## Authentication
Expand Down
31 changes: 11 additions & 20 deletions cmd/cloudfront.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var cloudfrontCmd = &cobra.Command{
summary string
totalCrit int
totalWarn int
totalOk int
rc int
states []int
distributions []*c.GetDistributionOutput
Expand Down Expand Up @@ -57,48 +58,38 @@ var cloudfrontCmd = &cobra.Command{
}
}

summary += fmt.Sprintf("Found %d Distributions - ", len(distributions))
summary += fmt.Sprintf("%d Distributions: ", len(distributions))

for _, distribution := range distributions {
var val string

if *distribution.Distribution.DistributionConfig.Enabled == false {
val = "disabled"
rc = 2
totalCrit++
} else if *distribution.Distribution.Status == "InProgress" {
val = "inprogress"
rc = 1
totalWarn++
} else {
val = "enabled"
rc = 0
totalOk++
}

states = append(states, rc)

if rc != 0 {
output += client.GetOutput(rc, distribution)
}
output += client.GetOutput(rc, distribution)

p := perfdata.Perfdata{
Label: *distribution.Distribution.Id,
Value: *distribution.Distribution.Status,
Value: val,
}

perf.Add(&p)

if len(distributions) > 1 {
output += "\n"
}
}

if result.WorstState(states...) == 0 {
output = fmt.Sprintf("")
}

summary += fmt.Sprintf("critical %d - warning %d\n", totalCrit, totalWarn)

if len(distributions) > 1 {
if result.WorstState(states...) != 0 {
summary += "\n"
}
}
summary += fmt.Sprintf("%d Disabled - %d InProgress - %d Enabled\n", totalCrit, totalWarn, totalOk)

check.ExitRaw(result.WorstState(states...), summary+output, "|", perf.String())
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/ec2_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var ec2InstanceCmd = &cobra.Command{
}

output := instance.GetOutput()
output += "\n\n" + instance.GetLongOutput()
output += "\n" + instance.GetLongOutput()

check.Exit(instance.GetStatus(), output)
},
Expand Down
11 changes: 8 additions & 3 deletions cmd/ec2_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ var ec2InstancesCmd = &cobra.Command{
states[*instance.Instance.State.Name]++
}

summary := fmt.Sprintf("%d Instances found", len(instances.Instances))
summary := fmt.Sprintf("%d Instances:", len(instances.Instances))

ctr := 0
for state, count := range states {
summary += fmt.Sprintf(" - %d %s", count, state)
summary += fmt.Sprintf(" %d %s ", count, state)
ctr += count
if ctr != len(instances.Instances) {
summary += fmt.Sprintf("-")
}
}

check.Exit(instances.GetStatus(), summary+"\n\n"+instances.GetOutput())
check.Exit(instances.GetStatus(), summary+"\n"+instances.GetOutput())
},
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/s3_buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var s3BucketCmd = &cobra.Command{
states []int
totalCrit int
totalWarn int
totalOk int
rc int
perf perfdata.PerfdataList
)
Expand Down Expand Up @@ -86,6 +87,7 @@ var s3BucketCmd = &cobra.Command{
totalWarn++
} else {
rc = 0
totalOk++
}

states = append(states, rc)
Expand All @@ -107,7 +109,7 @@ var s3BucketCmd = &cobra.Command{
perf.Add(&p)
}

summary += fmt.Sprintf("Found %d buckets - critical %d - warning %d\n", len(buckets.Buckets), totalCrit, totalWarn)
summary += fmt.Sprintf("%d Buckets: %d Critical - %d Warning - %d Ok\n", len(buckets.Buckets), totalCrit, totalWarn, totalOk)

check.ExitRaw(result.WorstState(states...), summary+output, "|", perf.String())
},
Expand Down
20 changes: 5 additions & 15 deletions cmd/s3_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var s3ObjectCmd = &cobra.Command{
states []int
totalCrit int
totalWarn int
totalOk int
totalObjects int64
rc int
perf perfdata.PerfdataList
Expand Down Expand Up @@ -79,7 +80,7 @@ var s3ObjectCmd = &cobra.Command{
check.ExitError(err)
}

output += fmt.Sprintf("[%s]:\n", *bucket.Name)
output += fmt.Sprintf(" \\_[%s]:\n", *bucket.Name)

for _, content := range objectsOutput.V2Output.Contents {
if crit.DoesViolate(float64(*content.Size)) {
Expand All @@ -90,13 +91,12 @@ var s3ObjectCmd = &cobra.Command{
totalWarn++
} else {
rc = 0
totalOk++
}

states = append(states, rc)

if rc != 0 {
output += objectsOutput.GetObjectOutput(*content.Size, rc, *content.Key)
}
output += objectsOutput.GetObjectOutput(*content.Size, rc, *content.Key)

p := perfdata.Perfdata{
Label: *content.Key,
Expand All @@ -112,17 +112,7 @@ var s3ObjectCmd = &cobra.Command{
}
}

if result.WorstState(states...) == 0 {
output = fmt.Sprintf("")
}

summary += fmt.Sprintf("Found %d objects - critical %d - warning %d", totalObjects, totalCrit, totalWarn)

if len(buckets.Buckets) > 1 {
if result.WorstState(states...) != 0 {
summary += "\n"
}
}
summary += fmt.Sprintf("%d Objects: %d Critical - %d Warning - %d Ok\n", totalObjects, totalCrit, totalWarn, totalOk)

if ShowPerfdata {
check.ExitRaw(result.WorstState(states...), summary+output, "|", perf.String())
Expand Down
2 changes: 1 addition & 1 deletion internal/cloudfront/cloudfront.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type GetDistributionOutput struct {
}

func (c *CloudfrontClient) GetOutput(rc int, distribution *cloudfront.GetDistributionOutput) (output string) {
output = fmt.Sprintf("[%s] %s status=%s enabled=%t",
output = fmt.Sprintf(" \\_[%s] %s status=%s enabled=%t\n",
check.StatusText(rc),
*distribution.Distribution.Id,
*distribution.Distribution.Status,
Expand Down
18 changes: 9 additions & 9 deletions internal/ec2/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ func (i *Instance) GetLongOutput() (out string) {
}
}

out += "ID: " + *i.Instance.InstanceId + "\n"
out += "Type: " + *i.Instance.InstanceType + "\n"
out += "AutoScaling: " + autoscaling + "\n"
out += " \\_ID: " + *i.Instance.InstanceId + "\n"
out += " \\_Type: " + *i.Instance.InstanceType + "\n"
out += " \\_AutoScaling: " + autoscaling + "\n"

return
}

// * instance-state-name - The state of the instance (pending | running |
// shutting-down | terminated | stopping | stopped).
// * instance-state-name - The state of the instance (pending | running |
// shutting-down | terminated | stopping | stopped).
//
// * instance-status.status - The status of the instance (ok | impaired |
// initializing | insufficient-data | not-applicable).
// * instance-status.status - The status of the instance (ok | impaired |
// initializing | insufficient-data | not-applicable).
//
// * system-status.status - The system status of the instance (ok | impaired
// | initializing | insufficient-data | not-applicable).
// * system-status.status - The system status of the instance (ok | impaired
// | initializing | insufficient-data | not-applicable).
func (i *Instance) GetStatus() int {
states := []int{3, 3, 3}

Expand Down
2 changes: 1 addition & 1 deletion internal/ec2/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (i Instances) GetStatus() int {

func (i Instances) GetOutput() (output string) {
for _, instance := range i.Instances {
output += fmt.Sprintf("[%s] %s %s\n",
output += fmt.Sprintf(" \\_[%s] %s %s\n",
check.StatusText(instance.GetStatus()),
*instance.Instance.InstanceId,
instance.GetOutput())
Expand Down
2 changes: 1 addition & 1 deletion internal/s3/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type V2Output struct {
}

func (v *V2Output) GetBucketOutput(size int64, status int) (output string) {
output = fmt.Sprintf("[%s] %s: %s",
output = fmt.Sprintf(" \\_[%s] %s - value: %s",
check.StatusText(status),
*v.V2Output.Name,
convert.BytesIEC(size))
Expand Down
2 changes: 1 addition & 1 deletion internal/s3/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func (v *V2Output) GetObjectOutput(size int64, status int, path string) (output string) {
output += fmt.Sprintf(" \\_[%s] %s: %s\n",
output += fmt.Sprintf(" \\_[%s] %s: %s\n",
check.StatusText(status),
path,
convert.BytesIEC(size))
Expand Down