sensu-plugins-filesystem-checks 0.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +44 -2
- data/README.md +155 -11
- data/bin/check-checksums.rb +5 -5
- data/bin/check-ctime.rb +107 -0
- data/bin/check-dir-size.rb +1 -1
- data/bin/check-file-exists.rb +27 -7
- data/bin/check-fs-writable.rb +9 -9
- data/bin/check-tail.rb +1 -1
- data/bin/{metric-dirsize.rb → metrics-dirsize.rb} +2 -2
- data/bin/{metric-filesize.rb → metrics-filesize.rb} +1 -1
- data/bin/metrics-nfsstat.rb +53 -0
- data/lib/sensu-plugins-filesystem-checks/version.rb +2 -2
- metadata +36 -52
- checksums.yaml.gz.sig +0 -3
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 907a6790b2330c1f26dcfe45a40c8fff14f10227d3cab676ab613bba9a3ac8ac
|
4
|
+
data.tar.gz: f8fc51cf1c491717775421f67cf0753a7a6dd269f916d91602f7b54c5578419c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 170ba92fcc702beb1da29f5fa9bc45a075b578f196c7d709eee7644810de6814e583db2cf812b84c7e9b857ff9668aeb614bcd4538c92b0d37f08bfe084ef8fc
|
7
|
+
data.tar.gz: d5cf0c94b1c39f8d1264aee18c298aa4e9c6296c02176d9ab8567673b6a4ced1af75262dc486638bf7b130d54ef30569c6cb5af5a77971365081c436225c12e5
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,40 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
3
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
|
-
|
7
|
-
-
|
6
|
+
### Added
|
7
|
+
- Added 'check-ctime.rb' for checking the file created time (@landondao1)
|
8
|
+
|
9
|
+
## [Unreleased]
|
10
|
+
|
11
|
+
## [2.1.1] - 2020-07-27
|
12
|
+
### Removed
|
13
|
+
- Fixed Asset deployment to bonsai by removing reference for generic "centos" assets.
|
14
|
+
|
15
|
+
## [2.1.0] - 2020-07-16
|
16
|
+
### Added
|
17
|
+
- Updated asset build targets to support centos6
|
18
|
+
|
19
|
+
## [2.0.0] - 2019-05-07
|
20
|
+
### Breaking Changes
|
21
|
+
- Update minimum required ruby version to 2.3. Drop unsupported ruby versions.
|
22
|
+
- Bump `sensu-plugin` dependency from `~> 1.2` to `~> 4.0` you can read the changelog entries for [4.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#400---2018-02-17), [3.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#300---2018-12-04), and [2.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#v200---2017-03-29)
|
23
|
+
|
24
|
+
### Added
|
25
|
+
- Added testing on Ruby 2.4.1 (@portertech)
|
26
|
+
- Travis build automation to generate Sensu Asset tarballs that can be used n conjunction with Sensu provided ruby runtime assets and the Bonsai Asset Index
|
27
|
+
- Require latest sensu-plugin for [Sensu Go support](https://github.com/sensu-plugins/sensu-plugin#sensu-go-enablement)
|
28
|
+
|
29
|
+
## [1.0.0] - 2017-07-01
|
30
|
+
### Added
|
31
|
+
- Added testing on Ruby 2.3.0 (@Evesy)
|
32
|
+
- Added support for globbing in 'check-file-exists.rb' (@Evesy)
|
33
|
+
- Added 'metrics-nfsstat.rb' for collecting nfsstat metrics (@maoe)
|
34
|
+
|
35
|
+
### Breaking Changes
|
36
|
+
- Dropped Ruby 1.9 support
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
- Renamed metric-{dirsize,filename} to metrics-{dirsize,filename}
|
8
40
|
|
9
41
|
## [0.1.0] - 2015-08-04
|
10
42
|
### Added
|
@@ -34,3 +66,13 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
34
66
|
## 0.0.1 - [2015-04-30]
|
35
67
|
### Added
|
36
68
|
- initial release
|
69
|
+
|
70
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/2.1.1...HEAD
|
71
|
+
[2.1.1]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/2.1.0...2.1.1
|
72
|
+
[2.1.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/2.0.0...2.1.0
|
73
|
+
[2.0.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/1.0.0...2.0.0
|
74
|
+
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.4...1.0.0
|
75
|
+
[0.1.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.3...0.0.4
|
76
|
+
[0.0.4]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.3...0.0.4
|
77
|
+
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.2...0.0.3
|
78
|
+
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.1...0.0.2
|
data/README.md
CHANGED
@@ -1,16 +1,33 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-filesystem-checks)
|
3
2
|
[ ![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-filesystem-checks.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-filesystem-checks)
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-filesystem-checks.svg)](http://badge.fury.io/rb/sensu-plugins-filesystem-checks)
|
5
4
|
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-filesystem-checks/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-filesystem-checks)
|
6
5
|
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-filesystem-checks/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-filesystem-checks)
|
7
6
|
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-filesystem-checks.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-filesystem-checks)
|
8
|
-
[ ![Codeship Status for sensu-plugins/sensu-plugins-filesystem-checks](https://codeship.com/projects/4b97d0a0-db4c-0132-445b-5ad94843e341/status?branch=master)](https://codeship.com/projects/79592)
|
9
7
|
|
10
|
-
##
|
8
|
+
## Sensu Plugins Filesystem Checks Plugin
|
9
|
+
|
10
|
+
- [Overview](#overview)
|
11
|
+
- [Files](#files)
|
12
|
+
- [Usage examples](#usage-examples)
|
13
|
+
- [Configuration](#configuration)
|
14
|
+
- [Sensu Go](#sensu-go)
|
15
|
+
- [Asset registration](#asset-registration)
|
16
|
+
- [Asset definition](#asset-definition)
|
17
|
+
- [Check definition](#check-definition)
|
18
|
+
- [Sensu Core](#sensu-core)
|
19
|
+
- [Check definition](#check-definition)
|
20
|
+
- [Installation from source](#installation-from-source)
|
21
|
+
- [Additional notes](#additional-notes)
|
22
|
+
- [Contributing](#contributing)
|
23
|
+
|
24
|
+
### Overview
|
11
25
|
|
12
|
-
|
26
|
+
This plugin provides native instrumentation for monitoring and metrics collection, including health, usage, and various metrics of filesystem attributes.
|
27
|
+
|
28
|
+
### Files
|
13
29
|
* bin/check-checksums.rb
|
30
|
+
* bin/check-ctime.rb
|
14
31
|
* bin/check-dir-count.rb
|
15
32
|
* bin/check-dir-size.rb
|
16
33
|
* bin/check-file-exists.rb
|
@@ -18,13 +35,140 @@
|
|
18
35
|
* bin/check-fs-writable.rb
|
19
36
|
* bin/check-mtime.rb
|
20
37
|
* bin/check-tail.rb
|
21
|
-
* bin/
|
22
|
-
* bin/
|
38
|
+
* bin/metrics-dirsize.rb
|
39
|
+
* bin/metrics-filesize.rb
|
40
|
+
* bin/metrics-nfsstat.rb
|
41
|
+
|
42
|
+
**check-checksums**
|
43
|
+
Checks a file against its checksum.
|
44
|
+
|
45
|
+
**check-dir-count**
|
46
|
+
Checks the number of files in a directory.
|
47
|
+
|
48
|
+
**check-dir-size**
|
49
|
+
Checks the size of a directory using `du`. Includes optional command line parameter to ignore a missing directory. WARNING: When using this with a directory with many files, there will be some lag as `du` recursively goes through the directory.
|
50
|
+
|
51
|
+
**check-file-exists**
|
52
|
+
Checks whether alerting is functioning as designed. Can be set to check for the existence of any file for which you have read-level permissions. Looks in `/tmp` folder for the files CRITICAL, WARNING, or UNKNOWN and if any are found, sends the corresponding status to Sensu (otherwise, sends an "ok"). This allows you to send an alert for something like `touch /tmp/CRITICAL` and then set it ok again with `rm /tmp/CRITICAL`. Supports globbing for basic wildcard matching. Wildcard charaters must be quoted or escaped to prevent shell expansion.
|
53
|
+
|
54
|
+
**check-file-size**
|
55
|
+
Checks the file size of a given file. Includes optional command line parameters to ignore missing files.
|
56
|
+
|
57
|
+
**check-fs-writable**
|
58
|
+
Checks that a filesystem is writable. Useful for checking for stale NFS mounts.
|
59
|
+
|
60
|
+
**check-mtime**
|
61
|
+
Checks a given file's modified time.
|
62
|
+
|
63
|
+
**check-tail**
|
64
|
+
Checks the tail of a file for a given patten and sends critical (or optional warning) message if found. Alternatively, failure can be triggered when the pattern is not found by passing the 'absent' flag.
|
65
|
+
|
66
|
+
**metrics-dirsize**
|
67
|
+
Provides a simple wrapper around `du` for getting directory size stats in real size, apparent size, and inodes (when supported).
|
68
|
+
|
69
|
+
**metrics-filesize**
|
70
|
+
Provies a simple wrapper around `stat` for getting file size stats in both in both, bytes and blocks.
|
71
|
+
|
72
|
+
**metrics-nfsstat**
|
73
|
+
Provides a simple wrapper around `nfsstat` for getting nfs server/client stats.
|
74
|
+
|
75
|
+
## Usage examples
|
76
|
+
|
77
|
+
### Help
|
78
|
+
|
79
|
+
**check-dir-count.rb**
|
80
|
+
```
|
81
|
+
Usage: check-dir-count.rb (options)
|
82
|
+
-c, --critical NUM Critical if count of files is greater than provided number (required)
|
83
|
+
-d, --dir DIR Directory to count files in (required)
|
84
|
+
-w, --warning NUM Warn if count of files is greater than provided number (required)
|
85
|
+
```
|
86
|
+
|
87
|
+
**metrics-dirsize.rb**
|
88
|
+
```
|
89
|
+
Usage: metrics-dirsize.rb (options)
|
90
|
+
-a, --apparent Report apparent size (bytes) (required)
|
91
|
+
-d, --dir PATH Absolute path to directory to measure (required)
|
92
|
+
-i, --inodes Report inodes used instead of bytes. Not all Linux distributions support this. (required)
|
93
|
+
-r, --real Report real size (bytes) (required)
|
94
|
+
-s, --scheme SCHEME Metric naming scheme, text to prepend to metric (required)
|
95
|
+
```
|
96
|
+
|
97
|
+
## Configuration
|
98
|
+
### Sensu Go
|
99
|
+
#### Asset registration
|
100
|
+
|
101
|
+
Assets 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 or later, you can use the following command to add the asset:
|
102
|
+
|
103
|
+
`sensuctl asset add sensu-plugins/sensu-plugins-logs`
|
104
|
+
|
105
|
+
If you're using an earlier version of sensuctl, you can download the asset definition from [this project's Bonsai asset index page](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-logs).
|
106
|
+
|
107
|
+
#### Asset definition
|
108
|
+
|
109
|
+
```yaml
|
110
|
+
---
|
111
|
+
type: Asset
|
112
|
+
api_version: core/v2
|
113
|
+
metadata:
|
114
|
+
name: sensu-plugins-filesystem-checks
|
115
|
+
spec:
|
116
|
+
url: https://assets.bonsai.sensu.io/ccce3fd9dd55770aeadd5034b674b763945454ac/sensu-plugins-filesystem-checks_2.0.0_centos_linux_amd64.tar.gz
|
117
|
+
sha512: ecac91a77c2e27bb650dcb61a64d62fa92e98ffa1e754008b6b9bd94bf8e6c8862bdaf40ccf65447dd8be5e037acacb3fc2d20e39519167da05b55b0b9c3e880
|
118
|
+
```
|
119
|
+
|
120
|
+
#### Check definition
|
121
|
+
|
122
|
+
```yaml
|
123
|
+
---
|
124
|
+
type: CheckConfig
|
125
|
+
spec:
|
126
|
+
command: "check-dir-count.rb"
|
127
|
+
handlers: []
|
128
|
+
high_flap_threshold: 0
|
129
|
+
interval: 10
|
130
|
+
low_flap_threshold: 0
|
131
|
+
publish: true
|
132
|
+
runtime_assets:
|
133
|
+
- sensu-plugins/sensu-plugins-filesystem-checks
|
134
|
+
- sensu/sensu-ruby-runtime
|
135
|
+
subscriptions:
|
136
|
+
- linux
|
137
|
+
```
|
138
|
+
|
139
|
+
### Sensu Core
|
140
|
+
|
141
|
+
#### Check definition
|
142
|
+
```json
|
143
|
+
{
|
144
|
+
"checks": {
|
145
|
+
"check-dir-count": {
|
146
|
+
"command": "check-dir-count.rb",
|
147
|
+
"subscribers": ["linux"],
|
148
|
+
"interval": 10,
|
149
|
+
"refresh": 10,
|
150
|
+
"handlers": ["influxdb"]
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
```
|
155
|
+
|
156
|
+
## Installation from source
|
157
|
+
|
158
|
+
### Sensu Go
|
159
|
+
|
160
|
+
See the instructions above for [asset registration](#asset-registration).
|
161
|
+
|
162
|
+
### Sensu Core
|
163
|
+
|
164
|
+
Install and setup plugins on [Sensu Core](https://docs.sensu.io/sensu-core/latest/installation/installing-plugins/).
|
165
|
+
|
166
|
+
## Additional notes
|
23
167
|
|
24
|
-
|
168
|
+
### Sensu Go Ruby Runtime Assets
|
25
169
|
|
26
|
-
|
170
|
+
The Sensu assets packaged from this repository are built against the Sensu Ruby runtime environment. When using these assets as part of a Sensu Go resource (check, mutator, or handler), make sure to include the corresponding [Sensu Ruby Runtime Asset](https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime) in the list of assets needed by the resource.
|
27
171
|
|
28
|
-
|
172
|
+
## Contributing
|
29
173
|
|
30
|
-
|
174
|
+
See [CONTRIBUTING.md](https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/blob/master/CONTRIBUTING.md) for information about contributing to this plugin.
|
data/bin/check-checksums.rb
CHANGED
@@ -59,11 +59,11 @@ class Checksum < Sensu::Plugin::Check::CLI
|
|
59
59
|
unknown 'We have nothing to compare this file with.'
|
60
60
|
end
|
61
61
|
|
62
|
-
if config[:hashfile]
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
hash = if config[:hashfile]
|
63
|
+
IO.read(config[:hashfile]).chomp
|
64
|
+
else
|
65
|
+
config[:hash] || Digest::SHA2.file(files.first).hexdigest
|
66
|
+
end
|
67
67
|
|
68
68
|
errors = []
|
69
69
|
|
data/bin/check-ctime.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-ctime
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin checks a given file's created time.
|
7
|
+
# If a directory is passed in, it will get the oldest
|
8
|
+
# file in the directory.
|
9
|
+
#
|
10
|
+
# This is useful when checking to see if a file or
|
11
|
+
# directory is being cleared out.
|
12
|
+
#
|
13
|
+
# OUTPUT:
|
14
|
+
# plain text
|
15
|
+
#
|
16
|
+
# PLATFORMS:
|
17
|
+
# Linux, Windows
|
18
|
+
#
|
19
|
+
# DEPENDENCIES:
|
20
|
+
# gem: sensu-plugin
|
21
|
+
#
|
22
|
+
# USAGE:
|
23
|
+
# LINUX
|
24
|
+
# /opt/sensu/embedded/bin/check-ctime.rb -f /path/to/myFile.txt -w 600
|
25
|
+
# /opt/sensu/embedded/bin/check-ctime.rb -d /path/to/myDirectory -w 600 -e
|
26
|
+
#
|
27
|
+
# WINDOWS
|
28
|
+
# * Use forward slashes for path!!
|
29
|
+
# c:/opt/sensu/embedded/bin/ruby c:/opt/sensu/embedded/bin/check-ctime.rb -f c:/path/to/myFile.txt -w 600
|
30
|
+
# c:/opt/sensu/embedded/bin/ruby c:/opt/sensu/embedded/bin/check-ctime.rb -d c:/path/to/myDirectory -w 600 -e
|
31
|
+
#
|
32
|
+
# NOTES:
|
33
|
+
#
|
34
|
+
# LICENSE:
|
35
|
+
# Copyright 2014 Sonian, Inc. and contributors.
|
36
|
+
# <support@sensuapp.org> and <landon.dao@ge.com>
|
37
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
38
|
+
# for details.
|
39
|
+
#
|
40
|
+
|
41
|
+
require 'sensu-plugin/check/cli'
|
42
|
+
require 'fileutils'
|
43
|
+
|
44
|
+
class Ctime < Sensu::Plugin::Check::CLI
|
45
|
+
option :file,
|
46
|
+
description: 'File (or directory) to check created time',
|
47
|
+
short: '-f FILE',
|
48
|
+
long: '--file FILE'
|
49
|
+
|
50
|
+
option :directory,
|
51
|
+
description: 'Directory to check oldest file created time',
|
52
|
+
short: '-d DIRECTORY',
|
53
|
+
long: '--directory DIRECTORY'
|
54
|
+
|
55
|
+
option :warn,
|
56
|
+
description: 'Warn if ctime greater than provided age in seconds',
|
57
|
+
short: '-w SECONDS',
|
58
|
+
long: '--warning SECONDS'
|
59
|
+
|
60
|
+
option :crit,
|
61
|
+
description: 'Critical if ctime greater than provided age in seconds',
|
62
|
+
short: '-c SECONDS',
|
63
|
+
long: '--critical SECONDS'
|
64
|
+
|
65
|
+
option :exclude_directories,
|
66
|
+
description: 'Ignores directories (used when passing in a directory)',
|
67
|
+
short: '-e',
|
68
|
+
long: '--exclude-directories',
|
69
|
+
boolean: true,
|
70
|
+
default: false
|
71
|
+
|
72
|
+
option :ok_no_exist,
|
73
|
+
description: 'OK if file does not exist',
|
74
|
+
short: '-o',
|
75
|
+
long: '--ok-no-exist',
|
76
|
+
boolean: true,
|
77
|
+
default: false
|
78
|
+
|
79
|
+
def run
|
80
|
+
unknown 'No file or directory specified' unless config[:file] || config[:directory]
|
81
|
+
unknown 'No warn or critical age specified' unless config[:warn] || config[:crit]
|
82
|
+
|
83
|
+
requested_files = if config[:file]
|
84
|
+
Dir.glob(config[:file])
|
85
|
+
elsif config[:directory]
|
86
|
+
Dir.glob(config[:directory] + '/*')
|
87
|
+
end
|
88
|
+
|
89
|
+
if !requested_files.empty?
|
90
|
+
if config[:directory] && config[:exclude_directories]
|
91
|
+
requested_files = requested_files.reject { |f| File.directory?(f) }
|
92
|
+
end
|
93
|
+
|
94
|
+
# Gets oldest file by creation time
|
95
|
+
oldest_file = requested_files.min_by { |f| File.ctime f }
|
96
|
+
age = Time.now.to_i - File.ctime(oldest_file).to_i
|
97
|
+
|
98
|
+
critical "file is #{age - config[:crit].to_i} seconds past critical" if config[:crit] && age >= config[:crit].to_i
|
99
|
+
warning "file is #{age - config[:warn].to_i} seconds past warning" if config[:warn] && age >= config[:warn].to_i
|
100
|
+
ok "file is #{age} seconds old"
|
101
|
+
elsif config[:ok_no_exist]
|
102
|
+
ok 'file does not exist'
|
103
|
+
else
|
104
|
+
critical 'file not found'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/bin/check-dir-size.rb
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
# [-w|--warn] <size, in bytes, to warn on>
|
25
25
|
# [-c|--critical] <size, in bytes, to go CRITICAL on>
|
26
26
|
# [-p|--du-path] <path/to/du>
|
27
|
-
# [--
|
27
|
+
# [--ignore-missing]
|
28
28
|
#
|
29
29
|
# EXAMPLE:
|
30
30
|
# check-dir-size.rb /var/spool/example_dir -w 1500000 -c 2000000
|
data/bin/check-file-exists.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
2
3
|
#
|
3
4
|
# check-file-exists
|
4
5
|
#
|
@@ -18,6 +19,9 @@
|
|
18
19
|
# And then set it ok again with:
|
19
20
|
# rm /tmp/CRITICAL
|
20
21
|
#
|
22
|
+
# Supports globbing for basic wildcard matching
|
23
|
+
# Wildcard charaters must be quoted or escaped to prevent shell expansion
|
24
|
+
#
|
21
25
|
# OUTPUT:
|
22
26
|
# plain text
|
23
27
|
#
|
@@ -54,14 +58,30 @@ class CheckFileExists < Sensu::Plugin::Check::CLI
|
|
54
58
|
default: '/tmp/UNKNOWN'
|
55
59
|
|
56
60
|
def run
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
critical_values = []
|
62
|
+
warning_values = []
|
63
|
+
unknown_values = []
|
64
|
+
|
65
|
+
Dir.glob(config[:critical]).each do |file|
|
66
|
+
critical_values << file
|
67
|
+
end
|
68
|
+
|
69
|
+
Dir.glob(config[:warning]).each do |file|
|
70
|
+
warning_values << file
|
71
|
+
end
|
72
|
+
|
73
|
+
Dir.glob(config[:unknown]).each do |file|
|
74
|
+
unknown_values << file
|
75
|
+
end
|
76
|
+
|
77
|
+
if critical_values.any?
|
78
|
+
critical "#{critical_values.count} matching file(s) found: #{critical_values.join(', ')}"
|
79
|
+
elsif warning_values.any?
|
80
|
+
warning "#{warning_values.count} matching file(s) found: #{warning_values.join(', ')}"
|
81
|
+
elsif unknown_values.any?
|
82
|
+
unknown "#{unknown_values.count} matching file(s) found: #{unknown_values.join(', ')}"
|
63
83
|
else
|
64
|
-
ok 'No
|
84
|
+
ok 'No matching files found'
|
65
85
|
end
|
66
86
|
end
|
67
87
|
end
|
data/bin/check-fs-writable.rb
CHANGED
@@ -77,7 +77,7 @@ class CheckFSWritable < Sensu::Plugin::Check::CLI
|
|
77
77
|
def acquire_mnt_pts
|
78
78
|
mnt_pts = []
|
79
79
|
vol_groups = acquire_vol_groups.split("\n")
|
80
|
-
vol_groups.each
|
80
|
+
vol_groups.each do |vol_group|
|
81
81
|
`grep #{vol_group} /proc/self/mounts | awk '{print $2, $4}' | awk -F, '{print $1}' | awk '{print $1, $2}'`.split("\n").each do |mnt|
|
82
82
|
mnt_pts << mnt
|
83
83
|
end
|
@@ -88,8 +88,8 @@ class CheckFSWritable < Sensu::Plugin::Check::CLI
|
|
88
88
|
# Does proc list the mount point as rw
|
89
89
|
#
|
90
90
|
def rw_in_proc?(mount_info)
|
91
|
-
mount_info.each
|
92
|
-
@crit_pt_proc <<
|
91
|
+
mount_info.each do |pt|
|
92
|
+
@crit_pt_proc << pt.split[0].to_s if pt.split[1] != 'rw'
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -99,13 +99,13 @@ class CheckFSWritable < Sensu::Plugin::Check::CLI
|
|
99
99
|
#
|
100
100
|
def rw_test?(mount_info)
|
101
101
|
mount_info.each do |pt|
|
102
|
-
(Dir.exist? pt.split[0]) || (@crit_pt_test <<
|
102
|
+
(Dir.exist? pt.split[0]) || (@crit_pt_test << pt.split[0].to_s)
|
103
103
|
file = Tempfile.new('.sensu', pt.split[0])
|
104
104
|
puts "The temp file we are writing to is: #{file.path}" if config[:debug]
|
105
105
|
# #YELLOW
|
106
106
|
# need to add a check here to validate permissions, if none it pukes
|
107
|
-
file.write('mops') || @crit_pt_test <<
|
108
|
-
file.read || @crit_pt_test <<
|
107
|
+
file.write('mops') || @crit_pt_test << pt.split[0].to_s
|
108
|
+
file.read || @crit_pt_test << pt.split[0].to_s
|
109
109
|
file.close
|
110
110
|
file.unlink
|
111
111
|
end
|
@@ -133,13 +133,13 @@ class CheckFSWritable < Sensu::Plugin::Check::CLI
|
|
133
133
|
#
|
134
134
|
def manual_test
|
135
135
|
config[:dir].each do |d|
|
136
|
-
(Dir.exist? d) || (@crit_pt_test <<
|
136
|
+
(Dir.exist? d) || (@crit_pt_test << d.to_s)
|
137
137
|
file = Tempfile.new('.sensu', d)
|
138
138
|
puts "The temp file we are writing to is: #{file.path}" if config[:debug]
|
139
139
|
# #YELLOW
|
140
140
|
# need to add a check here to validate permissions, if none it pukes
|
141
|
-
file.write('mops') || @crit_pt_test <<
|
142
|
-
file.read || @crit_pt_test <<
|
141
|
+
file.write('mops') || @crit_pt_test << d.to_s
|
142
|
+
file.read || @crit_pt_test << d.to_s
|
143
143
|
file.close
|
144
144
|
file.unlink
|
145
145
|
end
|
data/bin/check-tail.rb
CHANGED
@@ -76,7 +76,7 @@ class Tail < Sensu::Plugin::Check::CLI
|
|
76
76
|
if pattern_match?
|
77
77
|
send(
|
78
78
|
# #YELLOW
|
79
|
-
config[:warn_only] ? :warning : :critical,
|
79
|
+
config[:warn_only] ? :warning : :critical, # rubocop:disable BlockNesting
|
80
80
|
"Pattern matched: #{config[:pattern]}"
|
81
81
|
)
|
82
82
|
else
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# metrics-dirsize
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
6
|
# Simple wrapper around `du` for getting directory size stats,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# gem: sensu-plugin
|
19
19
|
#
|
20
20
|
# USAGE:
|
21
|
-
#
|
21
|
+
# metrics-dirsize.rb --dir /var/backups/postgres/ --real
|
22
22
|
#
|
23
23
|
# NOTES:
|
24
24
|
#
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# metrics-nfsstat
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Simple wrapper around `nfsstat` for getting nfs server/client stats.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# metric data
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
#
|
17
|
+
# USAGE:
|
18
|
+
#
|
19
|
+
# NOTES:
|
20
|
+
#
|
21
|
+
# LICENSE:
|
22
|
+
# Copyright 2016 Mitsutoshi Aoe
|
23
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
24
|
+
# for details.
|
25
|
+
#
|
26
|
+
|
27
|
+
require 'socket'
|
28
|
+
require 'sensu-plugin/metric/cli'
|
29
|
+
|
30
|
+
class NfsstatMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
31
|
+
option :scheme,
|
32
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
33
|
+
short: '-s SCHEME',
|
34
|
+
long: '--scheme SCHEME',
|
35
|
+
default: "#{Socket.gethostname}.nfsstat"
|
36
|
+
|
37
|
+
def run
|
38
|
+
begin
|
39
|
+
output = `/usr/sbin/nfsstat -l`
|
40
|
+
rescue Errno::ENOENT => err
|
41
|
+
unknown err
|
42
|
+
end
|
43
|
+
|
44
|
+
output.each_line do |line|
|
45
|
+
next unless /^nfs\s+(.+):\s+(\d+)/ =~ line
|
46
|
+
key = Regexp.last_match[1].split.join('.')
|
47
|
+
val = Regexp.last_match[2].to_i
|
48
|
+
output "#{config[:scheme]}.#{key}", val
|
49
|
+
end
|
50
|
+
|
51
|
+
ok
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,65 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-filesystem-checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
14
|
-
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
15
|
-
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
16
|
-
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
17
|
-
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
18
|
-
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
19
|
-
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
20
|
-
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
21
|
-
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
22
|
-
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
23
|
-
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
-
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
25
|
-
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
26
|
-
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
27
|
-
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
28
|
-
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
-
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
-
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
-
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
-
-----END CERTIFICATE-----
|
33
|
-
date: 2015-08-05 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
34
12
|
dependencies:
|
35
13
|
- !ruby/object:Gem::Dependency
|
36
14
|
name: sensu-plugin
|
37
15
|
requirement: !ruby/object:Gem::Requirement
|
38
16
|
requirements:
|
39
|
-
- -
|
17
|
+
- - "~>"
|
40
18
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
19
|
+
version: '4.0'
|
42
20
|
type: :runtime
|
43
21
|
prerelease: false
|
44
22
|
version_requirements: !ruby/object:Gem::Requirement
|
45
23
|
requirements:
|
46
|
-
- -
|
24
|
+
- - "~>"
|
47
25
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
26
|
+
version: '4.0'
|
49
27
|
- !ruby/object:Gem::Dependency
|
50
28
|
name: bundler
|
51
29
|
requirement: !ruby/object:Gem::Requirement
|
52
30
|
requirements:
|
53
31
|
- - "~>"
|
54
32
|
- !ruby/object:Gem::Version
|
55
|
-
version: '1
|
33
|
+
version: '2.1'
|
56
34
|
type: :development
|
57
35
|
prerelease: false
|
58
36
|
version_requirements: !ruby/object:Gem::Requirement
|
59
37
|
requirements:
|
60
38
|
- - "~>"
|
61
39
|
- !ruby/object:Gem::Version
|
62
|
-
version: '1
|
40
|
+
version: '2.1'
|
63
41
|
- !ruby/object:Gem::Dependency
|
64
42
|
name: codeclimate-test-reporter
|
65
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,14 +58,14 @@ dependencies:
|
|
80
58
|
requirements:
|
81
59
|
- - "~>"
|
82
60
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
61
|
+
version: '3.0'
|
84
62
|
type: :development
|
85
63
|
prerelease: false
|
86
64
|
version_requirements: !ruby/object:Gem::Requirement
|
87
65
|
requirements:
|
88
66
|
- - "~>"
|
89
67
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
68
|
+
version: '3.0'
|
91
69
|
- !ruby/object:Gem::Dependency
|
92
70
|
name: pry
|
93
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,14 +86,14 @@ dependencies:
|
|
108
86
|
requirements:
|
109
87
|
- - "~>"
|
110
88
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
89
|
+
version: '12.3'
|
112
90
|
type: :development
|
113
91
|
prerelease: false
|
114
92
|
version_requirements: !ruby/object:Gem::Requirement
|
115
93
|
requirements:
|
116
94
|
- - "~>"
|
117
95
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
96
|
+
version: '12.3'
|
119
97
|
- !ruby/object:Gem::Dependency
|
120
98
|
name: redcarpet
|
121
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,16 +126,16 @@ dependencies:
|
|
148
126
|
name: rubocop
|
149
127
|
requirement: !ruby/object:Gem::Requirement
|
150
128
|
requirements:
|
151
|
-
- -
|
129
|
+
- - "~>"
|
152
130
|
- !ruby/object:Gem::Version
|
153
|
-
version: 0.
|
131
|
+
version: 0.40.0
|
154
132
|
type: :development
|
155
133
|
prerelease: false
|
156
134
|
version_requirements: !ruby/object:Gem::Requirement
|
157
135
|
requirements:
|
158
|
-
- -
|
136
|
+
- - "~>"
|
159
137
|
- !ruby/object:Gem::Version
|
160
|
-
version: 0.
|
138
|
+
version: 0.40.0
|
161
139
|
- !ruby/object:Gem::Dependency
|
162
140
|
name: yard
|
163
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,19 +150,24 @@ dependencies:
|
|
172
150
|
- - "~>"
|
173
151
|
- !ruby/object:Gem::Version
|
174
152
|
version: '0.8'
|
175
|
-
description:
|
153
|
+
description: |-
|
154
|
+
This plugin provides native instrumentation for monitoring and metrics
|
155
|
+
collection, including:health, usage, and various metrics of filesystem
|
156
|
+
attributes.
|
176
157
|
email: "<sensu-users@googlegroups.com>"
|
177
158
|
executables:
|
178
|
-
- metric-filesize.rb
|
179
|
-
- metric-dirsize.rb
|
180
|
-
- check-tail.rb
|
181
|
-
- check-mtime.rb
|
182
|
-
- check-fs-writable.rb
|
183
|
-
- check-file-size.rb
|
184
|
-
- check-file-exists.rb
|
185
159
|
- check-dir-size.rb
|
160
|
+
- check-ctime.rb
|
161
|
+
- check-file-exists.rb
|
186
162
|
- check-dir-count.rb
|
163
|
+
- check-fs-writable.rb
|
187
164
|
- check-checksums.rb
|
165
|
+
- metrics-dirsize.rb
|
166
|
+
- metrics-filesize.rb
|
167
|
+
- check-mtime.rb
|
168
|
+
- check-tail.rb
|
169
|
+
- check-file-size.rb
|
170
|
+
- metrics-nfsstat.rb
|
188
171
|
extensions: []
|
189
172
|
extra_rdoc_files: []
|
190
173
|
files:
|
@@ -192,6 +175,7 @@ files:
|
|
192
175
|
- LICENSE
|
193
176
|
- README.md
|
194
177
|
- bin/check-checksums.rb
|
178
|
+
- bin/check-ctime.rb
|
195
179
|
- bin/check-dir-count.rb
|
196
180
|
- bin/check-dir-size.rb
|
197
181
|
- bin/check-file-exists.rb
|
@@ -199,8 +183,9 @@ files:
|
|
199
183
|
- bin/check-fs-writable.rb
|
200
184
|
- bin/check-mtime.rb
|
201
185
|
- bin/check-tail.rb
|
202
|
-
- bin/
|
203
|
-
- bin/
|
186
|
+
- bin/metrics-dirsize.rb
|
187
|
+
- bin/metrics-filesize.rb
|
188
|
+
- bin/metrics-nfsstat.rb
|
204
189
|
- lib/sensu-plugins-filesystem-checks.rb
|
205
190
|
- lib/sensu-plugins-filesystem-checks/version.rb
|
206
191
|
homepage: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks
|
@@ -221,15 +206,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
206
|
requirements:
|
222
207
|
- - ">="
|
223
208
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
209
|
+
version: '2.3'
|
225
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
211
|
requirements:
|
227
212
|
- - ">="
|
228
213
|
- !ruby/object:Gem::Version
|
229
214
|
version: '0'
|
230
215
|
requirements: []
|
231
|
-
|
232
|
-
rubygems_version: 2.4.8
|
216
|
+
rubygems_version: 3.0.8
|
233
217
|
signing_key:
|
234
218
|
specification_version: 4
|
235
219
|
summary: Sensu plugins for filesystems
|
checksums.yaml.gz.sig
DELETED
data.tar.gz.sig
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
���1:;�3��q�'=SK��5�:n���G�a�Hu�p���lH/��=2qJ�"��4�!{1�:�`.��2ˈ�C�Z+(DT1=��{j� .�X� 9��Axm{o��)a��
|
metadata.gz.sig
DELETED
Binary file
|