SICM Simple Infrastructure Capacity Monitor

 

SourceForge.net Logo

rrdtool.org logo

SICM Modules

SICM provides a capability of developing custom built modules and using existing or custom modules to query any device.

Four modules have been developed and included with SICM :

  • Apache statistics
  • MySQL performance
  • TCP ping (ftp, http, smtp, telnet, etc), and
  • Percent disk space

Modules provided with SICM

A description, installation and configuration instructions as well as references are provided for the four modules included with SICM

Module Apache statistics
File sicm/lib/Apachestats.pm
Description Outputs current statistics of an apache web server
Installation
  1. ActivePerl usually includes LWP::UserAgent hence installation may not be required. To search to see if LWP::UserAgent is installed:
       C:\Perl>ppm search LWP-UserAgent

    If it is missing and you are on-line, then:

       C:\Perl>ppm install LWP-UserAgent

    Linux installations should download LWP::UserAgent from CPAN and use: perl Makefile.PL, make, make test and make install as appropriate.

  2. Ensure the following is in httpd.conf of the target apache server:

    LoadModule status_module    libexec/apache/mod_status.so
    ExtendedStatus On
     
    <Location /server-status>
      SetHandler server-status
      Order deny,allow
      Deny from all
      Allow from localhost
    </Location>
Configuration

In templates.xml use

  Apachestats::stats('ip_address', 'counter_type')

Where counter_type is one of:

    apache_total_hits
    apache_total_kbytes
    apache_busy_workers
    apache_idle_workers
    req_per_sec
    bytes_per_sec
    bytes_per_req
References http://httpd.apache.org/docs/2.0/mod/mod_status.html
 
Module MySQL performance
File sicm/lib/Mysqlstats.pm
Description Outputs current statistics of a mysql server
Installation
  1. For Activeperl, install perl module Net-mysql:
       C:\Perl>ppm install Net-mysql

    Linux installations should download Net::mysql from CPAN and use: perl Makefile.PL, make, make test and make install as appropriate.

  2. If using MySQL on Windows XP SP2, set an exception on the firewall for MySQL (default = TCP 3306)
    If the following error occurs when you try to connect from a remote host, it means there is no row in the MySQL user table with a Host value that matches the remote host: "Host ... is not allowed to connect to this MySQL server"
    This can overcome by by setting up a MySQL account for the combination of remote hostname and username that you are using when trying to connect. If you do not know the IP number or hostname of the remote machine from which you are connecting, you should put a row with '%' as the Host column value in the user table. After trying to connect from the client machine, use a SELECT USER() query to see how you really did connect. (Then change the '%' in the user table row to the actual hostname that shows up in the log. Otherwise, the system maybe left insecure as it allows connections from any host for the given username.)
Configuration

In templates.xml use

Mysqlstats::stats( 'database', 'variable', 'ip_address', 'user', 'password' );

Where: variable is one of those referenced in: http://dev.mysql.com/doc/mysql/en/server-status-variables.html

References http://search.cpan.org/dist/Net-MySQL/MySQL.pm
http://dev.mysql.com/doc/mysql/en/server-status-variables.html
 
Module TCP ping
File sicm/lib/Tcpping.pm
Description Outputs the latency for creating a tcp (socket) connection to a target
The tcp connection can be any port number (ftp = 21, telnet = 23, smtp = 25, http = 80, etc)
Installation

ActivePerl usually includes IO::Socket and Time::HiRes hence installation may not be required. To search to see if IO::Socket and Time::HiRes are installed:

   C:\Perl>ppm search IO-Socket
C:\Perl>ppm search Time-HiRes

If they are missing and you are on-line, then:

   C:\Perl>ppm install IO-Socket
C:\Perl>ppm install Time-HiRes

Linux installations should download IO::Socket and Time::HiRes from CPAN and use: perl Makefile.PL, make, make test and make install as appropriate.

Configuration

In templates.xml use

Tcpping::query('ip_address', 'port_num')
References http://www.iana.org/assignments/port-numbers
 
Module Percent disk space
File sicm/lib/Percentdiskspace.pm
Description Uses SNMP MIB2 OIDs to query the current disk space used in percent. Suitable for Win32 and Linux volumes
Configuration

