route and masquerad ip from any host
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward
get os info
#lsb_release -rd
ps power
ps -eo user,pcpu,vsize --no-headers | awk '{num[$1]++; cpu[$1] += $2; mem[$1] += $3} \
END{\
printf("NPROC\tUSER\tCPU\tMEM\n");\
for (user in cpu)\
printf("%d\t%s\t%.2f%\t%s K\n",num[user], user, cpu[user], mem[user])\
}'
async delegates in... bash!
# Runs a command asynchronously
# $1 is the command to run
# $2 is the callback function
async_run() {
{
$1 &>/dev/null
# calling the callback passing the result
$2 $?
}&
}
nfs_callback() {
if [ $1 == "0" ]
then
touch /tmp/$$
fi
}
for i in $(mount -l -t nfs | grep nfs2 | awk -F ":" '{print $1}')
do
if [ $NFS_OK == "1" ]
then
async_run "/usr/sbin/rpcinfo -p $i" nfs_callback
disown
fi
done
sleep 1s
if [ -f /tmp/$$ ]
then
echo "NFS OK"
else
echo "NFS NOT OK"
fi
urlencode
perl -MURI::Escape -e "print uri_escape('$1');"