This is a configurable Ruby gem providing a collection of server monitoring scripts.
- Mailq - check number of messages in the server's mail queue
- MegaCliVDStatus - check the status of LSI RAID Controller Virtual Drive
- MegaCliDiskSMARTStatus - check if disk returns a S.M.A.R.T alert
#!/usr/bin/env ruby -w
require "servermonitor/mailq"
ServerMonitor::Mailq.configure do |config|
config.path = "/opt/zimbra/common/sbin/postqueue -p"
config.grep = "/bin/grep"
config.exit_codes = false
end
ServerMonitor::Mailq.run
#!/usr/bin/env ruby -w
require "servermonitor/megacli_vd_status"
ServerMonitor::MegaCliVDStatus.configure do |config|
config.megacli = "/usr/sbin/megacli"
config.grep = "/bin/grep"
config.exit_codes = false
end
ServerMonitor::MegaCliVDStatus.run
#!/usr/bin/env ruby -w
require "servermonitor/megacli_vd_status"
ServerMonitor::MegaCliVDStatus.configure do |config|
config.megacli = "/usr/sbin/megacli"
config.grep = "/bin/grep"
config.exit_codes = false
config.email_to = "[email protected]"
config.email_from = "[email protected]"
config.smtp_address = "server"
config.smtp_port = "25"
config.smtp_username = "username"
config.smtp_password = "password"
end
ServerMonitor::MegaCliVDStatus.run
#!/usr/bin/env ruby -w
require "servermonitor/megacli_disk_smart_status"
ServerMonitor::MegaCliDiskSMARTStatus.configure do |config|
config.megacli = "/usr/sbin/megacli"
config.grep = "/bin/grep"
config.exit_codes = false
end
ServerMonitor::MegaCliDiskSMARTStatus.run
#!/usr/bin/env ruby -w
require "servermonitor/megacli_disk_smart_status"
ServerMonitor::MegaCliDiskSMARTStatus.configure do |config|
config.megacli = "/usr/sbin/megacli"
config.grep = "/bin/grep"
config.exit_codes = false
config.email_to = "[email protected]"
config.email_from = "[email protected]"
config.smtp_address = "server"
config.smtp_port = "25"
config.smtp_username = "username"
config.smtp_password = "password"
end
ServerMonitor::MegaCliDiskSMARTStatus.run
#!/usr/bin/env rvm-auto-ruby
require "servermonitor/mailq"
ServerMonitor::Mailq.configure do |config|
config.path = "/opt/zimbra/common/sbin/postqueue -p"
config.grep = "/bin/grep"
config.exit_codes = false
end
ServerMonitor::Mailq.run
Set exit_codes to true in order to use with monit
- find out path of binary with
which postmailq
- put script in
/etc/monit/conf.d/chech_mail-queue
check program CheckMailQueue path "/home/nedim/.rvm/gems/ruby-2.4.2/bin/postmailq"
if status != 0 then alert
- replace
/home/nedim/.rvm/gems/ruby-2.4.2/bin/postmailq
with output you got fromwhich postmailq
servermonitor
postmailq
Add to your Gemfile
gem 'servermonitor', git: 'https://github.com/neidiom/servermonitor.git'
Run bundler
bundle install
gem build servermonitor.gemspec
ls *.gem
gem install servermonitor-*.gem