gitorious-munin-plugins 0.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "gitorious-munin-plugins"
|
3
|
+
require "gitorious-munin-plugins/database"
|
4
|
+
|
5
|
+
database = GitoriousMuninPlugins::Database.new
|
6
|
+
cmd = ARGV.shift
|
7
|
+
case cmd
|
8
|
+
when "autoconf"
|
9
|
+
puts "no"
|
10
|
+
when "config"
|
11
|
+
puts "graph_title New SshKeys (within last 24 hrs)"
|
12
|
+
puts 'graph_args -l 0'
|
13
|
+
puts 'graph_vlabel SshKeys'
|
14
|
+
puts 'graph_category Gitorious'
|
15
|
+
puts "new.label SshKeys"
|
16
|
+
puts "new.draw LINE2"
|
17
|
+
puts "new.type GAUGE"
|
18
|
+
else
|
19
|
+
database.select("select count(*) as count from ssh_keys where created_at >= date_sub(now(), interval 24 hour)").each_hash do |row|
|
20
|
+
puts "new.value #{row['count'].to_i}"
|
21
|
+
end
|
22
|
+
end
|
data/bin/gitorious_users
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "gitorious-munin-plugins"
|
3
|
+
require "gitorious-munin-plugins/database"
|
4
|
+
|
5
|
+
database = GitoriousMuninPlugins::Database.new
|
6
|
+
|
7
|
+
cmd = ARGV.shift
|
8
|
+
case cmd
|
9
|
+
when "autoconf"
|
10
|
+
puts "no"
|
11
|
+
when "config"
|
12
|
+
puts "graph_title New users (within last 24 hrs)"
|
13
|
+
puts 'graph_args -l 0'
|
14
|
+
puts 'graph_vlabel Users'
|
15
|
+
puts 'graph_category Gitorious'
|
16
|
+
puts "new.label Users"
|
17
|
+
puts "new.draw LINE2"
|
18
|
+
puts "new.type GAUGE"
|
19
|
+
else
|
20
|
+
database.select("select count(*) as count from users where created_at >= date_sub(now(), interval 24 hour)").each_hash do |row|
|
21
|
+
puts "new.value #{row['count'].to_i}"
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "gitorious-munin-plugins/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "gitorious-munin-plugins"
|
6
|
+
s.version = GitoriousMuninPlugins::VERSION
|
7
|
+
s.authors = ["Marius Mathiesen"]
|
8
|
+
s.email = ["marius@gitorious.com"]
|
9
|
+
s.homepage = "http://gitorious.org/gitorious/gitorious-munin-plugins"
|
10
|
+
s.summary = "Gitorious Munin Plugins"
|
11
|
+
s.description = "Various binaries that can be used as Munin plugins for a Gitorious server"
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n") - [".gitignore", "readme.org"]
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
|
17
|
+
s.add_dependency "mysql", "~> 2.8"
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module GitoriousMuninPlugins
|
2
|
+
class Database
|
3
|
+
def initialize
|
4
|
+
end
|
5
|
+
|
6
|
+
def configuration
|
7
|
+
@configuration ||= load_configuration
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_configuration
|
11
|
+
begin
|
12
|
+
gitorious_conf = File.read("/etc/gitorious.conf")
|
13
|
+
dir = gitorious_conf.scan(/^GITORIOUS_HOME=(.*)$/).flatten.first
|
14
|
+
raise NotFound, "/etc/gitorious.conf was found, but no GITORIOUS_HOME was defined" unless dir
|
15
|
+
rails_env = gitorious_conf.scan(/^RAILS_ENV=(.*)$/).flatten.first || "production"
|
16
|
+
database_yaml = Pathname(dir) + "config/database.yml"
|
17
|
+
raise NotFound, "No database.yml found in #{database_yml}" unless database_yaml.exist?
|
18
|
+
YAML::load_file(database_yaml)[rails_env]
|
19
|
+
rescue Errno::ENOENT
|
20
|
+
raise NotFound, "Gitorious configuration file /etc/gitorious.conf was not found, exiting"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def select(sql)
|
25
|
+
begin
|
26
|
+
conn = Mysql.new(configuration["host"], configuration["username"], configuration["password"], configuration["database"])
|
27
|
+
conn.query(sql)
|
28
|
+
ensure
|
29
|
+
conn.close
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class NotFound < StandardError; end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitorious-munin-plugins
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
version: "0.9"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Marius Mathiesen
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-10-31 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: mysql
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 19
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 8
|
32
|
+
version: "2.8"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Various binaries that can be used as Munin plugins for a Gitorious server
|
36
|
+
email:
|
37
|
+
- marius@gitorious.com
|
38
|
+
executables:
|
39
|
+
- gitorious_ssh_keys
|
40
|
+
- gitorious_users
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- bin/gitorious_ssh_keys
|
47
|
+
- bin/gitorious_users
|
48
|
+
- gitorious-munin-plugins.gemspec
|
49
|
+
- lib/gitorious-munin-plugins.rb
|
50
|
+
- lib/gitorious-munin-plugins/database.rb
|
51
|
+
- lib/gitorious-munin-plugins/version.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://gitorious.org/gitorious/gitorious-munin-plugins
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.4.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Gitorious Munin Plugins
|
86
|
+
test_files: []
|
87
|
+
|