Commit 1908a7ed authored by nazarf's avatar nazarf

add send miners status

parent eab742ef
...@@ -32,6 +32,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] ...@@ -32,6 +32,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "httparty" gem "httparty"
gem 'whenever', require: false gem 'whenever', require: false
gem "google_drive" gem "google_drive"
gem 'telegram_bot', '~> 0.0.4'
group :development do group :development do
gem 'web-console', '~> 2.0' gem 'web-console', '~> 2.0'
......
...@@ -44,6 +44,10 @@ GEM ...@@ -44,6 +44,10 @@ GEM
arel (6.0.4) arel (6.0.4)
autoprefixer-rails (10.4.13.0) autoprefixer-rails (10.4.13.0)
execjs (~> 2) execjs (~> 2)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
bcrypt (3.1.18) bcrypt (3.1.18)
binding_of_caller (1.0.0) binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
...@@ -80,6 +84,8 @@ GEM ...@@ -80,6 +84,8 @@ GEM
chronic (0.10.2) chronic (0.10.2)
ckeditor (5.1.1) ckeditor (5.1.1)
orm_adapter (~> 0.5.0) orm_adapter (~> 0.5.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (4.1.1) coffee-rails (4.1.1)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x) railties (>= 4.0.0, < 5.1.x)
...@@ -92,6 +98,8 @@ GEM ...@@ -92,6 +98,8 @@ GEM
crass (1.0.6) crass (1.0.6)
debug_inspector (1.1.0) debug_inspector (1.1.0)
declarative (0.0.20) declarative (0.0.20)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.9.0) devise (4.9.0)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
...@@ -102,6 +110,7 @@ GEM ...@@ -102,6 +110,7 @@ GEM
devise (>= 4.9.0) devise (>= 4.9.0)
digest (3.1.1) digest (3.1.1)
erubis (2.7.0) erubis (2.7.0)
excon (0.100.0)
execjs (2.8.1) execjs (2.8.1)
faraday (1.10.3) faraday (1.10.3)
faraday-em_http (~> 1.0) faraday-em_http (~> 1.0)
...@@ -176,6 +185,7 @@ GEM ...@@ -176,6 +185,7 @@ GEM
httpclient (2.8.3) httpclient (2.8.3)
i18n (0.9.5) i18n (0.9.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
io-wait (0.3.0) io-wait (0.3.0)
jbuilder (2.9.1) jbuilder (2.9.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
...@@ -318,6 +328,9 @@ GEM ...@@ -318,6 +328,9 @@ GEM
net-ssh (>= 2.8.0) net-ssh (>= 2.8.0)
ssrf_filter (1.0.8) ssrf_filter (1.0.8)
strscan (3.0.6) strscan (3.0.6)
telegram_bot (0.0.8)
excon (>= 0.30.0)
virtus (>= 1.0.0)
temple (0.10.0) temple (0.10.0)
thor (1.2.1) thor (1.2.1)
thread_safe (0.3.6) thread_safe (0.3.6)
...@@ -337,6 +350,10 @@ GEM ...@@ -337,6 +350,10 @@ GEM
uber (0.1.0) uber (0.1.0)
uglifier (4.2.0) uglifier (4.2.0)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
virtus (2.0.0)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
warden (1.2.7) warden (1.2.7)
rack (>= 1.0) rack (>= 1.0)
web-console (2.3.0) web-console (2.3.0)
...@@ -382,6 +399,7 @@ DEPENDENCIES ...@@ -382,6 +399,7 @@ DEPENDENCIES
sass-rails (~> 5.0) sass-rails (~> 5.0)
sdoc (~> 0.4.0) sdoc (~> 0.4.0)
simple_form simple_form
telegram_bot (~> 0.0.4)
turbolinks turbolinks
twitter-bootstrap-rails twitter-bootstrap-rails
tzinfo-data tzinfo-data
......
set :output, 'log/cron.log' set :output, 'log/cron.log'
# every("*/5 * * * *", roles: [:app]) { rake "miners:check_miners" } # every("*/5 * * * *", roles: [:app]) { rake "miners:check_miners" }
every("*/5 * * * *", roles: [:app]) { rake "miners:check_safex_active_miner" } every("*/5 * * * *", roles: [:app]) { rake "miners:check_safex_active_miner" }
\ No newline at end of file every("0 2 * * *", roles: [:app]) { rake "miners:miners_status_notification" }
\ No newline at end of file
...@@ -133,4 +133,30 @@ namespace :miners do ...@@ -133,4 +133,30 @@ namespace :miners do
end end
end end
end end
end
task miners_status_notification: :environment do
require 'logger'
require 'telegram_bot'
TELEGRAM_BOT_TOKEN = "5829604433:AAG5CeFBygU1lvV5oeeDyT_v0CqzjAWCNlY"
CHAT_ID = "-1001516309000"
bot = TelegramBot.new(token: TELEGRAM_BOT_TOKEN, logger: Logger.new(STDOUT))
channel = TelegramBot::Channel.new(id: CHAT_ID)
message = TelegramBot::OutMessage.new
message.chat = channel
miss_miner = Miner.where(status: Miner::STATUSES[0])
restart_miner = Miner.where(status: Miner::STATUSES[1])
active_miner = Miner.where(status: Miner::STATUSES[2])
message.text = "Date: #{DateTime.now.strftime("%d.%m.%Y %H:%M")}\n
Total: #{Miner.count}\n
Active: #{active_miner.count}\n
Restart: #{restart_miner.count}\n
Miss: #{miss_miner.count}\n
#{miss_miner.map(&:name).join(', ')}
"
message.send_with(bot)
end end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment