All pastes #767477 Raw Edit

kevev

public text v1 · immutable
·published 2007-11-09 19:58 UTC
rendered paste body
# Author
puts ''
puts 'LAMP Alive'
puts ''
puts 'BY:  Kevin Evans (kevev)irc.freenode.net'
puts '     John Lauck (notjohn)irc.freenode.net'
puts''
puts''

#!/usr/bin/env ruby
## Begin Code
require 'open-uri'

#
# variables
#

glusterfsd = nil
mysql = nil
ucarp = nil
glusterfs_client = nil
mysql_proxy = nil

#
# methods
#

def test_glusterfsd
  !`ps h -C glusterfsd`.empty?
end

def test_mysql
  !`ps h -C mysqld`.empty?
end

def test_ucarp
  !`ps h -C ucarp`.empty?
end

def test_glusterfs_client
  !`ps h -C glusterfs`.empty?
end

def test_mysql_proxy
  !`ps h -C mysql-proxy`.empty?
end

def test_httpd
  begin 
    open('http://192.168.233.140/index.html')
    return 1
  rescue
    return 0
  end
end

# 
# main
#

while true do
  if test_glusterfsd() == false
    `/etc/init.d/glusterfsd start`
        until !`ps h -C glusterfsd`.empty?
          sleep(1)
        end

    elsif test_glusterfs_client() == false
      `/etc/init.d/glusterfs-client start`
        until !`ps h -C glusterfs-client`.empty?
          sleep(1)
        end

        until `ps h -C gluster-clien`.empty?
          sleep(1)
        end

      elsif test_mysql() == false
        `/etc/init.d/mysqld start`
        until !`ps h -C mysqld`.empty?
          sleep(1)
        end

        elsif test_mysql_proxy() == false
          `/etc/init.d/mysql-proxy start`
        until !`ps h -C mysql_proxy`.empty?
          sleep(1)
        end

          elsif test_httpd() == 0
            `/etc/init.d/httpd restart`
            sleep(2)
          else
            sleep(5)
             puts test_glusterfsd
             puts test_glusterfs_client
             puts test_mysql
             puts test_mysql_proxy
             puts test_httpd
          end
        end