In Consideration SNMP Monitoring - IN CONSIDERATION

[email protected]

Joined
Dec 15, 2015
Messages
1
Reaction score
26
It would be nice if you implement SNMP Monitoring. This will allow to monitor things like:
-Active Calls:
-Between Extensions
-Between Bridges
-PSTN Calls
-Incoming Calls
-Outgoing Calls
-Online Extensions
-Offline Extensions
-CPU usage per 3CX Process
-Memory usage per 3CX Process
-Logging attempts.
-3CX Service Status

And so on.

Thanks in advance.
 
Upvote 249
SNMP would be great! Maybe even a Prometheus exporter.
 
Up!
 
Definitely Usefull! +1 on this!
 
+1
 
Yes please ... one here as well!
 
Might i suggest: AND YES, it is real! https://pbxmonitor.net
Quanitity discount is negotiable. ;)
Does not require installing "ANYTHING" to the 3CX Servers, works on Windows or Linux.
10952
 
Last edited:
PRTG, we would like to monitor paging duration, since these hangs on some customers pbx and also other limitations.
 
+1
 
Template for Zabbix would be very nice to have, or PRTG

anything SNMP really..
 
+1

As an MSP, it is critical that we have advanced monitoring capabilities (beyond resource utilization).
 
Hi,
since SNMP Monitoring is still not implemented, I started hacking something…
What you would need:

Steps to do:
  • Change usernames and passwords in the perl script below to adapt your needs
  • Call the perl script cyclically (cron)
  • Create a Grafana Graph
The result on my side looks like this:
13199


The Perl Script:
Perl:
#!/usr/bin/perl

use strict;
use warnings;
use DBI;
use Data::Dumper;
use REST::Client;
use JSON;

my $client = REST::Client->new();
$client->setHost('http://your3cx.yourdomain.com');
$client->addHeader('Accept', 'application/json');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->getUseragent()->cookie_jar({});

print ": --- 3CX to MySQL ---\n";
my $req = '{"username":"3CXUSERNAME","password":"SECRET"}';
$client->POST('/api/login', $req);

if ($client->responseContent() eq 'AuthSuccess')
{
  print ": login ok\n";
  $client->GET('/api/activeCalls'); # or /api/SystemStatus (Call config page and network debug with browser)
  my $pbxdata = from_json($client->responseContent());
    
  $req = '{}';
  $client->POST('/api/logout', $req);
  print ": logout: ".$client->responseContent()."\n";

  # print Dumper $pbxdata;
 
  my $strext = "SIP-Trunk"; # The Text which indentifies a External Call
  my $calls_external = 0;
  my $calls_internal = 0;
 
  for my $item( @{$pbxdata->{'list'}} ) {
      print $item->{'Caller'} . " ---> ". $item->{'Callee'} . "\n";
      
      if ( (index($item->{'Caller'}, $strext) != -1) || (index($item->{'Callee'}, $strext) != -1) ) {
        $calls_external++;
      }
      else {
        $calls_internal++;
      }
  }

  print "Internal:".$calls_internal."  External:".$calls_external."\n";

  print ": Insert to DB...\n";
  my $dbh = DBI->connect("DBI:mysql:database=YOURDB;host=yourmysql.yourdomain.com", "MYSQLUSERNAME", "SECRET", {'RaiseError' => 1});
  $dbh->do("INSERT INTO pbx (time, CallsInternal, CallsExternal) VALUES (NOW(),
      \'".$calls_internal."\',
      \'".$calls_external."\'
  )");
  $dbh->disconnect();
}
else
{
    print ": ERROR - Login failed\n";
}

print ": Finished\n";

Create the Grafana Graph with:

SQL:
SELECT
  UNIX_TIMESTAMP(time) as time_sec,
  CallsExternal,
  CallsInternal
FROM pbx
WHERE
  $__timeFilter(time)
ORDER BY time

Finished
 
Hi,
additionally, if you want to use with PRTG:
Result:

13205

The Batch
Code:
@echo off

set PORTPERL=c:\tool\strawberry-perl-5.30.0.1-64bit-portable\

set PATH=%PORTPERL%perl\site\bin;%PORTPERL%perl\bin;%PORTPERL%c\bin;%PATH%

set TERM=
set PERL_JSON_BACKEND=
set PERL_YAML_BACKEND=
set PERL5LIB=
set PERL5OPT=
set PERL_MM_OPT=
set PERL_MB_OPT=

perl "%~dp0poll3cx.pl"
Perl
Perl:
#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
use REST::Client;
use JSON;

my $client = REST::Client->new();
my $result = "";
$client->setHost('http://pbx.schleissheimer.de');
$client->addHeader('Accept', 'application/json');
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->getUseragent()->cookie_jar({});

my $req = '{"username":"3CXUSERNAME","password":"SECRET"}';
$client->POST('/api/login', $req);

if ($client->responseContent() eq 'AuthSuccess')
{
  $client->GET('/api/activeCalls');
  my $pbxdata = from_json($client->responseContent());
    
  $req = '{}';
  $client->POST('/api/logout', $req);

  # print Dumper $pbxdata;
 
  my $strext = "SIP-Trunk";
  my $calls_external = 0;
  my $calls_internal = 0;
 
  for my $item( @{$pbxdata->{'list'}} ) {
      if ( (index($item->{'Caller'}, $strext) != -1) || (index($item->{'Callee'}, $strext) != -1) ) {
        $calls_external++;
      }
      else {
        $calls_internal++;
      }
  }
  # print "Internal:".$calls_internal."  External:".$calls_external."\n";
 
  $result = '{ "prtg": { "result": [ { "channel": "calls_internal", "value": "'.$calls_internal.'" }, { "channel": "calls_external", "value": "'.$calls_external.'" }, { "channel": "sum", "value": "'. ($calls_external + $calls_internal).'" } ] } }';

  print $result . "\n";
 

}
else
{
    # print ": ERROR - Login failed\n";
  exit 1;
}

# print ": Finished\n";
exit 0;

cu SveN
 

Forum statistics

Threads
111,974
Messages
590,081
Members
164,899
Latest member
mazet