riemann-tools 1.12.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -3
  3. data/.github/workflows/codeql-analysis.yml +4 -4
  4. data/.rubocop.yml +1 -1
  5. data/CHANGELOG.md +53 -10
  6. data/Gemfile +1 -11
  7. data/README.markdown +4 -3
  8. data/lib/riemann/tools/apache_status.rb +1 -0
  9. data/lib/riemann/tools/bench.rb +1 -0
  10. data/lib/riemann/tools/cloudant.rb +1 -0
  11. data/lib/riemann/tools/haproxy.rb +1 -0
  12. data/lib/riemann/tools/health.rb +7 -5
  13. data/lib/riemann/tools/hwmon.rb +24 -7
  14. data/lib/riemann/tools/mdstat_parser.tab.rb +137 -127
  15. data/lib/riemann/tools/memcached.rb +1 -0
  16. data/lib/riemann/tools/nginx_status.rb +1 -0
  17. data/lib/riemann/tools/portcheck.rb +1 -0
  18. data/lib/riemann/tools/riemann_client_wrapper.rb +49 -6
  19. data/lib/riemann/tools/tls_check.rb +3 -1
  20. data/lib/riemann/tools/uptime_parser.tab.rb +1 -1
  21. data/lib/riemann/tools/version.rb +1 -1
  22. data/lib/riemann/tools/zookeeper.rb +1 -0
  23. data/lib/riemann/tools.rb +4 -1
  24. data/riemann-tools.gemspec +1 -1
  25. data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +1 -0
  26. data/tools/riemann-aws/lib/riemann/tools/aws/elb_metrics.rb +1 -0
  27. data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +1 -0
  28. data/tools/riemann-aws/lib/riemann/tools/aws/s3_list.rb +1 -0
  29. data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +1 -0
  30. data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +1 -0
  31. data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +1 -0
  32. data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +4 -4
  33. data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +3 -2
  34. data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +4 -4
  35. data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +4 -4
  36. data/tools/riemann-munin/lib/riemann/tools/munin.rb +1 -0
  37. data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +3 -3
  38. data/tools/riemann-riak/lib/riemann/tools/riak.rb +3 -2
  39. metadata +7 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 074d3c18c2108c352d43fec2b29ccff5f717a2369ee5649a61b91f9eaded3eaf
4
- data.tar.gz: bf6c07e31ce1723645429924e3ad9ae6a2500dd83495518038a40f33fab22fad
3
+ metadata.gz: c688bb624c4171f8baab09545f0be418766c717493f31ff1a13e3e9c20039786
4
+ data.tar.gz: 90d7c75b516dffb0c91201218349914cc6eb48718f99cbdc090f888a4a068d5c
5
5
  SHA512:
6
- metadata.gz: 1cedba2b8086abf960e954f26646049146cd3ba3fab037f612299a0754e6d60504dd9610f05b34a96c089a1f3312e93b936976143d50e500cf967ed0c4c48855
7
- data.tar.gz: c177966cf0e558ff52569d44f08bf1bfe9c07975cf7b01a3ee13aed71e30742186855943647cc7c3c74e24a3d6953cf3652cbffd42caed9ab7485abeb85745e3
6
+ metadata.gz: f5a1698690f11146fc1ebab73f6b5e7a6f0afcaef291eb8270032e8be142639f23a2ce34ceeb621d98a4294c083840137b2882d13cd1fc2615cd58faf2173638
7
+ data.tar.gz: 84eef56087c0d462d4f7f97f977cccb312cfcfa6431f071d2957ff0b99a471e71a208a85ee81f6ef3f4edb83eec03417eae5e20d50fbd6494cee4685dec6ed24
@@ -13,7 +13,7 @@ jobs:
13
13
  lint:
14
14
  runs-on: ubuntu-latest
15
15
  steps:
16
- - uses: actions/checkout@v4
16
+ - uses: actions/checkout@v6
17
17
  - name: Setup ruby
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
@@ -27,7 +27,6 @@ jobs:
27
27
  strategy:
28
28
  matrix:
29
29
  ruby-version:
30
- - '2.6'
31
30
  - '2.7'
32
31
  - '3.0'
33
32
  - '3.1'
@@ -35,7 +34,7 @@ jobs:
35
34
  - '3.3'
36
35
  - '3.4'
37
36
  steps:
38
- - uses: actions/checkout@v4
37
+ - uses: actions/checkout@v6
39
38
  - name: Setup Ruby
40
39
  uses: ruby/setup-ruby@v1
41
40
  with:
@@ -38,11 +38,11 @@ jobs:
38
38
 
39
39
  steps:
40
40
  - name: Checkout repository
41
- uses: actions/checkout@v4
41
+ uses: actions/checkout@v6
42
42
 
43
43
  # Initializes the CodeQL tools for scanning.
44
44
  - name: Initialize CodeQL
45
- uses: github/codeql-action/init@v3
45
+ uses: github/codeql-action/init@v4
46
46
  with:
47
47
  languages: ${{ matrix.language }}
48
48
  # If you wish to specify custom queries, you can do so here or in a config file.
@@ -56,7 +56,7 @@ jobs:
56
56
  # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57
57
  # If this step fails, then you should remove it and run the build manually (see below)
58
58
  - name: Autobuild
59
- uses: github/codeql-action/autobuild@v3
59
+ uses: github/codeql-action/autobuild@v4
60
60
 
61
61
  # ℹ️ Command-line programs to run using the OS shell.
62
62
  # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -69,4 +69,4 @@ jobs:
69
69
  # ./location_of_script_within_repo/buildscript.sh
70
70
 
71
71
  - name: Perform CodeQL Analysis
72
- uses: github/codeql-action/analyze@v3
72
+ uses: github/codeql-action/analyze@v4
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ AllCops:
4
4
  Exclude:
5
5
  - lib/riemann/tools/*_parser.tab.rb
6
6
  - vendor/bundle/**/*
7
- require:
7
+ plugins:
8
8
  - rubocop-rake
9
9
  - rubocop-rspec
