This script is designed for monitoring SIP peers in Asterisk-based systems that use chan_sip (not pjsip), with a particular focus on multi-tenant systems such as SIPSTACK UC or Thirdlane. These systems typically name their extensions with the tenant name, making it possible to filter and monitor SIP peers based on tenant-specific criteria. The script checks for UNREACHABLE SIP peers and sends email notifications, with a built-in mute period to prevent repeated alerts for the same device within a given timeframe.
- Tenant Filtering: Supports monitoring SIP peers by specific tenant names, making it ideal for multi-tenant PBX systems.
- Email Notifications: Sends email alerts for
UNREACHABLESIP peers, with detailed information including extension, last known IP, and port. - Mute Period: Configurable mute period to limit repeat notifications for the same
UNREACHABLESIP peer within the set timeframe.
- Asterisk-based system using
chan_sipmodule. sendmailor compatible MTA (Mail Transfer Agent) configured for sending emails from the command line.
To use the script, simply clone or download it to your Asterisk server and make it executable:
chmod +x sip_peer_monitor.shRun the script with optional arguments:
./sip_peer_monitor.sh [tenant] [recipient email] [mute period in seconds]- tenant: Optional. Specify the tenant name to filter SIP peers. If omitted, all peers are considered.
- recipient email: Mandatory. The email address where notifications will be sent.
- mute period: Optional. Time in seconds to mute repeated alerts for the same device. Defaults to 86400 seconds (24 hours).
Monitor SIP peers for tenant: tenantNameHere and send notifications to admin@example.com, with a mute period of 12 hours (43200 seconds):
./sip_peer_monitor.sh "" admin@example.com tenantNameHere 43200To automate monitoring, you can set up a cron job to run the script at desired intervals. For example, to check every 15 minutes:
*/15 * * * * /path/to/sip_peer_monitor.sh "" admin@example.com tenantNameHere 43200Adjust the script path, email address, and mute period as needed.
This script is provided under the MIT License. See the included LICENSE file for details.
This script is offered AS IS, without warranty of any kind. The author(s) will not be liable for any damages, loss of data, or any other harm arising from its use. Users are encouraged to review and test the script thoroughly before relying on it in production environments.