sensu-plugins-filesystem-checks 0.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bf30978522e96e61fd63a7207cd9fd8af9b9f4c4
4
- data.tar.gz: e58cdfc8263fff11f0d25ea34cb39a5bae1546b7
2
+ SHA256:
3
+ metadata.gz: 01c081f5d9339af42084c7e2fa126dd4f33e3d3c174647d6a9067e6770b8d52b
4
+ data.tar.gz: '080eaf108f3fb46ad0c5188313477302c4e1e94ef7ae4aa065a28a413fd677f8'
5
5
  SHA512:
6
- metadata.gz: beb4b58f755e8c9c4b9c51233899b4f656fc97121c1b0cdf096aabdfe98437406d876cdf22ec6867d87ee2307fe344d091069c97ad8fa49212b540ed4d50bc8d
7
- data.tar.gz: f581c11eb41b5cb660ac615b5cf9eeb074473f28d81796db8ad03bbf6b0a144f80b186e643c787577bd9a932387e07955355597f0a8f71b794580ff04567cf1e
6
+ metadata.gz: 7eea798999fe5a7256ee77b4747f85696939417cabee02d54f20792869b4a533b43280e57e2c6813f1efcc94d9190188349f326cbf2a20294592d2194f047d2b
7
+ data.tar.gz: 24991ed0cc343922c6c9aacb350183bf0c663c4665be3cc4e1c1145077fee16aa3a20bba80d8160a3142480d2d933baacb92587fd6d96270a449952764c2a6e3
@@ -3,10 +3,42 @@ 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
- ## [Unreleased][unreleased]
7
- - nothing
6
+ ### Added
7
+ - Added 'check-ctime.rb' for checking the file created time (@landondao1)
8
+
9
+ ## [Unreleased]
10
+
11
+ ## [2.1.0] - 2020-07-16
12
+ ### Added
13
+ - Updated asset build targets to support centos6
14
+
15
+ ## [2.0.0] - 2019-05-07
16
+ ### Breaking Changes
17
+ - Update minimum required ruby version to 2.3. Drop unsupported ruby versions.
18
+ - 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)
19
+
20
+ ### Added
21
+ - Added testing on Ruby 2.4.1 (@portertech)
22
+ - 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
23
+ - Require latest sensu-plugin for [Sensu Go support](https://github.com/sensu-plugins/sensu-plugin#sensu-go-enablement)
24
+
25
+ ## [1.0.0] - 2017-07-01
26
+ ### Added
27
+ - Added testing on Ruby 2.3.0 (@Evesy)
28
+ - Added support for globbing in 'check-file-exists.rb' (@Evesy)
29
+ - Added 'metrics-nfsstat.rb' for collecting nfsstat metrics (@maoe)
30
+
31
+ ### Breaking Changes
32
+ - Dropped Ruby 1.9 support
8
33
 
9
- ## [0.0.4] - 2015-08-04
34
+ ### Changed
35
+ - Renamed metric-{dirsize,filename} to metrics-{dirsize,filename}
36
+
37
+ ## [0.1.0] - 2015-08-04
38
+ ### Added
39
+ - Added new checks for file and directory size
40
+
41
+ ## [0.0.4] - 2015-08-04 (Pulled)
10
42
  ### Changed
11
43
  - Added 'check-dir-size.rb' for checking the total size of a directory
12
44
  - Recommited 'check-file-size.rb' from previous repo, with a couple of updates
@@ -30,3 +62,12 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
30
62
  ## 0.0.1 - [2015-04-30]
31
63
  ### Added
32
64
  - initial release
65
+
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
68
+ [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/1.0.0...2.0.0
69
+ [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.4...1.0.0
70
+ [0.1.0]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.3...0.0.4
71
+ [0.0.4]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.3...0.0.4
72
+ [0.0.3]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.2...0.0.3
73
+ [0.0.2]: https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/compare/0.0.1...0.0.2
data/README.md CHANGED
@@ -1,28 +1,174 @@
1
- ## Sensu-Plugins-filesystem-checks
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
- ## Functionality
8
+ ## Sensu Plugins Filesystem Checks Plugin
11
9
 
12
- ## Files
13
- * bin/check-dir-count.rb
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
25
+
26
+ This plugin provides native instrumentation for monitoring and metrics collection, including health, usage, and various metrics of filesystem attributes.
27
+
28
+ ### Files
14
29
  * bin/check-checksums.rb
30
+ * bin/check-ctime.rb
31
+ * bin/check-dir-count.rb
32
+ * bin/check-dir-size.rb
15
33
  * bin/check-file-exists.rb
34
+ * bin/check-file-size.rb
16
35
  * bin/check-fs-writable.rb
17
36
  * bin/check-mtime.rb
18
37
  * bin/check-tail.rb
19
- * bin/metric-dirsize.rb
20
- * bin/metric-filesize.rb
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
21
167
 
22
- ## Usage
168
+ ### Sensu Go Ruby Runtime Assets
23
169
 
24
- ## Installation
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.
25
171
 
26
- [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
172
+ ## Contributing
27
173
 
28
- ## Notes
174
+ See [CONTRIBUTING.md](https://github.com/sensu-plugins/sensu-plugins-filesystem-checks/blob/master/CONTRIBUTING.md) for information about contributing to this plugin.
@@ -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
- hash = IO.read(config[:hashfile]).chomp
64
- else
65
- hash = config[:hash] || Digest::SHA2.file(files.first).hexdigest
66
- end
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
 
@@ -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
@@ -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
- # [--ignore_missing]
27
+ # [--ignore-missing]
28
28
  #
29
29
  # EXAMPLE:
30
30
  # check-dir-size.rb /var/spool/example_dir -w 1500000 -c 2000000
@@ -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
- if config[:critical] && File.exist?(config[:critical])
58
- critical "#{config[:critical]} exists!"
59
- elsif config[:warning] && File.exist?(config[:warning])
60
- warning "#{config[:warning]} exists!"
61
- elsif config[:unknown] && File.exist?(config[:unknown])
62
- unknown "#{config[:unknown]} exists!"
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 test files exist'
84
+ ok 'No matching files found'
65
85
  end
66
86
  end
67
87
  end
@@ -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 do |vol_group|
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 do |pt|
92
- @crit_pt_proc << "#{pt.split[0]}" if pt.split[1] != 'rw'
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 << "#{pt.split[0]}")
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 << "#{pt.split[0]}"
108
- file.read || @crit_pt_test << "#{pt.split[0]}"
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 << "#{d}")
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 << "#{d}"
142
- file.read || @crit_pt_test << "#{d}"
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
@@ -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, # rubocop:disable BlockNesting
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
- # metric-dirsize
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
- # metric-dirsize.rb --dir /var/backups/postgres/ --real
21
+ # metrics-dirsize.rb --dir /var/backups/postgres/ --real
22
22
  #
23
23
  # NOTES:
24
24
  #
@@ -1,6 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
2
  #
3
- # metric-filesize
3
+ # metrics-filesize
4
4
  #
5
5
  # DESCRIPTION:
6
6
  # Simple wrapper around `stat` for getting file size stats,
@@ -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
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsFilesystemChecks
2
2
  module Version
3
- MAJOR = 0
4
- MINOR = 0
5
- PATCH = 4
3
+ MAJOR = 2
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  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: 0.0.4
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
- 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-17 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: 1.2.0
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: 1.2.0
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.7'
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.7'
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: '1.3'
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: '1.3'
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: '10.0'
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: '10.0'
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.32.1
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.32.1
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: Sensu plugins for filesystems
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/metric-dirsize.rb
203
- - bin/metric-filesize.rb
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,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
206
  requirements:
222
207
  - - ">="
223
208
  - !ruby/object:Gem::Version
224
- version: 1.9.3
209
+ version: '2.3'
225
210
  required_rubygems_version: !ruby/object:Gem::Requirement
226
211
  requirements:
227
212
  - - ">="
@@ -229,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
214
  version: '0'
230
215
  requirements: []
231
216
  rubyforge_project:
232
- rubygems_version: 2.4.8
217
+ rubygems_version: 2.7.7
233
218
  signing_key:
234
219
  specification_version: 4
235
220
  summary: Sensu plugins for filesystems
Binary file
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- }�A��b�m�=_�]��o�ކ�HqV��p{M��re�=�:cUe2<@��%��k.��/`��ab��G�͞H&�0����7y��B���� ���<����a�>�!�S��{����rw�>m�
2
- ���c��7�Wk\C+��$M��u5��KX����>B<H���`�>�'&]6����mb�V註I���2���@a��kϘ��'.w|�<�8J� ɌU�P�qO�)���+����
metadata.gz.sig DELETED
Binary file