From 9f56a03d058b152cad46938ab7eb25dd5ccaa8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sun, 30 Dec 2012 13:04:25 -0800 Subject: [PATCH] asterisk: add asterisk_voicemail replacement code as well. This is a bit trickier, since the voicemail might not be enabled anywhere. Unfortunately it's not easy to set this up during autoconfig, as voicemails can be added on the fly. --- plugins/asterisk/asterisk | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/plugins/asterisk/asterisk b/plugins/asterisk/asterisk index 2cf93cd9..fe507b97 100755 --- a/plugins/asterisk/asterisk +++ b/plugins/asterisk/asterisk @@ -11,7 +11,10 @@ This plugin will produce multiple graphs showing: - total number of active channels (replaces asterisk_channels), together with breakdown of specific channel types (replaces - asterisk_channelstypes). + asterisk_channelstypes); + + - the number of messages in all voicemail boxes (replaces + asterisk_voicemail). =head1 CONFIGURATION @@ -136,6 +139,16 @@ $channel.label $channel channels END } +print <print("Action: command\nCommand: core show channels\n\n"); #--END COMMAND-- my $shown_channels = readreply $socket; +$socket->print("Action: command\nCommand: voicemail show users\n\n"); +#Response: Follows +#Context Mbox User Zone NewMsg +#default 1234 Example Mailbox 1 +#other 1234 Company2 User 0 +#2 voicemail users configured. +#--END COMMAND-- +my $voicemail_response = readreply $socket; +$voicemail_response = undef if $voicemail_response =~ /Response: Error/; + $socket->close(); my $active_channels = 'U'; @@ -171,3 +194,16 @@ foreach my $channel (@CHANNELS) { scalar(grep(/^$channel\//, @channels_list)) . "\n"; } + +print "\nmultigraph asterisk_voicemail\n"; +if ( !$voicemail_response or $voicemail_response =~ /no voicemail users/ ) { + print "total.value U\n"; +} else { + my $messages = 0; + foreach my $line (split(/\r\n/, $voicemail_response)) { + next unless $line =~ / ([0-9]+)$/; + $messages += $1; + } + + print "total.value $messages\n"; +}