Having Asterisk give server status

Looking for a module or custom work where a customer calls in and Asterisk would report if a server is known offline or no outages to report.

Maybe it would simply check by ping. If no ping response, report offline.

We would have to know what you mean by what “a customer calls” and what is “a server” in your concept, (there are lots out there :slight_smile: )

If you want to “monitor” a particular trunk, there are posts here and a GUI place to stick such found scripts, if you want to know if networks are working, similarly. Ping is unreliable, you need to use a protocol that the server responds to, probably netcat can do that.

I run a small wireless internet comapny. I want asterisk to let a customer know calling support if we have a server down.

example:

Customer calls in, asterisk checks if a list of 12 servers are pingable. If not the message would be given, We currently have an outage on _____ server.

otherwise. We currently have no outage. MESSAGE would be given.

Maybe there is another way to check the server by snmp or somthing but im thinking a ping test would be easiest?

It depends on what your servers are serving, as I said , look at netcat to do that scriptwise for you, generally to be low profile use -z (but don’t do that too many times or a good firewall will reject you quite quickly)

as i said… Just to see if its pingable. doesnt matter what the server is serving or if its a printer. or computer… Any device thats pingable could be reported by Asterisk. I just dont know where to start so came here for direction or even someone who did programing work for $

ping is ICMP , IT IS NOT RELIABLE and has nothing to do with whether “the server” at that address is effective, connect on a port that the server expects to be connected to or you are wasting your time.

Give an example of what servers and what protocols you are intersted in and you might get an answer for free.

Generally Asterisk by default listens on UDP/5060 and maybe 5061 and possibly TCP same thing, the FreePBX distro also listens ineffectually on TCP/5038 which is quite “tell-tale”

They would be routers located at the towers.
By default SSH, WEB, PING is active on them

Well

netcat -z you.rip.add.ress 22;echo $?

returns 0 ssh is listening on you.rip.add.ress , it it returns 1, not so much.

The ruslult in no ways says that is woking though, look at moit, mon, check-mk for more robust code.

my problem now is i have no idea how to get Asterisk to do that.

Asterisk can’t it is a voip server. The underlying OS probably can.

Well I understand that, Dont know how to setup somthing that would work

mon works, monit works, check-mk works, you shouldn’t try and force a square peg into a round hole. you need to further explore how asterisk works under linux(bsd) and what linux can do, when you get it working then asterisk can query the underlying OS.

(That is going to be an ongoing problem until you do know how :slight_smile:

apt-get|yum install mon
man mon

or

apt-get|yum install monit
man monit

might get you started
)

If I were you I would look at adding an AGI script to your system and doing the code there –

There is a good explanation on the VoIP info site on how to get stared, and Google will find you a number of good examples for this -

http://www.voip-info.org/wiki/view/Asterisk+AGI

the OP is looking for something like the following shell script being called when a user dials in to the appropriate phone number
(with ‘asterisk-s ays’ invoking the appropriate functionality).:

servers=“web1 web2 ast-main ast-backup sql1 sqldev”

bad=""
for server in $servers ; do

if ! ping -q -w1 -c 4 $server > /dev/null ; then
bad="$bad $server"
fi
done

if -z "$bad’ ; then
asterisk-says "no servers down"
else
for server in $bad ; do
asterisk-says "server $server is down"
done
fi

For that direct functionality you will need as suggested an AGI script to call the “say” command after gleaning the necessary information.

That having been said, if you are serious about monitoring a network then as suggested set up a check-mk server to do the monitoring and add the asterisk plugin,

https://mathias-kettner.com/checkmk_flexible_notifications.html

it can then premptively call through asterisk to deliver a message that specific sets of apache or ssh on various hosts are not running properly, add to that disk space, cpu load and whatever else even your asterisk servers themselves through SNMP, probably better not to try and reinvent the wheel here.