Go-based tooling used to monitor memory usage.
- Project home
- Overview
- Features
- Changelog
- Requirements
- Installation
- Configuration
- Examples
- License
- References
See our GitHub repo for the latest code, to file an issue or submit improvements for review and potential inclusion into the project.
This repo is intended to provide various tools used to monitor memory usage.
| Tool Name | Overall Status | Description |
|---|---|---|
check_memory |
Alpha | Nagios plugin used to monitor memory usage. |
Initial support has been added for emitting Performance Data / Metrics, but refinement suggestions are welcome.
Consult the table below for the metrics implemented thus far.
Please add to an existing Discussion thread (if applicable) or open a new one with any feedback that you may have. Thanks in advance!
| Emitted Performance Data / Metric | Meaning |
|---|---|
time |
Runtime for plugin |
memory_available |
Total memory available in KB |
memory_total |
Total memory in KB |
memory_usage |
Percentage of memory used |
Nagios plugin (check_memory) used to monitor for problematic process states
on Linux distros.
Note
The intent is to support multiple operating systems, but as of this writing Linux is the only supported OS.
-
Optional branding "signature"
- used to indicate what Nagios plugin (and what version) is responsible for the service check result
-
Optional, leveled logging using
rs/zerologpackagelogfmtformat output (tostderr)- choice of
disabled,panic,fatal,error,warn,info(the default),debugortrace
See the CHANGELOG.md file for the changes associated with
each release of this application. Changes that have been merged to master,
but not yet an official release may also be noted in the file under the
Unreleased section. A helpful link to the Git commit history since the last
official release is also provided for further review.
The following is a loose guideline. Other combinations of Go and operating systems for building and running tools from this repo may work, but have not been tested.
- Go
- see this project's
go.modfile for the target version this project was developed against - this project tests against officially supported Go
releases
- the most recent stable release (aka, "stable")
- the prior, but still supported release (aka, "oldstable")
- see this project's
- GCC
- if building with custom options (as the provided
Makefiledoes)
- if building with custom options (as the provided
make- if using the provided
Makefile
- if using the provided
- Red Hat Enterprise Linux 8
- Ubuntu 22.04
- Download Go
- Install Go
- Clone the repo
cd /tmpgit clone https://github.com/atc0005/check-memorycd check-memory
- Install dependencies (optional)
- for Ubuntu Linux
sudo apt-get install make gcc
- for CentOS Linux
sudo yum install make gcc
- for Ubuntu Linux
- Build
- manually, explicitly specifying target OS and architecture
GOOS=linux GOARCH=amd64 go build -mod=vendor ./cmd/check_memory/- most likely this is what you want (if building manually)
- substitute
amd64with the appropriate architecture if using different hardware (e.g.,arm64or386)
- using Makefile
linuxrecipemake linux- generates x86 and x64 binaries
- using Makefile
release-buildrecipemake release-build- generates the same release assets as provided by this project's releases
- manually, explicitly specifying target OS and architecture
- Locate generated binaries
- if using
Makefile- look in
/tmp/check-memory/release_assets/check_memory/
- look in
- if using
go build- look in
/tmp/check-memory/
- look in
- if using
- Copy the applicable binaries to whatever systems needs to run them so that they can be deployed
NOTE: Depending on which Makefile recipe you use the generated binary
may be compressed and have an xz extension. If so, you should decompress the
binary first before deploying it (e.g., xz -d check_memory-linux-amd64.xz).
- Download the latest release binaries
- Decompress binaries
- e.g.,
xz -d check_memory-linux-amd64.xz
- e.g.,
- Copy the applicable binaries to whatever systems needs to run them so that they can be deployed
NOTE:
DEB and RPM packages are provided as an alternative to manually deploying binaries.
- Place
check_memoryin a location where it can be executed by the monitoring agent- Usually the same place as other Nagios plugins
- For example, on a default Red Hat Enterprise Linux system using
check_nrpethecheck_memoryplugin would be deployed to/usr/lib64/nagios/plugins/check_memoryor/usr/local/nagios/libexec/check_memory
NOTE:
DEB and RPM packages are provided as an alternative to manually deploying binaries.
- Use the
-hor--helpflag to display current usage information. - Flags marked as
requiredmust be set via CLI flag. - Flags not marked as required are for settings where a useful default is already defined, but may be overridden if desired.
| Flag | Required | Default | Repeat | Possible | Description |
|---|---|---|---|---|---|
branding |
No | false |
No | branding |
Toggles emission of branding details with plugin status details. This output is disabled by default. |
h, help |
No | false |
No | h, help |
Show Help text along with the list of supported flags. |
version |
No | false |
No | version |
Whether to display application version and then immediately exit application. |
ll, log-level |
No | info |
No | disabled, panic, fatal, error, warn, info, debug, trace |
Log message priority filter. Log messages with a lower level are ignored. |
c, critical |
No | 3 |
No | positive whole number between 0-100, exclusive | Specifies the available memory percentage (as a whole number) when a CRITICAL threshold is reached. |
w, warning |
No | 6 |
No | positive whole number between 0-100, exclusive | Specifies the available memory percentage (as a whole number) when a WARNING threshold is reached. |
This output is emitted by the plugin when memory availability is greater than specified thresholds.
$ ./check_memory -w 6 -c 3
OK: 1052 MB (53%) available memory | 'memory_available'=1077532;;;; 'memory_total'=2014912;;;; 'memory_usage'=47%;94;97;; 'time'=1ms;;;;
$ ./check_memory
OK: 1049 MB (53%) available memory | 'memory_available'=1075004;;;; 'memory_total'=2014912;;;; 'memory_usage'=47%;94;97;; 'time'=1ms;;;;Regarding the output:
- Similar output is emitted by specifying explicit arguments (which match default threshold values) and running the plugin without arguments (relying solely on default values).
- The values and the
|symbol are performance data metrics emitted by the plugin. Depending on your monitoring system, these metrics may be collected and exposed as graphs/charts. - This output was captured on an Ubuntu 22.04 WSL instance. The output is comparable to other Linux distros.
This output is emitted by the plugin when available memory drops below the specified WARNING threshold. Here we use fake problem thresholds to trigger a WARNING state.
$ ./check_memory -w 54 -c 53
WARNING: 1048 MB (53%) available memory
**ERRORS**
* available memory below specified threshold
| 'memory_available'=1073188;;;; 'memory_total'=2014912;;;; 'memory_usage'=47%;46;47;; 'time'=3ms;;;;This output is emitted by the plugin when available memory drops below the specified CRITICAL threshold. Here we use fake problem thresholds to trigger a CRITICAL state.
$ ./check_memory -w 60 -c 54
CRITICAL: 1048 MB (53%) available memory
**ERRORS**
* available memory below specified threshold
| 'memory_available'=1074036;;;; 'memory_total'=2014912;;;; 'memory_usage'=47%;40;46;; 'time'=2ms;;;;See the LICENSE file for details.
MemAvailablefield added to/proc/meminfoin Linux kernel 3.14+ and backported to similar age OSes- http://access.redhat.com/solutions/776393
- https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html-single/7.6_release_notes/index#new_features_kernel
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0a
- https://unix.stackexchange.com/questions/261247/how-can-i-get-the-amount-of-available-memory-portably-across-distributions