Wednesday, October 20, 2010

Zenoss Installation on CentOS /RedHat /Fedora

This is a how to on installing Zenoss 2.0 core on a new Centos 5.0 installation. This guide assumes a new Centos 5 install with the default "server" software selection, no gui, and has SElinux disabled, if it is not disabled run setenforce 0 as root before starting. If you want to install the old 1.2 version of Zenoss 

#yum -y install mysql mysql-server net-snmp net-snmp-utils
#service mysqld start
#mysql_secure_installation (set up root password)
#wget http://downloads.sourceforge.net/zenoss/zenoss-stack-3.0.2-linux.bin
#chmod 777 zenoss-stack-3.0.2-linux.bin
#./zenoss-stack-3.0.2-linux.bin 













Tuesday, October 19, 2010

Bash function to decompress archives

 extract () {
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2)   tar xvjf $1        ;;
            *.tar.gz)    tar xvzf $1     ;;
            *.bz2)       bunzip2 $1       ;;
            *.rar)       unrar x $1     ;;
            *.gz)        gunzip $1     ;;
            *.tar)       tar xvf $1        ;;
            *.tbz2)      tar xvjf $1      ;;
            *.tgz)       tar xvzf $1       ;;
            *.zip)       unzip $1     ;;
            *.Z)         uncompress $1  ;;
            *.7z)        7z x $1    ;;
            *)           echo "'$1' cannot be extracted via >extract<" ;;
        esac
    else
        echo "'$1' is not a valid file"
    fi
}

Port Scan in RedHat /CentOS /Fedora /Ubuntu

#HOST=127.0.0.1;for((port=1;port<=65535;++port));do echo -en "$port ";if echo -en "open $HOST $port\nlogout\quit" | telnet 2>/dev/null | grep 'Connected to' > /dev/null;then echo -en "\n\nport $port/tcp is open\n\n";fi;done

if you need pls change ipaddress and you can add more number 65535 

CentOS /Fedora /RedHat /Ubuntu if disk space is low send mail

PATHS="/export/home /home"

AWK=/usr/bin/awk

DU="/usr/bin/du -ks"

GREP=/usr/bin/grep

DF="/usr/bin/df -k"

TR=/usr/bin/tr

SED=/usr/bin/sed

CAT=/usr/bin/cat

MAILFILE=/tmp/mailviews$$

MAILER=/bin/mailx

mailto="rajat@yeswedeal.com" 

for path in $PATHS

do

 DISK_AVAIL=`$DF $path |  $GREP -v "Filesystem" | $AWK '{print $5}'|$SED 's/%//g'` 

 if [ $DISK_AVAIL -gt 90 ];then

  echo "Please clean up your stuff\n\n" > $MAILFILE

  $CAT $MAILFILE | $MAILER -s "Clean up stuff" $mailto 

 fi

done