From 46b5f4bd1359ee85b071d31d4f13a2358f550cb0 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 10 Aug 2019 12:40:33 -0400 Subject: [PATCH 1/5] asterisk: add graph for confbridge The MeetMe Asterisk application has been deprecated since Asterisk 1.8. Debian has also stopped distributing the module with version 11.5.1. Users now need to migrate to using the ConfBridge application. Since the application still exists, and some ppl in other Linux distros probably still use it, we'll keep the code for parsing meetme info for some time. --- plugins/asterisk/asterisk | 51 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/plugins/asterisk/asterisk b/plugins/asterisk/asterisk index 5c28a6df..8d278b94 100755 --- a/plugins/asterisk/asterisk +++ b/plugins/asterisk/asterisk @@ -16,8 +16,11 @@ This plugin will produce multiple graphs showing: - the number of messages in all voicemail boxes (replaces asterisk_voicemail); - - the number of active MeetMe conferences and users connected to them - (replace asterisk_meetme and asterisk_meetmeusers, respectively); + - DEPRECATED: the number of active MeetMe conferences and users connected to + them (replace asterisk_meetme and asterisk_meetmeusers, respectively); + + - the number of active ConfBridge conferences (e.g. non-empty ones) and users + connected to them - the number of active channels for a given codec, for both SIP and IAX2 channels (replaces asterisk_sipchannels and asterisk_codecs). @@ -191,6 +194,16 @@ END print < Date: Sat, 10 Aug 2019 13:32:50 -0400 Subject: [PATCH 2/5] asterisk: Add configuration options to disable conference graphs Since the MeetMe application is not available anymore on Debian, it makes no sense to keep the graph around. We do however want to keep code around for parsing stats from MeetMe. So we'll add two "binary" flags that'll let users which of these two graphs they want. The default values will favor getting information from ConfBridge which is the suggested replacement for MeetMe. An added bonus of this is that some users might decide to disable both graphs if they use neither applications, which was impossible before. --- plugins/asterisk/asterisk | 117 ++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 48 deletions(-) diff --git a/plugins/asterisk/asterisk b/plugins/asterisk/asterisk index 8d278b94..5b6d72ce 100755 --- a/plugins/asterisk/asterisk +++ b/plugins/asterisk/asterisk @@ -30,13 +30,15 @@ This plugin will produce multiple graphs showing: The following configuration parameters are used by this plugin [asterisk] - env.host - hostname to connect to - env.port - port number to connect to - env.username - username used for authentication - env.secret - secret used for authentication - env.channels - The channel types to look for - env.codecsx - List of codec IDs (hexadecimal values) - env.codecs - List of codecs names, matching codecsx order + env.host - hostname to connect to + env.port - port number to connect to + env.username - username used for authentication + env.secret - secret used for authentication + env.channels - The channel types to look for + env.codecsx - List of codec IDs (hexadecimal values) + env.codecs - List of codecs names, matching codecsx order + env.meetme - Set to 1 to enable graphs for the MeetMe application + env.confbridge - Set to 1 to enable graphs for the ConfBridge application The "username" and "secret" parameters are mandatory, and have no defaults. @@ -49,6 +51,8 @@ defaults. env.channels Zap IAX2 SIP env.codecsx 0x2 0x4 0x8 env.codecs gsm ulaw alaw + env.meetme 0 + env.confbridge 1 =head2 WILDCARD CONFIGURATION @@ -122,6 +126,9 @@ my @CHANNELS = exists $ENV{'channels'} ? split ' ',$ENV{'channels'} : qw(Zap IAX my @CODECS = exists $ENV{'codecs'} ? split ' ',$ENV{'codecs'} : qw(gsm ulaw alaw); my @CODECSX = exists $ENV{'codecsx'} ? split ' ',$ENV{'codecsx'} : qw(0x2 0x4 0x8); +my $meetme_enabled = $ENV{'meetme'} || '0'; +my $confbridge_enabled = $ENV{'confbridge'} || '1'; + my $line, my $error; my $socket = new IO::Socket::INET(PeerAddr => $peeraddr, PeerPort => $peerport, @@ -182,7 +189,8 @@ graph_category voip total.label Total messages END -print < Date: Sat, 10 Aug 2019 21:43:36 -0400 Subject: [PATCH 3/5] asterisk: change tabs for spaces for indentation the plugin currently has inconsistencies with how lines are indented: some lines only use tab characters while all other lines use spaces. Let's make the coding style more uniform by using spaces everywhere. --- plugins/asterisk/asterisk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/asterisk/asterisk b/plugins/asterisk/asterisk index 5b6d72ce..938bbbdd 100755 --- a/plugins/asterisk/asterisk +++ b/plugins/asterisk/asterisk @@ -131,8 +131,8 @@ my $confbridge_enabled = $ENV{'confbridge'} || '1'; my $line, my $error; my $socket = new IO::Socket::INET(PeerAddr => $peeraddr, - PeerPort => $peerport, - Proto => 'tcp') + PeerPort => $peerport, + Proto => 'tcp') or $error = "Could not create socket: $!"; if ( $socket ) { @@ -403,9 +403,9 @@ END } foreach my $codec (@CODECSX) { if ($fields[4] eq "$codec") { - $results[$i] = $results[$i] + 1; - $found = 1; - last; + $results[$i] = $results[$i] + 1; + $found = 1; + last; } $i++; } @@ -426,9 +426,9 @@ END } foreach my $codec (@CODECS) { if ($fields[8] eq "$codec") { - $results[$i] = $results[$i] + 1; - $found = 1; - last; + $results[$i] = $results[$i] + 1; + $found = 1; + last; } $i++; } From b8eba4d75c75bca54e4db4b3f121e2e60e958228 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 10 Aug 2019 21:45:18 -0400 Subject: [PATCH 4/5] asterisk: rename options for enabling/disabling graphs With this "enable_" prefix, it will be clearer to users that those options are boolean flags. --- plugins/asterisk/asterisk | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/asterisk/asterisk b/plugins/asterisk/asterisk index 938bbbdd..da633741 100755 --- a/plugins/asterisk/asterisk +++ b/plugins/asterisk/asterisk @@ -30,15 +30,15 @@ This plugin will produce multiple graphs showing: The following configuration parameters are used by this plugin [asterisk] - env.host - hostname to connect to - env.port - port number to connect to - env.username - username used for authentication - env.secret - secret used for authentication - env.channels - The channel types to look for - env.codecsx - List of codec IDs (hexadecimal values) - env.codecs - List of codecs names, matching codecsx order - env.meetme - Set to 1 to enable graphs for the MeetMe application - env.confbridge - Set to 1 to enable graphs for the ConfBridge application + env.host - hostname to connect to + env.port - port number to connect to + env.username - username used for authentication + env.secret - secret used for authentication + env.channels - The channel types to look for + env.codecsx - List of codec IDs (hexadecimal values) + env.codecs - List of codecs names, matching codecsx order + env.enable_meetme - Set to 1 to enable graphs for the MeetMe application + env.enable_confbridge - Set to 1 to enable graphs for the ConfBridge application The "username" and "secret" parameters are mandatory, and have no defaults. @@ -51,8 +51,8 @@ defaults. env.channels Zap IAX2 SIP env.codecsx 0x2 0x4 0x8 env.codecs gsm ulaw alaw - env.meetme 0 - env.confbridge 1 + env.enable_meetme 0 + env.enable_confbridge 1 =head2 WILDCARD CONFIGURATION @@ -126,8 +126,8 @@ my @CHANNELS = exists $ENV{'channels'} ? split ' ',$ENV{'channels'} : qw(Zap IAX my @CODECS = exists $ENV{'codecs'} ? split ' ',$ENV{'codecs'} : qw(gsm ulaw alaw); my @CODECSX = exists $ENV{'codecsx'} ? split ' ',$ENV{'codecsx'} : qw(0x2 0x4 0x8); -my $meetme_enabled = $ENV{'meetme'} || '0'; -my $confbridge_enabled = $ENV{'confbridge'} || '1'; +my $meetme_enabled = $ENV{'enable_meetme'} || '0'; +my $confbridge_enabled = $ENV{'enable_confbridge'} || '1'; my $line, my $error; my $socket = new IO::Socket::INET(PeerAddr => $peeraddr, From e14659d02c76e7b52b3d7d9e83591ba8bec86909 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 10 Aug 2019 21:46:30 -0400 Subject: [PATCH 5/5] asterisk: use eq instead of == for comparing a variable to a string sumpfralle suggested this change on github, since the comparisons are meant to be string comparisons. --- plugins/asterisk/asterisk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/asterisk/asterisk b/plugins/asterisk/asterisk index da633741..e7f37c2a 100755 --- a/plugins/asterisk/asterisk +++ b/plugins/asterisk/asterisk @@ -258,7 +258,7 @@ my $voicemail_response = asterisk_command($socket, "voicemail show users"); #2 voicemail users configured. my $meetme_response; -if ($meetme_enabled == '1') { +if ($meetme_enabled eq '1') { $meetme_response = asterisk_command($socket, "meetme list"); #Conf Num Parties Marked Activity Creation #5500 0001 N/A 00:00:03 Static @@ -266,7 +266,7 @@ if ($meetme_enabled == '1') { } my $confbridge_response; -if ($confbridge_enabled == '1') { +if ($confbridge_enabled eq '1') { $confbridge_response = asterisk_command($socket, "confbridge list"); #Conference Bridge Name Users Marked Locked Muted #================================ ====== ====== ====== =====