Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
elfranne committed Jun 29, 2023
0 parents commit 7b72f59
Show file tree
Hide file tree
Showing 13 changed files with 946 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .bonsai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
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 == 'arm'"
- "entity.system.arm_version == 7"

- platform: "linux"
arch: "armv6"
asset_filename: "#{repo}_#{version}_linux_armv6.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'arm'"
- "entity.system.arm_version == 6"

- 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'"

20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: goreleaser

on:
push:
tags:
- '*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
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@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
id: go
- name: Test
run: go test -v ./...
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
sensu-top-process

# 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/
44 changes: 44 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
builds:
# List of builds
- # First Build
env:
- CGO_ENABLED=0
main: .
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}}'
# 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:
- darwin_amd64
- linux_386
- linux_amd64
- linux_arm_5
- linux_arm_6
- linux_arm_7
- linux_arm64
- windows_386
- windows_amd64

checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_sha512-checksums.txt"
algorithm: sha512

archives:
- id: tar
format: tar.gz
files:
- LICENSE
- README.md
- CHANGELOG.md
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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.0.1] - 2000-01-01

### Added
- Initial release
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2023 elfranne

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.
111 changes: 111 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
[![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)
![Go Test](https://github.com/elfranne/sensu-top-process/workflows/Go%20Test/badge.svg)
![goreleaser](https://github.com/elfranne/sensu-top-process/workflows/goreleaser/badge.svg)

# Check Plugin Template

## Overview
check-plugin-template is a template repository which wraps the [Sensu Plugin SDK][2].
To use this project as a template, click the "Use this template" button from the main project page.
Once the repository is created from this template, you can use the [Sensu Plugin Tool][9] to
populate the templated fields with the proper values.

## Functionality

After successfully creating a project from this template, update the `Config` struct with any
configuration options for the plugin, map those values as plugin options in the variable `options`,
and customize the `checkArgs` and `executeCheck` functions in [main.go][7].

When writing or updating a plugin's README from this template, review the Sensu Community
[plugin README style guide][3] for content suggestions and guidance. Remove everything
prior to `# sensu-top-process` from the generated README file, and add additional context about the
plugin per the style guide.

## Releases with Github Actions

To release a version of your project, simply tag the target sha with a semver release without a `v`
prefix (ex. `1.0.0`). This will trigger the [GitHub action][5] workflow to [build and release][4]
the plugin with goreleaser. Register the asset with [Bonsai][8] to share it with the community!

***

# sensu-top-process

## Table of Contents
- [Overview](#overview)
- [Files](#files)
- [Usage examples](#usage-examples)
- [Configuration](#configuration)
- [Asset registration](#asset-registration)
- [Check definition](#check-definition)
- [Installation from source](#installation-from-source)
- [Additional notes](#additional-notes)
- [Contributing](#contributing)

## Overview

The sensu-top-process is a [Sensu Check][6] that ...

## Files

## Usage examples

## Configuration

### Asset registration

[Sensu Assets][10] 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 elfranne/sensu-top-process
```

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].

### Check definition

```yml
---
type: CheckConfig
api_version: core/v2
metadata:
name: sensu-top-process
namespace: default
spec:
command: sensu-top-process --example example_arg
subscriptions:
- system
runtime_assets:
- elfranne/sensu-top-process
```
## 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 script from this source.
From the local path of the sensu-top-process repository:
```
go build
```

## Additional notes

## Contributing

For more information about contributing to this plugin, see [Contributing][1].

[1]: https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md
[2]: https://github.com/sensu/sensu-plugin-sdk
[3]: https://github.com/sensu-plugins/community/blob/master/PLUGIN_STYLEGUIDE.md
[4]: https://github.com/elfranne/sensu-top-process/blob/master/.github/workflows/release.yml
[5]: https://github.com/elfranne/sensu-top-process/actions
[6]: https://docs.sensu.io/sensu-go/latest/reference/checks/
[7]: https://github.com/sensu/check-plugin-template/blob/master/main.go
[8]: https://bonsai.sensu.io/
[9]: https://github.com/sensu/sensu-plugin-tool
[10]: https://docs.sensu.io/sensu-go/latest/reference/assets/
55 changes: 55 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module github.com/elfranne/sensu-top-process

go 1.18

require (
github.com/sensu/core/v2 v2.19.0
github.com/sensu/sensu-plugin-sdk v0.18.0
github.com/shirou/gopsutil/v3 v3.23.5
)

require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/echlebek/timeproxy v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/robertkrimen/otto v0.0.0-20221006114523-201ab5b34f52 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/sensu/sensu-api-tools v0.1.0 // indirect
github.com/sensu/sensu-licensing/v2 v2.2.1 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/cobra v1.4.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit 7b72f59

Please sign in to comment.