Skip to content

Automated script for monitoring and alerting on UNREACHABLE SIP peers in multi-tenant Asterisk systems using chan_sip

License

jonathangeller/asterisk-unreachable-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Asterisk SIP Peer Monitor

Overview

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.

Features

  • Tenant Filtering: Supports monitoring SIP peers by specific tenant names, making it ideal for multi-tenant PBX systems.
  • Email Notifications: Sends email alerts for UNREACHABLE SIP peers, with detailed information including extension, last known IP, and port.
  • Mute Period: Configurable mute period to limit repeat notifications for the same UNREACHABLE SIP peer within the set timeframe.

Requirements

  • Asterisk-based system using chan_sip module.
  • sendmail or compatible MTA (Mail Transfer Agent) configured for sending emails from the command line.

Usage

To use the script, simply clone or download it to your Asterisk server and make it executable:

chmod +x sip_peer_monitor.sh

Run 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).

Example

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 43200

Cron Job Suggestion

To 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 43200

Adjust the script path, email address, and mute period as needed.

License

This script is provided under the MIT License. See the included LICENSE file for details.

Disclaimer

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.

About

Automated script for monitoring and alerting on UNREACHABLE SIP peers in multi-tenant Asterisk systems using chan_sip

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages