Ad Widget

Collapse

Monitoring Grandstream IP phones

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dzhirkov
    Junior Member
    • Dec 2017
    • 2

    #1

    Monitoring Grandstream IP phones

    Hello all ,

    I was looking a solution to monitor Grandstream GXP1615/GXP2130 IP phones working with remote off-site SIP PBX.
    The only way I found was ICMP pinging , but i wanted to control SIP registration as well.

    Idea came to use CTI technology (http://www.grandstream.com/sites/def.../CTI_Guide.pdf ) and scripting.
    I wrote a script which returns "1" if phone is registered to IP PBX, "0" - otherwise.
    Here it is below. Just change default "admin" passcode to your own and create item with trigger ..

    #!/usr/bin/perl
    use strict;
    use JSON qw/ decode_json from_json/;
    use Encode qw/decode_utf8/;
    use HTTP::Request;
    use LWP::UserAgent;

    my $passcode = "admin";

    my $iphone = shift or die "Usage: $0 <IP phone address or DNS name\n";

    my $URL = "http://$iphone/cgi-bin/api-get_phone_status?passcode=$passcode";
    my $ua = new LWP::UserAgent( timeout => 600 );
    my $request = HTTP::Request->new('GET', $URL);
    my $response = $ua->request($request);

    if ($response->is_success){
    my $result = from_json(Encode::decode_utf8($response->decoded_content())) || {};
    my $status = $result->{'body'};
    if ( $status eq "available" ) {
    print "1\n";
    } else {
    print "0\n";
    }
    }elsif ($response->is_error){
    print "Error:$URL\n";
    exit 1;
    }
  • dzhirkov
    Junior Member
    • Dec 2017
    • 2

    #2
    important addition

    when the phone is used for conversation , the "body" key has "busy" value .
    But since that means everything is Ok with the phone , the script should be modified :
    please, replace string
    "...
    if ( $status eq "available" ) {
    ..."
    with

    if ( ($status eq "available") or ($status eq "busy") ) {

    Comment

    Working...