Archive for the ‘Scripts’ Category
-
SSH login expect shell script to supply username and password
Thursday, August 12th, 2010
#!/usr/bin/expect -f # Expect script to supply root/admin password for remote ssh server # and execute command. # This script needs three argument to(s) connect to remote server: # password = Password of remote UNIX server, for root user. # ipaddr = IP Addreess of remote UNIX server, no hostname # scriptname = Path to [...]
-
How imports historical Nagios log files into the mysql database
Friday, March 5th, 2010
NDO Utilities:- The NDO utilities add-on, written by Nagios developer Ethan Galstad, is designed to output events and data from Nagios to standard files or to a Unix socket. It also comes with a module called NDO2DB that allows Nagios data to be written to a MySQL or PostgreSQL database The add-on is made up [...]
-
To delete a string (192.168.1.1) from the file
Wednesday, January 20th, 2010
sed -i “/string/d” Filename /bin/sed -i “/192.168.1.1/d” /var/log/messages %s/,mianl//g Trim Space at the end ######################################## sed ‘s/ *$//g’ ${LOGFILE} > ${LOGFILE}.1 mv ${LOGFILE}.1 ${LOGFILE}
-
BASH Scripting ~ learning by examples
Wednesday, January 20th, 2010
—————————————– Program (1) ~ array.sh —————————————– #!/bin/bash echo “==============” declare -a myarr[0]=”Manoj” declare -a myarr1 myarr1=(Manoj Chauhan bangalore mumbai pune delhi) myarr[1]=”Chauhan” echo “my name is ${myarr[0]} ${myarr[1]}” echo “————————–” echo “${myarr1[*]}” echo ${myarr1[2]} echo ${myarr1[@]} echo “————————–” echo “Total no of elements in array – ${#myarr1[*]}” echo “Total no of elements in array – [...]
-
Nagios Script for Varnish Server
Saturday, October 31st, 2009
#!/bin/bash # Varnish Process Monitor # Written By: Manoj Chauhan # Email ID: mchauhan75@gmail.com # Dated: 31-07-2009 # Restart Varnish Server When It Goes Down LOG=/usr/bin/logger RESTART=”/usr/bin/sudo /etc/init.d/varnishncsa restart” STATUS=”/etc/init.d/varnishncsa status” # Path to pgrep command PGREP=”/usr/bin/pgrep” VARNISHPID=”varnishncsa” Hostname=`hostname` STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 STATE_DEPENDENT=4 FLAG=0 /etc/init.d/varnishncsa status >/dev/null 2>&1 if [ $? -ne "0" ];then [...]




