Skip to content

Commit 7b72f59

Browse files
committed
Initial commit
0 parents  commit 7b72f59

File tree

13 files changed

+946
-0
lines changed

13 files changed

+946
-0
lines changed

.bonsai.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
description: "#{repo}"
3+
builds:
4+
- platform: "linux"
5+
arch: "amd64"
6+
asset_filename: "#{repo}_#{version}_linux_amd64.tar.gz"
7+
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
8+
filter:
9+
- "entity.system.os == 'linux'"
10+
- "entity.system.arch == 'amd64'"
11+
12+
- platform: "linux"
13+
arch: "386"
14+
asset_filename: "#{repo}_#{version}_linux_386.tar.gz"
15+
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
16+
filter:
17+
- "entity.system.os == 'linux'"
18+
- "entity.system.arch == '386'"
19+
20+
- platform: "linux"
21+
arch: "arm64"
22+
asset_filename: "#{repo}_#{version}_linux_arm64.tar.gz"
23+
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
24+
filter:
25+
- "entity.system.os == 'linux'"
26+
- "entity.system.arch == 'arm64'"
27+
28+
- platform: "linux"
29+
arch: "armv7"
30+
asset_filename: "#{repo}_#{version}_linux_armv7.tar.gz"
31+
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
32+
filter:
33+
- "entity.system.os == 'linux'"
34+
- "entity.system.arch == 'arm'"
35+
- "entity.system.arm_version == 7"
36+
37+
- platform: "linux"
38+
arch: "armv6"
39+
asset_filename: "#{repo}_#{version}_linux_armv6.tar.gz"
40+
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
41+
filter:
42+
- "entity.system.os == 'linux'"
43+
- "entity.system.arch == 'arm'"
44+
- "entity.system.arm_version == 6"
45+
46+
- platform: "OSX"
47+
arch: "amd64"
48+
asset_filename: "#{repo}_#{version}_darwin_amd64.tar.gz"
49+
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
50+
filter:
51+
- "entity.system.os == 'darwin'"
52+
- "entity.system.arch == 'amd64'"
53+
54+
- platform: "Windows"
55+
arch: "amd64"
56+
asset_filename: "#{repo}_#{version}_windows_amd64.tar.gz"
57+
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
58+
filter:
59+
- "entity.system.os == 'windows'"
60+
- "entity.system.arch == 'amd64'"
61+

.github/workflows/lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Go Lint
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
name: Lint
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest]
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
- name: Set up Go
16+
uses: actions/setup-go@v4
17+
with:
18+
go-version-file: 'go.mod'
19+
- name: Run golangci-lint
20+
uses: golangci/golangci-lint-action@v3

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
- name: Unshallow
15+
run: git fetch --prune --unshallow
16+
- name: Set up Go
17+
uses: actions/setup-go@v4
18+
with:
19+
go-version-file: 'go.mod'
20+
- name: Run GoReleaser
21+
uses: goreleaser/goreleaser-action@v4
22+
with:
23+
version: latest
24+
args: release --rm-dist
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Go Test
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
name: Test
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [macos-latest, windows-latest, ubuntu-latest]
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
- name: Set up Go
16+
uses: actions/setup-go@v4
17+
with:
18+
go-version-file: 'go.mod'
19+
id: go
20+
- name: Test
21+
run: go test -v ./...

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
sensu-top-process
8+
9+
# Test binary, build with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool, specifically when used with LiteIDE
13+
*.out
14+
15+
# dep
16+
vendor/
17+
18+
# deploy
19+
bonsai/
20+
dist/

