Skip to content

Commit

Permalink
move to makijapan org
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelCharles committed Nov 24, 2023
1 parent ca6f82f commit af11410
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*.dll
*.so
*.dylib
check-cpu-usage-with-process-list
cpu-process-profiler

# Test binary, build with `go test -c`
*.test
Expand Down
38 changes: 16 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/MichaelCharles/check-cpu-usage-with-process-list)
![Go Test](https://github.com/MichaelCharles/check-cpu-usage-with-process-list/workflows/Go%20Test/badge.svg)
![goreleaser](https://github.com/MichaelCharles/check-cpu-usage-with-process-list/workflows/goreleaser/badge.svg)
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/makijapan/cpu-process-profiler)
![Go Test](https://github.com/makijapan/cpu-process-profiler/workflows/Go%20Test/badge.svg)
![goreleaser](https://github.com/makijapan/cpu-process-profiler/workflows/goreleaser/badge.svg)

# Sensu CPU usage check
# CPU Usage Check with Process Profiler

## Table of Contents

Expand All @@ -16,22 +16,16 @@

## Overview

The Sensu CPU usage check is a [Sensu Check][1] that provides alerting and
metrics for CPU usage. Metrics are provided in [nagios_perfdata][5] format.

**Note:** The macOS binary is built using [cgo][6] and may not be portable
across all versions of macOS.

Additionally, it will append a list of the 10 processes consuming the most CPU resources.
CPU Usage Check with Process Profiler is a [Sensu Check][1] that was built as an extension of the official `check-cpu-usage` check. At the time of this writing, it provides the same functionality as the original `check-cpu-usage` check, with the added benefit of providing a list of the 10 top resource intensive processes at the time that the check was carried out.

## Usage examples

```
Check CPU usage and provide metrics
Check CPU usage and provide metrics with a list of top resource intensive processes
Usage:
check-cpu-usage-with-process-list [flags]
check-cpu-usage-with-process-list [command]
cpu-process-profiler [flags]
cpu-process-profiler [command]
Available Commands:
help Help about any command
Expand All @@ -41,9 +35,9 @@ Flags:
-c, --critical float Critical threshold for overall CPU usage (default 90)
-w, --warning float Warning threshold for overall CPU usage (default 75)
-s, --sample-interval int Length of sample interval in seconds (default 2)
-h, --help help for check-cpu-usage-with-process-list
-h, --help help for cpu-process-profiler
Use "check-cpu-usage-with-process-list [command] --help" for more information about a command.
Use "cpu-process-profiler [command] --help" for more information about a command.
```

## Configuration
Expand All @@ -55,7 +49,7 @@ using an asset, please consider doing so! If you're using sensuctl 5.13 with
Sensu Backend 5.13 or later, you can use the following command to add the asset:

```
sensuctl asset add MichaelCharles/check-cpu-usage-with-process-list
sensuctl asset add makijapan/cpu-process-profiler
```

If you're using an earlier version of sensuctl, you can find the asset on the
Expand All @@ -68,11 +62,11 @@ If you're using an earlier version of sensuctl, you can find the asset on the
type: CheckConfig
api_version: core/v2
metadata:
name: check-cpu-usage-with-process-list
name: cpu-process-profiler
namespace: default
spec:
command: >-
check-cpu-usage-with-process-list
cpu-process-profiler
--critical 95
--warning 85
--sample-interval 2
Expand All @@ -82,7 +76,7 @@ spec:
subscriptions:
- system
runtime_assets:
- MichaelCharles/check-cpu-usage-with-process-list
- makijapan/cpu-process-profiler
```
## Installation from source
Expand All @@ -92,7 +86,7 @@ Asset. If you would like to compile and install the plugin from source or
contribute to it, download the latest version or create an executable from this
source.
From the local path of the check-cpu-usage-with-process-list repository:
From the local path of the cpu-process-profiler repository:
```
go build
Expand All @@ -104,7 +98,7 @@ For more information about contributing to this plugin, see [Contributing][4].

[1]: https://docs.sensu.io/sensu-go/latest/reference/checks/
[2]: https://docs.sensu.io/sensu-go/latest/reference/assets/
[3]: https://bonsai.sensu.io/assets/MichaelCharles/check-cpu-usage-with-process-list
[3]: https://bonsai.sensu.io/assets/makijapan/cpu-process-profiler
[4]: https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md
[5]: https://docs.sensu.io/sensu-go/latest/observability-pipeline/observe-schedule/collect-metrics-with-checks/#supported-output-metric-formats
[6]: https://golang.org/cmd/cgo/
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/MichaelCharles/check-cpu-usage-with-process-list
module github.com/makijapan/cpu-process-profiler

go 1.14

Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ func getTopCPUProcesses() ([]ProcessInfo, error) {
var (
plugin = Config{
PluginConfig: sensu.PluginConfig{
Name: "check-cpu-usage-with-process-list",
Name: "cpu-process-profiler",
Short: "Check CPU usage and provide metrics",
Keyspace: "sensu.io/plugins/check-cpu-usage-with-process-list/config",
Keyspace: "sensu.io/plugins/cpu-process-profiler/config",
},
}

Expand Down Expand Up @@ -161,7 +161,7 @@ func executeCheck(event *types.Event) (int, error) {
return sensu.CheckStateCritical, fmt.Errorf("Error obtaining top CPU processes: %v", err)
}

processInfo := "Top CPU processes:\n"
processInfo := "\nTop CPU processes:\n"
for _, p := range topProcesses {
processInfo += fmt.Sprintf("PID %d (%s): %.2f%%\n", p.PID, p.Name, p.CPU)
}
Expand Down

0 comments on commit af11410

Please sign in to comment.