After becoming frustrated with the lack of built in monitoring for Avaya ACM trunk usage (ie how many concurrent phone calls were happening) I decided to have a poke around using SNMP to see if it was possible. In the end, I found a way to poll for the current status of each channel on each trunk, and then it was just a case of adding up the active ones to get a number of concurrent calls. It is written in PHP and can either be called from the command line, or as I have done, tied into Cacti to create historic graphs for each trunk.
There are two scripts on offer here, both can be run as standalone scripts while troubleshooting. The first one is a tool which will interrogate your Avaya system. This provides feedback on all the trunks it contains, and which channels are active on each trunk. The information is dumped out to the CLI, but its in a nice PHP array form which is ready for any further modification you may wish to make.
The second script, will take the Avaya host and trunk number as parameters and will return the total number of channels and how many are active. This is the script which gets called by the Cacti poller to allow it to graph channel usage.
The CLI Script: avaya_active_trunks.php
<?php
/* A SNMP Poller to find out what the Avaya trunks are doing.
*
* An HRH script !!
*
*/
/* Variables */
$server = "youravayaip"; # Set this to the Management IP of your Avaya box
$community = "yourcommunity"; # Should be set to the SNMP community configured on the Avaya box
/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
die("<br><strong>This script is only meant to run at the command line.</strong>");
}
$no_http_headers = true;
/* display No errors */
error_reporting(0);
/* Do a quick dummy walk to 'wake up' the avaya box */
echo "Waking up SNMP on the Avaya, with a SNMPWALK request\n";
snmpwalk($server,$community,"1.3.6.1.4.1.6889.2.8.1.14.1.1.1.1");
echo "Collecting the trunk channels and membership array\n";
$raw_trunk_array = snmpwalk($server,$community,"1.3.6.1.4.1.6889.2.8.1.14.1.1.1");
echo "Collecting the channel status array\n";
$raw_channel_status = snmpwalk($server,$community,"1.3.6.1.4.1.6889.2.8.1.14.1.1.3");
# Start working with the data
$num_channels = count($raw_trunk_array);
$num_trunks = 0;
$b = 1; // Incrementer for trunks
$c = 0; // Incrementer for chanels
for($a = 0; $a < $num_channels; $a ++) {
$trunk_num = str_replace("INTEGER: ","",$raw_trunk_array[$a]);
# Check if we are working on a different trunk to the previous loop
if($trunk_num != $trunk_array[($b -1)]['name'] ) {
$trunk_array[$b]['name'] = $trunk_num;
$trunk_array[($b - 1 )]['channels'] = $c;
$b++;
$c = 0;
}
$c ++;
}
$trunk_array[$b -1]['channels'] = $c;
sort( $trunk_array );
array_shift( $trunk_array );
## Now that we have the trunk and channel groups,
# we can add in the channel status to the trunk_array
for($a = 0; $a < count($trunk_array); $a ++) {
$channels_in_use = 0;
for($b = 0; $b < $trunk_array[$a]['channels']; $b ++) {
$text = str_replace('"',"",str_replace("STRING: ","",$raw_channel_status[$num]));
switch($text) {
case "in-service/idle":
$channel_status = 0;
break;
case "in-service/active":
$channel_status = 1;
break;
case "OOS/FE-idle":
$channel_status = -1;
break;
case "out-of-service-NE":
$channel_status = -1;
break;
default:
$channel_status = -1;
break;
}
$trunk_array[$a]['status'][$b] = $channel_status;
$channels_in_use += $channel_status;
}
$trunk_array[$a]['total'] = $channels_in_use;
$channels_in_use = 0;
}
print_r($trunk_array);
?>
The Cacti Script: single_trunk_status.php
#!/usr/bin/php
<?php
/* A script to find out how many channels are active on an Avaya Trunk
* returned in a format which can be read by a person or Cacti.
*
* An HRH script !!
*
*/
/* variables */
$community = "yourcommunity";
/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
die("
This script is only meant to run at the command line.");
}
$no_http_headers = true;
/* display No errors */
error_reporting(0);
/* Make sure that this script has been called with a hostname and trunk number */
if(isset($argv[1])) { $host = $argv[1]; } else { die("no host name"); }
if(isset($argv[2])) { $trunk_no = $argv[2]; } else { die("no trunk number"); }
/* create the OID we will walk from */
$oid = '1.3.6.1.4.1.6889.2.8.1.14.1.1.3.' . $trunk_no;
/* Do a quick dummy walk to 'wake up' the avaya box */
snmpwalk($host,$community,"1.3.6.1.4.1.6889.2.8.1.14.1.1.1.1");
/* now we have awoken the beast, do the real work */
$raw_channel_status = snmpwalk($host,$community,$oid);
/* work out how many were in use */
$used = 0;
for($a = 0; $a < count($raw_channel_status); $a ++) {
$text = str_replace('"',"",str_replace("STRING: ","",$raw_channel_status[$a]));
switch($text) {
case "in-service/idle":
$channel_status = 0;
break;
case "in-service/active":
$channel_status = 1;
break;
case "OOS/FE-idle":
$channel_status = -1;
break;
case "out-of-service-NE":
$channel_status = -1;
break;
default:
$channel_status = -1;
break;
}
$used += $channel_status;
}
/* return the data */
echo "active_channels:$used total_channels:". count($raw_channel_status);
?>
Example output - When run from cli
[user@server scripts] php single_trunk_status.php 10.10.10.10 15 #15 is the trunk number
active_channels:2 total_channels:30
Installing into Cacti
Its been a while since I did this so if you get stuck, please let me know and I will try to assist! You might also want to read here, which is the Cacti guide to adding external scripts:
http://www.cacti.net/downloads/docs/html/making_scripts_work_with_cacti.html
1.
Create the data input method - From the console, click on Data Input Methods, then click on Add in the top right hand corner. Give it a name, and put the path to the script in as below then click create. Once that is done, add in the Input and Output Fields as below.
2. Click on the Data Source tab in the console, give it a name and and select Trunk Check for the Data input method. For the data Soure Item tab you will need to add in both "active_channels" & "total_channels". Finally you should add the Hostname and Trunk Number which the script will need to monitor.
3. With all that in place, you can create a graph for the data :)
Notes
- You will need to ensure that your Avaya system is configured to accept SNMP requests. You can check your current settings from the web portal of the server under the maintenance tab. From there SNMP settings are listed. You will need to configure an SNMP community and allow access from the server which will poll it. In my experience I also had to restart the agent after each change.
- Your PHP installation will need to have been installed with SNMP support (I believe this is normally a default)
OIDS - These were surprisingly hard to find, so I hope I can save someone some time!
g3pkprincipalCallsCCAC | 1.3.6.1.4.1.6889.2.8.1.139.6.1.9 |
g3trunksta | 1.3.6.1.4.1.6889.2.8.1.14 |
g3trunkstaTable | 1.3.6.1.4.1.6889.2.8.1.14.1 |
g3trunkstaEntry | 1.3.6.1.4.1.6889.2.8.1.14.1.1 |
g3trunkstaTrunkGroup | 1.3.6.1.4.1.6889.2.8.1.14.1.1.1 |
g3trunkstaConnPort6 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.10 |
g3trunkstaConnPort7 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.11 |
g3trunkstaConnPort8 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.12 |
g3trunkstaConnPort9 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.13 |
g3trunkstaMember | 1.3.6.1.4.1.6889.2.8.1.14.1.1.2 |
g3trunkstaServiceState | 1.3.6.1.4.1.6889.2.8.1.14.1.1.3 |
g3trunkstaMaintBusy | 1.3.6.1.4.1.6889.2.8.1.14.1.1.4 |
g3trunkstaConnPort1 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.5 |
g3trunkstaConnPort2 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.6 |
g3trunkstaConnPort3 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.7 |
g3trunkstaConnPort4 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.8 |
g3trunkstaConnPort5 | 1.3.6.1.4.1.6889.2.8.1.14.1.1.9 |