.goreleaser.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
builds:
2+
# List of builds
3+
- # First Build
4+
env:
5+
- CGO_ENABLED=0
6+
main: .
7+
ldflags: '-s -w -X github.com/sensu/sensu-plugin-sdk/version.version={{.Version}} -X github.com/sensu/sensu-plugin-sdk/version.commit={{.Commit}} -X github.com/sensu/sensu-plugin-sdk/version.date={{.Date}}'
8+
# Set the binary output location to bin/ so archive will comply with Sensu Go Asset structure
9+
binary: bin/{{ .ProjectName }}
10+
goos:
11+
- darwin
12+
- linux
13+
- windows
14+
goarch:
15+
- amd64
16+
- 386
17+
- arm
18+
- arm64
19+
goarm:
20+
- 5
21+
- 6
22+
- 7
23+
targets:
24+
- darwin_amd64
25+
- linux_386
26+
- linux_amd64
27+
- linux_arm_5
28+
- linux_arm_6
29+
- linux_arm_7
30+
- linux_arm64
31+
- windows_386
32+
- windows_amd64
33+
34+
checksum:
35+
name_template: "{{ .ProjectName }}_{{ .Version }}_sha512-checksums.txt"
36+
algorithm: sha512
37+
38+
archives:
39+
- id: tar
40+
format: tar.gz
41+
files:
42+
- LICENSE
43+
- README.md
44+
- CHANGELOG.md

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic
6+
Versioning](http://semver.org/spec/v2.0.0.html).
7+
8+
## Unreleased
9+
10+
## [0.0.1] - 2000-01-01
11+
12+
### Added
13+
- Initial release

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2023 elfranne
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/elfranne/sensu-top-process)
2+
![Go Test](https://github.com/elfranne/sensu-top-process/workflows/Go%20Test/badge.svg)
3+
![goreleaser](https://github.com/elfranne/sensu-top-process/workflows/goreleaser/badge.svg)
4+
5+
# Check Plugin Template
6+
7+
## Overview
8+
check-plugin-template is a template repository which wraps the [Sensu Plugin SDK][2].
9+
To use this project as a template, click the "Use this template" button from the main project page.
10+
Once the repository is created from this template, you can use the [Sensu Plugin Tool][9] to
11+
populate the templated fields with the proper values.
12+
13+
## Functionality
14+
15+
After successfully creating a project from this template, update the `Config` struct with any
16+
configuration options for the plugin, map those values as plugin options in the variable `options`,
17+
and customize the `checkArgs` and `executeCheck` functions in [main.go][7].
18+
19+
When writing or updating a plugin's README from this template, review the Sensu Community
20+
[plugin README style guide][3] for content suggestions and guidance. Remove everything
21+
prior to `# sensu-top-process` from the generated README file, and add additional context about the
22+
plugin per the style guide.
23+
24+
## Releases with Github Actions
25+
26+
To release a version of your project, simply tag the target sha with a semver release without a `v`
27+
prefix (ex. `1.0.0`). This will trigger the [GitHub action][5] workflow to [build and release][4]
28+
the plugin with goreleaser. Register the asset with [Bonsai][8] to share it with the community!
29+
30+
***
31+
32+
# sensu-top-process
33+
34+
## Table of Contents
35+
- [Overview](#overview)
36+
- [Files](#files)
37+
- [Usage examples](#usage-examples)
38+
- [Configuration](#configuration)
39+
- [Asset registration](#asset-registration)
40+
- [Check definition](#check-definition)
41+
- [Installation from source](#installation-from-source)
42+
- [Additional notes](#additional-notes)
43+
- [Contributing](#contributing)
44+
45+
## Overview
46+
47+
The sensu-top-process is a [Sensu Check][6] that ...
48+
49+
## Files
50+
51+
## Usage examples
52+
53+
## Configuration
54+
55+
### Asset registration
56+
57+
[Sensu Assets][10] are the best way to make use of this plugin. If you're not using an asset, please
58+
consider doing so! If you're using sensuctl 5.13 with Sensu Backend 5.13 or later, you can use the
59+
following command to add the asset:
60+
61+
```
62+
sensuctl asset add elfranne/sensu-top-process
63+
```
64+
65+
If you're using an earlier version of sensuctl, you can find the asset on the [Bonsai Asset Index][https://bonsai.sensu.io/assets/elfranne/sensu-top-process].
66+
67+
### Check definition
68+
69+
```yml
70+
---
71+
type: CheckConfig
72+
api_version: core/v2
73+
metadata:
74+
name: sensu-top-process
75+
namespace: default
76+
spec:
77+
command: sensu-top-process --example example_arg
78+
subscriptions:
79+
- system
80+
runtime_assets:
81+
- elfranne/sensu-top-process
82+
```
83+
84+
## Installation from source
85+
86+
The preferred way of installing and deploying this plugin is to use it as an Asset. If you would
87+
like to compile and install the plugin from source or contribute to it, download the latest version
88+
or create an executable script from this source.
89+
90+
From the local path of the sensu-top-process repository:
91+
92+
```
93+
go build
94+
```
95+
96+
## Additional notes
97+
98+
## Contributing
99+
100+
For more information about contributing to this plugin, see [Contributing][1].
101+
102+
[1]: https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md
103+
[2]: https://github.com/sensu/sensu-plugin-sdk
104+
[3]: https://github.com/sensu-plugins/community/blob/master/PLUGIN_STYLEGUIDE.md
105+
[4]: https://github.com/elfranne/sensu-top-process/blob/master/.github/workflows/release.yml
106+
[5]: https://github.com/elfranne/sensu-top-process/actions
107+
[6]: https://docs.sensu.io/sensu-go/latest/reference/checks/
108+
[7]: https://github.com/sensu/check-plugin-template/blob/master/main.go
109+
[8]: https://bonsai.sensu.io/
110+
[9]: https://github.com/sensu/sensu-plugin-tool
111+
[10]: https://docs.sensu.io/sensu-go/latest/reference/assets/

go.mod

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module github.com/elfranne/sensu-top-process
2+
3+
go 1.18
4+
5+
require (
6+
github.com/sensu/core/v2 v2.19.0
7+
github.com/sensu/sensu-plugin-sdk v0.18.0
8+
github.com/shirou/gopsutil/v3 v3.23.5
9+
)
10+
11+
require (
12+
github.com/blang/semver/v4 v4.0.0 // indirect
13+
github.com/coreos/go-semver v0.3.0 // indirect
14+
github.com/echlebek/timeproxy v1.0.0 // indirect
15+
github.com/fsnotify/fsnotify v1.4.7 // indirect
16+
github.com/go-ole/go-ole v1.2.6 // indirect
17+
github.com/gogo/protobuf v1.3.2 // indirect
18+
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
19+
github.com/golang/protobuf v1.5.2 // indirect
20+
github.com/google/go-cmp v0.5.9 // indirect
21+
github.com/google/uuid v1.3.0 // indirect
22+
github.com/hashicorp/hcl v1.0.0 // indirect
23+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
24+
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
25+
github.com/magiconair/properties v1.8.1 // indirect
26+
github.com/mitchellh/mapstructure v1.1.2 // indirect
27+
github.com/pelletier/go-toml v1.2.0 // indirect
28+
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
29+
github.com/robertkrimen/otto v0.0.0-20221006114523-201ab5b34f52 // indirect
30+
github.com/robfig/cron/v3 v3.0.1 // indirect
31+
github.com/sensu/sensu-api-tools v0.1.0 // indirect
32+
github.com/sensu/sensu-licensing/v2 v2.2.1 // indirect
33+
github.com/shoenig/go-m1cpu v0.1.6 // indirect
34+
github.com/sirupsen/logrus v1.9.0 // indirect
35+
github.com/spf13/afero v1.1.2 // indirect
36+
github.com/spf13/cast v1.3.0 // indirect
37+
github.com/spf13/cobra v1.4.0 // indirect
38+
github.com/spf13/jwalterweatherman v1.0.0 // indirect
39+
github.com/spf13/pflag v1.0.5 // indirect
40+
github.com/spf13/viper v1.7.0 // indirect
41+
github.com/subosito/gotenv v1.2.0 // indirect
42+
github.com/tklauser/go-sysconf v0.3.11 // indirect
43+
github.com/tklauser/numcpus v0.6.0 // indirect
44+
github.com/yusufpapurcu/wmi v1.2.3 // indirect
45+
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
46+
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
47+
golang.org/x/sys v0.8.0 // indirect
48+
golang.org/x/text v0.3.6 // indirect
49+
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
50+
google.golang.org/grpc v1.41.0 // indirect
51+
google.golang.org/protobuf v1.26.0 // indirect
52+
gopkg.in/ini.v1 v1.51.0 // indirect
53+
gopkg.in/sourcemap.v1 v1.0.5 // indirect
54+
gopkg.in/yaml.v2 v2.4.0 // indirect
55+
)

0 commit comments

Comments
 (0)