[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] Perl Help - Again



Okay.  I have a cool script for monitoring log files (thanks to
File::Tail).  I can automatically gather IP addresses, and nmap scan the
machines.  The problem is the program waits until the scan finishes
before returning control to the infinite loop monitoring the log file.

How should I split off the scanning from the monitoring?  I'm planning
on setting up a scheduled NESSUS scan, but I'd like the nmap to happen
in near-real time.  Is this a fork() or threads situation?

A basic overview of the script:

sub nmapscan
{	
	$result = qx/nmap -sSU $machine_ip/;
	PERL::DBI Stuff
	INSERT into COMPUTERSCANS (id, computer_id, results) values ('',
$computer_id, $result);
	close PERL::DBI stuff
}

Start Infinite loop 

Monitor /var/log/messages

If $line contains "DHCPACK" then parse it for IP/MAC/NAME and create
appropriate variables

Check DB for current record of machine, if exists, create global
variable $computer_id.  

If not, create a record, and store primary key into $computer_id. 

If new IP address, update hosts table w/new IP address.
nmapscan();

Restart the loop;

-- 
Jonathan Glass
Systems Support Specialist II
Institute for Bioengineering & Bioscience
Georgia Institute of Technology
Email: jonathan.glass at ibb.gatech.edu
Office: 404-385-0127
Fax: 404-894-2291