Esempio n. 1
0
static unsigned int new_host(void)
{
    unsigned int i;
    void        *v;

    if ((i = vec_add(host, sizeof (struct host))))
    {
        memset(host +i, 0, sizeof (struct host));
        return i;
    }

    if ((v = vec_gro(host, sizeof (struct host))))
    {
        host = (struct host *) v;
        return new_host();
    }
    return 0;
}
Esempio n. 2
0
unsigned int add_host(const char *name, int x, int y, int w, int h)
{
    unsigned int i;

    if ((i = new_host()))
    {
        host[i].flags = 0;
        host[i].n     = 0;

        /* Store the name for future host name searching. */

        strncpy(host[i].name, name, MAXNAME);

        /* The rectangle defines window size and default total display size. */

        host[i].tot_x = host[i].win_x = x;
        host[i].tot_y = host[i].win_y = y;
        host[i].tot_w = host[i].win_w = w;
        host[i].tot_h = host[i].win_h = h;
    }
    return i;
}
Esempio n. 3
0
int get_nodes_to_display(mon_disp_prop_t* display) {
    idata_t *infod_data = NULL;
    idata_entry_t *curInfoEntry = NULL;
    idata_iter_t *iter = NULL;

    mlog_bn_db("info", "Getting nodes to display\n");
    
    if (display == NULL)
        return 1;

    if (display->need_dest) {
        new_host(display, NULL);
        return 1;
    }

    // TODO : move this line out of here
    //bottom status line
    display_totals(display, display->show_status);

    if (!get_data_from_infod(display, &infod_data))
        return 0;

    display->last_host = display->info_src_host;

    // Calculating the memory size for each node and allocating memory
    if (display->raw_data == NULL) {
        allocate_display_raw_data_mem(display, infod_data->num);
    }

    //set needed info in the current_set
    set_settings(display, &current_set);

    if (!(iter = idata_iter_init(infod_data))) {
        free(infod_data);
        return 0;
    }

    // Setting the data in the raw data array (ordered as received from infod)
    // Which means ordered by IP
    int raw_index = 0;
    for (int i = 0; (curInfoEntry = idata_iter_next(iter)); i++) {
        // raw_index is advanced only if set_raw_data_item returns 1; If the node is filtered out we get 0
        if (set_raw_data_item(display, raw_index, curInfoEntry))
            raw_index++;
    }
    idata_iter_done(iter);

    display->nodes_count = raw_index;
    mlog_bn_db("info", "Data count : %d\n", display->nodes_count);

    // Sort the raw_data array by number
    qsort(display->raw_data,
            display->nodes_count,
            display->block_length,
            &compare_num);

    // Building the alive_arr
    int infodStatusItemId = dm_getIdByName("infod-status");

    for (int i = 0; i < display->nodes_count; i++) {
        void *raw_status_ptr =
                (void*) ((long) (display->raw_data) + (i * display->block_length) + get_pos(infodStatusItemId));
        int infod_status = (int) scalar_div_x(infodStatusItemId, raw_status_ptr, 1);
        display->alive_arr[i] = infod_status & INFOD_ALIVE;
    }

    free(infod_data);
    //free(temp);
    if (dbg_flg) fprintf(dbg_fp, "Data retrieved.\n");

    return 1;
}