5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 07:36:22 +00:00

monitorear

This commit is contained in:
f 2020-09-18 20:51:52 -03:00
parent 6d3b2dac16
commit d489ef0bf2
9 changed files with 32 additions and 23 deletions

View file

@ -111,6 +111,8 @@ USER root
RUN install -m 755 /srv/http/sync_assets.sh /usr/local/bin/sync_assets RUN install -m 755 /srv/http/sync_assets.sh /usr/local/bin/sync_assets
# Instalar la configuración de monit # Instalar la configuración de monit
RUN install -m 640 -o root -g root /srv/http/monit.conf /etc/monit.d/sutty.conf RUN install -m 640 -o root -g root /srv/http/monit.conf /etc/monit.d/sutty.conf
RUN apk add --no-cache daemonize
RUN install -m 755 /srv/http/prometheus.sh /usr/local/bin/prometheus
# Mantener estos directorios! # Mantener estos directorios!
VOLUME "/srv/http/data" VOLUME "/srv/http/data"

View file

@ -78,6 +78,7 @@ gem 'flamegraph'
gem 'memory_profiler' gem 'memory_profiler'
gem 'rack-mini-profiler' gem 'rack-mini-profiler'
gem 'stackprof' gem 'stackprof'
gem 'prometheus_exporter'
group :themes do group :themes do
gem 'adhesiones-jekyll-theme', require: false gem 'adhesiones-jekyll-theme', require: false

View file

@ -205,7 +205,7 @@ GEM
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
i18n (1.8.5) i18n (1.8.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
icalendar (2.6.1) icalendar (2.7.0)
ice_cube (~> 0.16) ice_cube (~> 0.16)
ice_cube (0.16.3) ice_cube (0.16.3)
image_processing (1.11.0) image_processing (1.11.0)
@ -214,7 +214,7 @@ GEM
inline_svg (1.7.1) inline_svg (1.7.1)
activesupport (>= 3.0) activesupport (>= 3.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
jbuilder (2.10.0) jbuilder (2.10.1)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
jekyll (4.1.1) jekyll (4.1.1)
addressable (~> 2.4) addressable (~> 2.4)
@ -309,6 +309,7 @@ GEM
forwardable-extended (~> 2.6) forwardable-extended (~> 2.6)
pg (1.2.3) pg (1.2.3)
popper_js (1.16.0) popper_js (1.16.0)
prometheus_exporter (0.5.3)
pry (0.13.1) pry (0.13.1)
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
@ -405,7 +406,7 @@ GEM
rubocop-ast (>= 0.3.0, < 1.0) rubocop-ast (>= 0.3.0, < 1.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0) unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.3.0) rubocop-ast (0.4.0)
parser (>= 2.7.1.4) parser (>= 2.7.1.4)
rubocop-rails (2.8.0) rubocop-rails (2.8.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
@ -453,7 +454,7 @@ GEM
sprockets (4.0.2) sprockets (4.0.2)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (> 1, < 3) rack (> 1, < 3)
sprockets-rails (3.2.1) sprockets-rails (3.2.2)
actionpack (>= 4.0) actionpack (>= 4.0)
activesupport (>= 4.0) activesupport (>= 4.0)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
@ -565,6 +566,7 @@ DEPENDENCIES
minima minima
mobility mobility
pg pg
prometheus_exporter
pry pry
puma puma
pundit pundit

View file

@ -4,3 +4,4 @@ blazer_5m: bundle exec rake blazer:run_checks SCHEDULE="5 minutes"
blazer_1h: bundle exec rake blazer:run_checks SCHEDULE="1 hour" blazer_1h: bundle exec rake blazer:run_checks SCHEDULE="1 hour"
blazer_1d: bundle exec rake blazer:run_checks SCHEDULE="1 day" blazer_1d: bundle exec rake blazer:run_checks SCHEDULE="1 day"
blazer: bundle exec rake blazer:send_failing_checks blazer: bundle exec rake blazer:send_failing_checks
prometheus: bundle exec prometheus_exporter -b 0.0.0.0 --prefix "sutty_" -d

View file

@ -0,0 +1,6 @@
unless Rails.env.test?
require 'prometheus_exporter/middleware'
# This reports stats per request like HTTP status and timings
Rails.application.middleware.unshift PrometheusExporter::Middleware
end

View file

@ -56,4 +56,9 @@ end
# #
on_worker_boot do on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord) ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
require 'prometheus_exporter/instrumentation'
PrometheusExporter::Instrumentation::ActiveRecord.start(custom_labels: { type: 'puma_worker' }, config_labels: %i[database host])
PrometheusExporter::Instrumentation::Puma.start
PrometheusExporter::Instrumentation::Process.start(type: 'web')
end end

View file

@ -1,24 +1,6 @@
#!/bin/sh #!/bin/sh
set -e set -e
export RAILS_ENV=production
case $1 in case $1 in
rails) prometheus) daemonize -c /srv/http -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u app /usr/bin/foreman start prometheus ;;
cd /srv/http
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec puma -d config.ru
exit $?
;;
darkhttpd)
darkhttpd /srv/http/public \
--no-server-id \
--pidfile /tmp/darkhttpd.pid \
--uid darkhttpd \
--gid www-data \
--no-listing \
--daemon \
--port 8080
exit $?
;;
esac esac

View file

@ -3,6 +3,10 @@ check process sutty with pidfile /srv/http/tmp/puma.pid
as uid "app" and gid "www-data" as uid "app" and gid "www-data"
stop program = "/bin/sh -c 'cat /srv/http/tmp/puma.pid | xargs kill'" stop program = "/bin/sh -c 'cat /srv/http/tmp/puma.pid | xargs kill'"
check process prometheus with pidfile /tmp/prometheus.pid
start program = "/usr/local/bin/prometheus"
stop program = "/bin/sh -c 'cat /tmp/prometheus.pid | xargs kill'"
check program sync_assets check program sync_assets
with path /usr/local/bin/sync_assets with path /usr/local/bin/sync_assets
if status = 0 then unmonitor if status = 0 then unmonitor

6
prometheus.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
set -e
case $1 in
prometheus) daemonize -c /srv/http -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u app /usr/bin/foreman start prometheus ;;
esac