In templates.xml use

Percentdiskspace::used('ip_address', 'interface', 'community')

If you have a requirement for a module and need assistance, please contact the author via the SICM forum at sourceforge

How to configure Modules in SICM

When configuring the templates file (eg templates.xml), modules may be configured within each template. If modules are used, the following requirements apply:

  • Modules must be located in SICM's \lib directory.
  • The module must return a single numeric value. SICM validates this, returning UNKNOWN if invalid.
  • The module is required to exit gracefully in the event of a failure.
  • The module must be written in perl.
  • Three optional variables are avaivable within SICM to assist module parameters:
    • %ip_address% - the ip address of the target
    • %metric%     - the metric as defined in the target file (eg targets.xml)
    • %community%  - the snmp community string for the target

An example is apache_hits where %ip_address% is used as a module parameter:

   <metric module="Apachestats::stats( '%ip_address%', 'apache_total_hits')"
      data_source_type="COUNTER" convert="60" plot="LINE2"
      color="00BB00" consolidate="MAX">apache_hits</metric>

It is strongly recommended to test the module before using within SICM.

For further information, refer to: How to create a SICM module and How to test and implement a SICM module

How to create a SICM module

Note: To assist in creating modules, three have been developed and placed in SICM's /lib directory. It is recommended to use these as examples to assist in developing additional modules.

  1. Build a perl script that queries the computing device or application. To minimise development effort, take advantage of CPAN and the many other sources of libraries, modules and examples available on the Internet.
    • For success, ensure there is only one numeric value returned.
    • In the event of failure, the return of a 'plain language' reason for failure is acceptable, SICM will log this.
    • The script may use parameters to set variable query data, for example: ip_address, login and password. This will provide greater flexibility when configuring SICM.
  2. Test your script for success, also test your script for graceful completion in the event of failure.
  3. Convert your script (.pl) to a module (.pm). To assist in simplifying this, the following template and procedures have been developed:
        ## -*- perl -*-
        package Mymodule;
        use strict;
        use warnings;
        our $VERSION = '0.00';
        use other_modules_if_required;
        sub mysubroutine {
         
          ...add query details here...
         
          return $my_query_value;
        }
        1;
    • Copy the script into the module template, ensuring the structure of the template is maintained:
    • The module must contain a package, eg: package Mymodule;
    • The query must be inside a subroutine, eg: sub mysubroutine {...}
    • The module must return a single numeric value, eg: return $my_query_value;
  4. Implement the module as per How to test and implement a SICM module

If you require assistance in developing a module, please contact the author via the SICM forum at sourceforge

How to test and implement a SICM module

  1. Install the perl module in SICM's /lib directory.
  2. Ensure the module is tested successfully on the SICM server.
    An example test script to achieve this is:
        #!/usr/bin/perl -w
        use strict;
        use warnings;
        use FindBin;
        use lib "$FindBin::Bin/lib";
        use Mymodule;
        my $test = Mymodule::mysubroutine('192.168.1.1', 'param2', 'param3');
        print "$test\n";
  3. Run the test numerous times, cycling through each parameter, varying it for success and failure. Ensure the module behaves appropriately in all circumstances.
  4. Create a new, or modify existing SICM template (in template.xml) as required. The template may include, for example:
        <metric module="Mymodule::mysubroutine('%ip_address%', 'param2',
    	'param3')" data_source_type="GAUGE" plot="AREA"
    	color="00BB00">add_description_here</metric>
  5. Add the device to the target file
  6. Stop, then run SICM in test mode to validate
  7. Start SICM
  8. View the results after allowing 2 * frequency time to pass
  9. Important: When SICM is installed on a Win32 server, monitor the memory and threads (using Windows Task Manager or similar) used by perl.exe.
    • If the memory continually increases over time, there is a memory leak,
    • If there is more than 1 thread used perl, hence SICM, may eventually fail.
    The thread issue is not of concern on *nix servers.
For further information, refer to: How to configure Modules in SICM
SICM v0.95 Copyright 2003-2006 Thomas Price