Jan 07 2009

Shell script for checking a sytem alive or not

Category: Shell ScriptsBipin Balakrishnan @ 6:08 pm

It is necessary in certain cases we need to check whether the system  or server is alive and if we want some alert like email or sms to inform you that the system is down.We can do it by a simple shell script .All we need is to install a package call fping

fping  is a program like ping which uses the Internet Control Message Protocol (ICMP) echo request to determine if a target host is responding.  fping differs from ping in that you can specify any number of targets on the command  line,  or  specify a file containing the lists of targets to ping. Instead of sending to one target until it  times out or replies, fping will send out a ping packet and move on to the next target in a round-robin fashion.
installing command

sudo apt-get install fping

Script:

#!/bin/sh
status=`fping 192.168.1.22 | cut -d ' ' -f 3`
if [ $status != "alive" ]
then
echo 'system is down' //Here use your alert as you like email, sms, voice alert etc
fi

Will check the system with IP 192.168.1.22 alive or not.Put it as a cron job and schedule the time interval to automatically check system status and get the alert…:)

Tags: ,


Jan 01 2009

Asterisk noise issue

Category: AsteriskBipin Balakrishnan @ 4:08 pm

A few weeks back  i faced a strange issue when installed asterisk in a server which uses ss7 line signalling.The issue was with the sound quality when making calls.Spoiled my two days with the issue and finally it got sloved. Here i am sharing my experience, hope it might be helpful for you guys.

Normally the noise issue can occur due to the following reason.

  • Hardware issue ( With Server / The card)
  • Codec Problem.
  • IRQ Sharing.
  • CPU load issue.

The Hardware issue

Please make sure that your server configuration is matching with what recommended by the digium. Please follow the link to choose your server.

http://www.voip-info.org/wiki/index.php?page=Asterisk+hardware+recommendations

If the server configuration is ok you can now double check the card, some time the card can also cause noice issue.Replace a the card and try again. Some card may have echo cancellation facility make sure that it is also enabled in the asterisk part also.

Codec Problem

A codec is a device or computer program capable of encoding and/or decoding a digital data stream or signal .Asterisk support different kinds of codes like gsm,wav,ulaw,alaw etc.The codec mostly used in gsm network is the gsm.Normally the MSC will convert any format to gsm format before transmitting to the mobile.If there you get a disturbed sound while making calls with a gsm format file try with wav format which is having a better sound quality than gsm.Please note to change the sound frequency that should be understood by asterisk (Asterisk normally understand sound in 8KHz ).

You can use sox for the sound conversion.

Example below converts a wav file to a file  with frequency 8KHz supported by asterisk.

sox file.wav -r 8000 -c 1 -s -w file1.wav resample -ql

IRQ Sharing

An interrupt is a method by which a piece of hardware communicates with the processor. It’s called an interrupt, because the device (such as a network card) interrupts the computer to carry out a function such as I received information, do something with it, or i’m ready with this task, give me a new one.

If  E1 card is sharing the IRQ with I/O devices the sound quality issue can occur  .We can check the interrupt status by using the command.

cat /proc/interrupts

If the any other resources is sharing the IRQ with the E1 card we can try options like putting up the card in another slot or can go to BIOS and can disable the interrupt sharing devices.

CPU load issue

The CUP load issue can be occured by many reason like MYSQL load, the  AGI programs load etc.We can see which process is consuming more memory-CPU by using the top command and can try to optimise it. Asterisk communicates with the AGI program over stdin and stdout. The arguments are passed directly to the AGI program at execution time.As AGI use  stdin and stdout reading and writing it will definitely affect the performance of the system.Better to implement almost all things in the dial plan itself. if your are 100% sure it can’t be done  with dial plan then move to AGI script.

Tags: , ,