Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

(code) Check for particular services running on remote WinNT host(s)

by ybiC (Prior)
on Mar 23, 2001 at 01:05 UTC ( #66464=snippet: print w/replies, xml ) Need Help??
Description: A little ditty I threw together for our server dudes.   It automates their checks of remote WinNT hosts' Tivoli services.

Update: (Thanks|++) to Tye and dws for helpful suggestions.

#!/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<enter>

=head1 Updated

 2001-03-22  Initial working code

=head1 ToDos

 Fix "tsmstat.pl > outfile".  Dunno why it produces 0byte outfile.
 Simultaneously print output to console and outfile
   Usage would then be something like: services.pl outfile<enter>
 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
  • Comment on (code) Check for particular services running on remote WinNT host(s)
  • Download Code
Replies are listed 'Best First'.
(tye)Re: Check for particular services running on remote WinNT host(s)
by tye (Sage) on Mar 23, 2001 at 01:07 UTC

    Don't use Win32::API, just use Win32::Service.

            - tye (but my friends call me "Tye")
Re: Check for particular services running on remote WinNT host(s)
by dws (Chancellor) on Mar 23, 2001 at 01:15 UTC
    To protect against output getting out of order if something invoked by system() chokes, adding $|++; to the top of the script is a good idea.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: snippet [id://66464]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2023-12-10 13:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (40 votes). Check out past polls.

    Notices?