function plugin_activity($conn, $data)
{
    $asset_id = $data['asset'];
    ossim_valid($asset_id, OSS_HEX, 'illegal:' . _("ASSET"));
    check_ossim_error();
    $active_plugin = array();
    $total_plugins = 0;
    try {
        $sensors = Asset_host_sensors::get_sensors_by_id($conn, $asset_id);
        $client = new Alienvault_client();
        foreach ($sensors as $sensor_id => $s_data) {
            $plugins = $client->sensor(Util::uuid_format($sensor_id))->get_plugins_by_assets();
            $plugins = @json_decode($plugins, TRUE);
            if ($plugins['status'] == 'success') {
                if (array_key_exists($asset_id, $plugins['data']['plugins'])) {
                    $plugins = $plugins['data']['plugins'][$asset_id];
                    foreach ($plugins as $pdata) {
                        $active = Asset_host_devices::check_device_connectivity($conn, $asset_id, $pdata['plugin_id'], $sensor_id, TRUE);
                        if ($active) {
                            $row_id = md5($asset_id . $pdata['cpe'] . $sensor_id);
                            $active_plugin[$row_id] = TRUE;
                        }
                        $total_plugins++;
                    }
                }
            }
        }
    } catch (Exception $e) {
        //nothing here
    }
    $response['error'] = FALSE;
    $response['data']['plugins'] = $active_plugin;
    $response['data']['total_p'] = $total_plugins;
    return $response;
}
function net_devices_activity($conn)
{
    $response = array();
    $wizard = Welcome_wizard::get_instance();
    if ($wizard === FALSE) {
        throw new Exception(_("There was an error, the Welcome_wizard object doesn't exist. Try again later"));
    }
    $plugins = array();
    $flag_end = FALSE;
    $task_id = $wizard->get_step_data('task_id');
    if ($task_id == 'ffffffff-ffff-ffff-ffff-ffffffffffff') {
        $status = 1;
    } else {
        $status = Welcome_wizard::current_jobs($task_id);
        $status = in_array($status['job_status'], array('task-failed', 'task-succeeded', 'task-revoked')) ? 1 : 0;
    }
    if ($status == 1) {
        $devices = Plugin::get_plugins_by_assets();
        foreach ($devices as $h_id => $p_data) {
            $h_id = Util::uuid_format_nc($h_id);
            $p_data = is_array($p_data) ? $p_data : array();
            foreach ($p_data as $pkey => $pdata) {
                $active = Asset_host_devices::check_device_connectivity($conn, $h_id, $pdata['plugin_id'], '', TRUE);
                $plugins[$h_id][$pkey] = $active;
                if ($flag_end) {
                    $flag_end = TRUE;
                }
            }
        }
    }
    $wizard->set_step_data('net_devices_data', $flag_end);
    $wizard->save_status();
    $response['error'] = FALSE;
    $response['data']['plugins'] = $plugins;
    $response['data']['status'] = $status;
    return $response;
}