icap_enable on
icap_preview_enable on
icap_preview_size 128
icap_send_client_ip on
icap_service service_avi_req reqmod_precache 0 icap://localhost:1344/srv_clamav
icap_service service_avi respmod_precache 1 icap://localhost:1344/srv_clamav
icap_class class_antivirus service_avi service_avi_req
icap_access class_antivirus allow all
Friday, December 24, 2010
Nmap To Discover Network IP,Openport,OS Type IN XML Format
#! /bin/bash
ETHERNET=eth0
HostList=(`arp -vni $ETHERNET |cut -d " " -f 1 |grep -r 192 |xargs`)
for (( i = 0 ; i <= ${#HostList[*]} ; i++ ))
do
nmap -F -O -o2 --osscan-limit -oX ${HostList[i]}_$i.xml ${HostList[i]}
done
ETHERNET=eth0
HostList=(`arp -vni $ETHERNET |cut -d " " -f 1 |grep -r 192 |xargs`)
for (( i = 0 ; i <= ${#HostList[*]} ; i++ ))
do
nmap -F -O -o2 --osscan-limit -oX ${HostList[i]}_$i.xml ${HostList[i]}
done
Bandwidthd CDF File Processing
#! /bin/bash
user_array=`cat log.*.cdf |cut -d , -f 1 |sort -u |xargs`
for B in $user_array
do
c=2
echo -e "For the IP $B"
echo "" > /tmp/port$$$
while [ $c -le 16 ]
do
cat log.*.cdf |grep $B |cut -d , -f $c |xargs >/tmp/ele$$$
I=0
for N in `cat /tmp/ele$$$`
do
I=`expr $I + $N`
done
echo $I >>/tmp/port$$$
(( c++ ))
done
sleep 2
echo -e "\t `cat /tmp/port$$$ |xargs`"
done
rm -rf *.cdf
/etc/init.d/bandwidthd restart
user_array=`cat log.*.cdf |cut -d , -f 1 |sort -u |xargs`
for B in $user_array
do
c=2
echo -e "For the IP $B"
echo "" > /tmp/port$$$
while [ $c -le 16 ]
do
cat log.*.cdf |grep $B |cut -d , -f $c |xargs >/tmp/ele$$$
I=0
for N in `cat /tmp/ele$$$`
do
I=`expr $I + $N`
done
echo $I >>/tmp/port$$$
(( c++ ))
done
sleep 2
echo -e "\t `cat /tmp/port$$$ |xargs`"
done
rm -rf *.cdf
/etc/init.d/bandwidthd restart
How To Keep Track On Disk Usage @Linux
#! /bin/bash
# chetan.muneshwar@gmail.com
# script to get disk space status on multiple instances and alert Admin
bulk_data=(`df -Ph | grep -r '/' | awk '{ printf "%s-%s-%s-%s ",$3,$4,$5,$6 }'`)
for (( i = 0 ; i < ${#bulk_data[*]}; i++ ))
do
threshold="`echo ${bulk_data[i]}|cut -d "-" -f 3|cut -d "%" -f 1` "
if [ $threshold -le 0 ] ; then
shm_val="`echo ${bulk_data[i]}|grep -r 'shm'`"
if [ "$shm_val" == "" ] ; then
echo "SERVER ${bulk_data[i]} " | mail -s " Disk vol fuLL ISHY-SERVER " chetan.muneshwar@labs.net -c shrikant.lokhande@labs.net
else
echo ""
fi
else
if [ $threshold -le 90 ] ;then
echo ""
else
echo "SERVER ${bulk_data[i]} " | mail -s " Disk vol warning ISHY-SERVER " chetan.muneshwar@labs.net -c shrikant.lokhande@labs.net
fi
fi
done
Finally add cronjob : * * * * * /usr/bin/DISK
# chetan.muneshwar@gmail.com
# script to get disk space status on multiple instances and alert Admin
bulk_data=(`df -Ph | grep -r '/' | awk '{ printf "%s-%s-%s-%s ",$3,$4,$5,$6 }'`)
for (( i = 0 ; i < ${#bulk_data[*]}; i++ ))
do
threshold="`echo ${bulk_data[i]}|cut -d "-" -f 3|cut -d "%" -f 1` "
if [ $threshold -le 0 ] ; then
shm_val="`echo ${bulk_data[i]}|grep -r 'shm'`"
if [ "$shm_val" == "" ] ; then
echo "SERVER ${bulk_data[i]} " | mail -s " Disk vol fuLL ISHY-SERVER " chetan.muneshwar@labs.net -c shrikant.lokhande@labs.net
else
echo ""
fi
else
if [ $threshold -le 90 ] ;then
echo ""
else
echo "SERVER ${bulk_data[i]} " | mail -s " Disk vol warning ISHY-SERVER " chetan.muneshwar@labs.net -c shrikant.lokhande@labs.net
fi
fi
done
Finally add cronjob : * * * * * /usr/bin/DISK
Monday, November 1, 2010
Anaconda Installer With Custom Brand/Product name
Mount stage2.img from iso .
edit mount_root/usr/lib/anaconda/product.py
comment the line as below save rebuild stage2.img
Thats it in short .
edit mount_root/usr/lib/anaconda/product.py
comment the line as below save rebuild stage2.img
[root@localhost anaconda]# cat product.py
#
# product.py: product identification string
#
import os
#if os.access("/tmp/product/.buildstamp", os.R_OK):
# path = "/tmp/product/.buildstamp"
#elif os.access("/.buildstamp", os.R_OK):
# path = "/.buildstamp"
#elif os.environ.has_key("PRODBUILDPATH") and \
# os.access(os.environ["PRODBUILDPATH"], os.R_OK):
# path = os.environ["PRODBUILDPATH"]
#else:
# path = None
productStamp = ""
productName = "SimpleWall"
productVersion = "bluesky"
productPath = "CentOS"
bugUrl = "Cnetos bugy."
#if path is not None:
# f = open(path, "r")
# lines = f.readlines()
# if len(lines) >= 3:
# productStamp = lines[0][:-1]
# productName = lines[1][:-1]
# productVersion = lines[2][:-1]
# if len(lines) >= 4:
# productPath = lines[3][:-1]
# if len(lines) >= 5:
# bugUrl = lines[4][:-1]
#if os.environ.has_key("ANACONDA_PRODUCTNAME"):
# productName = os.environ["ANACONDA_PRODUCTNAME"]
#if os.environ.has_key("ANACONDA_PRODUCTVERSION"):
# productVersion = os.environ["ANACONDA_PRODUCTVERSION"]
#if os.environ.has_key("ANACONDA_PRODUCTPATH"):
# productPath = os.environ["ANACONDA_PRODUCTPATH"]
#if os.environ.has_key("ANACONDA_BUGURL"):
# bugUrl = os.environ["ANACONDA_BUGURL"]
#
# product.py: product identification string
#
import os
#if os.access("/tmp/product/.buildstamp", os.R_OK):
# path = "/tmp/product/.buildstamp"
#elif os.access("/.buildstamp", os.R_OK):
# path = "/.buildstamp"
#elif os.environ.has_key("PRODBUILDPATH") and \
# os.access(os.environ["PRODBUILDPATH"], os.R_OK):
# path = os.environ["PRODBUILDPATH"]
#else:
# path = None
productStamp = ""
productName = "SimpleWall"
productVersion = "bluesky"
productPath = "CentOS"
bugUrl = "Cnetos bugy."
#if path is not None:
# f = open(path, "r")
# lines = f.readlines()
# if len(lines) >= 3:
# productStamp = lines[0][:-1]
# productName = lines[1][:-1]
# productVersion = lines[2][:-1]
# if len(lines) >= 4:
# productPath = lines[3][:-1]
# if len(lines) >= 5:
# bugUrl = lines[4][:-1]
#if os.environ.has_key("ANACONDA_PRODUCTNAME"):
# productName = os.environ["ANACONDA_PRODUCTNAME"]
#if os.environ.has_key("ANACONDA_PRODUCTVERSION"):
# productVersion = os.environ["ANACONDA_PRODUCTVERSION"]
#if os.environ.has_key("ANACONDA_PRODUCTPATH"):
# productPath = os.environ["ANACONDA_PRODUCTPATH"]
#if os.environ.has_key("ANACONDA_BUGURL"):
# bugUrl = os.environ["ANACONDA_BUGURL"]
Thats it in short .
How To Connect To Mysql With SSH tunnel
Remote connection of mysql is always pain for security concern ssh tunnel is best option .
#! /bin/bash
# Copy This script to /usr/bin/
Tunnel_check="`sudo netstat -tulnp 3307 |grep 127.0.0.1:3307`"
if [ "$Tunnel_check" == "" ] ;then
echo "Tunnel is really Running ?"
/usr/bin/ssh -2 -f -C -N deploy@ec2-23.45.124.compute-1.amazonaws.com -L 3307/127.0.0.1/3306
else
echo "Tunnel is Running"
fi
#! /bin/bash
# Copy This script to /usr/bin/
Tunnel_check="`sudo netstat -tulnp 3307 |grep 127.0.0.1:3307`"
if [ "$Tunnel_check" == "" ] ;then
echo "Tunnel is really Running ?"
/usr/bin/ssh -2 -f -C -N deploy@ec2-23.45.124.compute-1.amazonaws.com -L 3307/127.0.0.1/3306
else
echo "Tunnel is Running"
fi
Wednesday, October 20, 2010
Schedule Scripts With Interval of One Second
Cron jobs with default setting has default scheduling time Of 1MIN.
Below is the trick to operate in seconds.
#! /bin/bash
PROCNAME=’/usr/bin/xyz.rb’
PIDS=`ps -efa | grep $PROCNAME | grep -v grep | awk ‘{ print $2 }’`
for ff in $PIDS
do
echo “$ff” > /tmp/w
done
if [ -f "/tmp/w" ] ; then
pid=$(cat /tmp/w)
if [ "$pid" == "" ] ;then
/usr/local/bin/ruby /usr/bin/xyz.rb
else
echo “Already running $pid”
fi
rm -rf /tmp/w
else
/usr/local/bin/ruby /usr/bin/xyz.rb &
fi
Where xyz.rb is simple rb program in loop
require ‘rubygems’
require ‘daemons’
loop do
system(‘/usr/bin/Server_get |xargs >/var/www/html/text.txt’)
system(‘/usr/bin/get_app_stats |xargs >/var/www/html/app_stat.txt’)
sleep (25)
end
At the last add it to crontab
* * * * * /usr/bin/fast_cron
cheers its much useful in fast messaging,emailing campaigns .
Below is the trick to operate in seconds.
#! /bin/bash
PROCNAME=’/usr/bin/xyz.rb’
PIDS=`ps -efa | grep $PROCNAME | grep -v grep | awk ‘{ print $2 }’`
for ff in $PIDS
do
echo “$ff” > /tmp/w
done
if [ -f "/tmp/w" ] ; then
pid=$(cat /tmp/w)
if [ "$pid" == "" ] ;then
/usr/local/bin/ruby /usr/bin/xyz.rb
else
echo “Already running $pid”
fi
rm -rf /tmp/w
else
/usr/local/bin/ruby /usr/bin/xyz.rb &
fi
Where xyz.rb is simple rb program in loop
require ‘rubygems’
require ‘daemons’
loop do
system(‘/usr/bin/Server_get |xargs >/var/www/html/text.txt’)
system(‘/usr/bin/get_app_stats |xargs >/var/www/html/app_stat.txt’)
sleep (25)
end
At the last add it to crontab
* * * * * /usr/bin/fast_cron
cheers its much useful in fast messaging,emailing campaigns .
Subscribe to:
Posts (Atom)