/**
 * scan a subnet using fing
 */
function get_fing_scan($ip, $mask)
{
    global $FING_ssh_binary;
    if (!$FING_ssh_binary) {
        throw new FingException("\$FING_ssh_binary is not defined in secret.php");
    }
    $settings = get_fing_settings($ip, $mask);
    $fing_gw = $settings["gateway"];
    $user = $settings["user"];
    $sudo = $settings["gateway"] ? "sudo" : "";
    $id_file = $settings["id_file"];
    $cmd = "{$FING_ssh_binary} {$user}@{$fing_gw} -v -i {$id_file} -o 'PasswordAuthentication no' {$sudo}  fing -r 1 -n {$ip}/{$mask} -o table,csv,console --silent";
    $ret_val = my_shell_exec("{$cmd}", $std_out, $std_err);
    if ($ret_val > 0) {
        throw new FingException("Error executing fing:<br><pre>Command: {$cmd}\n\n exit code: {$ret_val}\n\n STDERR: {$std_err}\n\n STDOUT: {$std_out}\n</pre>");
    }
    $known_ips = parse_fing_csv($std_out);
    return $known_ips;
}
Beispiel #2
0
 function send_dnsserver_files($server)
 {
     # if remote machine is not yours, then, additional security should be taken here. **
     print __FUNCTION__ . ": basliyor \n";
     print_r($server);
     if (is_array($serverip)) {
         $serverip = $serverip['ip'];
     }
     # accept both until all code is standard.
     if (trim($serverip) == '') {
         $serverip = 'localhost';
     }
     if ($serverip != 'localhost') {
         my_shell_exec("rsync -arvz {$this->ehcpdir}/serverfiles/{$serverip}/named/* {$serverip}:/etc/bind/", __FUNCTION__);
     }
     # for local server, files are directly written to normal destination, no need to send.
 }