Archive for September 2009

Bash Server Ping Checking Script -written by Dave Crouse

I had alot of fun writing this little ping testing utility. It works/looks best if you have a color enabled terminal.
Could be easily modified to email you if the server failed. Anyway, just thought I’d share :)

#!/bin/bash
# Bash Server Ping Checking Script
# 09-24-2009 Crouse
# Pretty simple, add servers/ip's/Ln (line numbers) in the format shown in the two column examples.
# Tested with over 50 servers, worked for what I needed, thought i'd share :) ~~Crouse.

# Ideas  --- ad another array for Headers. so Hn could print headers with bold/etc. Might be neat.
declare -a Sn # Server Name
declare -a Ip # IP address of server.
declare -a Ln # Line number to display on in Row1.
declare -a Sn2 # Server Name
declare -a Ip2 # IP address of server.
declare -a Ln2 # Line number to display on in Row2.
############################################################################### Server List Row 1
###############################################################################
Sn[1]="usalug.org"
Ip[1]="67.15.6.98"
Ln[1]="6"

Sn[2]="archlinux.me"
Ip[2]="208.92.232.122"
Ln[2]="7"
###############################################################################
###############################################################################

############################################################################### Server List Row 2
###############################################################################
Sn2[1]="usalug.org"
Ip2[1]="67.15.6.98"
Ln2[1]="6"