10
10
  Gemspec/RequiredRubyVersion:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [v2.0.0](https://github.com/riemann/riemann-tools/tree/v2.0.0) (2026-05-28)
4
+
5
+ [Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.12.0...v2.0.0)
6
+
7
+ **Breaking changes:**
8
+
9
+ - Drop support for Ruby \< 2.7 [\#305](https://github.com/riemann/riemann-tools/pull/305) ([smortex](https://github.com/smortex))
10
+
11
+ **Implemented enhancements:**
12
+
13
+ - Ignore null-critical value for `riemann-hwmon` [\#307](https://github.com/riemann/riemann-tools/pull/307) ([smortex](https://github.com/smortex))
14
+ - Distinguish i2c devices in `riemann-hwmon` [\#306](https://github.com/riemann/riemann-tools/pull/306) ([smortex](https://github.com/smortex))
15
+ - Ignore `efivarfs` disks in `riemann-health` checks [\#304](https://github.com/riemann/riemann-tools/pull/304) ([smortex](https://github.com/smortex))
16
+
17
+ **Fixed bugs:**
18
+
19
+ - Fix `riemann-wrapper` connection sharing [\#315](https://github.com/riemann/riemann-tools/pull/315) ([smortex](https://github.com/smortex))
20
+ - Fix reporting of free disk space [\#314](https://github.com/riemann/riemann-tools/pull/314) ([smortex](https://github.com/smortex))
21
+ - Fix `riemann-md` not recognizing mdstat `auto-read-only` mode [\#312](https://github.com/riemann/riemann-tools/pull/312) ([smortex](https://github.com/smortex))
22
+ - Ignore invalid data in `riemann-hwmon` [\#303](https://github.com/riemann/riemann-tools/pull/303) ([smortex](https://github.com/smortex))
23
+
24
+ **Closed issues:**
25
+
26
+ - RFC: retire tools that monitor Mesos and related projects [\#311](https://github.com/riemann/riemann-tools/issues/311)
27
+
28
+ **Merged pull requests:**
29
+
30
+ - Mark Mesos monitoring tools as deprecated [\#313](https://github.com/riemann/riemann-tools/pull/313) ([l2dy](https://github.com/l2dy))
31
+
3
32
  ## [v1.12.0](https://github.com/riemann/riemann-tools/tree/v1.12.0) (2025-01-15)
4
33
 
5
34
  [Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.11.0...v1.12.0)
@@ -411,7 +440,7 @@
411
440
 
412
441
  - Send out "expired" state when riemann-net stops seeing an interface [\#114](https://github.com/riemann/riemann-tools/pull/114) ([md5](https://github.com/md5))
413
442
  - Skip network metric comparison for newly added interfaces [\#113](https://github.com/riemann/riemann-tools/pull/113) ([md5](https://github.com/md5))
414
- - riemann-proc alerts output which processes matched [\#111](https://github.com/riemann/riemann-tools/pull/111) ([tcrayford](https://github.com/tcrayford))
443
+ - riemann-proc alerts output which processes matched [\#111](https://github.com/riemann/riemann-tools/pull/111) ([tom-pang](https://github.com/tom-pang))
415
444
  - abort if no DB specified [\#110](https://github.com/riemann/riemann-tools/pull/110) ([peterneubauer](https://github.com/peterneubauer))
416
445
  - Adding monitoring of an RDS instance [\#109](https://github.com/riemann/riemann-tools/pull/109) ([peterneubauer](https://github.com/peterneubauer))
417
446
  - Added NTP statistics collector [\#108](https://github.com/riemann/riemann-tools/pull/108) ([jamtur01](https://github.com/jamtur01))
@@ -427,7 +456,7 @@
427
456
 
428
457
  - Adding support for https connection [\#102](https://github.com/riemann/riemann-tools/pull/102) ([peterneubauer](https://github.com/peterneubauer))
429
458
  - Adds monitoring a folder based on its number of files [\#100](https://github.com/riemann/riemann-tools/pull/100) ([iramello](https://github.com/iramello))
430
- - add directory space use monitoring [\#96](https://github.com/riemann/riemann-tools/pull/96) ([tcrayford](https://github.com/tcrayford))
459
+ - add directory space use monitoring [\#96](https://github.com/riemann/riemann-tools/pull/96) ([tom-pang](https://github.com/tom-pang))
431
460
 
432
461
  ## [0.2.3](https://github.com/riemann/riemann-tools/tree/0.2.3) (2015-01-06)
433
462
 
@@ -458,19 +487,22 @@
458
487
 
459
488
  - one-character fix: Make riemann-aws-billing work again [\#85](https://github.com/riemann/riemann-tools/pull/85) ([benley](https://github.com/benley))
460
489
  - Fix for latest riemann-client changes [\#83](https://github.com/riemann/riemann-tools/pull/83) ([eric](https://github.com/eric))
461
- - riemann proc regex should quote args to grep [\#82](https://github.com/riemann/riemann-tools/pull/82) ([tcrayford](https://github.com/tcrayford))
490
+ - riemann proc regex should quote args to grep [\#82](https://github.com/riemann/riemann-tools/pull/82) ([tom-pang](https://github.com/tom-pang))
462
491
  - riemann-redis migrated to https://github.com/riemann/riemann-redis [\#81](https://github.com/riemann/riemann-tools/pull/81) ([fborgnia](https://github.com/fborgnia))
463
492
 
464
493
  ## [0.2.1](https://github.com/riemann/riemann-tools/tree/0.2.1) (2014-03-26)
465
494
 
466
495
  [Full Changelog](https://github.com/riemann/riemann-tools/compare/0.2.0...0.2.1)
467
496
 
497
+ **Implemented enhancements:**
498
+
499
+ - rieman-tools aws billing [\#74](https://github.com/riemann/riemann-tools/pull/74) ([jespada](https://github.com/jespada))
500
+
468
501
  **Merged pull requests:**
469
502
 
470
503
  - Update FreeBSD load average for 1 min [\#79](https://github.com/riemann/riemann-tools/pull/79) ([zachfi](https://github.com/zachfi))
471
504
  - Added riemann-varnish collector script [\#77](https://github.com/riemann/riemann-tools/pull/77) ([pradeepchhetri](https://github.com/pradeepchhetri))
472
505
  - allow dashes in diskstats volume names to support lvm volumes like "dm-0" [\#75](https://github.com/riemann/riemann-tools/pull/75) ([cmerrick](https://github.com/cmerrick))
473
- - rieman-tools aws billing [\#74](https://github.com/riemann/riemann-tools/pull/74) ([jespada](https://github.com/jespada))
474
506
  - Added basic metric monitoring for zookeeper [\#73](https://github.com/riemann/riemann-tools/pull/73) ([aterreno](https://github.com/aterreno))
475
507
 
476
508
  ## [0.2.0](https://github.com/riemann/riemann-tools/tree/0.2.0) (2014-01-23)
@@ -556,22 +588,31 @@
556
588
 
557
589
  [Full Changelog](https://github.com/riemann/riemann-tools/compare/0.1.2...0.1.3)
558
590
 
591
+ **Implemented enhancements:**
592
+
593
+ - Add ability to add attributes from CLI [\#38](https://github.com/riemann/riemann-tools/pull/38) ([lwf](https://github.com/lwf))
594
+
595
+ **Fixed bugs:**
596
+
597
+ - Handle timeouts [\#42](https://github.com/riemann/riemann-tools/pull/42) ([lwf](https://github.com/lwf))
598
+
559
599
  **Closed issues:**
560
600
 
561
601
  - riemann-kvminstance\(s\) duplicate scripts [\#34](https://github.com/riemann/riemann-tools/issues/34)
562
602
 
563
603
  **Merged pull requests:**
564
604
 
565
- - Remove dead code [\#43](https://github.com/riemann/riemann-tools/pull/43) ([lwf](https://github.com/lwf))
566
- - Handle timeouts [\#42](https://github.com/riemann/riemann-tools/pull/42) ([lwf](https://github.com/lwf))
567
605
  - Allow riemann resmon to use hostname or FQDN for events [\#41](https://github.com/riemann/riemann-tools/pull/41) ([gsandie](https://github.com/gsandie))
568
606
  - Remove duplicated file riemann-kvminstances. [\#39](https://github.com/riemann/riemann-tools/pull/39) ([default50](https://github.com/default50))
569
- - Add ability to add attributes from CLI [\#38](https://github.com/riemann/riemann-tools/pull/38) ([lwf](https://github.com/lwf))
570
607
 
571
608
  ## [0.1.2](https://github.com/riemann/riemann-tools/tree/0.1.2) (2013-04-30)
572
609
 
573
610
  [Full Changelog](https://github.com/riemann/riemann-tools/compare/0.0.9...0.1.2)
574
611
 
612
+ **Implemented enhancements:**
613
+
614
+ - Add riemann-aws-status [\#13](https://github.com/riemann/riemann-tools/pull/13) ([lwf](https://github.com/lwf))
615
+
575
616
  **Closed issues:**
576
617
 
577
618
  - riemann-nginx? [\#31](https://github.com/riemann/riemann-tools/issues/31)
@@ -596,18 +637,21 @@
596
637
  - Default event hostname [\#20](https://github.com/riemann/riemann-tools/pull/20) ([timshadel](https://github.com/timshadel))
597
638
  - Add memcached monitoring support for riemann-tools. [\#19](https://github.com/riemann/riemann-tools/pull/19) ([fcuny](https://github.com/fcuny))
598
639
  - Typo in rieman-riak using :servie instead of :service [\#18](https://github.com/riemann/riemann-tools/pull/18) ([dgtized](https://github.com/dgtized))
599
- - Add riemann-aws-status [\#13](https://github.com/riemann/riemann-tools/pull/13) ([lwf](https://github.com/lwf))
600
640
 
601
641
  ## [0.0.9](https://github.com/riemann/riemann-tools/tree/0.0.9) (2012-12-08)
602
642
 
603
643
  [Full Changelog](https://github.com/riemann/riemann-tools/compare/version-0.0.2...0.0.9)
604
644
 
645
+ **Implemented enhancements:**
646
+
647
+ - Add riemann-diskstats [\#12](https://github.com/riemann/riemann-tools/pull/12) ([lwf](https://github.com/lwf))
648
+ - Add --tag option to specify tags [\#2](https://github.com/riemann/riemann-tools/pull/2) ([lwf](https://github.com/lwf))
649
+
605
650
  **Merged pull requests:**
606
651
 
607
652
  - fix overflowing text from ps by swapping args for comm [\#17](https://github.com/riemann/riemann-tools/pull/17) ([dch](https://github.com/dch))
608
653
  - Fix darwin cpu usage. Show used cpu instead of idle [\#15](https://github.com/riemann/riemann-tools/pull/15) ([henrikno](https://github.com/henrikno))
609
654
  - Fix core count on darwin [\#14](https://github.com/riemann/riemann-tools/pull/14) ([henrikno](https://github.com/henrikno))
610
- - Add riemann-diskstats [\#12](https://github.com/riemann/riemann-tools/pull/12) ([lwf](https://github.com/lwf))
611
655
  - Reflect each haproxy config as its own unique status [\#11](https://github.com/riemann/riemann-tools/pull/11) ([perezd](https://github.com/perezd))
612
656
  - allow for a commandline configurable TTL. [\#10](https://github.com/riemann/riemann-tools/pull/10) ([perezd](https://github.com/perezd))
613
657
  - add host properties to cloudant, haproxy, redis. [\#8](https://github.com/riemann/riemann-tools/pull/8) ([perezd](https://github.com/perezd))
@@ -616,7 +660,6 @@
616
660
  - adds redis monitoring support to riemann-tools. [\#5](https://github.com/riemann/riemann-tools/pull/5) ([perezd](https://github.com/perezd))
617
661
  - Prevent riemann-health from failing to report memory on OpenVZ virtual machines.  [\#4](https://github.com/riemann/riemann-tools/pull/4) ([mindreframer](https://github.com/mindreframer))
618
662
  - added a script to report kvm instances running on a host [\#3](https://github.com/riemann/riemann-tools/pull/3) ([wjimenez5271](https://github.com/wjimenez5271))
619
- - Add --tag option to specify tags [\#2](https://github.com/riemann/riemann-tools/pull/2) ([lwf](https://github.com/lwf))
620
663
  - add freebsd and darwin support to riemann-health [\#1](https://github.com/riemann/riemann-tools/pull/1) ([joecaswell](https://github.com/joecaswell))
621
664
 
622
665
  ## [version-0.0.2](https://github.com/riemann/riemann-tools/tree/version-0.0.2) (2012-04-17)
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gemspec
8
8
  gem 'github_changelog_generator'
9
9
  gem 'maxmind-geoip2'
10
10
  gem 'racc'
11
+ gem 'rackup'
11
12
  gem 'rake'
12
13
  gem 'rspec'
13
14
  gem 'rubocop'
@@ -15,14 +16,3 @@ gem 'rubocop-rake'
15
16
  gem 'rubocop-rspec'
16
17
  gem 'sinatra'
17
18
  gem 'webrick'
18
-
19
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
20
- # XXX: Needed for Ruby 2.6 compatibility
21
- #
22
- # With Ruby 2.6 an older version of rakup is installed that cause other gems
23
- # to be installed with a legacy version.
24
- #
25
- # Because rakup is only needed when using rack 3, we can just ignore this
26
- # with Ruby 2.6.
27
- gem 'rackup'
28
- end
data/README.markdown CHANGED
@@ -56,13 +56,14 @@ gem install riemann-aws
56
56
 
57
57
  * riemann-aws - Monitor various AWS services.
58
58
  * riemann-elasticsearch - Monitor Elasticsearch.
59
- * riemann-mesos - Monitor Mesos.
60
59
  * riemann-rabbitmq - Monitor RabbitMQ.
61
60
  * riemann-docker - Monitor Docker.
62
- * riemann-marathon - Monitor Marathon.
63
61
  * riemann-munin - Monitor Munin.
64
62
  * riemann-riak - Monitor Riak.
65
- * riemann-chronos - Monitor Chronos.
63
+ * Mesos (deprecated)
64
+ * riemann-mesos - Monitor Mesos.
65
+ * riemann-marathon - Monitor Marathon.
66
+ * riemann-chronos - Monitor Chronos.
66
67
 
67
68
  There are also a number of additional, stand-alone tools, contained in
68
69
  the [Riemann GitHub account](https://github.com/riemann/).
@@ -11,6 +11,7 @@ module Riemann
11
11
  module Tools
12
12
  class ApacheStatus
13
13
  include Riemann::Tools
14
+
14
15
  require 'net/http'
15
16
  require 'uri'
16
17
 
@@ -9,6 +9,7 @@ module Riemann
9
9
  module Tools
10
10
  class Bench
11
11
  include Riemann::Tools
12
+
12
13
  attr_accessor :hosts, :services, :states
13
14
 
14
15
  def initialize
@@ -8,6 +8,7 @@ module Riemann
8
8
  module Tools
9
9
  class Cloudant
10
10
  include Riemann::Tools
11
+
11
12
  require 'net/http'
12
13
  require 'json'
13
14
 
@@ -8,6 +8,7 @@ module Riemann
8
8
  module Tools
9
9
  class Haproxy
10
10
  include Riemann::Tools
11
+
11
12
  require 'net/http'
12
13
  require 'csv'
13
14
 
@@ -21,7 +21,7 @@ module Riemann
21
21
  opt :disk_warning_leniency, 'Disk warning threshold (amount of free space)', short: :none, default: '500G'
22
22
  opt :disk_critical_leniency, 'Disk critical threshold (amount of free space)', short: :none, default: '250G'
23
23
  opt :disk_ignorefs, 'A list of filesystem types to ignore',
24
- default: %w[anon_inodefs autofs cd9660 devfs devtmpfs fdescfs iso9660 linprocfs linsysfs nfs overlay procfs squashfs tmpfs]
24
+ default: %w[anon_inodefs autofs cd9660 devfs devtmpfs efivarfs fdescfs iso9660 linprocfs linsysfs nfs overlay procfs squashfs tmpfs]
25
25
  opt :load_warning, 'Load warning threshold (load average / core)', default: 3.0
26
26
  opt :load_critical, 'Load critical threshold (load average / core)', default: 8.0
27
27
  opt :memory_warning, 'Memory warning threshold (fraction of RAM)', default: 0.85
@@ -441,9 +441,9 @@ module Riemann
441
441
  x = used.to_f / total_without_reservation
442
442
 
443
443
  if x > @limits[:disk][:critical] && available < @limits[:disk][:critical_leniency_kb]
444
- alert "disk #{f[5]}", :critical, x, "#{f[4]} used"
444
+ alert "disk #{f[5]}", :critical, x, "#{f[4]} used, #{number_to_human_size(available * 1024, :floor)} free"
445
445
  elsif x > @limits[:disk][:warning] && available < @limits[:disk][:warning_leniency_kb]
446
- alert "disk #{f[5]}", :warning, x, "#{f[4]} used"
446
+ alert "disk #{f[5]}", :warning, x, "#{f[4]} used, #{number_to_human_size(available * 1024, :floor)} free"
447
447
  else
448
448
  alert "disk #{f[5]}", :ok, x, "#{f[4]} used, #{number_to_human_size(available * 1024, :floor)} free"
449
449
  end
@@ -530,10 +530,12 @@ module Riemann
530
530
  end
531
531
 
532
532
  def number_to_human_size(value, rounding = :round)
533
- return value.to_s if value < 1024
533
+ return "#{value}B" if value.abs < 1024
534
534
 
535
+ neg = value.negative?
536
+ value = value.abs
535
537
  r = Math.log(value, 1024).floor
536
- format('%<size>.1f%<unit>ciB', size: (value.to_f / (1024**r)).send(rounding, 1), unit: SI_UNITS[r])
538
+ format('%<sign>s%<size>.1f%<unit>ciB', sign: (neg ? '-' : ''), size: (value.to_f / (1024**r)).send(rounding, 1), unit: SI_UNITS[r])
537
539
  end
538
540
 
539
541
  def tick
@@ -17,8 +17,16 @@ module Riemann
17
17
  @number = number
18
18
 
19
19
  @crit = scale(read_hwmon_i('crit'))
20
+ @crit = nil if @crit&.zero? # Some buggy drivers report a zero critical value. Ignore these
20
21
  @lcrit = scale(read_hwmon_i('lcrit'))
21
- @service = ['hwmon', read_hwmon_file('name'), read_hwmon_s('label')].compact.join(' ')
22
+ @service = ['hwmon', name, read_hwmon_s('label')].compact.join(' ')
23
+ end
24
+
25
+ def name
26
+ result = read_hwmon_file('name')
27
+ filename = File.realpath(hwmon_file_path('name'))
28
+ result.concat(' at ', Regexp.last_match[1]) if filename.match(%r{/(i2c-\d+/\d+-[[:xdigit:]]+)/hwmon/})
29
+ result
22
30
  end
23
31
 
24
32
  def input
@@ -28,14 +36,17 @@ module Riemann
28
36
  def report
29
37
  value = scale(input)
30
38
 
31
- state = :ok
32
- state = :critical if crit && value >= crit
33
- state = :critical if lcrit && value <= lcrit
39
+ state = nil
40
+ if crit || lcrit
41
+ state = :ok
42
+ state = :critical if crit && value >= crit
43
+ state = :critical if lcrit && value <= lcrit
44
+ end
34
45
  {
35
46
  service: service,
36
47
  state: state,
37
48
  metric: value,
38
- description: fromat_input(value),
49
+ description: format_input(value),
39
50
  }
40
51
  end
41
52
 
@@ -52,7 +63,7 @@ module Riemann
52
63
  end
53
64
  end
54
65
 
55
- def fromat_input(value)
66
+ def format_input(value)
56
67
  case type
57
68
  when :in then format('%<value>.3f V', { value: value })
58
69
  when :fan then "#{value} RPM"
@@ -76,10 +87,14 @@ module Riemann
76
87
  end
77
88
 
78
89
  def read_hwmon_file(file)
79
- File.read("/sys/class/hwmon/hwmon#{hwmon}/#{file}").chomp
90
+ File.read(hwmon_file_path(file)).chomp
80
91
  rescue Errno::ENOENT
81
92
  nil
82
93
  end
94
+
95
+ def hwmon_file_path(file)
96
+ "/sys/class/hwmon/hwmon#{hwmon}/#{file}"
97
+ end
83
98
  end
84
99
 
85
100
  attr_reader :devices
@@ -104,6 +119,8 @@ module Riemann
104
119
  def tick
105
120
  devices.each do |device|
106
121
  report(device.report)
122
+ rescue Errno::ENODATA
123
+ # Some sensors are buggy and cannot report properly
107
124
  end
108
125
  end
109
126
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.7.3
3
+ # This file is automatically generated by Racc 1.8.1
4
4
  # from Racc grammar file "mdstat_parser.y".
5
5
  #
6
6
 
@@ -15,7 +15,7 @@ module Riemann
15
15
  module Tools
16
16
  class MdstatParser < Racc::Parser
17
17
 
18
- module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 58)
18
+ module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 62)
19
19
 
20
20
  def parse(text)
21
21
  s = Utils::StringTokenizer.new(text)
@@ -23,7 +23,7 @@ module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 58)
23
23
  until s.eos? do
24
24
  case
25
25
  when s.scan(/\n/) then s.push_token(nil)
26
- when s.scan(/\s+/) then s.push_token(nil)
26
+ when s.scan(/[[:blank:]]+/) then s.push_token(nil)
27
27
 
28
28
  when s.scan(/\([WJFSR]\)/) then s.push_token(:DISK_STATUS)
29
29
  when s.scan(/<none>/) then s.push_token(:NONE)
@@ -40,6 +40,7 @@ module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 58)
40
40
  when s.scan(/\[/) then s.push_token('[')
41
41
  when s.scan(/]/) then s.push_token(']')
42
42
 
43
+ when s.scan(/auto-read-only\b/) then s.push_token(:AUTO_READ_ONLY)
43
44
  when s.scan(/DELAYED\b/) then s.push_token(:DELAYED)
44
45
  when s.scan(/KB\b/) then s.push_token(:BYTE_UNIT)
45
46
  when s.scan(/K\/sec\b/) then s.push_token(:SPEED_UNIT)
@@ -89,154 +90,157 @@ module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 58)
89
90
  ##### State transition tables begin ###
90
91
 
91
92
  racc_action_table = [
92
- 60, 17, 10, 53, 54, 15, 73, 55, 56, 14,
93
- 3, 13, 10, 28, 4, 7, 12, 61, 72, 62,
94
- 63, 11, 71, 18, 19, 20, 21, 22, 23, 24,
95
- 10, 27, 30, 32, 34, 35, 36, 37, 38, 39,
96
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
97
- 50, 51, 58, 64, 65, 66, 67, 68, 69, 70,
98
- 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
99
- 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
100
- 94, 95, 96, 97, 98, 99, 100 ]
93
+ 64, 17, 10, 57, 58, 15, 77, 59, 60, 14,
94
+ 3, 13, 10, 32, 4, 7, 12, 65, 76, 66,
95
+ 67, 11, 75, 18, 19, 20, 21, 22, 24, 25,
96
+ 26, 27, 28, 10, 31, 34, 36, 38, 39, 40,
97
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
98
+ 51, 52, 53, 54, 55, 62, 68, 69, 70, 71,
99
+ 72, 73, 74, 78, 79, 80, 81, 82, 83, 84,
100
+ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
101
+ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104 ]
101
102
 
102
103
  racc_action_check = [
103
- 53, 11, 5, 50, 50, 11, 66, 50, 50, 10,
104
- 0, 10, 25, 25, 1, 4, 6, 53, 66, 53,
105
- 53, 5, 66, 12, 13, 14, 16, 18, 19, 20,
106
- 23, 24, 28, 30, 31, 32, 33, 34, 36, 37,
107
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
108
- 48, 49, 52, 54, 55, 56, 58, 59, 64, 65,
109
- 67, 68, 74, 75, 76, 77, 78, 79, 80, 81,
110
- 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
111
- 92, 93, 94, 95, 97, 98, 99 ]
104
+ 57, 11, 5, 54, 54, 11, 70, 54, 54, 10,
105
+ 0, 10, 29, 29, 1, 4, 6, 57, 70, 57,
106
+ 57, 5, 70, 12, 13, 14, 16, 18, 19, 20,
107
+ 23, 24, 25, 26, 27, 32, 34, 35, 36, 37,
108
+ 38, 40, 41, 42, 43, 44, 45, 46, 47, 48,
109
+ 49, 50, 51, 52, 53, 56, 58, 59, 60, 62,
110
+ 63, 68, 69, 71, 72, 78, 79, 80, 81, 82,
111
+ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
112
+ 93, 94, 95, 96, 97, 98, 99, 101, 102, 103 ]
112
113
 
113
114
  racc_action_pointer = [
114
- -8, 14, nil, nil, 15, -10, -16, nil, nil, nil,
115
- -23, -11, 4, 12, 12, nil, 14, nil, -6, 9,
116
- -4, nil, nil, 18, 22, 0, nil, nil, 28, nil,
117
- 4, 20, 24, 4, 24, nil, 25, 3, 5, 28,
118
- 29, 13, 11, 38, 14, 11, 36, 47, 17, 38,
119
- -18, nil, 49, -6, 16, 17, 18, nil, 22, 20,
120
- nil, nil, nil, nil, 34, 35, -2, 47, 50, nil,
121
- nil, nil, nil, nil, 27, 25, 51, 26, 49, 54,
122
- 36, 34, 57, 58, 67, 33, 41, 65, 40, 40,
123
- 65, 68, 75, 66, 75, 56, nil, 47, 72, 58,
124
- nil ]
115
+ -9, 14, nil, nil, 15, -11, -17, nil, nil, nil,
116
+ -24, -12, 3, 11, 11, nil, 13, nil, -7, -9,
117
+ -5, nil, nil, 10, 28, 22, 20, -4, nil, -1,
118
+ nil, nil, 30, nil, 6, 22, 26, 6, 26, nil,
119
+ 27, 3, 7, 30, 31, 15, 13, 40, 16, 11,
120
+ 38, 50, 19, 40, -19, nil, 51, -7, 16, 17,
121
+ 18, nil, 24, 20, nil, nil, nil, nil, 36, 37,
122
+ -3, 49, 52, nil, nil, nil, nil, nil, 29, 25,
123
+ 53, 31, 51, 56, 38, 36, 59, 60, 69, 38,
124
+ 43, 67, 40, 40, 67, 70, 77, 68, 77, 58,
125
+ nil, 47, 74, 60, nil ]
125
126
 
126
127
  racc_action_default = [
127
- -33, -33, -6, -4, -33, -33, -2, 101, -1, -5,
128
- -33, -33, -33, -33, -33, -29, -30, -32, -33, -33,
129
- -33, -31, -3, -33, -11, -33, -9, -10, -33, -8,
130
- -13, -15, -33, -33, -33, -12, -33, -33, -33, -33,
131
- -33, -33, -33, -33, -33, -33, -33, -33, -33, -33,
132
- -24, -14, -17, -33, -33, -33, -33, -7, -33, -33,
133
- -25, -26, -27, -28, -33, -33, -33, -33, -33, -19,
134
- -20, -21, -22, -23, -33, -33, -33, -33, -33, -33,
135
- -33, -33, -33, -33, -33, -33, -33, -33, -33, -33,
136
- -33, -33, -33, -33, -33, -33, -16, -33, -33, -33,
137
- -18 ]
128
+ -35, -35, -6, -4, -35, -35, -2, 105, -1, -5,
129
+ -35, -35, -35, -35, -35, -31, -32, -34, -35, -9,
130
+ -35, -33, -3, -35, -35, -13, -35, -35, -12, -35,
131
+ -11, -8, -35, -10, -15, -17, -35, -35, -35, -14,
132
+ -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
133
+ -35, -35, -35, -35, -26, -16, -19, -35, -35, -35,
134
+ -35, -7, -35, -35, -27, -28, -29, -30, -35, -35,
135
+ -35, -35, -35, -21, -22, -23, -24, -25, -35, -35,
136
+ -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
137
+ -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
138
+ -18, -35, -35, -35, -20 ]
138
139
 
139
140
  racc_goto_table = [
140
- 9, 1, 2, 5, 8, 6, 25, 31, 33, 52,
141
- 57, 59, 16, nil, nil, nil, nil, nil, 26, nil,
142
- 29 ]
141
+ 9, 1, 2, 5, 8, 6, 23, 29, 35, 37,
142
+ 56, 61, 63, 16, nil, nil, nil, nil, nil, nil,
143
+ nil, 30, nil, nil, 33 ]
143
144
 
144
145
  racc_goto_check = [
145
146
  6, 1, 2, 3, 4, 5, 7, 8, 9, 10,
146
- 11, 12, 13, nil, nil, nil, nil, nil, 6, nil,
147
- 6 ]
147
+ 11, 12, 13, 14, nil, nil, nil, nil, nil, nil,
148
+ nil, 6, nil, nil, 6 ]
148
149
 
149
150
  racc_goto_pointer = [
150
- nil, 1, 2, 1, -1, 2, -5, -17, -23, -23,
151
- -41, -42, -42, 1 ]
151
+ nil, 1, 2, 1, -1, 2, -5, -13, -19, -26,
152
+ -26, -44, -45, -45, 2 ]
152
153
 
153
154
  racc_goto_default = [
154
155
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
155
- nil, nil, nil, nil ]
156
+ nil, nil, nil, nil, nil ]
156
157
 
157
158
  racc_reduce_table = [
158
159
  0, 0, :racc_error,
159
- 3, 42, :_reduce_1,
160
- 2, 43, :_reduce_none,
161
- 4, 46, :_reduce_none,
162
- 0, 46, :_reduce_none,
163
- 2, 44, :_reduce_5,
164
- 0, 44, :_reduce_6,
165
- 19, 47, :_reduce_7,
166
- 2, 48, :_reduce_none,
167
- 1, 48, :_reduce_none,
168
- 5, 47, :_reduce_none,
160
+ 3, 43, :_reduce_1,
161
+ 2, 44, :_reduce_none,
169
162
  4, 47, :_reduce_none,
170
- 2, 49, :_reduce_none,
163
+ 0, 47, :_reduce_none,
164
+ 2, 45, :_reduce_5,
165
+ 0, 45, :_reduce_6,
166
+ 20, 48, :_reduce_7,
167
+ 3, 49, :_reduce_none,
171
168
  0, 49, :_reduce_none,
172
- 9, 50, :_reduce_none,
173
- 0, 50, :_reduce_none,
174
- 14, 52, :_reduce_none,
175
- 0, 52, :_reduce_none,
176
- 18, 51, :_reduce_none,
177
- 3, 51, :_reduce_none,
178
- 3, 51, :_reduce_none,
179
- 3, 51, :_reduce_none,
180
- 3, 51, :_reduce_none,
181
- 3, 51, :_reduce_none,
169
+ 2, 50, :_reduce_none,
170
+ 1, 50, :_reduce_none,
171
+ 5, 48, :_reduce_none,
172
+ 4, 48, :_reduce_none,
173
+ 2, 51, :_reduce_none,
182
174
  0, 51, :_reduce_none,
183
- 1, 53, :_reduce_none,
184
- 1, 53, :_reduce_none,
185
- 1, 53, :_reduce_none,
186
- 1, 53, :_reduce_none,
187
- 2, 45, :_reduce_none,
188
- 2, 45, :_reduce_none,
189
- 2, 54, :_reduce_none,
190
- 1, 54, :_reduce_none ]
191
-
192
- racc_reduce_n = 33
193
-
194
- racc_shift_n = 101
175
+ 9, 52, :_reduce_none,
176
+ 0, 52, :_reduce_none,
177
+ 14, 54, :_reduce_none,
178
+ 0, 54, :_reduce_none,
179
+ 18, 53, :_reduce_none,
180
+ 3, 53, :_reduce_none,
181
+ 3, 53, :_reduce_none,
182
+ 3, 53, :_reduce_none,
183
+ 3, 53, :_reduce_none,
184
+ 3, 53, :_reduce_none,
185
+ 0, 53, :_reduce_none,
186
+ 1, 55, :_reduce_none,
187
+ 1, 55, :_reduce_none,
188
+ 1, 55, :_reduce_none,
189
+ 1, 55, :_reduce_none,
190
+ 2, 46, :_reduce_none,
191
+ 2, 46, :_reduce_none,
192
+ 2, 56, :_reduce_none,
193
+ 1, 56, :_reduce_none ]
194
+
195
+ racc_reduce_n = 35
196
+
197
+ racc_shift_n = 105
195
198
 
196
199
  racc_token_table = {
197
200
  false => 0,
198
201
  :error => 1,
199
202
  :ALGORITHM => 2,
200
- :BITMAP => 3,
201
- :BLOCKS => 4,
202
- :BYTE_UNIT => 5,
203
- :CHECK => 6,
204
- :CHUNK => 7,
205
- :DELAYED => 8,
206
- :DISK_STATUS => 9,
207
- :FINISH => 10,
208
- :FLOAT => 11,
209
- :IDENTIFIER => 12,
210
- :INTEGER => 13,
211
- :LEVEL => 14,
212
- :MIN => 15,
213
- :NONE => 16,
214
- :PAGES => 17,
215
- :PERSONALITIES => 18,
216
- :PERSONALITY => 19,
217
- :PENDING => 20,
218
- :PROGRESS => 21,
219
- :RECOVER => 22,
220
- :RECOVERY => 23,
221
- :REMOTE => 24,
222
- :RESHAPE => 25,
223
- :RESYNC => 26,
224
- :SPEED => 27,
225
- :SPEED_UNIT => 28,
226
- :SUPER => 29,
227
- :UNIT => 30,
228
- :UNUSED_DEVICES => 31,
229
- "[" => 32,
230
- "]" => 33,
231
- ":" => 34,
232
- "/" => 35,
233
- "," => 36,
234
- "=" => 37,
235
- "%" => 38,
236
- "(" => 39,
237
- ")" => 40 }
238
-
239
- racc_nt_base = 41
203
+ :AUTO_READ_ONLY => 3,
204
+ :BITMAP => 4,
205
+ :BLOCKS => 5,
206
+ :BYTE_UNIT => 6,
207
+ :CHECK => 7,
208
+ :CHUNK => 8,
209
+ :DELAYED => 9,
210
+ :DISK_STATUS => 10,
211
+ :FINISH => 11,
212
+ :FLOAT => 12,
213
+ :IDENTIFIER => 13,
214
+ :INTEGER => 14,
215
+ :LEVEL => 15,
216
+ :MIN => 16,
217
+ :NONE => 17,
218
+ :PAGES => 18,
219
+ :PERSONALITIES => 19,
220
+ :PERSONALITY => 20,
221
+ :PENDING => 21,
222
+ :PROGRESS => 22,
223
+ :RECOVER => 23,
224
+ :RECOVERY => 24,
225
+ :REMOTE => 25,
226
+ :RESHAPE => 26,
227
+ :RESYNC => 27,
228
+ :SPEED => 28,
229
+ :SPEED_UNIT => 29,
230
+ :SUPER => 30,
231
+ :UNIT => 31,
232
+ :UNUSED_DEVICES => 32,
233
+ "[" => 33,
234
+ "]" => 34,
235
+ ":" => 35,
236
+ "/" => 36,
237
+ "(" => 37,
238
+ ")" => 38,
239
+ "," => 39,
240
+ "=" => 40,
241
+ "%" => 41 }
242
+
243
+ racc_nt_base = 42
240
244
 
241
245
  racc_use_result_var = true
242
246
 
@@ -261,6 +265,7 @@ Racc_token_to_s_table = [
261
265
  "$end",
262
266
  "error",
263
267
  "ALGORITHM",
268
+ "AUTO_READ_ONLY",
264
269
  "BITMAP",
265
270
  "BLOCKS",
266
271
  "BYTE_UNIT",
@@ -294,11 +299,11 @@ Racc_token_to_s_table = [
294
299
  "\"]\"",
295
300
  "\":\"",
296
301
  "\"/\"",
302
+ "\"(\"",
303
+ "\")\"",
297
304
  "\",\"",
298
305
  "\"=\"",
299
306
  "\"%\"",
300
- "\"(\"",
301
- "\")\"",
302
307
  "$start",
303
308
  "target",
304
309
  "personalities",
@@ -306,6 +311,7 @@ Racc_token_to_s_table = [
306
311
  "unused_devices",
307
312
  "list_of_personalities",
308
313
  "device",
314
+ "auto_read_only",
309
315
  "list_of_devices",
310
316
  "super",
311
317
  "level",
@@ -350,7 +356,7 @@ module_eval(<<'.,.,', 'mdstat_parser.y', 11)
350
356
 
351
357
  module_eval(<<'.,.,', 'mdstat_parser.y', 13)
352
358
  def _reduce_7(val, _values, result)
353
- result = { val[0][:value] => val[15][:value] }
359
+ result = { val[0][:value] => val[16][:value] }
354
360
  result
355
361
  end
356
362
  .,.,
@@ -405,6 +411,10 @@ module_eval(<<'.,.,', 'mdstat_parser.y', 13)
405
411
 
406
412
  # reduce 32 omitted
407
413
 
414
+ # reduce 33 omitted
415
+
416
+ # reduce 34 omitted
417
+
408
418
  def _reduce_none(val, _values, result)
409
419
  val[0]
410
420
  end
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Tools
8
8
  class Memcached
9
9
  include Riemann::Tools
10
+
10
11
  require 'socket'
11
12
 
12
13
  opt :memcached_host, 'Memcached hostname', default: 'localhost'
@@ -9,6 +9,7 @@ module Riemann
9
9
  module Tools
10
10
  class NginxStatus
11
11
  include Riemann::Tools
12
+
12
13
  require 'net/http'
13
14
  require 'uri'
14
15
 
@@ -8,6 +8,7 @@ module Riemann
8
8
  module Tools
9
9
  class Portcheck
10
10
  include Riemann::Tools
11
+
11
12
  require 'socket'
12
13
 
13
14
  opt :hostname, 'Host, defaults to localhost', default: `hostname`.chomp
@@ -7,18 +7,49 @@ require 'riemann/client'
7
7
  module Riemann
8
8
  module Tools
9
9
  class RiemannClientWrapper
10
- attr_reader :options
10
+ include Singleton
11
11
 
12
12
  BACKOFF_TMIN = 0.5 # Minimum delay between reconnection attempts
13
13
  BACKOFF_TMAX = 30.0 # Maximum delay
14
14
  BACKOFF_FACTOR = 2
15
15
 
16
- def initialize(options)
17
- @options = options
16
+ # The wrapper manage a single connection to riemann, transport options
17
+ # cannot be adjusted when riemann-wrapper is running, and enqueing events
18
+ # should not happen when the system is tearing down. This is achieved
19
+ # with this simple state machine
20
+ #
21
+ # [idle] --client--> [running] --drain--> [draining]
22
+ # ^ |
23
+ # +-------[#reset (development only)]-------+
24
+ attr_reader :state
25
+
26
+ STATE_IDLE = 1
27
+ STATE_RUNNING = 2
28
+ STATE_DRAINING = 3
29
+
30
+ # These options are transport-related, and SHALL be the same for each
31
+ # tool running in riemann-wrapper. Other options are ignored as far as
32
+ # the wrapper is concerned.
33
+ ALLOWED_OPTIONS = %i[host port timeout tls tls_key tls_cert tls_ca_cert tls_verify tcp tls].freeze
34
+
35
+ attr_reader :options
36
+
37
+ def options=(options)
38
+ if state == STATE_IDLE
39
+ @options = options
40
+ @client = nil
41
+ else
42
+ return if options.slice(*ALLOWED_OPTIONS) == @options.slice(*ALLOWED_OPTIONS)
18
43
 
44
+ raise 'Cannot change options while running'
45
+ end
46
+ end
47
+
48
+ def initialize
49
+ @options = nil
19
50
  @queue = Queue.new
20
51
  @max_bulk_size = 1000
21
- @draining = false
52
+ @state = STATE_IDLE
22
53
 
23
54
  @worker = Thread.new do
24
55
  Thread.current.abort_on_exception = true
@@ -49,6 +80,8 @@ module Riemann
49
80
 
50
81
  def client
51
82
  @client ||= begin
83
+ @state = STATE_RUNNING
84
+
52
85
  r = Riemann::Client.new(
53
86
  host: options[:host],
54
87
  port: options[:port],
@@ -69,15 +102,25 @@ module Riemann
69
102
  end
70
103
 
71
104
  def <<(event)
72
- raise('Cannot queue events when draining') if @draining
105
+ raise('Cannot queue events while draining') if state == STATE_DRAINING
73
106
 
74
107
  @queue << event
75
108
  end
76
109
 
77
110
  def drain
78
- @draining = true
111
+ @state = STATE_DRAINING
79
112
  sleep(1) until @queue.empty? || @worker.stop?
80
113
  end
114
+
115
+ private
116
+
117
+ # For development purpose only: we do not want the singleton to leak
118
+ # state from one test to another.
119
+ def reset
120
+ @options = nil
121
+ @queue.clear
122
+ @state = STATE_IDLE
123
+ end
81
124
  end
82
125
  end
83
126
  end
@@ -24,7 +24,7 @@ module URI
24
24
  end
25
25
  end
26
26
 
27
- module Riemann
27
+ module Riemann # rubocop:disable Style/OneClassPerFile
28
28
  module Tools
29
29
  class TLSCheck
30
30
  include Riemann::Tools
@@ -202,6 +202,8 @@ module Riemann
202
202
  description.start_with? 'OCSP'
203
203
  end
204
204
 
205
+ return '' unless ocsp
206
+
205
207
  ocsp_uri = URI(ocsp[/URI:(.*)/, 1])
206
208
 
207
209
  http_response = ::Net::HTTP.start(ocsp_uri.hostname, ocsp_uri.port) do |http|
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.6.0
3
+ # This file is automatically generated by Racc 1.6.2
4
4
  # from Racc grammar file "".
5
5
  #
6
6
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Riemann
4
4
  module Tools # :nodoc:
5
- VERSION = '1.12.0'
5
+ VERSION = '2.0.0'
6
6
  end
7
7
  end
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Tools
8
8
  class Zookeeper
9
9
  include Riemann::Tools
10
+
10
11
  require 'socket'
11
12
 
12
13
  opt :zookeeper_host, 'Zookeeper hostname', default: 'localhost'
data/lib/riemann/tools.rb CHANGED
@@ -82,7 +82,10 @@ module Riemann
82
82
  end
83
83
 
84
84
  def riemann
85
- @riemann ||= RiemannClientWrapper.new(options)
85
+ @riemann ||= begin
86
+ RiemannClientWrapper.instance.options = options
87
+ RiemannClientWrapper.instance
88
+ end
86
89
  end
87
90
  alias r riemann
88
91
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Collection of utilities which submit events to Riemann,'
13
13
  spec.homepage = 'https://github.com/aphyr/riemann-tools'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
16
16
 
17
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
18
18
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class Billing
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
 
12
13
  opt :fog_credentials_file, 'Fog credentials file', type: String
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class ElbMetrics
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'time'
12
13
 
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class RdsStatus
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'date'
12
13
  require 'time'
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class S3List
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'time'
12
13
 
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class S3Status
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'time'
12
13
 
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class SqsStatus
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
 
12
13
  opt :access_key, 'AWS access key', type: String
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class Status
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'date'
12
13
 
@@ -49,15 +49,15 @@ module Riemann
49
49
  def health_url
50
50
  path_prefix = options[:path_prefix]
51
51
  path_prefix[0] = '' if path_prefix[0] == '/'
52
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
53
- "http://#{options[:chronos_host]}:#{options[:chronos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/metrics"
52
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
53
+ "http://#{options[:chronos_host]}:#{options[:chronos_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/metrics"
54
54
  end
55
55
 
56
56
  def jobs_url
57
57
  path_prefix = options[:path_prefix]
58
58
  path_prefix[0] = '' if path_prefix[0] == '/'
59
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
60
- "http://#{options[:chronos_host]}:#{options[:chronos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/scheduler/jobs"
59
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
60
+ "http://#{options[:chronos_host]}:#{options[:chronos_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/scheduler/jobs"
61
61
  end
62
62
 
63
63
  def tick
@@ -6,6 +6,7 @@ module Riemann
6
6
  module Tools
7
7
  class Elasticsearch
8
8
  include Riemann::Tools
9
+
9
10
  require 'faraday'
10
11
  require 'json'
11
12
  require 'uri'
@@ -42,8 +43,8 @@ module Riemann
42
43
  def make_es_url(path)
43
44
  path_prefix = options[:path_prefix]
44
45
  path_prefix[0] = '' if path_prefix[0] == '/'
45
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
46
- "http://#{options[:es_host]}:#{options[:es_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/#{path}"
46
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
47
+ "http://#{options[:es_host]}:#{options[:es_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/#{path}"
47
48
  end
48
49
 
49
50
  def health_url
@@ -49,15 +49,15 @@ module Riemann
49
49
  def health_url
50
50
  path_prefix = options[:path_prefix]
51
51
  path_prefix[0] = '' if path_prefix[0] == '/'
52
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
53
- "http://#{options[:marathon_host]}:#{options[:marathon_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/metrics"
52
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
53
+ "http://#{options[:marathon_host]}:#{options[:marathon_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/metrics"
54
54
  end
55
55
 
56
56
  def apps_url
57
57
  path_prefix = options[:path_prefix]
58
58
  path_prefix[0] = '' if path_prefix[0] == '/'
59
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
60
- "http://#{options[:marathon_host]}:#{options[:marathon_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/v2/apps"
59
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
60
+ "http://#{options[:marathon_host]}:#{options[:marathon_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/v2/apps"
61
61
  end
62
62
 
63
63
  def tick
@@ -42,15 +42,15 @@ module Riemann
42
42
  def health_url
43
43
  path_prefix = options[:path_prefix]
44
44
  path_prefix[0] = '' if path_prefix[0] == '/'
45
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
46
- "http://#{options[:mesos_host]}:#{options[:mesos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/metrics/snapshot"
45
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
46
+ "http://#{options[:mesos_host]}:#{options[:mesos_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/metrics/snapshot"
47
47
  end
48
48
 
49
49
  def slaves_url
50
50
  path_prefix = options[:path_prefix]
51
51
  path_prefix[0] = '' if path_prefix[0] == '/'
52
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
53
- "http://#{options[:mesos_host]}:#{options[:mesos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/master/slaves"
52
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
53
+ "http://#{options[:mesos_host]}:#{options[:mesos_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/master/slaves"
54
54
  end
55
55
 
56
56
  def tick
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Tools
8
8
  class Munin
9
9
  include Riemann::Tools
10
+
10
11
  require 'munin-ruby'
11
12
 
12
13
  def initialize
@@ -100,9 +100,9 @@ module Riemann
100
100
  svc = "rabbitmq.queue.#{queue['vhost']}.#{queue['name']}"
101
101
  errs = []
102
102
 
103
- errs << 'Queue has jobs but no consumers' if !queue['messages_ready'].nil? && (queue['messages_ready']).positive? && (queue['consumers']).zero?
103
+ errs << 'Queue has jobs but no consumers' if !queue['messages_ready'].nil? && queue['messages_ready'].positive? && queue['consumers'].zero?
104
104
 
105
- errs << "Queue has #{queue['messages_ready']} jobs" if (max_size_check_filter.nil? || queue['name'] !~ (max_size_check_filter)) && !queue['messages_ready'].nil? && (queue['messages_ready'] > opts[:max_queue_size])
105
+ errs << "Queue has #{queue['messages_ready']} jobs" if (max_size_check_filter.nil? || queue['name'] !~ max_size_check_filter) && !queue['messages_ready'].nil? && (queue['messages_ready'] > opts[:max_queue_size])
106
106
 
107
107
  if errs.empty?
108
108
  report(
@@ -133,7 +133,7 @@ module Riemann
133
133
 
134
134
  stats.each_pair do |k, v|
135
135
  service = "#{svc}.#{k}"
136
- metric = if k =~ (/details$/) && !v.nil?
136
+ metric = if k =~ /details$/ && !v.nil?
137
137
  v['rate']
138
138
  else
139
139
  v
@@ -9,6 +9,7 @@ module Riemann
9
9
  module Tools
10
10
  class Riak
11
11
  include Riemann::Tools
12
+
12
13
  require 'net/http'
13
14
  require 'net/https'
14
15
  require 'yajl/json_gem'
@@ -157,7 +158,7 @@ module Riemann
157
158
  case val
158
159
  when 0..limit
159
160
  'ok'
160
- when limit..limit * 2
161
+ when limit..(limit * 2)
161
162
  'warning'
162
163
  else
163
164
  'critical'
@@ -289,7 +290,7 @@ module Riemann
289
290
  fsm_types.each do |typespec|
290
291
  typespec.each do |type, prop|
291
292
  fsm_percentiles.each do |percentile|
292
- val = stats[fsm_stat(type, prop, percentile)].to_i || 0
293
+ val = stats[fsm_stat(type, prop, percentile)].to_i
293
294
  val = 0 if val == 'undefined'
294
295
  val /= 1000.0 if prop == 'time' # Convert us to ms
295
296
  state = if prop == 'time'
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Kingsbury
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-01-15 00:00:00.000000000 Z
11
+ date: 2026-05-28 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: csv
@@ -246,6 +247,7 @@ metadata:
246
247
  homepage_uri: https://github.com/aphyr/riemann-tools
247
248
  source_code_uri: https://github.com/aphyr/riemann-tools
248
249
  changelog_uri: https://github.com/aphyr/riemann-tools
250
+ post_install_message:
249
251
  rdoc_options: []
250
252
  require_paths:
251
253
  - lib
@@ -253,14 +255,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
253
255
  requirements:
254
256
  - - ">="
255
257
  - !ruby/object:Gem::Version
256
- version: 2.6.0
258
+ version: 2.7.0
257
259
  required_rubygems_version: !ruby/object:Gem::Requirement
258
260
  requirements:
259
261
  - - ">="
260
262
  - !ruby/object:Gem::Version
261
263
  version: '0'
262
264
  requirements: []
263
- rubygems_version: 3.6.2
265
+ rubygems_version: 3.3.3
266
+ signing_key:
264
267
  specification_version: 4
265
268
  summary: Utilities which submit events to Riemann.
266
269
  test_files: []