riemann-valkey 1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ee49d80a95b0b42bf94b1c96329eba9327f72bcd0b20655596c0e9bb759dae64
4
+ data.tar.gz: 28468a6f097b4a6481098d4cd73c1a4b9312fa4b930c900f70d7c2e89d0c9194
5
+ SHA512:
6
+ metadata.gz: 36e6a2c8659e85d2dce3ad44beeafa716880d1a2010e3c5fc03df92975f5f6ea504ec0e2923fa09036ba1d3baef958fda2a5ad3d233449986396e8590c152a79
7
+ data.tar.gz: 30993467a972d9a1410a1deacb776e084ecddb265d5834ea75e5e026da647b5a74c4e7ffb54e08e0e73cebe086f5db41bb2ad3beab3b4940faca29d74b677d69
@@ -0,0 +1 @@
1
+ * @opus-codium/core
@@ -0,0 +1,9 @@
1
+ version: 2
2
+ updates:
3
+ # Maintain dependencies for GitHub Actions
4
+ - package-ecosystem: github-actions
5
+ directory: "/"
6
+ schedule:
7
+ interval: daily
8
+ time: "13:00"
9
+ open-pull-requests-limit: 10
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: CI
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request:
9
+ branches:
10
+ - main
11
+
12
+ jobs:
13
+ standard:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v6
17
+ - name: Setup ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: 3.0
21
+ bundler-cache: true
22
+ - name: Run static code analysis
23
+ run: bundle exec standardrb
24
+ unit:
25
+ runs-on: ubuntu-latest
26
+ needs: standard
27
+ strategy:
28
+ matrix:
29
+ ruby:
30
+ - "2.6"
31
+ - "2.7"
32
+ - "3.0"
33
+ - "3.1"
34
+ - "3.2"
35
+ - "3.3"
36
+ name: Ruby ${{ matrix.ruby }}
37
+ steps:
38
+ - uses: actions/checkout@v6
39
+ - name: Setup ruby
40
+ uses: ruby/setup-ruby@v1
41
+ with:
42
+ ruby-version: ${{ matrix.ruby }}
43
+ bundler-cache: true
44
+ - name: Run tests without uploading code coverage
45
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ coverage
3
+ spec/examples.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.simplecov ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # vim:set syntax=ruby:
4
+
5
+ SimpleCov.start do
6
+ add_filter "/spec/"
7
+ end
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in riemann-tools.gemspec
6
+ gemspec
7
+
8
+ gem "github_changelog_generator"
9
+ gem "rake"
10
+ gem "rspec"
11
+ gem "simplecov"
12
+ gem "standardrb"
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # riemann-valkey
2
+
3
+ [![CI](https://github.com/opus-codium/riemann-valkey/actions/workflows/ci.yml/badge.svg)](https://github.com/opus-codium/riemann-valkey/actions/workflows/ci.yml)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/c98331204e2fdc0a7093/maintainability)](https://codeclimate.com/github/opus-codium/riemann-valkey/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/c98331204e2fdc0a7093/test_coverage)](https://codeclimate.com/github/opus-codium/riemann-valkey/test_coverage)
6
+
7
+ Submits valkey information to riemann.
8
+
9
+ ## Get started
10
+
11
+ ```
12
+ gem install riemann-valkey
13
+ ```
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "riemann/tools/valkey/version"
4
+
5
+ require "bundler/gem_tasks"
6
+ require "rspec/core/rake_task"
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task default: :spec
11
+
12
+ require "github_changelog_generator/task"
13
+
14
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
15
+ config.user = "opus-codium"
16
+ config.project = "riemann-valkey"
17
+ config.exclude_labels = %w[dependencies skip-changelog]
18
+ config.future_release = "v#{Riemann::Tools::Valkey::VERSION}"
19
+ config.since_tag = "v1.0.0"
20
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ Process.setproctitle($PROGRAM_NAME)
5
+
6
+ require 'riemann/tools/valkey'
7
+
8
+ Riemann::Tools::Valkey.run
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Riemann
4
+ module Tools # :nodoc:
5
+ class Valkey
6
+ VERSION = "1.0.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "redis"
4
+
5
+ require "riemann/tools"
6
+
7
+ module Riemann
8
+ module Tools
9
+ class Valkey
10
+ include Riemann::Tools
11
+
12
+ attr_reader :redis
13
+
14
+ def initialize
15
+ @redis = Redis.new
16
+ end
17
+
18
+ def tick
19
+ redis = Redis.new
20
+ memory_info = redis.info("MEMORY")
21
+ used_memory = memory_info["used_memory"].to_i
22
+ maxmemory = memory_info["maxmemory"].to_i
23
+
24
+ memory_usage = used_memory.to_f / maxmemory
25
+ report({
26
+ service: "valkey memory",
27
+ metric: memory_usage,
28
+ state: memory_state(memory_usage),
29
+ description: format("%.2f %%", memory_usage * 100)
30
+ })
31
+ end
32
+
33
+ def memory_state(metric)
34
+ if metric > 0.95
35
+ "critical"
36
+ elsif metric > 0.8
37
+ "warning"
38
+ else
39
+ "ok"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/riemann/tools/valkey/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "riemann-valkey"
7
+ spec.version = Riemann::Tools::Valkey::VERSION
8
+ spec.authors = ["Romain Tartière"]
9
+ spec.email = ["romain@blogreen.org"]
10
+
11
+ spec.summary = "Submits valkey information to riemann"
12
+ spec.homepage = "https://github.com/opus-codium/riemann-valkey"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = spec.homepage
21
+
22
+ spec.metadata["rubygems_mfa_required"] = "true"
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ end
29
+ spec.bindir = "bin"
30
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "redis", "~> 5.0"
34
+ spec.add_dependency "riemann-tools", "~> 1.0"
35
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riemann-valkey
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Romain Tartière
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: redis
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '5.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '5.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: riemann-tools
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ email:
41
+ - romain@blogreen.org
42
+ executables:
43
+ - riemann-valkey
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".github/CODEOWNERS"
48
+ - ".github/dependabot.yml"
49
+ - ".github/workflows/ci.yml"
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".simplecov"
53
+ - Gemfile
54
+ - README.md
55
+ - Rakefile
56
+ - bin/riemann-valkey
57
+ - lib/riemann/tools/valkey.rb
58
+ - lib/riemann/tools/valkey/version.rb
59
+ - riemann-valkey.gemspec
60
+ homepage: https://github.com/opus-codium/riemann-valkey
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ allowed_push_host: https://rubygems.org/
65
+ homepage_uri: https://github.com/opus-codium/riemann-valkey
66
+ source_code_uri: https://github.com/opus-codium/riemann-valkey
67
+ changelog_uri: https://github.com/opus-codium/riemann-valkey
68
+ rubygems_mfa_required: 'true'
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 2.6.0
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubygems_version: 3.7.2
84
+ specification_version: 4
85
+ summary: Submits valkey information to riemann
86
+ test_files: []