gitorious-munin-plugins 0.9 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require "gitorious-munin-plugins"
3
+ require "gitorious-munin-plugins/database"
4
+ require "gitorious-munin-plugins/cli"
5
+ require "gitorious-munin-plugins/plugin"
6
+ require "term/ansicolor"
7
+
8
+
9
+
10
+
11
+
12
+ all_plugins = GitoriousMuninPlugins::Plugin.all
13
+ called_as = Pathname($0).basename.to_s
14
+ cli = GitoriousMuninPlugins::Cli.new(all_plugins, called_as)
15
+ cli.run
@@ -15,4 +15,5 @@ Gem::Specification.new do |s|
15
15
  s.require_paths = ["lib"]
16
16
 
17
17
  s.add_dependency "mysql", "~> 2.8"
18
+ s.add_dependency "term-ansicolor", "~> 1.0"
18
19
  end
@@ -0,0 +1,39 @@
1
+ module GitoriousMuninPlugins
2
+ class Cli
3
+ attr_reader :plugins, :called_as
4
+
5
+ def initialize(plugins, called_as)
6
+ @plugins = plugins
7
+ @called_as = called_as
8
+ end
9
+
10
+ def run
11
+ if plugins.any? {|plugin| plugin.named?(called_as)}
12
+ load_plugin(called_as)
13
+ else
14
+ display_usage
15
+ end
16
+ end
17
+
18
+ def display_usage
19
+ msg = [Term::ANSIColor.bold { "Munin plugins for Gitorious, symlink to me in /etc/munin/plugins/"} ]
20
+ msg << ""
21
+ msg << "I may be called by these names:"
22
+ plugins.each do |p|
23
+ msg << "- #{p.description}"
24
+ end
25
+ msg << ""
26
+
27
+ fail_with_message(msg.join("\n"))
28
+ end
29
+
30
+ def fail_with_message(message)
31
+ puts message
32
+ exit 1
33
+ end
34
+
35
+ def load_plugin(name)
36
+ load Plugin.root.realpath + "#{name}.rb"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ module GitoriousMuninPlugins
2
+ class Plugin
3
+ def self.all
4
+ root.children.collect do |plugin|
5
+ name = plugin.basename.to_s.sub(/\.rb/, "")
6
+ new(name)
7
+ end
8
+ end
9
+
10
+ # Root of all plugins
11
+ def self.root
12
+ Pathname(File.dirname(__FILE__)) + "plugins"
13
+ end
14
+
15
+ attr_reader :name
16
+ def initialize(name)
17
+ @name = name
18
+ end
19
+
20
+ # Is there a symlink to us in /etc/munin/plugins ?
21
+ def installed?
22
+ File.exist?("/etc/munin/plugins/#{name}")
23
+ end
24
+
25
+ def named?(given)
26
+ name == given
27
+ end
28
+
29
+ def install_status
30
+ if installed?
31
+ Term::ANSIColor.green {"(installed)"}
32
+ else
33
+ Term::ANSIColor.red {"(not installed)"}
34
+ end
35
+ end
36
+
37
+ def description
38
+ "#{name} #{install_status}"
39
+ end
40
+ end
41
+ end
@@ -1,7 +1,3 @@
1
- #!/usr/bin/env ruby
2
- require "gitorious-munin-plugins"
3
- require "gitorious-munin-plugins/database"
4
-
5
1
  database = GitoriousMuninPlugins::Database.new
6
2
  cmd = ARGV.shift
7
3
  case cmd
@@ -1,7 +1,3 @@
1
- #!/usr/bin/env ruby
2
- require "gitorious-munin-plugins"
3
- require "gitorious-munin-plugins/database"
4
-
5
1
  database = GitoriousMuninPlugins::Database.new
6
2
 
7
3
  cmd = ARGV.shift
@@ -1,3 +1,3 @@
1
1
  module GitoriousMuninPlugins
2
- VERSION = "0.9"
2
+ VERSION = "0.9.12"
3
3
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitorious-munin-plugins
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 35
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- version: "0.9"
9
+ - 12
10
+ version: 0.9.12
10
11
  platform: ruby
11
12
  authors:
12
13
  - Marius Mathiesen
@@ -32,22 +33,39 @@ dependencies:
32
33
  version: "2.8"
33
34
  type: :runtime
34
35
  version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: term-ansicolor
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 15
45
+ segments:
46
+ - 1
47
+ - 0
48
+ version: "1.0"
49
+ type: :runtime
50
+ version_requirements: *id002
35
51
  description: Various binaries that can be used as Munin plugins for a Gitorious server
36
52
  email:
37
53
  - marius@gitorious.com
38
54
  executables:
39
- - gitorious_ssh_keys
40
- - gitorious_users
55
+ - gitorious-munin-plugin
41
56
  extensions: []
42
57
 
43
58
  extra_rdoc_files: []
44
59
 
45
60
  files:
46
- - bin/gitorious_ssh_keys
47
- - bin/gitorious_users
61
+ - bin/gitorious-munin-plugin
48
62
  - gitorious-munin-plugins.gemspec
49
63
  - lib/gitorious-munin-plugins.rb
64
+ - lib/gitorious-munin-plugins/cli.rb
50
65
  - lib/gitorious-munin-plugins/database.rb
66
+ - lib/gitorious-munin-plugins/plugin.rb
67
+ - lib/gitorious-munin-plugins/plugins/gitorious_ssh_keys.rb
68
+ - lib/gitorious-munin-plugins/plugins/gitorious_users.rb
51
69
  - lib/gitorious-munin-plugins/version.rb
52
70
  has_rdoc: true
53
71
  homepage: http://gitorious.org/gitorious/gitorious-munin-plugins