salted-rails 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +48 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +20 -0
  5. data/README.md +79 -0
  6. data/Rakefile +1 -0
  7. data/lib/salted_rails.rb +5 -0
  8. data/lib/salted_rails/base.rb +5 -0
  9. data/lib/salted_rails/capistrano.rb +6 -0
  10. data/lib/salted_rails/vagrant_helper.rb +155 -0
  11. data/lib/salted_rails/version.rb +3 -0
  12. data/pillar/capistrano.sls +3 -0
  13. data/pillar/capistrano/top.sls +5 -0
  14. data/pillar/common.sls +15 -0
  15. data/pillar/vagrant.sls +3 -0
  16. data/pillar/vagrant/top.sls +5 -0
  17. data/salt/apt/partner-sources.sls +13 -0
  18. data/salt/apt/unwanted.sls +5 -0
  19. data/salt/capistrano.sls +0 -0
  20. data/salt/capistrano/minion +14 -0
  21. data/salt/capistrano/minion.sls +6 -0
  22. data/salt/capistrano/top.sls +8 -0
  23. data/salt/common.sls +19 -0
  24. data/salt/crons/init.sls +23 -0
  25. data/salt/databases/mysql/client-encoding-and-collation.cnf +2 -0
  26. data/salt/databases/mysql/client.sls +17 -0
  27. data/salt/databases/mysql/common.sls +22 -0
  28. data/salt/databases/mysql/config.sls +6 -0
  29. data/salt/databases/mysql/custom_config.sls +14 -0
  30. data/salt/databases/mysql/default-table-engine.cnf +2 -0
  31. data/salt/databases/mysql/group.sls +4 -0
  32. data/salt/databases/mysql/init.sls +8 -0
  33. data/salt/databases/mysql/server-encoding-and-collation.cnf +4 -0
  34. data/salt/databases/mysql/server.sls +59 -0
  35. data/salt/databases/phpmyadmin/etc/nginx/sites-available/.gitignore +3 -0
  36. data/salt/databases/phpmyadmin/etc/nginx/sites-available/phpmyadmin.conf +24 -0
  37. data/salt/databases/phpmyadmin/init.sls +27 -0
  38. data/salt/develop/init.sls +3 -0
  39. data/salt/echo_pillar.sls +9 -0
  40. data/salt/editors/vim/init.sls +12 -0
  41. data/salt/editors/vim/vimrc +23 -0
  42. data/salt/lang/php/composer.sls +9 -0
  43. data/salt/lang/php/etc/php5/fpm/php.fpm.ini +1818 -0
  44. data/salt/lang/php/etc/php5/fpm/pool.d/www.conf +393 -0
  45. data/salt/lang/php/init.sls +38 -0
  46. data/salt/lang/php/nginx.sls +9 -0
  47. data/salt/lang/python/python-libs.sls +28 -0
  48. data/salt/lang/ruby.sls +60 -0
  49. data/salt/lang/ruby.sls.bak +106 -0
  50. data/salt/lang/system_ruby.sls +43 -0
  51. data/salt/munin/files/nginx/plugin-conf.d/nginx +2 -0
  52. data/salt/munin/files/nginx/plugins/nginx_combined_localhost +160 -0
  53. data/salt/munin/files/nginx/plugins/nginx_request +114 -0
  54. data/salt/munin/files/nginx/plugins/nginx_status +126 -0
  55. data/salt/munin/files/node/checkPermissions.sh +10 -0
  56. data/salt/munin/files/node/munin-node.conf +54 -0
  57. data/salt/munin/files/php5-fpm/plugins/phpfpm_average +39 -0
  58. data/salt/munin/files/php5-fpm/plugins/phpfpm_connections +71 -0
  59. data/salt/munin/files/php5-fpm/plugins/phpfpm_memory +24 -0
  60. data/salt/munin/files/php5-fpm/plugins/phpfpm_processes +38 -0
  61. data/salt/munin/files/php5-fpm/plugins/phpfpm_status +83 -0
  62. data/salt/munin/files/server/munin.conf +107 -0
  63. data/salt/munin/nginx.sls +13 -0
  64. data/salt/munin/node.sls +34 -0
  65. data/salt/munin/php5-fpm.sls +13 -0
  66. data/salt/munin/server.sls +7 -0
  67. data/salt/railsapp/database.sls +25 -0
  68. data/salt/railsapp/files/Gemfile +57 -0
  69. data/salt/railsapp/files/Gemfile.lock +133 -0
  70. data/salt/railsapp/gems.sls +18 -0
  71. data/salt/railsapp/init.sls +3 -0
  72. data/salt/run-standalone +3 -0
  73. data/salt/salt/minion/config.template +259 -0
  74. data/salt/salt/minion/debconf.sls +3 -0
  75. data/salt/salt/minion/init.sls +49 -0
  76. data/salt/salt/minion/lsb.sls +8 -0
  77. data/salt/salt/minion/mysql.conf +1 -0
  78. data/salt/salt/minion/mysql.sls +20 -0
  79. data/salt/server/monit.sls +31 -0
  80. data/salt/server/sudo/init.sls +16 -0
  81. data/salt/server/sudo/sudoers +90 -0
  82. data/salt/sysutils/file.sls +8 -0
  83. data/salt/sysutils/init.sls +5 -0
  84. data/salt/sysutils/net.sls +9 -0
  85. data/salt/sysutils/status.sls +11 -0
  86. data/salt/sysutils/tmux.sls +3 -0
  87. data/salt/vagrant.sls +0 -0
  88. data/salt/vagrant/minion +14 -0
  89. data/salt/vagrant/minion.sls +6 -0
  90. data/salt/vagrant/top.sls +8 -0
  91. data/salt/www/chromium.sls +6 -0
  92. data/salt/www/nginx/etc/nginx/nginx.conf +53 -0
  93. data/salt/www/nginx/init.sls +20 -0
  94. data/salt/www/users.sls +12 -0
  95. data/salted-rails.gemspec +23 -0
  96. metadata +163 -0
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/perl -w
2
+ # -*- cperl -*-
3
+
4
+ =head1 NAME
5
+
6
+ nginx_status - Munin plugin to show connection status for nginx
7
+
8
+ =head1 APPLICABLE SYSTEMS
9
+
10
+ Any nginx host
11
+
12
+ =head1 CONFIGURATION
13
+
14
+ This shows the default configuration of this plugin. You can override
15
+ the status URL.
16
+
17
+ [nginx*]
18
+ env.url http://localhost/nginx_status
19
+
20
+ Nginx must also be configured. Firstly the stub-status module must be
21
+ compiled, and secondly it must be configured like this:
22
+
23
+ server {
24
+ listen 127.0.0.1;
25
+ server_name localhost;
26
+ location /nginx_status {
27
+ stub_status on;
28
+ access_log off;
29
+ allow 127.0.0.1;
30
+ deny all;
31
+ }
32
+ }
33
+
34
+ =head1 MAGIC MARKERS
35
+
36
+ #%# family=auto
37
+ #%# capabilities=autoconf
38
+
39
+ =head1 VERSION
40
+
41
+ $Id: nginx_status.in 2431 2009-09-16 10:04:17Z janl $
42
+
43
+ =head1 BUGS
44
+
45
+ None known
46
+
47
+ =head1 AUTHOR
48
+
49
+ Unknown
50
+
51
+ =head1 LICENSE
52
+
53
+ Unknown. Not specified by the unknown author. Nginx has a BSD
54
+ license. Munin is GPLv2 licensed.
55
+
56
+ =cut
57
+
58
+ my $ret = undef;
59
+
60
+ if (! eval "require LWP::UserAgent;"){
61
+ $ret = "LWP::UserAgent not found";
62
+ }
63
+
64
+ my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://localhost/nginx_status";
65
+
66
+ if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" ) {
67
+ if ($ret){
68
+ print "no ($ret)\n";
69
+ exit 0;
70
+ }
71
+
72
+ my $ua = LWP::UserAgent->new(timeout => 30);
73
+ my $response = $ua->request(HTTP::Request->new('GET',$URL));
74
+
75
+ unless ($response->is_success and $response->content =~ /server/im) {
76
+ print "no (no nginx status on $URL)\n";
77
+ exit 0;
78
+ } else {
79
+ print "yes\n";
80
+ exit 0;
81
+ }
82
+ }
83
+
84
+ if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
85
+ print "graph_title NGINX status\n";
86
+ print "graph_args --base 1000\n";
87
+ print "graph_category nginx\n";
88
+ print "graph_vlabel Connections\n";
89
+
90
+ print "total.label Active connections\n";
91
+ print "total.info Active connections\n";
92
+ print "total.draw LINE2\n";
93
+
94
+ print "reading.label Reading\n";
95
+ print "reading.info Reading\n";
96
+ print "reading.draw LINE2\n";
97
+
98
+ print "writing.label Writing\n";
99
+ print "writing.info Writing\n";
100
+ print "writing.draw LINE2\n";
101
+
102
+ print "waiting.label Waiting\n";
103
+ print "waiting.info Waiting\n";
104
+ print "waiting.draw LINE2\n";
105
+
106
+ exit 0;
107
+ }
108
+
109
+ my $ua = LWP::UserAgent->new(timeout => 30);
110
+
111
+ my $response = $ua->request(HTTP::Request->new('GET',$URL));
112
+
113
+ #Active connections: 1845
114
+ #server accepts handled requests
115
+ # 4566318 4566318 84218236
116
+ # Reading: 2 Writing: 278 Waiting: 1565
117
+ if ($response->content =~ /Active connections:\s+(\d+).*Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/s) {
118
+ print "total.value $1\n";
119
+ print "reading.value $2\n";
120
+ print "writing.value $3\n";
121
+ print "waiting.value $4\n";
122
+ } else {
123
+ foreach (qw(total reading writing waiting)){
124
+ print "$_.value U\n";
125
+ }
126
+ }
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ num_of_files=$(find /etc/munin/plugins/ -maxdepth 1 -type f \! -perm -o+rx | wc -l)
4
+
5
+ if [ "$num_of_files" -ne "0" ]
6
+ then
7
+ exit 1
8
+ else
9
+ exit 0
10
+ fi
@@ -0,0 +1,54 @@
1
+ #
2
+ # Example config-file for munin-node
3
+ #
4
+
5
+ log_level 4
6
+ log_file /var/log/munin/munin-node.log
7
+ pid_file /var/run/munin/munin-node.pid
8
+
9
+ background 1
10
+ setsid 1
11
+
12
+ user root
13
+ group root
14
+
15
+ # Regexps for files to ignore
16
+
17
+ ignore_file ~$
18
+ #ignore_file [#~]$ # FIX doesn't work. '#' starts a comment
19
+ ignore_file DEADJOE$
20
+ ignore_file \.bak$
21
+ ignore_file %$
22
+ ignore_file \.dpkg-(tmp|new|old|dist)$
23
+ ignore_file \.rpm(save|new)$
24
+ ignore_file \.pod$
25
+
26
+ # Set this if the client doesn't report the correct hostname when
27
+ # telnetting to localhost, port 4949
28
+ #
29
+ #host_name localhost.localdomain
30
+
31
+ # A list of addresses that are allowed to connect. This must be a
32
+ # regular expression, since Net::Server does not understand CIDR-style
33
+ # network notation unless the perl module Net::CIDR is installed. You
34
+ # may repeat the allow line as many times as you'd like
35
+
36
+
37
+ # Add Allowed IPs Here
38
+ allow ^127\.0\.0\.1$
39
+ allow ^10\..$
40
+
41
+ # If you have installed the Net::CIDR perl module, you can use
42
+ # multiple cidr_allow and cidr_deny address/mask patterns. A
43
+ # connecting client must match any cidr_allow, and not match any
44
+ # cidr_deny. Example:
45
+
46
+ # cidr_allow 127.0.0.1/32
47
+ # cidr_allow 192.0.2.0/24
48
+ # cidr_deny 192.0.2.42/32
49
+
50
+ # Which address to bind to;
51
+ host *
52
+ # host 127.0.0.1
53
+
54
+ # And which port
@@ -0,0 +1,39 @@
1
+ #!/bin/sh
2
+ # -*- sh -*-
3
+ #
4
+ # Plugin to monitor the average process size of PHP5-FPM on the machine.
5
+ #
6
+ # Copyright TJ Stein 2010 http://constantshift.com
7
+ #
8
+ # Parameters:
9
+ #
10
+ # config (required)
11
+ # autoconf (optional - used by munin-config)
12
+ #
13
+ # Magick markers (optional - used by munin-config and som installation
14
+ # scripts):
15
+ #%# family=manual
16
+ #%# capabilities=autoconf
17
+
18
+ PHP_BIN=${phpbin-"php5-fpm"}
19
+
20
+ if [ "$1" = "autoconf" ]; then
21
+ echo yes
22
+ exit 0
23
+ fi
24
+
25
+ if [ "$1" = "config" ]; then
26
+ echo 'graph_title PHP5-FPM Average Process Size'
27
+ echo 'graph_args --base 1024 -l 0 '
28
+ echo 'graph_vlabel PHP5-FPM Average Process Size'
29
+ echo 'graph_category PHP'
30
+ echo 'graph_info This graph shows the average process size for PHP5-FPM'
31
+ echo 'php_average.label PHP5-FPM Average Proccess Size'
32
+ echo 'php_average.draw LINE2'
33
+ echo 'php_average.info The average process size for PHP5-FPM'
34
+ exit 0
35
+ fi
36
+
37
+ echo -n "php_average.value "
38
+ ps awwwux | grep $PHP_BIN | grep -v grep | grep -v master | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}'
39
+
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/perl
2
+ #
3
+ # Magic markers:
4
+ #%# family=auto
5
+ #%# capabilities=autoconf
6
+
7
+ my $ret = undef;
8
+
9
+ if (! eval "require LWP::UserAgent;")
10
+ {
11
+ $ret = "LWP::UserAgent not found";
12
+ }
13
+
14
+ my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/status";
15
+ my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
16
+
17
+ if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
18
+ {
19
+ if ($ret)
20
+ {
21
+ print "no ($ret)\n";
22
+ exit 1;
23
+ }
24
+
25
+ my $ua = LWP::UserAgent->new(timeout => 30);
26
+
27
+ my @badports;
28
+ foreach my $port (@PORTS) {
29
+ my $url = sprintf $URL, $port;
30
+ my $response = $ua->request(HTTP::Request->new('GET',$url));
31
+ push @badports, $port unless $response->is_success and $response->content =~ /^accepted conn:/im;
32
+ }
33
+ if (@badports) {
34
+ print "no (phpfpm-status)\n";
35
+ exit 1;
36
+ } else {
37
+ print "yes\n";
38
+ exit 0;
39
+ }
40
+ }
41
+
42
+ if ( defined $ARGV[0] and $ARGV[0] eq "config" )
43
+ {
44
+ print('graph_title PHP5-FPM Accepted Connections
45
+ graph_args --base 1024 -l 0
46
+ graph_vlabel Connections
47
+ graph_category PHP
48
+ graph_order Connections
49
+ graph_info Plugin created by TJ Stein
50
+ accepted.label Idle
51
+ accepted.draw AREA
52
+ accepted.type DERIVE
53
+ accepted.min 0
54
+ ');
55
+
56
+ exit 0;
57
+ }
58
+
59
+ foreach my $port (@PORTS)
60
+ {
61
+ my $ua = LWP::UserAgent->new(timeout => 30);
62
+ my $url = sprintf $URL, $port;
63
+ my $response = $ua->request(HTTP::Request->new('GET',$url));
64
+ if ($response->content =~ /accepted conn:\s+([0-9\.]+)/im) {
65
+ print "accepted.value $1\n";
66
+ } else {
67
+ print "accepted.value U\n";
68
+ }
69
+ }
70
+
71
+ # vim:syntax=perl
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # Munin plugin for monitoring PHP5-FPM memory usage
4
+ #
5
+ # Copyright TJ Stein 2010 http://constantshift.com
6
+
7
+ my $PHP_BIN = exists $ENV{'phpbin'} ? $ENV{'phpbin'} : "php5-fpm";
8
+
9
+ if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
10
+ print "graph_title PHP5-FPM Memory Usage\n";
11
+ print "graph_vlabel RAM\n";
12
+ print "graph_category PHP\n";
13
+ print "ram.label ram\n";
14
+ print "graph_args --base 1024\n";
15
+ } else {
16
+ my $i = Integer;
17
+ @cmd = `ps auwx | grep $PHP_BIN | grep -v grep | grep -v phpfpm_memory`;
18
+
19
+ foreach (@cmd) {
20
+ @return = split(/ +/, $_);
21
+ $i += @return[5]*1024;
22
+ }
23
+ print "ram.value ".$i."\n";
24
+ }
@@ -0,0 +1,38 @@
1
+ #!/bin/sh
2
+ # -*- sh -*-
3
+ #
4
+ # Plugin to monitor the number of PHP5-FPM processes on the machine.
5
+ #
6
+ # Copyright TJ Stein 2010 http://constantshift.com
7
+ #
8
+ # Parameters:
9
+ #
10
+ # config (required)
11
+ # autoconf (optional - used by munin-config)
12
+ #
13
+ # Magick markers (optional - used by munin-config and som installation
14
+ # scripts):
15
+ #%# family=manual
16
+ #%# capabilities=autoconf
17
+
18
+ PHP_BIN=${phpbin-"php5-fpm"}
19
+
20
+ if [ "$1" = "autoconf" ]; then
21
+ echo yes
22
+ exit 0
23
+ fi
24
+
25
+ if [ "$1" = "config" ]; then
26
+ echo 'graph_title PHP5-FPM Processes'
27
+ echo 'graph_args --base 1000 -l 0 '
28
+ echo 'graph_vlabel PHP5-FPM Processes'
29
+ echo 'graph_category PHP'
30
+ echo 'graph_info This graph shows the number of PHP5-FPM processes in the system.'
31
+ echo 'php_processes.label PHP5-FPM Processes'
32
+ echo 'php_processes.draw LINE2'
33
+ echo 'php_processes.info The current number of PHP5-FPM processes.'
34
+ exit 0
35
+ fi
36
+
37
+ echo -n "php_processes.value "
38
+ pgrep -c $PHP_BIN
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/perl
2
+ #
3
+ # Magic markers:
4
+ #%# family=auto
5
+ #%# capabilities=autoconf
6
+
7
+ my $ret = undef;
8
+
9
+ if (! eval "require LWP::UserAgent;")
10
+ {
11
+ $ret = "LWP::UserAgent not found";
12
+ }
13
+
14
+ my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/status";
15
+ my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
16
+
17
+ if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
18
+ {
19
+ if ($ret)
20
+ {
21
+ print "no ($ret)\n";
22
+ exit 1;
23
+ }
24
+
25
+ my $ua = LWP::UserAgent->new(timeout => 30);
26
+
27
+ my @badports;
28
+ foreach my $port (@PORTS) {
29
+ my $url = sprintf $URL, $port;
30
+ my $response = $ua->request(HTTP::Request->new('GET',$url));
31
+ push @badports, $port unless $response->is_success and $response->content =~ /^accepted conn:/im;
32
+ }
33
+ if (@badports) {
34
+ print "no (phpfpm-status)\n";
35
+ exit 1;
36
+ } else {
37
+ print "yes\n";
38
+ exit 0;
39
+ }
40
+ }
41
+
42
+ if ( defined $ARGV[0] and $ARGV[0] eq "config" )
43
+ {
44
+ print('graph_title PHP5-FPM Status
45
+ graph_args --base 1024 -l 0
46
+ graph_vlabel Connections
47
+ graph_category PHP
48
+ graph_order Idle Active Total
49
+ graph_info Plugin created by TJ Stein
50
+ idle.label Idle
51
+ idle.draw AREA
52
+ active.label Active
53
+ active.draw AREA
54
+ total.label Total
55
+ total.draw STACK
56
+ ');
57
+
58
+ exit 0;
59
+ }
60
+
61
+ foreach my $port (@PORTS)
62
+ {
63
+ my $ua = LWP::UserAgent->new(timeout => 30);
64
+ my $url = sprintf $URL, $port;
65
+ my $response = $ua->request(HTTP::Request->new('GET',$url));
66
+ if ($response->content =~ /idle processes:\s+([0-9\.]+)/im) {
67
+ print "idle.value $1\n";
68
+ } else {
69
+ print "idle.value U\n";
70
+ }
71
+ if ($response->content =~ /active processes:\s+([0-9\.]+)/im) {
72
+ print "active.value $1\n";
73
+ } else {
74
+ print "active.value U\n";
75
+ }
76
+ if ($response->content =~ /total processes:\s+([0-9\.]+)/im) {
77
+ print "total.value $1\n";
78
+ } else {
79
+ print "total.value U\n";
80
+ }
81
+ }
82
+
83
+ # vim:syntax=perl