Sn2[2]="archlinux.me"
Ip2[2]="208.92.232.122"
Ln2[2]="7"
################################################################################
################################################################################
tput civis # Hide the cursor
maxcount=${#Sn[*]}  #should report number of Servers listed in Sn variable
maxcount2=${#Sn2[*]}  #should report number of Servers listed in Sn2 varialbe
clear
#tput setf 2; #echo -e '\e[1;33m'
echo " "
tput setf 0;tput setb 2;
echo "       Bash Server Ping Checking Utility           version 2.0         Crouse.   "; #tput rmso;

tput setf 7;  tput setb 0; # List out servers now.
     for (( loop=1; $loop < $maxcount+1; loop++ ))
     do
        ( tput cup ${Ln[$loop]} 10; echo "${Sn[$loop]}"; tput rc)
     done
     for (( loop2=1; $loop2 < $maxcount2+1; loop2++ ))
     do
        ( tput cup ${Ln2[$loop2]} 50; echo "${Sn[$loop2]}"; tput rc)
     done
# Set traps so when we exit the big ass loop stuffs normal again.
gracefulexit () {
tput cnorm;
tput setb 0;
echo "Stopping Application"
tput setf 2;
exit
}
trap gracefulexit INT TERM EXIT
# Begin big ass loop
while true
do
    #First Row
    for (( loop=1; $loop < $maxcount+1; loop++ ))
    do
        (tput sc ;tput setb 0; tput setf 0; tput cup 4 10 ;
        echo "........................................................................";tput rc)
        (tput sc ;tput setb 0; tput setf 6; tput cup 4 10 ;
        echo "Checking ${Sn[$loop]} at IP: ${Ip[$loop]}" ; tput rc)
        (tput sc ;tput setb 0; tput setf 0; tput cup ${Ln[$loop]} 1 ; echo "........." ; tput rc)
        (tput sc ;tput setb 0; tput setf 6; tput cup ${Ln[$loop]} 1 ; echo "TESTING" ; tput rc)
        count=$(ping -c 5 ${Ip[$loop]} | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
        (tput sc ;tput setb 0; tput setf 0; tput cup ${Ln[$loop]} 1 ; echo "........." ; tput rc)
        if [[ "$count" == [45] ]]; then
            (tput sc ;tput setf 0; tput setb 2;tput cup ${Ln[$loop]} 5 ; echo " OK " ; tput rc)
        else
            if [[ "$count" == [123] ]]; then
                (tput sc ;tput setf 0; tput setb 6; tput cup ${Ln[$loop]} 4 ; echo "ALERT" ; tput rc)
        else
                (tput sc ;tput setf 7; tput setb 4; tput cup ${Ln[$loop]} 2 ; echo "WARNING" ; tput rc)
            fi
        fi
    done
    #Second Row
    for (( loop2=1; $loop2 < $maxcount2+1; loop2++ ))
    do
        (tput sc ;tput setb 0; tput setf 0; tput cup 4 10 ;
        echo "........................................................................";tput rc)
        (tput sc ;tput setb 0; tput setf 6; tput cup 4 10 ;
        echo "Checking ${Sn2[$loop2]} at IP: ${Ip2[$loop2]}" ; tput rc)
        (tput sc ;tput setb 0; tput setf 0; tput cup ${Ln2[$loop2]} 41 ; echo "........." ; tput rc)
        (tput sc ;tput setb 0; tput setf 6; tput cup ${Ln2[$loop2]} 41 ; echo "TESTING" ; tput rc)
        count2=$(ping -c 5 ${Ip2[$loop2]} | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
        (tput sc ;tput setb 0; tput setf 0; tput cup ${Ln2[$loop2]} 41 ; echo "........." ; tput rc)
        if [[ "$count2" == [45] ]]; then
            (tput sc ;tput setf 0; tput setb 2;tput cup ${Ln2[$loop2]} 45 ; echo " OK " ; tput rc)
        else
            if [[ "$count2" == [123] ]]; then
                (tput sc ;tput setf 0; tput setb 6; tput cup ${Ln2[$loop2]} 44 ; echo "ALERT" ; tput rc)
        else
                (tput sc ;tput setf 7; tput setb 4; tput cup ${Ln2[$loop2]} 42 ; echo "WARNING" ; tput rc)
            fi
        fi
    done
done

php update to 5.3.0-3 – FAIL

Can’t say I’m a fan of the way the php update worked at all. It’s not Arch’s fault, but still……. what a pain.
I’ve been running webservers for over a decade now, and the “split” ( see http://www.archlinux.org/pipermail/arch-dev-public/2009-August/012951.html ) of the php package into modules? sort of created havoc on archlinux.me for a few minutes tonight.
I still haven’t gotten it to work yet, but I’m getting closer. First off, you will need php-apache OR you will get errors that look like :

[root@Archie php]# httpd -t
httpd: Syntax error on line 119 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/libphp5.so into server: /etc/httpd/modules/libphp5.so: cannot open shared object file: No such file or directory

After screwing around with this for a bit, I decided to just revert the php package BACK to php 5.2.10 for now.

[root@Archie pkg]# pacman -U php-5.2.10-3-i686.pkg.tar.gz
loading package data…
checking dependencies…
(1/1) checking for file conflicts [#########################################################################] 100%
error: failed to prepare transaction (conflicting files)
php: /etc/httpd/conf/extra/php5_module.conf exists in filesystem
php: /usr/lib/httpd/modules/libphp5.so exists in filesystem

errors occurred, no packages were upgraded.
[root@Archie pkg]# pacman -Uf php-5.2.10-3-i686.pkg.tar.gz
loading package data…
checking dependencies…
warning: /etc/php/php.ini installed as /etc/php/php.ini.pacnew
(1/1) upgrading php [#########################################################################] 100%
New optional dependencies for php
bzip2: bz2
curl: curl
gdbm: dba
libpng: gd
libjpeg: gd
freetype2: gd
pam: imap
libldap: ldap
libmcrypt: mcrypt
libtool: mcrypt
libmysqlclient: mysql/mysqli/pdo_mysql
unixodbc: odbc/pdo_odbc
openssl: openssl
postgresql-libs: pgsql/pdo_pgsql
aspell: pspell
net-snmp: snmp
sqlite3: pdo_sqlite
tidyhtml: tidy
libxslt: xsl
mhash: mhash
gmp: gmp
[root@Archie pkg]# /etc/rc.d/httpd restart
:: Restarting httpd daemon [BUSY] [DONE]

php-5.2.10-3-i686.pkg.tar.gz << worked
php-5.3.0-3-i686.pkg.tar.gz << new package … bleh
php-apache-5.3.0-3-i686.pkg.tar.gz << required package for new package

I guess until I have more time to sort this out, I'll just have to stick with the 5.2.x php package for now.

———————————-

http://www.archlinux.org/news/465/

PHP 5.3 enters [extra]

The new major PHP 5.3 release is finally available in the [extra] repository.
This update will require manual adjustments:
* update your php.ini; see php.ini.pacnew as reference
* module path is now /usr/lib/php/modules
* session, mbstring and zlib are now built in
* the fileinfo module is now built in and no longer a separate package
* mysqlnd is anabled; so libmysqlclient is no longer needed
* Setting default-character-set in my.cnf may cause encoding problems
* Set date.timezone in php.ini
* third party extensions need to be updated
* There are also new versions of the suhosin and apc extension
make sure to review their configuration as well

PHP was split into the following packages:
* php
* php-apache
* php-cgi
* php-curl
* php-enchant
* php-gd
* php-gmp
* php-intl
* php-ldap
* php-mcrypt
* php-odbc
* php-pear
* php-pgsql
* php-pspell
* php-snmp
* php-sqlite
* php-tidy
* php-xsl

If you are using php on a webserver you either need the cgi or apache sapi.
The sqlite package includes the sqlite3 drivers; the legacy sqlite2 drive is
included in the php package itself.