Shell script to check if a process is running, if not start it.
We have 2 monitoring process which will check each other as well as the process
#!/bin/bash
#monitor.sh
#This process will monitor 1.Process is running
#
2.Other monitor process is running
#Sleeping time is 20s
myhome=/home/rset/Desktop
sleep 10
while :
do
sleep 20
#Process checking
#ps -ef | grep -v grep | grep process.sh
if ps -ef | grep -v grep | grep process.sh > /dev/null
then
echo "Running" > /dev/null
myprocessid=`pgrep process.sh`
echo "###########PROCESS STATUS#############" >> $myhome/procstats.log
cat /proc/$myprocessid/status > $myhome/procstats.log
echo "###########INSTRUCTION POINTER#############" >> $myhome/procstats.log
ps -o eip $myprocessid >> $myhome/procstats.log
echo "###########" >> $myhome/procstats.log
else
echo "Not Running"
#Start it
echo "Starting"
cd $myhome
./process.sh
echo "killed"
fi
if ps -ef | grep -v grep | grep monitorslave.sh > /dev/null
then
echo "Monitor slave already running" > /dev/null
else
echo "Monitor slave started"
cd $myhome
./monitorslave.sh
fi
done
#!/bin/bash
#monitorslave.sh
#This process will monitor 1.Process is running
#
2.Other monitor process is running
#Sleeping time is 20s
myhome=/home/rset/Desktop
while :
do
sleep 20
#Process checking
#ps -ef | grep -v grep | grep process.sh
if ps -ef | grep -v grep | grep process.sh > /dev/null
then
echo "Running" > /dev/null
myprocessid=`pgrep process.sh`
echo "###########PROCESS STATUS#############" >> $myhome/procstats_slave.log
cat /proc/$myprocessid/status > $myhome/procstats_slave.log
echo "###########INSTRUCTION POINTER#############" >> $myhome/procstats_slave.log
ps -o eip $myprocessid >> $myhome/procstats_slave.log
echo "###########" >> $myhome/procstats_slave.log
else
echo "Not Running"
#Start it
echo "Starting"
cd $myhome
./process.sh
echo "killed"
fi
if ps -ef | grep -v grep | grep monitor.sh > /dev/null
then
echo "Monitor already running" > /dev/null
File: /home/rset/Desktop/procesim
else
echo "Monitor started"
cd $myhome
./monitor.sh
fi
done
#!/bin/bash
#process.sh
#Process to print from up to 5000
i=`tail -1 process.log`
j=5000
while [[ $i -le $j ]]
do
sleep 2
echo $i >> process.log
echo $i
i=`expr $i + 1`
done
Omnipresent IT Solutions Pvt Ltd
Saturday, January 7, 2012
Channel Bonding in Ubuntu by Combining Wired and Wireless networking
Channel Bonding
Channel bonding allows to combine several network ports to a single group.Virtual NIC interface created provides increased bandwidth by merging the bandwidth of the individual ports/NICs. It's primary use is to increase a network link speed beyond the limits of any one single cable or port. Although It can also be used for failover, if one link dies all traffic to and from the machine should be routed to the remaining links.

Configuration
1. Need to install ifenslave
sudo apt-get install ifenslave
2.Edit /etc/network/interfaces and enter the following details
auto bond0
iface bond0 inet static
address 192.168.2.2
gateway 192.168.2.1
netmask 255.255.255.0
bond-slaves eth0 wlan0
bond_mode 0
bond_miimon 100
auto eth0
iface eth0 inet manual
3. Restart Networking
sudo /etc/init.d/networking restart
4. You can have different modes, change the value of bond_mode
mode=0 (balance-rr) Round-robin policy
5. You can check bond link information
root@opis-nb1:~# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.0 (June 2, 2010)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1e:ec:5f:ca:2b
Slave queue ID: 0
Slave Interface: wlan0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:22:69:7e:d0:92
Slave queue ID: 0
Channel bonding allows to combine several network ports to a single group.Virtual NIC interface created provides increased bandwidth by merging the bandwidth of the individual ports/NICs. It's primary use is to increase a network link speed beyond the limits of any one single cable or port. Although It can also be used for failover, if one link dies all traffic to and from the machine should be routed to the remaining links.
Configuration
1. Need to install ifenslave
sudo apt-get install ifenslave
2.Edit /etc/network/interfaces and enter the following details
auto bond0
iface bond0 inet static
address 192.168.2.2
gateway 192.168.2.1
netmask 255.255.255.0
bond-slaves eth0 wlan0
bond_mode 0
bond_miimon 100
auto eth0
iface eth0 inet manual
3. Restart Networking
sudo /etc/init.d/networking restart
4. You can have different modes, change the value of bond_mode
mode=0 (balance-rr) Round-robin policy
mode=1 (active-backup)Active-backup policy
mode=2 (balance-xor)XOR policy
mode=3 (broadcast)Broadcast policy
mode=4 (802.3ad)IEEE 802.3ad Dynamic link aggregation.
mode=5 (balance-tlb) Adaptive transmit load balancing
mode=6 (balance-alb) Adaptive load balancing5. You can check bond link information
root@opis-nb1:~# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.0 (June 2, 2010)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1e:ec:5f:ca:2b
Slave queue ID: 0
Slave Interface: wlan0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:22:69:7e:d0:92
Slave queue ID: 0
Subscribe to:
Posts (Atom)
