Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by ybiC (Prior)
on Mar 23, 2001 at 01:05 UTC ( [id://66464]=CUFP: print w/replies, xml ) Need Help??

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

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: CUFP [id://66464]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 06:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found