Example #1
0
 function nagios_check()
 {
     $conn =& $this->conn;
     $sql = "desc host_services;";
     $res = $conn->Execute($sql);
     $sql = "show columns from host_services where Field like 'nagios';";
     $res = $conn->Execute($sql);
     if ($res->EOF) {
         echo "Creating nagios flag for host_services<br>";
         $sql = "ALTER TABLE `host_services` ADD COLUMN `nagios` boolean  NOT NULL DEFAULT 1 AFTER `anom`;";
         $res = $conn->Execute($sql);
         if (!$res) {
             echo "Nagios flag was NOT created!";
             return true;
         }
     } else {
         echo "Nagios flag already created.. ok<br>";
     }
     // Create configurations for the old hosts that have nagios enabled
     $sql = "select h.ip, h.hostname from host h, host_scan hs where hs.plugin_id=2007 and hs.host_ip=inet_aton(h.ip);";
     $res = $conn->Execute($sql);
     if (!$res->EOF) {
         echo "Creating nagios host definitions<br>";
         while (!$res->EOF) {
             $host_ip = $res->fields["ip"];
             $hostname = $res->fields["hostname"];
             echo "Checking nagios config for {$hostname} ({$host_ip})<br>";
             $sensors = "";
             $q = new NagiosAdm();
             $q->addHost(new NagiosHost($host_ip, $hostname, $sensors));
             $q->close();
             $res->MoveNext();
         }
         echo "Done!<br>";
     } else {
         echo "The creation of nagios host definition is not needed right now<br>";
     }
     return true;
 }
Example #2
0
            }
            if ($flag == false) {
                if (Host_group_scan::can_delete_host_from_nagios($conn, $host, $hgname)) {
                    $q = new NagiosAdm();
                    $q->delHost(new NagiosHost($host, $host, ""));
                    $q->close();
                }
            }
        }
    }
    if ($nagios) {
        if (Host_group_scan::in_host_group_scan($conn, $hgname, 2007)) {
            Host_group_scan::delete($conn, $hgname, 2007);
        }
        Host_group_scan::insert($conn, $hgname, 2007);
        $q = new NagiosAdm();
        $q->addNagiosHostGroup(new NagiosHostGroup($hgname, $hosts, $sensors), $conn);
        $q->close();
    } else {
        if (Host_group_scan::in_host_group_scan($conn, $hgname, 2007)) {
            Host_group_scan::delete($conn, $hgname, 2007);
        }
    }
    Host_group::update($conn, $hgname, $threshold_c, $threshold_a, $rrd_profile, $sensors, $hosts, $descr);
    $db->close($conn);
    Util::clean_json_cache_files("(policy|vulnmeter|hostgroup)");
}
if (isset($_SESSION['_hostgroup'])) {
    unset($_SESSION['_hostgroup']);
}
if ($_SESSION["menu_sopc"] == "Host groups" && POST('withoutmenu') != "1") {
Example #3
0
require_once 'classes/Host_group.inc';
require_once 'classes/Host_group_scan.inc';
require_once 'classes/Host_group_reference.inc';
$db = new ossim_db();
$conn = $db->connect();
$hosts_list = Host_group_reference::get_list($conn, $name, "2007");
$i = 0;
if (Host_group::can_delete($conn, $name)) {
    $hostip = array();
    foreach ($hosts_list as $host) {
        $hostip[$i++] = $host->get_host_ip();
    }
    foreach ($hostip as $host) {
        if (Host_group_scan::can_delete_host_from_nagios($conn, $host, $name)) {
            require_once 'classes/NagiosConfigs.inc';
            $q = new NagiosAdm();
            $q->delHost(new NagiosHost($host, $host, ""));
            $q->close();
        }
    }
    if (Host_group_scan::in_host_group_scan($conn, $name, 2007)) {
        Host_group_scan::delete($conn, $name, 2007);
    }
    // get list host and Delete
    if ($type == 'groupAndHosts') {
        require_once 'classes/Host_scan.inc';
        $host_list = Host_group::get_hosts($conn, $name);
        foreach ($host_list as $host) {
            $ip = $host->get_host_ip();
            if (Host::can_delete($conn, $ip)) {
                if (Host_scan::in_host_scan($conn, $ip, 2007)) {
Example #4
0
                    $q = new NagiosAdm();
                    $q->delHost(new NagiosHost($h, $h, ""));
                    $q->close();
                }
            }
            Host_group_scan::delete($conn, $host_group_name, 2007);
        }
    }
    if ($nagios_action == "enable") {
        if (Host_group_scan::in_host_group_scan($conn, $host_group_name, 2007)) {
            Host_group_scan::delete($conn, $host_group_name, 2007);
        }
        Host_group_scan::insert($conn, $host_group_name, 2007);
        require_once 'classes/NagiosConfigs.inc';
        $q->addNagiosHostGroup(new NagiosHostGroup($host_group_name, $hosts, $sensors), $conn);
        $q = new NagiosAdm();
        $q->close();
    }
}
if (empty($order)) {
    $order = "name";
}
$start = ($page - 1) * $rp;
$limit = "LIMIT {$start}, {$rp}";
$xml = "";
$where = "";
if ($field == "name") {
    $where = " AND g.name like '%{$search}%'";
} else {
    if ($field == "ip") {
        $where = " AND r.host_ip like '%{$search}%'";