Hi,
This is a quick script I cobbled together for my own use, but I'd like to get it
ACK'ed and into the util/ directory, as it seems like it's widely useful. I got
sick of having to check individual services to see if any had failed, so I wrote this to
iterate over all the relevant services, check their status, and to ensure that the right
ports were up.
-- Matt
Show replies by date
---
util/check_services | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
create mode 100755 util/check_services
diff --git a/util/check_services b/util/check_services
new file mode 100755
index 0000000..15da4aa
--- /dev/null
+++ b/util/check_services
@@ -0,0 +1,36 @@
+#!/usr/bin/ruby
+init_scripts=%w(aeolus-conductor aeolus-connector condor conductor-dbomatic
conductor-delayed_job conductor-warehouse_sync deltacloud-core deltacloud-ec2-us-east-1
deltacloud-ec2-us-west-1 deltacloud-mock httpd imagefactory iwhd libvirtd mongod ntpd
postgresql qpidd)
+
+# Some status checks give weird results if this isn't run as root
+raise "\e[1;31mERROR:\e[0m This command must be run as root to give accurate
results" unless Process.euid==0
+
+init_scripts.each do |script|
+ puts "\nChecking #{script} ..."
+ cmd = "/etc/init.d/#{script} status"
+ out = `#{cmd}`
+ if $?.to_i == 0
+ puts " \e[1;32mSuccess:\e[0m #{out.strip}"
+ else
+ puts " \e[1;31mFAILURE:\e[0m #{out.strip}"
+ end
+end
+
+# Other checks
+commands = [
+ #{:name => 'Development Solr', :command => 'lsof -i :8981'},
+ {:name => 'Production Solr', :command => 'lsof -i :8983'},
+ {:name => 'Aeolus Connector', :command => 'lsof -i :2003'},
+ {:name => 'deltacloud-mock', :command => 'lsof -i :3002'},
+ {:name => 'deltacloud-ec2-us-east-1', :command => 'lsof -i
:3003'},
+ {:name => 'deltacloud-ec2-us-west-1', :command => 'lsof -i
:3004'}
+]
+commands.each do |cmd|
+ print "\nChecking port for #{cmd[:name]} ..."
+ cmd = "#{cmd[:command]}"
+ out = `#{cmd}`
+ if $?.to_i == 0
+ print " \e[1;32mSuccess:\e[0m\n#{out.strip}\n"
+ else
+ print " \e[1;31mFAILURE:\e[0m\n#{out.strip}\n"
+ end
+end
--
1.7.4.4