a Little Notes

Ikon

TUlisan dan Contekan

Server LTSP MACET

Weleh, server LTSP macet pas ada user ! Night mare bgt. Liat proses diserver ternyata ada banyak proses pada client yang masih jalan padahal kompinya udah pada mati. Nah ini dia problemnya, so cari sana sini di paman google and coba scripts untuk ngekill prosess yang enggak kepake setiap 1 menit di server LTSP.

Thx buat Murray Fleming atas scriptnya, mantep Ommm 🙂
# su – root
# isi root password km
# touch /usr/sbin/orphkill
# chmod 700 /usr/bin/orphkill
# edit file /usr/bin/orphkill (saya pake vile)

#!/bin/bash

# orphKill – This program searches for orphaned processes and kills them.
# This is particulary usefull for LTSP servers where the terminals are not logged off
# properly due to powercuts, etc.

# Written by Murray Fleming

# Declare arrays
declare -a procUsers #Process usernames
declare -a procIDs #Process IDs
declare -a safeUsers #List of safe users

# Fill procUsers and procUds arrays
num=0
num2=0
for i in `ps aux | awk ‘{print $1 ” ” $2}’` ; do
rem=$(($num % 2))
if [ $rem -eq 0 ]; then
procUsers[$num2]=$i
else
procIDs[$num2]=$i
num2=$(($num2 +1))
fi
num=$(($num + 1))
done
# Remove ps aux column headers
unset procUsers[0]
unset procIDs[0]
# Protect samba, imapd and gam_server daemons by marking their users as root
for i in `pgrep smbd && pgrep gam_server && pgrep imapd` ; do
num=0
while [ $num -lt ${#procIDs[@]} ]; do
if [ “$i” == “${procIDs[$num]}” ]; then
procUsers[$num]=”root”
fi
num=$(($num + 1))
done
done

# Fill safeUsers array
num=0
# Add logged in usernames and uids
for i in `last | awk ‘/'”still logged in”$’/ {print $1}’` ; do
safeUsers[$num]=$i
num=$(($num + 1))
if [ ${#i} -eq 8 ]; then
safeUsers[$num]=`grep ^$i /etc/passwd | awk ‘BEGIN {FS = “:”} {print $3}’`
else
safeUsers[$num]=`grep ^$i: /etc/passwd | awk ‘BEGIN {FS = “:”} {print $3}’`
fi
num=$(($num + 1))
done
# Add system usernames and uids
for i in `cat /etc/passwd | awk ‘BEGIN {FS = “:”} {if ($3 > /var/log/killed.log
echo `ps aux | grep ${procIDs[$num]} | grep -v grep` >> /var/log/killed.log
kill ${procIDs[$num]}
fi
num=$(($num + 1))
done

—————————-
Sekarang tinggal mengaktipkan script di crond

1 * * * * root /usr/sbin/orphkill >& /dev/null

Script aktif setiap 1 menit untuk ngecek proses diserver.

Iklan

Filed under: LinuX

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: