-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1527ffb
Showing
13 changed files
with
941 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
description: "#{repo}" | ||
builds: | ||
- platform: "linux" | ||
arch: "amd64" | ||
asset_filename: "#{repo}_#{version}_linux_amd64.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'linux'" | ||
- "entity.system.arch == 'amd64'" | ||
|
||
- platform: "linux" | ||
arch: "386" | ||
asset_filename: "#{repo}_#{version}_linux_386.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'linux'" | ||
- "entity.system.arch == '386'" | ||
|
||
- platform: "linux" | ||
arch: "arm64" | ||
asset_filename: "#{repo}_#{version}_linux_arm64.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'linux'" | ||
- "entity.system.arch == 'arm64'" | ||
|
||
- platform: "linux" | ||
arch: "armv7" | ||
asset_filename: "#{repo}_#{version}_linux_armv7.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'linux'" | ||
- "entity.system.arch == 'armv7'" | ||
|
||
- platform: "OSX" | ||
arch: "amd64" | ||
asset_filename: "#{repo}_#{version}_darwin_amd64.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'darwin'" | ||
- "entity.system.arch == 'amd64'" | ||
|
||
- platform: "Windows" | ||
arch: "amd64" | ||
asset_filename: "#{repo}_#{version}_windows_amd64.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'windows'" | ||
- "entity.system.arch == 'amd64'" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Go Lint | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Lint | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run golangci-lint | ||
uses: actions-contrib/golangci-lint@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Unshallow | ||
run: git fetch --prune --unshallow | ||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.14.x | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v1 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Go Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-latest, windows-latest, ubuntu-latest] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Go 1.14 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.14 | ||
id: go | ||
- name: Test | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
cpu-process-profiler | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# dep | ||
vendor/ | ||
|
||
# deploy | ||
bonsai/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
builds: | ||
# List of builds | ||
- # First Build | ||
id: non-cgo | ||
env: | ||
- CGO_ENABLED=0 | ||
main: main.go | ||
ldflags: '-s -w -X github.com/sensu-community/sensu-plugin-sdk/version.version={{.Version}} -X github.com/sensu-community/sensu-plugin-sdk/version.commit={{.Commit}} -X github.com/sensu-community/sensu-plugin-sdk/version.date={{.Date}}' | ||
# Set the binary output location to bin/ so archive will comply with Sensu Go Asset structure | ||
binary: bin/{{ .ProjectName }} | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
goarch: | ||
- amd64 | ||
- 386 | ||
- arm | ||
- arm64 | ||
goarm: | ||
- 5 | ||
- 6 | ||
- 7 | ||
targets: | ||
- linux_386 | ||
- linux_amd64 | ||
- linux_arm_5 | ||
- linux_arm_6 | ||
- linux_arm_7 | ||
- linux_arm64 | ||
- windows_386 | ||
- windows_amd64 | ||
- # macOS Build | ||
id: darwin-cgo | ||
env: | ||
- CGO_ENABLED=1 | ||
main: main.go | ||
ldflags: '-s -w -X github.com/sensu-community/sensu-plugin-sdk/version.version={{.Version}} -X github.com/sensu-community/sensu-plugin-sdk/version.commit={{.Commit}} -X github.com/sensu-community/sensu-plugin-sdk/version.date={{.Date}}' | ||
# Set the binary output location to bin/ so archive will comply with Sensu Go Asset structure | ||
binary: bin/{{ .ProjectName }} | ||
goos: | ||
- darwin | ||
goarch: | ||
- amd64 | ||
targets: | ||
- darwin_amd64 | ||
|
||
checksum: | ||
name_template: "{{ .ProjectName }}_{{ .Version }}_sha512-checksums.txt" | ||
algorithm: sha512 | ||
|
||
archives: | ||
- id: tar | ||
format: tar.gz | ||
files: | ||
- LICENSE | ||
- README.md | ||
- CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic | ||
Versioning](http://semver.org/spec/v2.0.0.html). | ||
|
||
## Unreleased | ||
|
||
## [0.2.2] - 2021-03-31 | ||
|
||
### Changed | ||
- Updated README | ||
|
||
## [0.2.1] - 2021-03-10 | ||
|
||
### Changed | ||
- Change release github action to use macos-latest so that macos cgo build works | ||
|
||
## [0.2.0] - 2021-03-10 | ||
|
||
### Changed | ||
- Updated goreleaser to build macOS version with cgo enabled | ||
|
||
## [0.1.0] - 2020-12-30 | ||
|
||
### Added | ||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2020 Todd Campbell | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
[![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) | ||
|
||
# CPU Usage Check with Process Profiler | ||
|
||
## Table of Contents | ||
|
||
- [Overview](#overview) | ||
- [Usage examples](#usage-examples) | ||
- [Configuration](#configuration) | ||
- [Asset registration](#asset-registration) | ||
- [Check definition](#check-definition) | ||
- [Installation from source](#installation-from-source) | ||
- [Contributing](#contributing) | ||
|
||
## Overview | ||
|
||
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 with a list of top resource intensive processes | ||
Usage: | ||
cpu-process-profiler [flags] | ||
cpu-process-profiler [command] | ||
Available Commands: | ||
help Help about any command | ||
version Print the version number of this plugin | ||
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 cpu-process-profiler | ||
Use "cpu-process-profiler [command] --help" for more information about a command. | ||
``` | ||
|
||
## Configuration | ||
|
||
### Asset registration | ||
|
||
[Sensu Assets][2] are the best way to make use of this plugin. If you're not | ||
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 makijapan/cpu-process-profiler | ||
``` | ||
|
||
If you're using an earlier version of sensuctl, you can find the asset on the | ||
[Bonsai Asset Index][3]. | ||
|
||
### Check definition | ||
|
||
```yml | ||
--- | ||
type: CheckConfig | ||
api_version: core/v2 | ||
metadata: | ||
name: cpu-process-profiler | ||
namespace: default | ||
spec: | ||
command: >- | ||
cpu-process-profiler | ||
--critical 95 | ||
--warning 85 | ||
--sample-interval 2 | ||
output_metric_format: nagios_perfdata | ||
output_metric_handlers: | ||
- influxdb | ||
subscriptions: | ||
- system | ||
runtime_assets: | ||
- makijapan/cpu-process-profiler | ||
``` | ||
## Installation from source | ||
The preferred way of installing and deploying this plugin is to use it as an | ||
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 cpu-process-profiler repository: | ||
``` | ||
go build | ||
``` | ||
|
||
## Contributing | ||
|
||
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/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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module github.com/makijapan/cpu-process-profiler | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect | ||
github.com/go-ole/go-ole v1.2.4 // indirect | ||
github.com/sensu-community/sensu-plugin-sdk v0.11.0 | ||
github.com/sensu/sensu-go/api/core/v2 v2.3.0 | ||
github.com/sensu/sensu-go/types v0.3.0 | ||
github.com/shirou/gopsutil v3.20.11+incompatible | ||
github.com/shirou/gopsutil/v3 v3.20.11 | ||
github.com/stretchr/testify v1.6.1 | ||
golang.org/x/sys v0.14.0 // indirect | ||
) |
Oops, something went wrong.