Welcome to PCCS-Linux.COM Hello, and welcome to the PCCS-Linux Home Page.
Your last visit was !!!
Your Browser is running on Other
 
using fping

Script to see if important net devices are available on the 
net.


cron job set to run every 5 minutes 
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/hostck.pl


#!/usr/local/bin/perl
use strict;
require '/usr/local/lib/perl5/5.6.1/.pl';

my $MAILTO = "chaunceyt";

my $pid = &("OUTPUT","INPUT","/usr/local/sbin/fping -u");

# get ipaddress of important devices...

my @check = (`cat /etc/ipaddress`);

foreach(@check) { 
        print INPUT "$_\n"; 
} 
close(INPUT);


my @output = ();
close(OUTPUT);

if ($#output != -1) {
        my $date = "";
        chop($date = `date`);MAIL,"|mail -s 'Hosts down...' $MAILTO"); 
        print MAIL "\nHosts down as of: $date\n\n"; 
        print MAIL @output;
        close MAIL;
} 


Discovery script, used to see what ip stations are running
Output file is processed by donmap

#!/usr/bin/perl
$fping = "/usr/local/sbin/fping";

# file containing all internal subnets

@aliveNet = `cat netaddress`;

foreach $network (@aliveNet) {OUTFILE, ">> netscan.out") or die "Unable toOutput file\n";
        chomp $network;
        ($oct1, $oct2, $oct3, $oct4) = split(/\./, $network);
        $net = "$oct1.$oct2.$oct3";
        for $host (1..254) {
                push(@netList, "$net.$host");
        }
        $aliveHosts = `$fping -a @netList`;
        @netList = ();
        print OUTFILE "$aliveHosts";
        close OUTFILE;
}


Script to determine port running on IP's discovered

#!/usr/bin/perl

$nmap = "/usr/local/bin/nmap";

@getaddr = `cat netscan.out`;

foreach $ip (@getaddr) {OUTFILE, ">> nmapscan.out") or die "Unable toOutput file\n";
        chomp $ip;
        $nmapdata = `$nmap $ip -O`;
        print OUTFILE "$nmapdata";
        print OUTFILE "%";
        close OUTFILE;
}



Page hits 101 on :02:37



This web site is prepared and maintained by Chauncey Thorn.
The information contained in this site was valid at the time of posting.
Chauncey Thorn, assumes no liability for damages incurred directly or indirectly as a result of errors, omissions or discrepancies.

Remember most of the content here are my notes...

All logos and trademarks in this site are property of their respective owner. All the rest © by PCCS-Linux.COM

PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002