Giter Club home page Giter Club logo

check-disk-usage's Introduction

sensu

Build Status Gem Version MIT Licensed Join the chat at https://slack.sensu.io/

โš ๏ธ ANNOUNCEMENT - Sensu 1.x has reached End-Of-Life (December 31st, 2019)

The Sensu 1.x project reached end-of-life on December 31st, 2019. The existing package repositories became unreachable on January 6th, 2020. Please see our blog post for more details: https://blog.sensu.io/announcing-the-sensu-archives

Sensu 1.x has been superseded by Sensu Go.

As always, we want to hear from the Community and please reach out on Slack or Discourse if you have any questions or concerns.

Sensu

A simple, malleable, and scalable framework for composing the monitoring system you need.

Sensu is offered in two flavors:

  • Sensu Core - this open source project
  • Sensu Enterprise - a full-featured commercial implementation, built on Sensu Core

Installation

Sensu supports a number of Unix-like platforms, as well as Windows. Please see the list of supported platforms for installation instructions.

Documentation

Please refer to the online documentation for details on configuring and operating Sensu.

Getting Help

If you have questions not covered by the documentation, the Sensu community is here to help. Please check out our chat on Slack, or the sensu-users discussion list.

Commercial support is also available. See the support section of our website for more detail.

Contributing

Please observe these guidelines on contributing.

License

Sensu Core is released under the MIT license.

check-disk-usage's People

Contributors

amdprophet avatar boagg avatar djm0 avatar echlebek avatar jadiunr avatar jspaleta avatar nixwiz avatar thoward avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

check-disk-usage's Issues

Add Human readable option support

Hi,

Would it be possible to add option to display, like df unix command, size of disks in a different way?

Available to talk about it,

Prometheus output is in random order

It's a little disorienting to see the Prometheus output coming through in a different order every time. This is due to the GoLang maps iterating keys in random order in the loop where we output the metrics, here:

g.Output()

Desired behavior is that these are returned in the same order every time.

Throws error after valid check with invalid memory address or nil pointer dereference when run via sensu user

Running the plugin either via sensu go backend or via console via "sudo -u sensu check-disk-usage ..." the plugin throws the error shown below. Running as root does not produce the error. The actual disk check seems to work fine, but there is something happening just as the plugin seem to finish up.

Test with simular results on CentOS 8 and Arch, using wither Sensu Go 6.1.3 og 6.2.

check-disk-usage       OK: /boot 44.40% - Total: 1.0 GB, Used: 423 MB, Free: 530 MB
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xba8d7d]

goroutine 1 [running]:
main.executeCheck(0x0, 0x0, 0x0, 0x0)
	/home/runner/work/check-disk-usage/check-disk-usage/main.go:126 +0x14d
github.com/sensu-community/sensu-plugin-sdk/sensu.(*GoCheck).goCheckWorkflow(0xc0001f8580, 0xc000270340, 0x0, 0x2, 0xc00026aa00, 0xc00027dcb0, 0xb93223)
	/home/runner/go/pkg/mod/github.com/sensu-community/[email protected]/sensu/gocheck.go:59 +0xed
github.com/sensu-community/sensu-plugin-sdk/sensu.(*basePlugin).cobraExecuteFunction(0xc0001f8580, 0xc000270340, 0x0, 0x2, 0x0, 0x0)
	/home/runner/go/pkg/mod/github.com/sensu-community/[email protected]/sensu/goplugin.go:234 +0x65
github.com/sensu-community/sensu-plugin-sdk/sensu.(*basePlugin).initPlugin.func1(0xc000230dc0, 0xc000270340, 0x0, 0x2, 0x0, 0x0)
	/home/runner/go/pkg/mod/github.com/sensu-community/[email protected]/sensu/goplugin.go:119 +0xad
github.com/spf13/cobra.(*Command).execute(0xc000230dc0, 0xc000190010, 0x2, 0x2, 0xc000230dc0, 0xc000190010)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:842 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xc000230dc0, 0xc0001f8580, 0x0, 0x0)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/sensu-community/sensu-plugin-sdk/sensu.(*basePlugin).Execute(0xc0001f8580)
	/home/runner/go/pkg/mod/github.com/sensu-community/[email protected]/sensu/goplugin.go:247 +0x3e
main.main()
	/home/runner/work/check-disk-usage/check-disk-usage/main.go:97 +0x7e

Increase test coverage

Currently main_test.go only has one test, for the CheckArgs function. This should be expanded to cover the basic functionality of the tool.

This may also require some minor refactoring so that the current monolithic executeCheck function is decomposed into smaller testable functions.

Squashfs filesystems should be excluded by default as pseudo-filesystems

When running check-disk-usage without -p I expect mounted squashfs entries to not be included.

Command:

check-disk-usage -w 10 -c 78

Result:

check-disk-usage  WARNING: / 35.24% - Total: 10 GB, Used: 3.5 GB, Free: 6.4 GB
check-disk-usage CRITICAL: /snap/core/10583 100.00% - Total: 103 MB, Used: 103 MB, Free: 0 B
check-disk-usage CRITICAL: /snap/core20/904 100.00% - Total: 65 MB, Used: 65 MB, Free: 0 B
check-disk-usage CRITICAL: /snap/certbot/952 100.00% - Total: 52 MB, Used: 52 MB, Free: 0 B
check-disk-usage CRITICAL: /snap/core/10823 100.00% - Total: 103 MB, Used: 103 MB, Free: 0 B
check-disk-usage CRITICAL: /snap/certbot/889 100.00% - Total: 52 MB, Used: 52 MB, Free: 0 B

