Thursday, September 11, 2008

Using screen on Linux ...Experience Remote Assistance in CLI

Below are the steps to attach two Linux shell sessions with screen.
Its like Remote Assistance in CLI.

1. Open two terminals with same login.

2. Run ps on both terminals.

3. Run screen -S on 1st terminal.

4. Run cd /var/run/screen/S-; ls on 2nd terminal.

5. Look for 1st terminal's bash PID entry.

6. Run screen -x on 2nd terminal.

Thursday, June 12, 2008

Shell script to monitor ur lab machines

Hello PPL,

After long time I addin new post. Below is the shell script using this can monitor server n their uptime.

[
#!/bin/bash

# add ip / hostname separated by while space
HOSTS="172.30.0.62 172.30.0.41 solaris netra1 172.30.0.76 172.30.0.114 aix"

# no ping request
COUNT=1

# email report when
SUBJECT="Ping failed"
EMAILID1="jack@knowlinux.com"
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -eq 0 ]; then
# 100% failed
echo "$myHost is not reachable"
echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID1 $EMAILID2 $EMAILID3
fi
done
]