LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-16-2010, 10:00 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Need to write a Shell Script for Zabbix Application Level Clustering


Dear All,

We have zabbix Network monitoring tool installed on two servers 172.17.11.6 ( Master ) and 172.17.11.3 ( Slave ) RHEL 5.4 Servers with 172.17.11.4 being Virtual Ipaddress.

We are trying to implement High Availability with Red Hat Cluster Suite.

OS level Clustering has been implemented with following cluster configuraiton.

Code:
<?xml version="1.0"?>
<cluster alias="CDCTGIMCLSSVR" config_version="9" name="new_cluster">
        <fence_daemon post_fail_delay="0" post_join_delay="3"/>

        <clusternodes>
                <clusternode name="172.17.11.6" nodeid="1" votes="1">
                        <fence>
                                <method name="1"/>
                        </fence>
                </clusternode>
                <clusternode name="172.17.11.3" nodeid="2" votes="1">
                        <fence>
                                <method name="1"/>
                        </fence>
                </clusternode>
        </clusternodes>

        <cman expected_votes="1" two_node="1"/>

        <fencedevices>
                <fencedevice agent="fence_xvm" name="vm_fencing"/>
        </fencedevices>
        
	<rm>
                <failoverdomains/>
                <resources>
                        <fs device="/dev/sdb1" force_fsck="0" force_unmount="0" fsid="1582" fstype="ext3" mountpoint="/data"
name="database" options="" self_fence="0"/>
                </resources>

                <service autostart="1" name="IP_Service">
                        <ip address="172.17.11.4" monitor_link="1"/>
                        <fs ref="database"/>
                </service>

        </rm>

</cluster>
This is working well when Master Server's OS goes down.

But we need to implement Application level clustering for Zabbix_server process which inturn depends on httpd and mysqld deamons to be running.
So I have to check the health of mysqld and httpd with a shell script along with the health of zabbix_server process.

Any good tutorials for this ? Any guidlines that I have to follow ?

Here I may need to take care of following things when any one of the process goes down

1. Shifhting Virtual IP
2. Shifting /dev/sdb1 ( Shared drive to slave )
3. stopping other services on master
4. starting all the services on slave

Please help..

Thanks in advance

Last edited by vinaytp; 08-16-2010 at 10:05 AM.
 
Old 08-17-2010, 02:52 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
For quick hints, you can check if the process of mysqld, httpd and zabbix_server is still running by using pidof. Example
Code:
pidof mysqld >/dev/null 2>&1 || echo 'mysqld is no longer running.'
If you can tell their PID, you can use these two methods:
Code:
[[ -d /proc/$PID ]] || echo '... is no longer running.'
Code:
kill -s 0 "$PID" || echo '... is no longer running.'
Or perhaps killall? Not sure which is the most suitable:
Code:
killall -s 0 mysqld || echo 'mysqld is no longer running.'
 
Old 08-17-2010, 03:03 AM   #3
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Example implementation script:
Code:
#!/bin/bash

function shutdownall {
	# place commands here the will close the servers
}

function checkprocessbyname {
	pidof "$1" >/dev/null 2>&1
}

function checkprocessbypid {
	kill -s 0 "$1" >/dev/null 2>&1
}

for (( ;; )); do
	if ! checkprocessbyname mysqld; then
		echo 'mysqld is no longer running.'
		shutdownall
	elif ! checkprocessbyname httpd; then
		echo 'httpd is no longer running.'
		shutdownall
	elif ! checkprocessbyname zabbix_server ; then
		echo 'zabbix_server is no longer running.'
		shutdownall
	fi
done
For the tutorials btw, I suggest Advanced Bash-Scripting Guide. You'll also find the bash manual and the help command very handy in most cases.
 
Old 08-17-2010, 07:21 AM   #4
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Thanks konsolebox !!

I am Writing the script, thanks again for your inputs.
 
Old 08-17-2010, 07:37 AM   #5
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
No prob.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need to write a run level 3 script knockout_artist Linux - Newbie 5 11-12-2008 12:45 PM
help for high level shell script kushkothari Programming 13 10-30-2008 12:16 AM
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 07:24 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 04:00 PM


All times are GMT -5. The time now is 02:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration