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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|