示例#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;
 }
示例#2
0
                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") {
    ?>
	<p><?php