Skip to content

Commit 50bac75

Browse files
author
Lorenz Kästle
committed
Initially transfer all work
1 parent 6c08898 commit 50bac75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5214
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
check_system_basics*
2+
.idea
3+
vendor/
4+
coverage.html
5+
coverage.out
6+
dist/

.golangci.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
run:
2+
timeout: 5m
3+
tests: false
4+
issues:
5+
exclude-rules:
6+
- path: 'cmd/memory.go'
7+
linters:
8+
- funlen
9+
- gocognit
10+
- gocyclo
11+
- maintidx
12+
- path: 'cmd/filesystem.go'
13+
linters:
14+
- funlen
15+
- gocognit
16+
- maintidx
17+
- gocyclo
18+
- path: 'internal/sensors/sensors.go'
19+
linters:
20+
- funlen
21+
- gocognit
22+
- path: 'internal/filesystem/filesystem.go'
23+
linters:
24+
- funlen
25+
- gocognit
26+
- gocyclo
27+
- maintidx
28+
- path: 'cmd/filesystem.go'
29+
linters:
30+
- nestif
31+
- path: 'internal/netdev/netdev.go'
32+
linters:
33+
- deadcode
34+
- golint
35+
- unused
36+
- nosnakecase
37+
- stylecheck
38+
- varcheck
39+
- revive
40+
linters:
41+
enable-all: true
42+
disable:
43+
- dupl
44+
- cyclop
45+
- depguard
46+
- exhaustivestruct
47+
- exhaustruct
48+
- forbidigo
49+
- forcetypeassert
50+
- gci
51+
- gochecknoglobals
52+
- gochecknoinits
53+
- godox
54+
- godot
55+
- goerr113
56+
- gofumpt
57+
- gomnd
58+
- lll
59+
- musttag
60+
- nakedret
61+
- nlreturn
62+
- nolintlint
63+
- nonamedreturns
64+
- tagliatelle
65+
- varnamelen
66+
- wrapcheck
67+
linters-settings:
68+
estif:
69+
min-complexity: 4
70+
maligned:
71+
suggest-new: true
72+
funlen:
73+
lines: 80
74+
statements: 70
75+
ignore-comments: true

Makefile

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.PHONY: test coverage lint vet build build-all
2+
3+
TARGET_BASENAME := check_system_basics
4+
TARGET_amd64 := $(TARGET_BASENAME)_amd64
5+
TARGET_arm64 := $(TARGET_BASENAME)_arm64
6+
TARGET_arm6 := $(TARGET_BASENAME)_arm6
7+
TARGET_riscv64 := $(TARGET_BASENAME)_riscv64
8+
9+
GIT_COMMIT := $(shell git rev-list -1 HEAD)
10+
VERSION = $(GIT_COMMIT)
11+
GIT_LAST_TAG_COMMIT := $(shell git rev-list --tags -1)
12+
13+
ifeq ($(GIT_COMMIT), $(GIT_LAST_TAG_COMMIT))
14+
VERSION = $(shell git tag -l --contains $(GIT_COMMIT))
15+
endif
16+
17+
GO_LINKERFLAGS := "-X main.version=$(VERSION)"
18+
19+
GO_LINKEROPTS := -ldflags $(GO_LINKERFLAGS)
20+
21+
GO_FILES = $(shell find . -iname '*.go')
22+
23+
build:
24+
go build
25+
26+
build-all: $(TARGET_arm6) $(TARGET_amd64) $(TARGET_arm64) $(TARGET_riscv64)
27+
28+
lint:
29+
go fmt $(go list ./... | grep -v /vendor/)
30+
vet:
31+
go vet $(go list ./... | grep -v /vendor/)
32+
test:
33+
go test -v -cover ./...
34+
coverage:
35+
go test -v -cover -coverprofile=coverage.out ./... &&\
36+
go tool cover -html=coverage.out -o coverage.html
37+
38+
$(TARGET_amd64): $(GO_FILES)
39+
CGO_ENABLED=0 go build $(GO_LINKEROPTS) -o $(TARGET_amd64)
40+
41+
$(TARGET_arm64): $(GO_FILES)
42+
CGO_ENABLED=0 GOARCH=arm64 go build $(GO_LINKEROPTS) -o $(TARGET_arm64)
43+
44+
$(TARGET_arm6): $(GO_FILES)
45+
CGO_ENABLED=0 GOARCH=arm GOARM=6 go build $(GO_LINKEROPTS) -o $(TARGET_arm6)
46+
47+
$(TARGET_riscv64): $(GO_FILES)
48+
CGO_ENABLED=0 GOARCH=riscv64 go build $(GO_LINKEROPTS) -o $(TARGET_riscv64)