df -hT output from agent host:

Filesystem                                        Type      Size  Used Avail Use% Mounted on
udev                                              devtmpfs  480M     0  480M   0% /dev
tmpfs                                             tmpfs      99M   12M   87M  12% /run
/dev/vda1                                         ext4      9.8G  3.3G  6.0G  36% /
tmpfs                                             tmpfs     494M     0  494M   0% /dev/shm
tmpfs                                             tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs                                             tmpfs     494M     0  494M   0% /sys/fs/cgroup
/dev/loop2                                        squashfs   98M   98M     0 100% /snap/core/10583
/dev/loop3                                        squashfs   62M   62M     0 100% /snap/core20/904
/dev/loop1                                        squashfs   50M   50M     0 100% /snap/certbot/952
/dev/loop0                                        squashfs   99M   99M     0 100% /snap/core/10823
/dev/loop4                                        squashfs   50M   50M     0 100% /snap/certbot/889
tmpfs                                             tmpfs      99M     0   99M   0% /run/user/1000
tmpfs                                             tmpfs      99M     0   99M   0% /run/user/0

Add metric output support

Add a --metrics flag to provide output in InfluxDB line format for metric collection.

Should this also include a --metrics-only flag to not check against thresholds?

Plugin parity - ability to monitor fstab

In a recent issue (internal ref HS-27996), it was noted that this plugin lacks the ability to monitor fstab for mounts that for some reason become unmounted.

In comparison, the Ruby-based disk checks plugin (https://github.com/sensu-plugins/sensu-plugins-disk-checks) contains an fstab check plugin.

As we move away from the Ruby plugins and the subsequent dependency on the Ruby runtime, we'll need to ensure that our plugins continue to maintain parity with their existing Ruby analogs.

https://secure.helpscout.net/conversation/1749777313/27996?folderId=1931919

Accept wildcards for --include-fs-path and --exclude-fs-path

With ZFS becoming more common the number of child file systems is increasing. On recent install of Ubuntu 22.04 using ZFS, df -h looks like this

udev                                             devtmpfs  65854284        0  65854284   0% /dev
tmpfs                                            tmpfs     13183828     2984  13180844   1% /run
rpool/ROOT/ubuntu_y0n4y7                         zfs      801073792  4717696 796356096   1% /
tmpfs                                            tmpfs     65919140        0  65919140   0% /dev/shm
tmpfs                                            tmpfs         5120        4      5116   1% /run/lock
tmpfs                                            tmpfs     65919140        0  65919140   0% /sys/fs/cgroup
rpool/USERDATA/tonkatest_85thdo                  zfs      796418944    62848 796356096   1% /home/xxx-userdir-xxx
rpool/USERDATA/root_85thdo                       zfs      796356352      256 796356096   1% /root
rpool/ROOT/ubuntu_y0n4y7/srv                     zfs      796356224      128 796356096   1% /srv
rpool/ROOT/ubuntu_y0n4y7/usr/local               zfs      796356224      128 796356096   1% /usr/local
rpool/ROOT/ubuntu_y0n4y7/var/games               zfs      796356224      128 796356096   1% /var/games
rpool/ROOT/ubuntu_y0n4y7/var/lib                 zfs      798986368  2630272 796356096   1% /var/lib
rpool/ROOT/ubuntu_y0n4y7/var/log                 zfs      797685376  1329280 796356096   1% /var/log
rpool/ROOT/ubuntu_y0n4y7/var/mail                zfs      796356224      128 796356096   1% /var/mail
rpool/ROOT/ubuntu_y0n4y7/var/snap                zfs      796356864      768 796356096   1% /var/snap
rpool/ROOT/ubuntu_y0n4y7/var/www                 zfs      796356224      128 796356096   1% /var/www
rpool/ROOT/ubuntu_y0n4y7/var/spool               zfs      796356224      128 796356096   1% /var/spool
rpool/ROOT/ubuntu_y0n4y7/var/lib/AccountsService zfs      796356224      128 796356096   1% /var/lib/AccountsService
rpool/containerd                                 zfs      846543744 50187648 796356096   6% /var/lib/containerd
rpool/ROOT/ubuntu_y0n4y7/var/lib/NetworkManager  zfs      796356352      256 796356096   1% /var/lib/NetworkManager
rpool/ROOT/ubuntu_y0n4y7/var/lib/apt             zfs      796486912   130816 796356096   1% /var/lib/apt
rpool/ROOT/ubuntu_y0n4y7/var/lib/dpkg            zfs      796391552    35456 796356096   1% /var/lib/dpkg
rpool/snapshot                                   zfs      796357120     1024 796356096   1% /var/lib/containerd/io.containerd.snapshotter.v1.zfs

I'd like to be able to ignore all filesystems matching /var/*

Plugin should exit with some other code than `0` if no disks are monitored

When running the check with an exclude flag of -e 'ext4,xfs, there's effectively no disks being monitored. However, the plugin still exits with a 0, which can be misleading. The plugin should exit with some other exit status to indicate that there's effectively no output and that what's being monitored isn't actually monitored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.