<?xml version="1.0" encoding="windows-1252"?>
<node id="66464" title="(code) Check for particular services running on remote WinNT host(s)" created="2001-03-22 20:05:05" updated="2005-07-21 10:43:37">
<type id="1980">
snippet</type>
<author id="14909">
ybiC</author>
<data>
<field name="doctext">
</field>
<field name="snippetdesc">
A little ditty I threw together for our server dudes. &amp;nbsp; It automates their checks of remote WinNT hosts'  Tivoli services.

&lt;p&gt;
&lt;b&gt;Update: &lt;/b&gt; (Thanks|++) to [Tye] and [dws] for helpful suggestions.</field>
<field name="snippetcode">
&lt;code&gt;#!/usr/bin/perl -w

use strict;

my $netsvc   = 'netsvc.exe';
my @services = (
    'TSM Client Acceptor',
    'TSM Client Scheduler',
    'TSM Remote Client Agent',
    );
my @hosts  = (
    '\\\\box1',
    '\\\\hostB',
    '\\\\serverIII',
    );

foreach my $host (@hosts) {
    print "  $host\n";
    foreach my $service (@services) {
        print "$service ";
        system ("$netsvc $host /query \"$service\"") == 0 and warn "  error $!";
        }
    print "\n";
    }


########################################################################

=head1 Name

 tsmstat.pl

=head1 Description

 Check multiple Win32 servers for running services

=head1 Requirements

 WinNT4 Resource Kit for "netsvc" command
 Run from Win32 host in same NT domain as target(s)
   or in domain trusted by target domain(s)

=head1 Tested

 ActiveState Perl 5.22 on WinNT4.0 sp6a

=head1 Usage

 tsmstat.pl&lt;enter&gt;

=head1 Updated

 2001-03-22  Initial working code

=head1 ToDos

 Fix "tsmstat.pl &gt; outfile".  Dunno why it produces 0byte outfile.
 Simultaneously print output to console and outfile
   Usage would then be something like: services.pl outfile&lt;enter&gt;
 Move @hosts and @sevices to external config file
 Use Win32::Service instead of system()
 Give explicit path to netsvc.exe in "my $netsvc"
   Works on my test PC but not Dave's PC
 Figure out how to prefix $host with NT domain

=head1 Author

 ybiC (for one of the server dudes)

=head1 Credits

 Thanks to Tye and dws for helpful suggestions

=cut


&lt;/code&gt;</field>
</data>
</node>
