Page 1 of 1

Here a pinging scanner for ZM ip cameras.

Posted: Wed Dec 30, 2009 9:32 pm
by johnnytolengo
I hope it helps.

Code: Select all

#!/usr/bin/perl -wT

use Net::Ping;
use strict;
use DBI; 


my $db="zm";    ## NOMBRE BASE DE DATOS
my $tabla="Monitors";              ## NOMBRE DE TABLA
my $usuario="zmuser";   ## USUARIO
my $password="zmpass";  ## CONTRASENA

my $dbh=DBI->connect("dbi:mysql:$db",$usuario,$password);
my $sth = $dbh->prepare(qq{
 
SELECT  SUBSTRING_INDEX(SUBSTRING_INDEX( `Host` , '.', 4 ),"@",-1) AS Host FROM $tabla where Enabled = "1" 

});

$sth->execute();

while (my ($Host) = $sth->fetchrow_array() ){

my $p = Net::Ping->new();
 if ($p->ping($Host)) {

        print $Host." reachable\n";

        }
else {
        print  $Host." unreachable\n";

}
$p->close();
}

$sth->finish();
$dbh->disconnect();

regards.[/code]

Posted: Wed Apr 14, 2010 12:30 am
by DREMA
Thanks! Very useful to me.

You could modify it a little to show the monitor names.