check_gms_directory_entries

On this page you will find the current version of the Polycom GMS Global Directory entry check script. Furthermore you will find a small description of the script parameters.

Idea

The base for this script is to be able to fetch the information automaticaly. As I found no documentation about the communication API between the GMS global addressbook service and the endpoints I tried to figure out the needed transactions by sniffing the network traffic. After some reasearch I was able to get the wanted results by using a simple telnet session connecting the port 3601 on the GMS system.

After having the basic information I wrote this small perl script which simply counts the number of entries.

With the basic communication information it is also possible to build some other things like e.g.

  • Dynamic webpage which displays the contents of the global addressbook
  • Monitor script which checks for special entries instead of just counting them
Sample output

Prerequisites

You will need the following perl modules to get the plugin running:

  • Net::Telnet
  • Getopt::Long

check_gms_directory_entries

Copy the file to your nagios/libexec directory, fix owner and make it executable.

#!/usr/bin/perl -w
#############################################################################
# 2008-11-19 Lars Michelsen <lars@vertical-visions.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
#
# GNU General Public License: http://www.gnu.org/licenses/gpl-2.0.txt
#
# ##############################################################################
# SCRIPT:       check_gms_directory_entries.pl
# VERSION:      1.0
# AUTHOR:       Lars Michelsen
# DECRIPTION:   Connects to the Polycom GMS global directory and counts the
#               number of entries in the global addressbook.
# ##############################################################################
 
use strict;
use Net::Telnet;
use Getopt::Long;
Getopt::Long::Configure('bundling');
 
my ($oHelp, $oHost, $oPw, $oName, $oIp, $oWarn, $oCrit, $oTimeout);
my ($telnet, $return, $addresses, @addresses);
 
my $host = '';
my $pw = '';
my $name = '';
my $ip = '';
my $timeout = 40;
my $prompt = '/^$/';
 
my $warn = -1;
my $crit = -1;
my $state = 'OK';
my $output = '';
my $perfdata = '';
 
# Exit-Status-Array
my %ERRORS = ('UNKNOWN' , '-1',
  'OK' , '0',
  'WARNING', '1',
  'CRITICAL', '2');
 
# Parameter handling ##########################################################
 
GetOptions("H|host:s" => \$oHost,
      "P|pw:s" => \$oPw,
      "N|name:s" => \$oName,
      "I|ip:s" => \$oIp,
      "w|warn:i" => \$oWarn,
      "c|crit:i" => \$oCrit,
      "t|timeout:i" => \$oTimeout,
      "h|help" => \$oHelp);
 
if($oHelp || !$oHost || !$oPw || !$oName || !$oIp) {
print <<EOU;
  Usage: $0 -H <FQDN/IP: string>
            -P <Password: string> -N <Client Name: string>
            -I <Client IP: string> [-t <timeout in seconds: integer>]
            [-w <warning level: integer] [-c <critical level: integer>]
            [-h]
 
 
    Options:
 
    -H --host STRING or IPADDRESS
        FQDN or IP-Address of the GMS host
    -P --pw STRING
        Password to access the global directory on GMS host
    -N --name STRING
        Name of the client host. In this case the monitoring server
    -I --ip String
        IP of the client host. In this case the monitoring server
    -w --warn INTEGER
        Warning treshold. Give the minimum number of entries in the
        directory
 
        Example:
        Give a number of 10 to get a WARNING state on less than 10 entires
    -c --crit INTEGER
        Critical treshold. Give the minimum number of entries in the
        directory
 
        Example:
        Give a number of 10 to get a CRITICAL state on less than 10 entires
        occupied before critical state occurs.
    -h --help
        Print this help text
EOU
 
  exit($ERRORS{'UNKNOWN'});
}
 
$host = $oHost;
$pw = $oPw;
$name = $oName;
$ip = $oIp;
 
if($oWarn) {
  $warn = $oWarn;
}
if($oCrit) {
  $crit = $oCrit;
}
if($oTimeout) {
  $timeout = $oTimeout;
}
 
# Script start ################################################################
 
$telnet = new Net::Telnet(Port => 3601, Timeout => $timeout, Errmode => 'return', Dump_Log => '',Prompt => $prompt);
$telnet->open($host);
 
# Authentication
$telnet->print('PVAL '.$pw);
 
$return = $telnet->waitfor('/^AUTHORIZED\s[0-9]+$/');
if(!$return) {
  print STDERR "ERROR: Not authorized (".$telnet->errmsg().")\n";
  exit(1);
}
 
# Register
$telnet->print('SITEREG '.$name.'\\'.$ip.'\\'.$name.'\\\\\\\\\\\\909b819f-e7f5-4f84-b1b5-7989e1bf79e7\\\\check_polycom_gms_addressbook\\UNKNOWN\\H.323\\\\\\3000\\\\\\No\\\\\\No\\\\:,:,:,:,\\\\'.$name.'\\\\\\\\\\\\H323\\Yes\\No\\No\\2\\No\\\\No\\');
 
$return = $telnet->waitfor('/REGCONFIRM/');
if(!$return) {
  print STDERR "ERROR: No regconfirm (".$telnet->errmsg().")\n";
  exit(1);
}
 
# Get all addresses
@addresses = $telnet->cmd(String => 'GETALL', Prompt => '/eob/');
 
# Filter addresses
for (my $i = 0; $i <= $#addresses; $i++ ) {
  if($addresses[$i] !~ m/^A2/) {
    splice(@addresses, $i, 1);
  }
}
 
if($warn != -1 && $#addresses < $warn) {
  $state = 'WARNING';
}
if($crit != -1 && $#addresses < $crit) {
  $state = 'CRITICAL';
}
 
$output = $state.': Found '.$#addresses.' entries in global directory';
$perfdata = ' | entries='.$#addresses;
 
# Verbindung trennen
$telnet->close();
 
print($output.$perfdata."\n");
exit($ERRORS{$state});

PNP-Template

I use the default PNP template for this simple script.

Parameters

  Usage: ./check_gms_directory_entries.pl -H <FQDN/IP: string>
            -P <Password: string> -N <Client Name: string>
            -I <Client IP: string> [-t <timeout in seconds: integer>]
            [-w <warning level: integer] [-c <critical level: integer>]
            [-h]
 
 
    Options:
 
    -H --host STRING or IPADDRESS
        FQDN or IP-Address of the GMS host
    -P --pw STRING
        Password to access the global directory on GMS host
    -N --name STRING
        Name of the client host. In this case the monitoring server
    -I --ip String
        IP of the client host. In this case the monitoring server
    -w --warn INTEGER
        Warning treshold. Give the minimum number of entries in the
        directory
 
        Example:
        Give a number of 10 to get a WARNING state on less than 10 entires
    -c --crit INTEGER
        Critical treshold. Give the minimum number of entries in the
        directory
 
        Example:
        Give a number of 10 to get a CRITICAL state on less than 10 entires
        occupied before critical state occurs.
    -h --help
        Print this help text

Sample configuration

Here some sample command and service definition for Nagios configuration.

define command {
  command_name  check_gms_directory_entries
  command_line  $USER1$/check_gms_directory_entries.pl -H $HOSTADDRESS$ -P $ARG1$ -N $ARG2$ -I $ARG3$ -w $ARG4$ -c $ARG5$
}
 
define service {
  hostgroup_name     gms
  service_description  GMS-NUM-ADDRESSES
  check_command        check_gms_directory_entries!<password>!nagios!<nagios-server-ip>!15!10
  use                  sdm-standard
}
Comments (0) Trackbacks (0)

No comments yet.

No trackbacks yet.