Note
Utilisation de INET_ATON de MySQL pour trier sur les IP
-
#!/usr/bin/perl -w
-
use strict;
-
use warnings;
-
use DBI;
-
#Connection à la base de donnes OCS
-
my $dns = ‘dbi:mysql:ocsweb:localhost’;
-
my $login = ‘root’;
-
my $passwd = ‘secret’;
-
# Recuperation des IP et des MAC des postes SANS “Anti-virus”
-
my $query = “SELECT DISTINCT hard.NAME, net.IPADDRESS, net.MACADDR “.
-
“FROM softwares AS soft, hardware AS hard, networks AS net “.
-
“WHERE hard.ID = soft.HARDWARE_ID “.
-
“AND hard.ID = net.HARDWARE_ID “.
-
“AND net.STATUS = ‘up’ “.
-
“AND soft.name NOT LIKE ‘%anti-virus%’ “.
-
“ORDER BY INET_ATON(net.IPADDRESS) “;
-
#$result->dump_results();
-
while ( my ($name, $ip, $mac) = $result->fetchrow_array()){
-
print “$name, \t$ip, \t$mac\n“;
-
}
-
$result->finish();
-
$dbh->disconnect();