Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

My apologies

by Marza (Vicar)
on Mar 28, 2002 at 22:38 UTC ( #155141=note: print w/replies, xml ) Need Help??

in reply to Re: Re: McAfee Dat Check
in thread McAfee Dat Check

Well I guess I should not post when I am tired. Does that sound better then posting without a license? ;-)

In your case that does make sense! 500 Servers ick. I was going to say why not automate but if you have 500 servers then you have a few thousand workstations. Right?

I only have about 350 machines total. The script I wrote checks all machines. I used the Roth NetAdmin mod to get a list of all NT/2000 workstations and servers. The only problem is that you have to build exclusion routines for stuff like Samba servers. But again in my case, people here would not always update the input file.

Why not build a ping into the routine. That way if a machine is down, you avoid the registry error when it tried to connect. I needed this because a few of our junior admins would go looking for the down machine and try and figure out why it did not have McAfee or Netshield installed! *SIGH*

A simple code:
my $p = Net::Ping->new("icmp"); if ($p->ping($computer)) { #run your checks } else { print"* Unable to Ping $computer *\n"; } $p->close(); }

Also this is strictly a choice of the person since there is no "real" noticible difference. But if you played with Connect option you could lesson some of your typing. As in:

if ($key = $Registry->Connect("$computer","LMachine/Software/Network A +ssociates/" . "TVD/NetShield NT/CurrentVersion/" {Access=>KEY_READ} ) ) { unless ($version = $key->GetValue("szProductVer")) { $version = "Unknown"; } unless ($dat = $key->GetValue("szVirDefVer")) { $dat = "Unknown"; } unless ($engine = $key->GetValue("szEngineVer")) { $engine = "Unknown"; } }

But this again is the choice of the person. For me if there was a typo, I would have to work at the long lines because I have dyslexia. So the chopped up lines make it a easier for me to read.

Oh did you know you could toss your delimeter up in the use statement? One less line....

use Win32::TieRegistry( Delimiter=>"/" );

How about a piece offering. This code will go out to the mcafee downloads site and get you the current dat, superdat and engine info. You will need LWP::UserAgent, HTTP::Request, and HTML::TableExtract(this is a slick mod).

For some strange reason the engine info comes out with a bunch of lines. Can't tell if NAI did something to their website or it is a bug. I think it is their site because it worked fine in the morning. You can correct this issue by resaving the engine var as an int

# # GetCurrentVersion will the Mcafee download page and grab the version + number # for the latest DAT, superDAT, and engine. sub GetCurrentVersion { my $key; my $dat; my $superdat; my $engine; my $html_code; my $row; my $ts; # # Lets access the Network Associates download page for the Virus I +nfo. my $ua = new LWP::UserAgent; my $url = ' +sp'; my $request = new HTTP::Request('GET',$url); # # Do we need to login? #$request->authorization_basic('login', 'password'); $ua->timeout(10); my $response = $ua->request($request); my $responsecode = $response->code(); # # Now we need to gather the information. if ($responsecode != 200) { print "Failed to Access the Mcafee site!: $responsecode\n"; } else { # # Load the HTML junk into a var. my @array = (split "\n", $ua->request($request)->as_string); foreach (@array) { $html_code .= $_ . "\n"; } } # # It's time to use TableExtract. We use the File Version and Date +for # header info to locate our tables. Once found; we look for certa +in # names and assing the version info to our needed vars. my $te = new HTML::TableExtract( headers => [qw(File Version Date) +] ); $te->parse($html_code); foreach $ts ($te->table_states) { #print "Table found at ", join(',', $ts->coords), ":\n"; foreach $row ($ts->rows) { # # DAT Version if (@$row[0] =~ /DAT File for weekly v4x \(DAT Only\)/) { #print "DAT = @$row[1]\n"; $dat = @$row[1]; } # # SuperDAT version which has both Engine and DAT. if (@$row[0] =~ /SuperDat File for v4x \(DAT \+ Engine\)/) + { #print "Superdat = @$row[1]\n"; $superdat = @$row[1]; } # # Engine only Version. if (@$row[0] =~ /Superdat File for v4x \(Intel Engine only +\)/) { $engine = @$row[1]; } #print " ", join(' , ', @$row), "\n"; } } return($dat, $superdat, $engine); }

So again I meant no disrespect. Sorry for such a wanky post.

Replies are listed 'Best First'.
There is always an afterthought.
by Marza (Vicar) on Mar 28, 2002 at 23:47 UTC

    Using the connect method does have one advantage over your approach.

    If I can't connect to a server be it from the remote registry service is down, the server is down, or there was an uninstall of netshield and *shock* the uninstaller left junk in the registry, the code I gave you will only make one attempt to connect with the server.

    Your code will try three times and get three errors.

    Okay, this is the last time I promise. ;-)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2023-09-22 18:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found