This script will send Nagios status sms by host, this will save your sms

Installation:
Copy all files to
/usr/local/nagios_sms

Set the owner to  "nagios"/the user which is running the nagios agend:
chown nagios:nagios /usr/local/nagios_sms -R

Set write permissions
chmod 666 /usr/local/nagios_sms/msg.log
chmod 666 /usr/local/nagios_sms/queue.db

Setup config file
 nano /etc/nagios_sms.conf

Install PHP (witch sqllite und pear mail):
apt-get install php5-cli php5-sqlite php-pear php-mail php-net-smtp php-net-socket
 sqlite is used for for grouping the service notifications to a single sms and for delaying the messages
 pear mail is used for sending info emails if your sms account is nearly empty 

Install the cron job which sends the delayed sms
place at the end of the /etc/crontab
 *  * 	* * *	nagios	/usr/bin/php -d safe_mode=Off -d memory_limit=2048M -d max_execution_time=999999 -f /usr/local/nagios_sms/cron.php
 

Install the nagios notification commands
nano /etc/nagios3/commands.cfg

define command {
  command_name          notify-by-aspsms
  command_line          /usr/bin/php -f "/usr/local/nagios_sms/nagios_sms.php" -- $CONTACTPAGER$ $HOSTALIAS$
}

define command {
  command_name          host-notify-by-aspsms
  command_line          /usr/bin/php -f "/usr/local/nagios_sms/nagios_sms.php" -- $CONTACTPAGER$ $HOSTALIAS$
}

DONE ;-)