You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This page is a companion to the Managing Servers and Services with NMIS8 page, and provides some examples of how various services can be monitored with NMIS.

Web

Web, end-to-end

DNS

remote, port only

NMIS can monitor the accessibility of TCP and UDP ports (using the NMAP tool), which in the case of DNS would give only a rough indication of whether the DNS server is reachable at all.

Here is a configuration snippet for this level of monitoring:

remote, protocol only

To verify the general operation of a remote DNS server, you can use the service 'dns' that's built into NMIS. This service will make a DNS request to the server in question and triggers based on getting a DNS record back or not, and captures the response time.

Here is how our own internal monitoring is set up to check our own domain, which involves servers outside of our control: We've defined PingOnly-entries for the external DNS servers in question, and activated service "opmantek-dns" for them, which looks like this:

local, custom script

On a system that is under your control, and which runs NMIS you can execute arbitrary scripts to collect service statuses. The example script below checks that the local NMIS server itself has a running BIND DNS server process:

#!/bin/sh
# small script that tests that a local bind is up and communicating
if /sbin/pidof named >/dev/null 2>&1 && /usr/sbin/rndc status | grep -q 'up and running'; then
        exit 100
else
        exit 0
fi

To use this, save the script somewhere NMIS can access it (as /usr/local/bin/bindpresent for example), then configure NMIS with this service of type "program" and activate  the service  for the  NMIS server in question:

 

MySQL Database

UPS Status

Cheaper UPS systems that don't have builtin networking or SNMP capabilities can be monitored by NMIS as well, as long as there is some sort of management infrastructure that supports querying the UPS status. In this example we're checking two UPS systems that are connected to our NMIS server via USB cables, where the NUT (Network UPS Tools) suite takes care of the interfacing.

The upstest.pl script below uses the NUT tools to query the named UPS and reports whether it's working and at what charge level it is. (NMIS does not yet graph extra variables like the charge level here as of version 8.5.4G, but this feature will be added soon.)

#!/usr/bin/perl
# a tiny wrapper around upsc to integrate with nmis
# exits with 100 if ups online, charge otherwise
# this means the service is down only when the ups is dead, 
# NOT while its discharging.
# also reports battery charge as charge=NNN
use strict;
# args: name of the ups
my $upsname = $ARGV[0];
die "usage: $0 <upsname>\n" if (!@ARGV);
my @knownones = `upsc -L 2>/dev/null`;
die "unknown ups $upsname\n" if !grep (/^$upsname:/, @knownones);
my ($status,$charge);
for my $line (`upsc $upsname 2>/dev/null`)
{
                chomp $line;
                my ($varname,$value) = split(/\s*:\s*/, $line);
                if ($varname eq "ups.status")
                {
                                $status = $value;
                }
                elsif ($varname eq "battery.charge")
                {
                                $charge = $value;
                }
}
print "charge=$charge\n" if (defined $charge);
exit ($status =~ /^OL/? 100 : $charge);

For our UPS systems we first make use of NMIS' builtin SNMP-based process status monitoring, which checks that there is at least one active process with a given name (here 'upsd'), and then added the per-UPS status checks with the UPS names passed to the upstest script.

 

  • No labels