README.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# check_system_basics
2+
3+
`check_system_basics` is a monitoring plugin, which is capable to check various Linux metrics such
4+
as memory or filesystem usage via subcommands.
5+
6+
In the current version check_system_basics supports the `memory`, `filesystem`, `psi`, `sensors`, `netdev` and `load` sub command.
7+
8+
## Usage
9+
10+
### memory
11+
12+
A sub command to measure and evaluate memory and swap usage. This is not a trivial topic, but there is [detailed information](https://www.thegeekdiary.com/understanding-proc-meminfo-file-analyzing-memory-utilization-in-linux/) available for those who search for it.
13+
14+
For the memory usage thresholds can be applied to either available, free or used memory. The recommended way is to set thresholds for available memory,
15+
since this is probably the metric most administrators are interested in.
16+
17+
18+
### filesystem
19+
20+
A sub command to check the usage of the currently mounted filesystems.
21+
22+
Thresholds can be applied on absolute values (in bytes) or percentage values of the free space on the filesystem
23+
or the free inodes.
24+
25+
* With `--exclude-fs-type` and `--include-fs-type` specific filesystem types can be excluded or explicitly included.
26+
* With `--exclude-device-path` and `--include-device-path` specific device paths can be excluded or explicitly included.
27+
* With `--exclude-mount-path` and `--include-mount-path` specific mount paths can be excluded or explicitly included.
28+
29+
30+
### load
31+
32+
A sub command to retrieve the current system load values and alerts if they are not within the defined thresholds.
33+
34+
By default no thresholds are applied.
35+
36+
37+
### psi
38+
39+
Note: The Pressure stall information interface is not available on all current Linux distributions (specifically it is not
40+
activated in their kernel configuration).
41+
Therefore this command is not available and will exit with an error.
42+
43+
A sub command to retrieve the current ["pressure stall information"](https://lwn.net/Articles/759781/) values of the system. These are useful metrics to determine a shortage
44+
of resources on the system, the resources being cpu, memory and io.
45+
For each of these resources a 10 second, 60 second and 300 second aggregate percentage value is available for which
46+
amount of time a process did not immediately receive the resource it was asking for and was therefore stalled.
47+
48+
The PSI interface might not be available on your systems, since not all distributions build it into their kernel (RHEL for example).
49+
In this case, the Plugin will return UNKNOWN.
50+
51+
At least on RHEL systems the PSI interface can be enabled via appending "psi=1" to the kernel commandline (`/etc/default/grub`).
52+
53+
The checks includes the three components CPU, IO and Memory by default, but individual components can be selected with the following flagS:
54+
55+
```
56+
--include-cpu
57+
--include-memory
58+
--include-io
59+
```
60+
61+
Default thresholds are applied to all of the measurements.
62+
63+
64+
65+
66+
### sensors
67+
68+
A sub command to read the sensors exposed by the linux kernel and display whether they
69+
are within their respective thresholds (if any are set on the system side).
70+
Additionally it will export the respective values as performance data to be rendered
71+
by a graphing system.
72+
73+
There are no parameters available at the point of writing.
74+
75+
76+
## Building
77+
78+
### Necessary tools
79+
80+
* the [`golang` toolchain](https://go.dev/)
81+
82+
### Compiling
83+
84+
```
85+
go build
86+
```
87+
executed in the main folder of this repository will generate an executable. If you are not on a linux system,
88+
it should probably look like this:
89+
90+
```
91+
GOOS=linux go build
92+
```
93+
94+
### Creating the Icinga2 CheckCommand config (if necessary)
95+
96+
```
97+
./check_system_basics --dump-icinga2-config > myConfigFile.conf
98+
```

0 commit comments

Comments
 (0)