Windows Client...

Mark D. Nagel mnagel at willingminds.com
Tue Jan 25 22:03:51 CET 2005


Emmett Hogan wrote:

> Thanks for the info.  Since we have a number of NT4 servers, I guess 
> we'll stick with nsclient.  I am having a problem determining the 
> status of services and processes where the name contains one or more 
> spaces.  I have tried all manner of quoting but to no avail.  Any 
> suggestions on how to find out the exact service name to use? (We are 
> using what shows up in the services dialog box on the NT machine). :-(


One way is to ask NSClient itself:

/usr/lib/nagios/plugins/check_nt -H <hostname> -v SERVICESTATE -d 
SHOWALL -l ALL

This will emit a comma-separate list of services with names you would 
use to check via NSClient.  However, I've see that the above seems to no 
longer work in Windows 2003, so it is not necessarily a reliable method 
to try.  May have to switch to NC_Net as Andreas mentioned earlier.

You can also use Perl Win32 modules to get this list -- below is a 
script that enumerates all service names and their execution account 
names on all domain servers -- feel free to adapt to your needs :).

Mark

use strict;
use Win32;
use Win32::NetAdmin;
use Win32::Service;
use Win32::Lanman;

my $domain = Win32::DomainName();
my $PDC;
my @servers1;
my @servers2;
my @servers3;
Win32::NetAdmin::GetDomainController("", $domain, $PDC) or
    die "Unable to obtain the PDC name for $domain.\n";
Win32::NetAdmin::GetServers($PDC, $domain, 0x00000008, \@servers1) or
    die "Unable to read NetBios 0008.\n";
Win32::NetAdmin::GetServers($PDC, $domain, 0x00000010, \@servers2) or
    die "Unable to read NetBios 0010.\n";
Win32::NetAdmin::GetServers($PDC, $domain, 0x00008000, \@servers3) or
    die "Unable to read NetBios 8000.\n";
my @servers = (@servers1, @servers2, @servers3);

for my $server (@servers) {
    print "$server\n";
    my %service = ();
    Win32::Service::GetServices($server, \%service);
    for my $service (values %service) {
    my %config = ();
    if (!Win32::Lanman::QueryServiceConfig("\\\\$server", '', $service, 
\%config)) {
        print "$service: error querying configuration: ",
              Win32::FormatMessage(Win32::Lanman::GetLastError()), "\n";
        next;
    }
        print "$service: $config{account}\n";
    }
    print "\n";
}

-- 
Mark D. Nagel, CCIE #3177 <mnagel at willingminds.com>
Principal Consultant, Willing Minds LLC
tel: 714-630-4772, fax: 714-630-4773, web: http://www.willingminds.com/



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list