Asterisk and Nagios enthusiasts, professionals and consultants based in Kuala Lumpur, Malaysia. Astiostech Sdn Bhd. Asterisk Malaysia. Nagios Malaysia.
Saturday, December 11, 2010
Google Voice on Asterisk 1.8 bug is now fixed!
When Asterisk 1.8 was released, it had a perfect integration with Google Voice @voice.google.com service. Sometime in the 4th week of November, this broke and Gtalk worked (calling other google accounts) but calling Google Voice (e.g calling to US numbers for Free), didn’t.
I just saw this fixed in Digium’s bug tracker here
Here’s how i got my current working Asterisk to apply the patch. I am sure there are more “polished” ways but this just worked for me
1) Go to your Asterisk source directory, mine is #cd /usr/src/asterisk-1.8.0
2) Go to the channels directory #cd channels
3) Backup the original chan_gtalk.c to somewhere # mv chan_gtalk.c /usr/src/somebackup
4) Get the patch # wget http://svnview.digium.com/svn/asterisk/trunk/channels/chan_gtalk.c?revision=297958&pathrev=297958
5) Rename it #mv chan_gtalk.c\?revision\=297958 chan_gtalk.c
6) Go back to asterisk source main directory #cd ..
7) # ./configure
8) make && make install
9) Stop and restart asterisk # asterisk –rx “core stop now”
And voila! Google Voice worked again, just dialed a friend in US for free <joy>, my dialplan had exten => _1. I dial straight from my Deskphone!
Perfect! now lets enjoy our weekend,
PS> If you want some (flexible) dialplans, here an article that can help you. Go to http://highsecurity.blogspot.com/2010/11/googlevoice-asterisk-18-with-freepbx.html
Tuesday, December 7, 2010
Asterisk Script for Recordings to Move or Copy -n- number of days old (an archiving tool if you may)
Here’s' a script that moves or copies certain files (in my case Asterisk recordings) of anything above a certain date (as defined in the CLI) to a destination you pick.
You must first define the sourcepath, sourcefilename, destination and an option to flag move or just copy.
Place it anywhere and execute ./archivefiles 10
-> which means move/copy files that are over 10 days old from date to a desired location.
You could of course run it in cron if you like on a regular basis. Say you run ./
Here’s the script. Copy from the start till the end.
1) nano /usr/bin/archivefiles # create it
2) paste start –> end of script below # copy the script
3) chmod +x /usr/bin/archivefiles # make it executable
NOTE: Make sure your date/time in server is consistent/correct.
###start###
#!/bin/bash
# sanjay@astiostech.com
# usage #archivefiles 10 (meaning archivefiles will find files older than 10 days to do a move or copy)
#
# DEFINE THESE
SOURCEPATH=/var/spool/asterisk/monitor/ # With trailing / (slash )
SOURCEFILENAME=*.wav # filetype
DEST=/usr/src/mytestdst/ # With trailing / (slash )
MOVE=0 # NOTE:0 - copy, 1 - move
#
#
#
# START THE SCRIPT
# CHECK IF OLDER THAN VARIABLE DEFINED
#
OLDERTHAN=$1
if [[ $OLDERTHAN = "" ]]; then
echo "Define a period. Like 10 for 10 days"
exit 1
else
echo ""
fi
# CHECK IF VALUE ENTERED IS AN INTEGER
#
if [ $OLDERTHAN ]; then
if [ ! $(echo "$OLDERTHAN" | grep -E "^[0-9]+$") ]; then
echo $OLDERTHAN is not a valid integer.
exit 1
else
if ! [ $OLDERTHAN -ge 0 ] || ! [ $OLDERTHAN -le 10000 ]; then
echo $OLDERTHAN is an invalid value. Range is [1-10000]
exit 1
fi
fi
fi
# CHECK IF SOURCE DIRECTORY EXIST
#
if [[ -d $SOURCEPATH ]]; then
echo "OK - Source directory exits"
cd $SOURCEPATH
else
echo "Source Directory not found, check your settings... quitting"
exit 1
fi
grabfiles=`ls -l $SOURCEPATH$SOURCEFILENAME | head -n 1 | grep -c "\-r"`
if [[ $grabfiles != "0" ]]; then
echo "OK - Source files exist"
else
echo "Oops, no source files, check your settings...quitting"
exit 1
fi
# CHECK IF DESTINATION EXISTS
#
if [ -d $DEST ]; then
echo "OK - Destination directory exits"
else
echo "Destination directory not found, check your settings... quitting"
exit 1
fi
# START OUR JOB, DEFINE ACTIONS
#
if [[ $MOVE = "1" ]];then
find $SOURCEPATH$SOURCEFILENAME -mtime +$OLDERTHAN -exec mv -f {} $DEST \;
else
find $SOURCEPATH$SOURCEFILENAME -mtime +$OLDERTHAN -exec cp -fpr {} $DEST \;
fi
###end###
Tuesday, November 30, 2010
FreePBX slow “Apply Configuration”
Some may have problems loading FreePBX that takes a few minutes esp with larger number of extensions.
This is actually addressed in this article in FreePBX.org http://www.freepbx.org/trac/ticket/4435 but if you just want to fix it and don’t read all the stories there, read on.
NOTE: This article is ala-debian, so please do your due diligence for non-debians.
IMPORTANT!
Make sure you do all updates of modules to the latest minor version (upgrade all) before doing this below In future when you upgrade the CORE and FRAMEWORK, this below patch will be overwritten, so you need to do this again.
For clusters setups, please note if you already replicate certain directories of Asterisk/WWW, this may only needed to be done on the Master (or active) node.
NOTE: THIS FIX IS PORTED TO VERSION 2.9, SO YOU DO NOT NEED TO DO THIS ON 2.9 ONWARDS (not available yet of course)
Here’s the step by step:
Patch php-asmanager.php
cd /var/www/html/admin/common/
wget http://210.5.42.12/downloads/asterisk/misc/freepbx-fix/astdb_cache.diff
cp php-asmanager.php ./php-asmanager.php-original
patch php-asmanager.php astdb_cache.diff
chown asterisk:asterisk php-asmanager.php
Patch retrieve_conf
cd /var/lib/asterisk/bin
wget http://210.5.42.12/downloads/asterisk/misc/freepbx-fix/retrieve_conf.diff
cp retrieve_conf ./retrieve_conf-original
patch retrieve_conf retrieve_conf.diff
chown asterisk:asterisk retrieve_conf
cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini-orig
sed -i "s/upload_max_filesize = 20M/upload_max_filesize = 120M/" /etc/php5/apache2/php.ini
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 120M/" /etc/php5/apache2/php.ini
sed -i "s/magic_quotes_gpc = On/magic_quotes_gpc = Off/" /etc/php5/apache2/php.ini
sed -i "s/memory_limit = 16M/memory_limit = 100M/" /etc/php5/apache2/php.ini
sed -i "s/memory_limit = 32M/memory_limit = 100M/" /etc/php5/apache2/php.ini
RESTART apache.
/etc/init.d/apache2 restart
Now, try modifying something and do your apply.
Sunday, November 28, 2010
Asterisk 1.8 Google Talk Inbound Caller ID (CallerID)
If you need to send the proper calling party’s caller ID to a phone when using GoogleTalk, follow the below dialplan. Without any setting, the caller number is set to UNKNOWN and only the CALLERID(name) field is sent with something like sanjayws@gmail.com/Talk.v10471914EB6E. So we tweak the dialplan to show the correct caller ID. Put this dialplan anywhere in your Google incoming dialplan and you should see the calling party just nicely.
exten => stunningsimplicity@gmail.com,n,Set(Thiscallchan=${CALLERID(name)})
exten => stunningsimplicity@gmail.com,n,Set(CALLERID(name)=${CUT(Thiscallchan,/,1)})
exten => stunningsimplicity@gmail.com,n,Set(CALLERID(num)=${CUT(CALLERID(name),@,1)})
Here’s what you will see
**Assuming here, that your diaplan starts with the email address like in a post i did previously below, otherwise, change that accordingly, or change stunningsimplicity to any incoming GoogleVoice email that is expected to land on asterisk.
We remove @gmail.com as it will not quite work with your phones as it will try to do a SIP/IAX @ gmail call.
It’s best to prefix some characters for gmail outbound calling, and in my sample configuration below, i do a g* followed by a google name to dial as we add @gmail in our outbound dialplan. So you can add for incoming a g* automatically like below
exten => stunningsimplicity@gmail.com,n,Set(CALLERID(num)=g*${CUT(CALLERID(name),@,1)})
And so because we add a g* the CallerID(num) field will change to g*sanjayws (where sanjayws is the calling party from an original string received like sanjayws@gmail.com/Talk.v10471914EB6E). Now a person receiving the call can simply redial.Saturday, November 27, 2010
Google Voice Talk on Asterisk 1.8 (with FreePBX) and a flexible dialplan
Google Voice Talk on Asterisk 1.8 (with FreePBX) and a flexible dialplan [Updated 12-04-2012]
Ok so you’ve got a 1.4 or 1.6 Asterisk with FreePBX running somewhere? Now you wish to use GoogleVoice/Talk with Asterisk 1.8. Here’s how.This guide is more for a Debian system, so if you are running other than, do a little google.
Firstly, get your FreePBX updated to v2.8, other versions apparently won’t support Asterisk 1.8.
After that, start the Asterisk upgrade process. (from Mikael Carlsson, FreePBX Development Team @ this article) and the necessary dependencies for Asterisk’s chan_gtalk and chan_jabber
- cd /usr/src
- wget http://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
- tar -zxvf iksemel-1.4.tar.gz
- cd iksemel-1.4
- ./configure
- make && make all && make install
- wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8-current.tar.gz
- tar xvfz asterisk-1.8-current.tar.gz
- cd asterisk-1.8.0
- contrib/scripts/get_mp3_source.sh
- ./configure
- make menuconfig
- Goto Add-ons and select –> app_mysqp, app_saycountpl, cdr_mysql, format_mp3, res_config_mysql
- Goto Extra-Sound-Packages and Select –> EXTRA-SOUNDS-<Yourlanguage>-GSM
- Goto Channel Drivers and ensure that > chan_gtalk and chan_jingle are selected
- Save and exit
- ./configure
- make && make install
- amportal stop
- amportal start
Now, here are some configuration files you can simply copy paste in /etc/asterisk/. You can follow exactly the same as i have to make things work first.
Edit /etc/asterisk/gtalk.conf, paste the following, modify accordingly. Note, for newer versions of FreePBX, it supports inbound routes with names (typically it would be numbers). So you can actually send the call to for example from-pstn or from-dahdi or from-trunnk, then you can add this "inbound route to route to a specific extension” as you would do with a normal DID for instance.
;####start####
[general]
context=google-incoming ;;##use from-trunk if using newer FBX 2.8 or higher
allowguests=yes
bindaddr=<yourinternalIP>
[guest]
disallow=all
allow=ulaw
context=google-incoming ;;##use from-trunk if using newer FBX 2.8 or higher
connection=sanjay-ac1
;####end####
Save and exit.
Now, edit, /etc/asterisk/jabber.conf, paste the following, modify accordingly
;####start####
[general]
debug=yes
autoprune=no
autoregister=yes
[sanjay-ac1]
type=client
serverhost=talk.google.com
username=highsecurity@gmail.com/Talk
secret=mysecretPassword
port=5222
usetls=yes
usesasl=yes
statusmessage="higsecurity@asterisk.gmail"
timeout=100
[sanjay-ac2]
type=client
serverhost=talk.google.com
username=stunningsimplicity@gmail.com/Talk2
secret=mysecretPassword
port=5222
usetls=yes
usesasl=yes
statusmessage="stunningsimplicity@asterisk.gmail"
timeout=100
;####end###
And finally, edit your custom dialplan e.g. /etc/asterisk/extensions_custom.conf, paste the following, modify accordingly. Yo u only do this below if you are not using FreePBX latest version 2.8 or higher. For FreePBX 2.8 or higher, see below this dialplan.
;####start####
[from-internal-custom]
include => google-outgoing
[google-incoming]
;this for internal gmail user highsecurity@gmail.com, ring her 1001 extension
exten => highsecurity@gmail.com,1,Macro(user-callerid,)
exten => highsecurity@gmail.com,n,Answer()
exten => highsecurity@gmail.com,n,Wait(2)
exten => highsecurity@gmail.com,n,Set(Thiscallchan=${CALLERID(name)})
exten => highsecurity@gmail.com,n,Set(CALLERID(name)=${CUT(Thiscallchan,/,1)})
exten => highsecurity@gmail.com,n,Set(CALLERID(num)=g*${CUT(CALLERID(name),@,1)})
exten => highsecurity@gmail.com,n,SendDTMF(1)
exten => highsecurity@gmail.com,n,Goto(from-internal,1001,1) or ,n,DIAL(SIP/1001)
; end gmail user highsecurity@gmail.com
;this for internal gmail user stunningsimplicity@gmail.com, ring her 1002 extension
exten => stunningsimplicity@gmail.com,1,Answer()
exten => stunningsimplicity@gmail.com,n,Wait(2)
exten => stunningsimplicity@gmail.com,n,Set(Thiscallchan=${CALLERID(name)})
exten => stunningsimplicity@gmail.com,n,Set(CALLERID(name)=${CUT(Thiscallchan,/,1)})
exten => stunningsimplicity@gmail.com,n,Set(CALLERID(num)=g*${CUT(CALLERID(name),@,1)})
exten => stunningsimplicity@gmail.com,n,SendDTMF(1)
exten => stunningsimplicity@gmail.com,n,Goto(from-internal,1002,1) # or ,n,DIAL(SIP/1002)
; end gmail user stunningsimplicity@gmail.com
[google-outgoing]
; Set the outgoing account per jabber.conf
exten => _g*.,1,Macro(user-callerid,SKIPTTL)
; Add more users here
exten => _g*.,n,ExecIf($["${AMPUSER}" = "1001"]?Set(gmailoutaccount=sanjay-ac1))
exten => _g*.,n,ExecIf($["${AMPUSER}" = "1002"]?Set(gmailoutaccount=sanjay-ac2))
;
; Normal outbound calling, g is prefixed so it will call google talk,
; and call other places using google voice, like below, a US number
exten => _g*.,n,Dial(gtalk/${gmailoutaccount}/${EXTEN:2}@gmail.com)
exten => _1XXXXXXXXXX,n,Dial(gtalk/${gmailoutaccount}/${EXTEN}@voice.google.com)
;
;
; Dialplan for sending messages
exten => _t*.,1,Macro(user-callerid,SKIPTTL)
exten => _t*.,n,ExecIf($["${AMPUSER}" = "1001"]?Set(gmailoutaccount=sanjay-ac1))
exten => _t*.,n,ExecIf($["${AMPUSER}" = "1002"]?Set(gmailoutaccount=sanjay-ac2))
;
exten => _t*.,n,JABBERSend(${gmailoutaccount},sanjayws@gmail.com,"${EXTEN:2}")
exten => h,1,(Hangup)
;####end####
At this point be sure to stop and start Asterisk (amportal kill / amportal start). Infact most settings made on gtalk.conf needs to restart Asterisk, not just reload.
With FreePBX
When using FreePBX 2.8 or higher, you don’t need to write manual dialplans for INBOUND (incoming) calls. You only need to customize the dialplan if you are planning to make outbound calls on Gtalk through Asterisk. Here below is a sample inbound route created in FreePBX.
Remember, this is for INCOMING only that will be handled by FreePBX, here any calls destined to highsecurity@gmail.com I will attempt to send to an extension (or anywhere as you please). As you can see below, if I set the context to from-trunk, I will see it like below in my cli
Notice the DID value there is highsecurity@gmail.com which mean, it is as simple as adding an Inbound Route in FreePBX like below;
Extra information manual dialplan creation
1) You must specify incoming and outgoing google accounts.
2) Incoming connections will dial internal extensions or just about anywhere you have designed in FreePBX, in this case, they are extensions.
3) Outgoing calls are matched based on the extension that is dialling (supports user/device mode as well) so that if extension 1001 is dialing out, the recipient will see highsecurity calling and if extension 1002 dialling, he/she will see stunningsimplicity
4) Anyone without that specific dialplan set for outbound can be limited to a failurecode (not defined in this sample here).
5) If someone wants to dial out, he/she dial g*<user> like for example gs*anjayws will dial the gmail user sanjayws. The g* is used as a prefix for dialling out so it is a clear path to dial google. To make redials easier, when an incoming call comes through the dialplan, we’ve added the g* at the begining of the callerID(name) field so that when a person redials, it will engage the outbound route. Notice that we do a CUT in there and that is to remove certain characters through a delimiter character.
6) Of course, you can also specify calling to other google voice numbers if you have google voice credits to those outgoing accounts created in jabber.conf. This example above, does US calls as it is free for now. Feel free to add any other calling matches to use google voice.
Done.
Do send your feedback to sanjay@astiostech.com
Thank you.
Resources:
http://forums.digium.com/viewtopic.php?f=1&t=76250
https://wiki.asterisk.org/wiki/display/AST/Calling+using+Google
http://www.freepbx.org/forum/freepbx/installation/asterisk-1-8-installation
Thursday, November 25, 2010
Fail2ban Manual Unban Single Host (for iptables)
UPDATE: Starting with version 0.8.8, the unban operations are now built-in, it is executed through the fail2ban-client app like this
# fail2ban-client set [ban-name]
# e.g. fail2ban-client set asterisk-iptables unbanip 8.8.8.
Check out the changelog here. Get version 0.8.8 here. You really should be upgrading your fail2ban to that above version and use the built-in tool.
[WARNING- THESE BELOW ARE OUTDATED]
Fail2Ban is a great way to protect your server from malicious attempts of brute force and other events that are deemed a problem. It does by very smartly checking your logs and if a particular event is repeated n number of times, you can set actions such as blocking or unblocking using software such as iptables based or software based firewalls or even write scripts to modify an external firewall.
There’s one drawback about it and that is the ability to unban just one IP (many reasons why that might be needed). Just follow these instructions and get the necessary script and you will have an idea or a fully working unban function (if you use iptables to ban)
Version that you MUST USE: Fail2Ban v0.8.4. Download and install Fail2Ban version 0.8.4, for Asterisk fail2banning for SIP brute force attack. Some help with installation here.
This guide was designed on a Debian system. Customization may be required. You can check the version after installing via cli like below
# fail2ban-client –V
Create the unban script, you may need to modify certain settings that would then match your jail setting, actions (in this script its for iptables) and logging options.
# cd /usr/src
# wget http://210.5.42.12/downloads/asterisk/misc/unban
# chmod +x unban
Now, we change or manipulate the actions.py file from Fail2ban for proper handling of unban script unbanning. You may need to modify this if it is not IPtables you use for banning action. See the section def __checkBan in actions.py there’s a modification of an external check command there called mycheck. If mycheck condition is true (returned value 0) it will proceed to ban that IP. The issue we had by just unbaning using the unban script was that fail2ban didn’t know we unban manually using cli. This caused fail2ban to never ban again the IP you just banned because it think that IP is still in its ban list. This “fix” ensures that the process/procedure will check against iptables (or any of your ban action) and reissue a ban if it doesn’t have the IP in its entry (like doing a iptables –n –-list)
# cd /usr/share/fail2ban/server/
# mv actions.py actions.py.original
# wget http://210.5.42.12/downloads/asterisk/misc/actions.py
Restart fail2ban (WARNING, RESTARTS WILL FLUSH ALL BAN IPs OFF THE LIST!)
# /etc/init.d/fail2ban restart
Try it out for yourself to unban some IP
# unban 202.188.0.133
If you do not specify an IP, it will list all banned IPs inside the Jailed context.
Sunday, October 17, 2010
Asterisk + FreePBX - Removing queue members with logout *12
The requirements form one of client is to “auto” logout someone from an Asterisk/FreePBX queue module when he/she logout from the user/device mode.
This script uses AGI. I have tested this on;
1) Debian 5
2) FreePBX 2.8 and below
3) Asterisk 1.6 (may work for 1.4- need to probably tweak the script)
NOTE: If the codes appear truncated, simply copy the whole table and paste into a text editor
Firstly, we use the override function in FreePBX to override the macro-user-logoff directive
| nano /etc/asterisk/extensions_override_freepbx.conf |
| [macro-user-logoff] ; check device type ; exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)}) exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1) exten => s,n,Set(dev=${DB(DEVICE/${CALLERID(num)}/user}) exten => s,n,AGI(kick.sh,${dev}) exten => s,n,AGI(user_login_out.agi,logout,${CALLERID(number)}) exten => s,n(done),Playback(vm-goodbye) exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged out of) exten => s-FIXED,n,Playback(an-error-has-occured&vm-goodbye) exten => s-FIXED,n,Hangup |
Now, create the AGI / bash script that will do the trick
| nano /var/lib/asterisk/agi-bin/kick.sh |
| #!/bin/bash # script by Sanjay Willie # v0.1-beta # tested on Asterisk 1.6/FreePBX 2.8/Debian 5.06 # maintainer: sanjay@astiostech.com # the directory /tmp should exist and can be accessible by user asterisk and group asterisk # NOTE: FILES IN /tmp normally gets flushed on restarts # On grabbing agent number, should look exactly like "Local/1000@from-queue" eventually and should not contain any preceding or trailing characters # the extraction of agents in the script in the line "for agents..." may or not yield output, so test it out. # The sed part is to remove brackets from the output in the front and back (seen in FBX 2.8) # if the sed isn't required (like in FreePBX 2.7 and below) you can remove it, also lookout for the print $3, in FreePBX 2.7 and below its print $1, so test it out first stdin="0" datenano=`date +%N-%F` regulardate=`date +%F-%T` gennum=$RANDOM-$datenano.int-tmp queuenumbers="4001 4002 4003 5001 5002 5003 4021 4022 4023 5021 5022 5023" ########### while [ "$stdin" != "" ] do read stdin if [ "$stdin" != EOF ] then echo $stdin | grep agi_arg_1 | awk {'print $2'} >> $gennum fi done ############ include=`cat $gennum` #include=2006 ############ cleanup=`rm -v /tmp/$gennum` #echo $cleanup >> /tmp/cleanup ############ if [[ "$include" == "" ]] ; then echo Nothing to do, quitting exit else for queue in $queuenumbers; do #echo $queue >> /tmp/logfile.txt # see NOTES above #for agents in `asterisk -rx "queue show $queue" | grep from-queue | awk '{print $3}' | grep -w "$include" | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/'`; do # freePBX 2.8 or higher for agents in `asterisk -rx "queue show $queue" | grep from-queue | awk '{print $1}' | grep -w "$include"`; do #echo $agents >> /tmp/logfile.txt asterisk -rx "queue remove member $agents from $queue" echo "we remove $agents in $queue" echo $regulardate - Attempt removing agent $agents from queue $queue >> /tmp/agentremover.log done done fi ############ exit 0 |
1) Once the Asterisk dial plan calls the script, it will parse the user into bash and we will remove that user with a script that walks through all queues you have specified looking for this user and does a removal using asterisk –rx
2) Stores a simple log in /tmp
Make it executable, chmod +x /var/lib/asterisk/agi-bin/kick.sh and make sure the asterisk user can read/run the file, chown asterisk:asterisk /var/lib/asterisk/agi-bin/kick.sh
Reload the dialplan
| asterisk -rx "dialplan reload" |
Let us know if this worked out. For help, write to sanjay@astiostech.com
Friday, July 2, 2010
Checking Windows Clusters / Cluster Resources Using Existing Check Plugins for Nagios
Now we all know when it comes to clustering its basically one up and the other down. So monitoring, say Exchange or SQL on the live or active one is just fine with all the disk checked and all the services are UP (while set to manual). Problem is when it comes to the passive server, how do we check for just about anything?
Simple. Try using this custom script i’ve written.
Here’s the script snippet.
| #!/bin/bash #GET VALUES FROM NAGIOS AND SET THEM AS VARIABLES hostname=$1 # Debug # We check if the quorum is running or not first getoutput=`/usr/local/nagios/libexec/check_nrpe -H $hostname -t 50 -c CheckDriveSize -a ShowAll=long MinWarnFree=10% MinCritFree=5% Drive=q: | grep -c "The system cannot find the path specified"` # DEBUG if [[ "$getoutput" == "1" ]]; then echo "OK: Clustered service is not failed over. We will not check this service now." else /usr/local/nagios/libexec/check_nrpe -H $hostname -t 50 -c checkServiceState -a ShowAll "$servicename" fi |
The idea of this script is to:
1) Check certain resources on the Cluster only if the quorum is alive!
2) If it’s not, send an OK value back to Nagios but in the comment section, mention that “its not failed over” or something.
3) Send fake performance data not to break the Performance Data values.
This value,
getoutput=`/usr/local/nagios/libexec/check_nrpe -H $hostname -t 50 -c CheckDriveSize -a ShowAll=long MinWarnFree=10% MinCritFree=5% Drive=q: | grep -c "The system cannot find the path specified"`
This above checks if the quorum is alive. It is normally the first resource that will fail over. In our case it was drive q!. So, when we are satisfied that the output of the plugin isn’t “…cannot find path”…only then we execute just about any plugin. And in this example above, check the services that are cluster monitored/managed.
Now, to execute the script on commands.cfg, is something like this.
| # Check Clustered Services: define command{ } |
On command line, you can simple parse
./check_floating_services <hostname/ip> <servicename>
And there you have it, cluster “enable” plugins.
Cheers!!!!
Tuesday, May 25, 2010
Nagios + PNP graphs PDF reports generator and emailer
We made a small script that we use in our customer’s site to basically pull out the PNP generated graphs through the Nagios Action Items icon. This script will basically download the current report output into PDF and emails them out based on the configuration found on the script header.
- This script does a simple task of creating PDF files via PNP url and emails it out
- This script must be executed as root
- This script may contain sensitive information such as usernames and passwords, so ensure only root has access to it
- The script works with the extra-option URL only to generate PDF graphs or MRTG, typically /pnp/index.php
- Make the script executable, i.e. chmod +x pnp_emailer.sh
It has basic options currently but you may extend the use of it to just about anything else you wish for it to do.
Eventually, run lines of the scripts as a cron job executed on a timely manner to generate in time reports.
The script is then executed with options at CLI that includes the servername and servicename as defined in the Nagios .CFG files.
Here’s the script. And as usual, your feedback is mucho appreciated.
http://210.5.42.12/downloads/nagios/pnp_emailer.sh
With best,
Sanjay & all Astiostechers!
Wednesday, April 14, 2010
free SIP phone for Windows mobile
I highly recommend you to use this, sounds great on the earpiece, just like using a normal phone, has buttons to enable speakermode etc...
Works great on WiFi or GSM (3G). Do note, with GSM/EDGE there’s some latency, naturally. So, whenever possible, use 3G/HSDPA
Download here: http://www.portsip.com/downloads.htm