Here a pinging scanner for ZM ip cameras.

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
johnnytolengo
Posts: 184
Joined: Tue Oct 14, 2008 5:59 pm

Here a pinging scanner for ZM ip cameras.

Post 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]
DREMA
Posts: 162
Joined: Fri Dec 12, 2008 2:39 am
Location: México

Post by DREMA »

Thanks! Very useful to me.

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