sensu-plugins-filesystem-checks 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +151 -11
- data/bin/check-ctime.rb +107 -0
- data/lib/sensu-plugins-filesystem-checks/version.rb +1 -1
- metadata +15 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01c081f5d9339af42084c7e2fa126dd4f33e3d3c174647d6a9067e6770b8d52b
|
4
|
+
data.tar.gz: '080eaf108f3fb46ad0c5188313477302c4e1e94ef7ae4aa065a28a413fd677f8'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eea798999fe5a7256ee77b4747f85696939417cabee02d54f20792869b4a533b43280e57e2c6813f1efcc94d9190188349f326cbf2a20294592d2194f047d2b
|
7
|
+
data.tar.gz: 24991ed0cc343922c6c9aacb350183bf0c663c4665be3cc4e1c1145077fee16aa3a20bba80d8160a3142480d2d933baacb92587fd6d96270a449952764c2a6e3
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,15 @@ 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
|
+
### Added
|
7
|
+
- Added 'check-ctime.rb' for checking the file created time (@landondao1)
|
8
|
+
|
6
9
|
## [Unreleased]
|
7
10
|
|
11
|
+
## [2.1.0] - 2020-07-16
|
12
|
+
### Added
|
13
|
+
- Updated asset build targets to support centos6
|
14
|
+
|
8
15
|
## [2.0.0] - 2019-05-07
|
9
16
|
### Breaking Changes
|
10
17
|
- Update minimum required ruby version to 2.3. Drop unsupported ruby versions.
|
@@ -56,7 +63,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
56
63
|
### Added
|
57
64
|
- initial release
|
58
65
|
|
59
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/2.
|
66
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/2.1.0...HEAD
|
67
|
+
[2.1.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/2.0.0...2.1.0
|
60
68
|
[2.0.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/1.0.0...2.0.0
|
61
69
|
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.4...1.0.0
|
62
70
|
[0.1.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.3...0.0.4
|
data/README.md
CHANGED
@@ -1,19 +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
|
-
[![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)
|
9
7
|
|
10
|
-
## Sensu
|
11
|
-
|
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
|
12
25
|
|
13
|
-
|
26
|
+
This plugin provides native instrumentation for monitoring and metrics collection, including health, usage, and various metrics of filesystem attributes.
|
14
27
|
|
15
|
-
|
28
|
+
### Files
|
16
29
|
* bin/check-checksums.rb
|
30
|
+
* bin/check-ctime.rb
|
17
31
|
* bin/check-dir-count.rb
|
18
32
|
* bin/check-dir-size.rb
|
19
33
|
* bin/check-file-exists.rb
|
@@ -24,11 +38,137 @@
|
|
24
38
|
* bin/metrics-dirsize.rb
|
25
39
|
* bin/metrics-filesize.rb
|
26
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
|
27
167
|
|
28
|
-
|
168
|
+
### Sensu Go Ruby Runtime Assets
|
29
169
|
|
30
|
-
|
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.
|
31
171
|
|
32
|
-
|
172
|
+
## Contributing
|
33
173
|
|
34
|
-
|
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-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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-filesystem-checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
33
|
+
version: '2.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
40
|
+
version: '2.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: codeclimate-test-reporter
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,17 +156,18 @@ description: |-
|
|
156
156
|
attributes.
|
157
157
|
email: "<sensu-users@googlegroups.com>"
|
158
158
|
executables:
|
159
|
-
-
|
159
|
+
- check-dir-size.rb
|
160
|
+
- check-ctime.rb
|
161
|
+
- check-file-exists.rb
|
162
|
+
- check-dir-count.rb
|
160
163
|
- check-fs-writable.rb
|
161
|
-
- check-file-size.rb
|
162
|
-
- metrics-dirsize.rb
|
163
|
-
- check-tail.rb
|
164
164
|
- check-checksums.rb
|
165
|
-
-
|
165
|
+
- metrics-dirsize.rb
|
166
166
|
- metrics-filesize.rb
|
167
|
-
- check-dir-count.rb
|
168
|
-
- check-dir-size.rb
|
169
167
|
- check-mtime.rb
|
168
|
+
- check-tail.rb
|
169
|
+
- check-file-size.rb
|
170
|
+
- metrics-nfsstat.rb
|
170
171
|
extensions: []
|
171
172
|
extra_rdoc_files: []
|
172
173
|
files:
|
@@ -174,6 +175,7 @@ files:
|
|
174
175
|
- LICENSE
|
175
176
|
- README.md
|
176
177
|
- bin/check-checksums.rb
|
178
|
+
- bin/check-ctime.rb
|
177
179
|
- bin/check-dir-count.rb
|
178
180
|
- bin/check-dir-size.rb
|
179
181
|
- bin/check-file-exists.rb
|
@@ -211,7 +213,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
213
|
- !ruby/object:Gem::Version
|
212
214
|
version: '0'
|
213
215
|
requirements: []
|
214
|
-
|
216
|
+
rubyforge_project:
|
217
|
+
rubygems_version: 2.7.7
|
215
218
|
signing_key:
|
216
219
|
specification_version: 4
|
217
220
|
summary: Sensu plugins for filesystems
|