コード例 #1
0
function GetOssimHostsFromHostGroups($hostgroup)
{
    $db = new ossim_db();
    $conn = $db->connect();
    $pg = array();
    try {
        $asset_group = new Asset_group($hostgroup);
        $asset_group->load_from_db($conn);
        $_hosts = $asset_group->get_hosts($conn, array(), TRUE);
        $hosts = $_hosts[0];
    } catch (Exception $e) {
        echo $e->getMessage();
        return $pg;
    }
    foreach ($hosts as $hg) {
        $pg[] = $hg[2];
        //  Array ( [0] => ID [1] => CTX [2] => IP [3] => Name )
    }
    $db->close();
    return $pg;
}
コード例 #2
0
    
    <body>
    <?php 
if ($data['status'] != 'error') {
    try {
        $db = new ossim_db();
        $conn = $db->connect();
        $asset_group = new Asset_group($id);
        $asset_group->load_from_db($conn);
        $asset_group->set_name($name);
        $asset_group->set_owner($owner);
        $asset_group->set_descr($descr);
        $asset_group->set_threshold($threshold_a, 'a');
        $asset_group->set_threshold($threshold_c, 'c');
        $asset_group->save_in_db($conn);
        $_hosts_data_aux = $asset_group->get_hosts($conn, '', TRUE);
        $hosts = array_keys($_hosts_data_aux[0]);
        if (!empty($nagios)) {
            if (Asset_group_scan::is_plugin_in_group($conn, $id, 2007)) {
                Asset_group_scan::delete_plugin_from_db($conn, $id, 2007);
            }
            Asset_group_scan::save_plugin_in_db($conn, $id, 2007);
            foreach ($hosts as $host_id) {
                if (!Asset_host_scan::is_plugin_in_host($conn, $host_id, 2007)) {
                    Asset_host_scan::save_plugin_in_db($conn, $host_id, 2007);
                }
            }
        } else {
            if (Asset_group_scan::is_plugin_in_group($conn, $id, 2007)) {
                Asset_group_scan::delete_plugin_from_db($conn, $id, 2007);
            }