bfire 0.2.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.
- data/LICENSE +0 -0
- data/README.md +90 -0
- data/bin/bfire +120 -0
- data/examples/benchmark.rb +18 -0
- data/examples/dag.rb +26 -0
- data/examples/elasticity.rb +105 -0
- data/examples/ibbt.rb +125 -0
- data/examples/mine.rb +40 -0
- data/examples/modules/apache2/manifests/init.pp +44 -0
- data/examples/modules/app/files/app/app.rb +29 -0
- data/examples/modules/app/files/app/config.ru +2 -0
- data/examples/modules/app/files/app.phtml +4 -0
- data/examples/modules/app/manifests/init.pp +19 -0
- data/examples/modules/common/manifests/init.pp +8 -0
- data/examples/modules/haproxy/files/default +4 -0
- data/examples/modules/haproxy/files/haproxy.rsyslog.conf +2 -0
- data/examples/modules/haproxy/manifests/init.pp +21 -0
- data/examples/modules/mysql/manifests/init.pp +40 -0
- data/examples/modules/rsyslog/files/rsyslog.conf +116 -0
- data/examples/modules/rsyslog/manifests/init.pp +15 -0
- data/examples/modules/sinatra/manifests/init.pp +9 -0
- data/examples/modules/web/files/monitor/app.rb +55 -0
- data/examples/modules/web/files/monitor/config.ru +2 -0
- data/examples/modules/web/files/monitor/haproxy.cfg.erb +50 -0
- data/examples/modules/web/manifests/init.pp +26 -0
- data/examples/simple.rb +58 -0
- data/lib/bfire/aggregator/zabbix.rb +55 -0
- data/lib/bfire/engine.rb +546 -0
- data/lib/bfire/group.rb +241 -0
- data/lib/bfire/metric.rb +36 -0
- data/lib/bfire/provider/puppet.rb +58 -0
- data/lib/bfire/pub_sub/publisher.rb +40 -0
- data/lib/bfire/rule.rb +110 -0
- data/lib/bfire/template.rb +142 -0
- data/lib/bfire/version.rb +3 -0
- data/lib/bfire.rb +10 -0
- metadata +241 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
class mysql {
|
2
|
+
include "mysql::${operatingsystem}"
|
3
|
+
}
|
4
|
+
|
5
|
+
# Class: mysql::debian
|
6
|
+
#
|
7
|
+
#
|
8
|
+
class mysql::debian {
|
9
|
+
package { "mysql-server":
|
10
|
+
ensure => installed,
|
11
|
+
}
|
12
|
+
|
13
|
+
service { "mysql":
|
14
|
+
ensure => running,
|
15
|
+
enable => true,
|
16
|
+
require => Package["mysql-server"];
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
# Class: mysql::ubuntu
|
21
|
+
#
|
22
|
+
#
|
23
|
+
class mysql::ubuntu {
|
24
|
+
include mysql::debian
|
25
|
+
}
|
26
|
+
|
27
|
+
# Class: mysql::centos
|
28
|
+
#
|
29
|
+
#
|
30
|
+
class mysql::centos {
|
31
|
+
package { "mysql-server":
|
32
|
+
ensure => installed,
|
33
|
+
}
|
34
|
+
|
35
|
+
service { "mysqld":
|
36
|
+
ensure => running,
|
37
|
+
enable => true,
|
38
|
+
require => Package["mysql-server"];
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# /etc/rsyslog.conf Configuration file for rsyslog.
|
2
|
+
#
|
3
|
+
# For more information see
|
4
|
+
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
|
5
|
+
|
6
|
+
|
7
|
+
#################
|
8
|
+
#### MODULES ####
|
9
|
+
#################
|
10
|
+
|
11
|
+
$ModLoad imuxsock # provides support for local system logging
|
12
|
+
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
|
13
|
+
#$ModLoad immark # provides --MARK-- message capability
|
14
|
+
|
15
|
+
# provides UDP syslog reception
|
16
|
+
$ModLoad imudp
|
17
|
+
$UDPServerRun 514
|
18
|
+
|
19
|
+
# provides TCP syslog reception
|
20
|
+
#$ModLoad imtcp
|
21
|
+
#$InputTCPServerRun 514
|
22
|
+
|
23
|
+
|
24
|
+
###########################
|
25
|
+
#### GLOBAL DIRECTIVES ####
|
26
|
+
###########################
|
27
|
+
|
28
|
+
#
|
29
|
+
# Use traditional timestamp format.
|
30
|
+
# To enable high precision timestamps, comment out the following line.
|
31
|
+
#
|
32
|
+
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
|
33
|
+
|
34
|
+
#
|
35
|
+
# Set the default permissions for all log files.
|
36
|
+
#
|
37
|
+
$FileOwner root
|
38
|
+
$FileGroup adm
|
39
|
+
$FileCreateMode 0640
|
40
|
+
$DirCreateMode 0755
|
41
|
+
$Umask 0022
|
42
|
+
|
43
|
+
#
|
44
|
+
# Include all config files in /etc/rsyslog.d/
|
45
|
+
#
|
46
|
+
$IncludeConfig /etc/rsyslog.d/*.conf
|
47
|
+
|
48
|
+
|
49
|
+
###############
|
50
|
+
#### RULES ####
|
51
|
+
###############
|
52
|
+
|
53
|
+
#
|
54
|
+
# First some standard log files. Log by facility.
|
55
|
+
#
|
56
|
+
auth,authpriv.* /var/log/auth.log
|
57
|
+
*.*;auth,authpriv.none -/var/log/syslog
|
58
|
+
#cron.* /var/log/cron.log
|
59
|
+
daemon.* -/var/log/daemon.log
|
60
|
+
kern.* -/var/log/kern.log
|
61
|
+
lpr.* -/var/log/lpr.log
|
62
|
+
mail.* -/var/log/mail.log
|
63
|
+
user.* -/var/log/user.log
|
64
|
+
|
65
|
+
#
|
66
|
+
# Logging for the mail system. Split it up so that
|
67
|
+
# it is easy to write scripts to parse these files.
|
68
|
+
#
|
69
|
+
mail.info -/var/log/mail.info
|
70
|
+
mail.warn -/var/log/mail.warn
|
71
|
+
mail.err /var/log/mail.err
|
72
|
+
|
73
|
+
#
|
74
|
+
# Logging for INN news system.
|
75
|
+
#
|
76
|
+
news.crit /var/log/news/news.crit
|
77
|
+
news.err /var/log/news/news.err
|
78
|
+
news.notice -/var/log/news/news.notice
|
79
|
+
|
80
|
+
#
|
81
|
+
# Some "catch-all" log files.
|
82
|
+
#
|
83
|
+
*.=debug;\
|
84
|
+
auth,authpriv.none;\
|
85
|
+
news.none;mail.none -/var/log/debug
|
86
|
+
*.=info;*.=notice;*.=warn;\
|
87
|
+
auth,authpriv.none;\
|
88
|
+
cron,daemon.none;\
|
89
|
+
mail,news.none -/var/log/messages
|
90
|
+
|
91
|
+
#
|
92
|
+
# Emergencies are sent to everybody logged in.
|
93
|
+
#
|
94
|
+
*.emerg *
|
95
|
+
|
96
|
+
#
|
97
|
+
# I like to have messages displayed on the console, but only on a virtual
|
98
|
+
# console I usually leave idle.
|
99
|
+
#
|
100
|
+
#daemon,mail.*;\
|
101
|
+
# news.=crit;news.=err;news.=notice;\
|
102
|
+
# *.=debug;*.=info;\
|
103
|
+
# *.=notice;*.=warn /dev/tty8
|
104
|
+
|
105
|
+
# The named pipe /dev/xconsole is for the `xconsole' utility. To use it,
|
106
|
+
# you must invoke `xconsole' with the `-file' option:
|
107
|
+
#
|
108
|
+
# $ xconsole -file /dev/xconsole [...]
|
109
|
+
#
|
110
|
+
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
|
111
|
+
# busy site..
|
112
|
+
#
|
113
|
+
daemon.*;mail.*;\
|
114
|
+
news.err;\
|
115
|
+
*.=debug;*.=info;\
|
116
|
+
*.=notice;*.=warn |/dev/xconsole
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class rsyslog {
|
2
|
+
package{"rsyslog":
|
3
|
+
ensure => installed
|
4
|
+
}
|
5
|
+
service{"rsyslog":
|
6
|
+
ensure => running,
|
7
|
+
require => Package["rsyslog"]
|
8
|
+
}
|
9
|
+
|
10
|
+
file{"/etc/rsyslog.conf":
|
11
|
+
source => "puppet:///modules/rsyslog/rsyslog.conf",
|
12
|
+
require => Package["rsyslog"],
|
13
|
+
notify => Service["rsyslog"]
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'erb'
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
# Warning: that thing will need to run as root!
|
6
|
+
|
7
|
+
configure do
|
8
|
+
set :hosts, Set.new
|
9
|
+
end
|
10
|
+
|
11
|
+
HAPROXY_CONFIG_FILE = "/etc/haproxy/haproxy.cfg"
|
12
|
+
|
13
|
+
helpers do
|
14
|
+
def haproxy_config
|
15
|
+
template = ERB.new(File.read(File.dirname(__FILE__)+'/haproxy.cfg.erb'))
|
16
|
+
content = template.result(binding)
|
17
|
+
File.open(HAPROXY_CONFIG_FILE, 'w+') do |f|
|
18
|
+
f << content
|
19
|
+
end
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
def haproxy_restart
|
24
|
+
system "/etc/init.d/haproxy reload"
|
25
|
+
end
|
26
|
+
|
27
|
+
def hosts
|
28
|
+
settings.hosts
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
get '/config' do
|
33
|
+
File.read(HAPROXY_CONFIG_FILE)
|
34
|
+
end
|
35
|
+
|
36
|
+
post '/hosts' do
|
37
|
+
ip = params[:ip]
|
38
|
+
if ip
|
39
|
+
settings.hosts.add(ip)
|
40
|
+
haproxy_config && haproxy_restart
|
41
|
+
"OK"
|
42
|
+
else
|
43
|
+
"KO - no IP provided"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
delete '/hosts/:ip' do |ip|
|
48
|
+
settings.hosts.delete(ip)
|
49
|
+
haproxy_config && haproxy_restart
|
50
|
+
"OK"
|
51
|
+
end
|
52
|
+
|
53
|
+
get '/stats' do
|
54
|
+
system "/usr/bin/tail -n 1 /var/log/haproxy.log"
|
55
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# this config needs haproxy-1.1.28 or haproxy-1.2.1
|
2
|
+
|
3
|
+
global
|
4
|
+
log 127.0.0.1 local0
|
5
|
+
log 127.0.0.1 local1 notice
|
6
|
+
#log loghost local0 info
|
7
|
+
maxconn 4096
|
8
|
+
#chroot /usr/share/haproxy
|
9
|
+
user haproxy
|
10
|
+
group haproxy
|
11
|
+
daemon
|
12
|
+
#debug
|
13
|
+
#quiet
|
14
|
+
|
15
|
+
defaults
|
16
|
+
log global
|
17
|
+
mode http
|
18
|
+
option httplog
|
19
|
+
option dontlognull
|
20
|
+
retries 3
|
21
|
+
option redispatch
|
22
|
+
maxconn 2000
|
23
|
+
contimeout 5000
|
24
|
+
clitimeout 50000
|
25
|
+
srvtimeout 50000
|
26
|
+
|
27
|
+
listen apps 0.0.0.0:80
|
28
|
+
|
29
|
+
stats uri /stats
|
30
|
+
option httpchk GET /
|
31
|
+
option httplog
|
32
|
+
log global
|
33
|
+
|
34
|
+
balance roundrobin
|
35
|
+
<% hosts.each_with_index do |host, index| %>
|
36
|
+
server inst<%= index %> <%= host %>:80 minconn 1 maxconn 3 check inter 3000 fall 5 rise 1
|
37
|
+
<% end %>
|
38
|
+
srvtimeout 20000
|
39
|
+
|
40
|
+
option httpclose # disable keep-alive
|
41
|
+
|
42
|
+
#errorloc 502 http://192.168.114.58/error502.html
|
43
|
+
#errorfile 503 /etc/haproxy/errors/503.http
|
44
|
+
errorfile 400 /etc/haproxy/errors/400.http
|
45
|
+
errorfile 403 /etc/haproxy/errors/403.http
|
46
|
+
errorfile 408 /etc/haproxy/errors/408.http
|
47
|
+
errorfile 500 /etc/haproxy/errors/500.http
|
48
|
+
errorfile 502 /etc/haproxy/errors/502.http
|
49
|
+
errorfile 503 /etc/haproxy/errors/503.http
|
50
|
+
errorfile 504 /etc/haproxy/errors/504.http
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class web {
|
2
|
+
include haproxy
|
3
|
+
include sinatra
|
4
|
+
|
5
|
+
file{"/tmp/monitor":
|
6
|
+
recurse => true,
|
7
|
+
source => "puppet:///modules/web/monitor",
|
8
|
+
notify => Service["monitorapp"]
|
9
|
+
}
|
10
|
+
|
11
|
+
service{"monitorapp":
|
12
|
+
ensure => running,
|
13
|
+
start => "/usr/bin/thin -d -l /var/log/thin.log -p 8000 -R config.ru -c /tmp/monitor --tag monitorapp start",
|
14
|
+
stop => "/usr/bin/thin -d -l /var/log/thin.log -p 8000 -R config.ru -c /tmp/monitor --tag monitorapp stop",
|
15
|
+
require => [
|
16
|
+
Package["libsinatra-ruby"],
|
17
|
+
File["/tmp/monitor"]
|
18
|
+
]
|
19
|
+
}
|
20
|
+
|
21
|
+
file{"/var/log/haproxy.log":
|
22
|
+
ensure => present,
|
23
|
+
mode => 644
|
24
|
+
}
|
25
|
+
|
26
|
+
}
|
data/examples/simple.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# $ bfire simple.rb
|
2
|
+
|
3
|
+
set :name, "Simple Experiment using bfire"
|
4
|
+
set :walltime, 3600
|
5
|
+
set :gateway, "ssh.bonfire.grid5000.fr"
|
6
|
+
set :user, ENV['USER']
|
7
|
+
set :logging, INFO
|
8
|
+
|
9
|
+
set :squeeze, "BonFIRE Debian Squeeze 2G v1"
|
10
|
+
set :zabbix, "BonFIRE Zabbix Aggregator v2"
|
11
|
+
set :wan, "BonFIRE WAN"
|
12
|
+
|
13
|
+
group :monitor do
|
14
|
+
at "uk-epcc"
|
15
|
+
instance_type "small"
|
16
|
+
deploy conf[:zabbix]
|
17
|
+
connect_to conf[:wan]
|
18
|
+
end
|
19
|
+
|
20
|
+
group :servers do
|
21
|
+
at "fr-inria"
|
22
|
+
instance_type "small"
|
23
|
+
deploy conf[:squeeze]
|
24
|
+
connect_to conf[:wan]
|
25
|
+
|
26
|
+
# This is not a runtime dependency, it starts right after the resources in
|
27
|
+
# the monitor group have been _created_ (they're not necessarily _running_).
|
28
|
+
depends_on :monitor do |group|
|
29
|
+
{:aggregator_ip => group.take(:first)['nic'][0]['ip']}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
group :clients do
|
34
|
+
at "fr-inria"
|
35
|
+
at "de-hlrs"
|
36
|
+
instance_type "small"
|
37
|
+
deploy conf[:squeeze]
|
38
|
+
connect_to conf[:wan]
|
39
|
+
|
40
|
+
depends_on :monitor do |group|
|
41
|
+
{:aggregator_ip => group.take(:first)['nic'][0]['ip']}
|
42
|
+
end
|
43
|
+
depends_on :servers do |group|
|
44
|
+
{:server_ips => group.map{|vm| vm['nic'][0]['ip']}}
|
45
|
+
end
|
46
|
+
|
47
|
+
on :launched do
|
48
|
+
puts "Yeah, our resources have been launched!"
|
49
|
+
end
|
50
|
+
|
51
|
+
# The ready event is generated once the group resources are launched AND
|
52
|
+
# ssh accessible.
|
53
|
+
on :ready do |group|
|
54
|
+
group.each{|vm|
|
55
|
+
puts "#{group.banner}#{vm['name']} - #{vm['nic'][0]['ip']}"
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Bfire
|
4
|
+
module Aggregator
|
5
|
+
class Zabbix
|
6
|
+
def initialize(session, experiment, opts = {})
|
7
|
+
@session = session
|
8
|
+
@username = opts[:username] || "Admin"
|
9
|
+
@password = opts[:password] || "zabbix"
|
10
|
+
@experiment = experiment
|
11
|
+
@token, @request_id = nil, 0
|
12
|
+
@uri = @experiment.uri.to_s+"/zabbix"
|
13
|
+
@max_attempts = 5
|
14
|
+
end
|
15
|
+
|
16
|
+
def request(method, params = {})
|
17
|
+
begin
|
18
|
+
authenticate if @token.nil? && method != "user.authenticate"
|
19
|
+
@request_id += 1
|
20
|
+
q = { "jsonrpc" => "2.0", "auth" => @token, "id" => @request_id,
|
21
|
+
"method" => method, "params" => params }
|
22
|
+
resource = @session.post(@uri,
|
23
|
+
JSON.dump(q),
|
24
|
+
:head => {
|
25
|
+
'Content-Type' => 'application/json',
|
26
|
+
'Accept' => 'application/json'
|
27
|
+
}
|
28
|
+
)
|
29
|
+
|
30
|
+
# That fucking zabbix API returns "text/plain" as content-type...
|
31
|
+
h = JSON.parse(resource.response.body)
|
32
|
+
|
33
|
+
if h['error']
|
34
|
+
if h['error']['data'] == "Not authorized"
|
35
|
+
@token = nil
|
36
|
+
request(method, params)
|
37
|
+
else
|
38
|
+
raise StandardError, "Received error: #{h.inspect}" if h['error']
|
39
|
+
end
|
40
|
+
else
|
41
|
+
h['result']
|
42
|
+
end
|
43
|
+
rescue Restfully::HTTP::Error => e
|
44
|
+
# retry ad vitam eternam
|
45
|
+
sleep 5
|
46
|
+
retry
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def authenticate
|
51
|
+
@token = request("user.authenticate", {"user" => @username, "password" => @password})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|