예제 #1
0
static void
update_proc(void)
	{
	GkrellmChart	*cp;
	GkrellmPanel	*p;
	gint			load;

	if (!proc.enabled)
		return;
	(*read_proc_data)();
	if (GK.five_second_tick)
		{
		(*read_user_data)();
		gkrellm_check_alert(users_alert, proc.n_users);
		}
	cp = proc.chart;
	p = cp->panel;
	gkrellm_update_krell(p, KRELL(p), proc.n_forks);
	gkrellm_draw_panel_layers(p);

	if (GK.second_tick)
		{
		/* Scale load since it is a small real and charts are integer only.
		|  Scale the forks number by fork_scaling.  See setup_proc_scaling().
		*/
		load = (int) (LOAD_SCALING * proc.fload);
		gkrellm_store_chartdata(cp, 0, load, fork_scaling * proc.n_forks);
		refresh_proc_chart(cp);
		gkrellm_check_alert(load_alert, proc.fload);
		gkrellm_check_alert(processes_alert, proc.n_processes);
		gkrellm_panel_label_on_top_of_decals(p,
				gkrellm_alert_decal_visible(load_alert) ||
				gkrellm_alert_decal_visible(users_alert) ||
				gkrellm_alert_decal_visible(processes_alert));

		}
	if (   (GK.two_second_tick && !sensor_separate_mode)
		|| (GK.five_second_tick && sensor_separate_mode)
	   )
		draw_sensor_decals();
	}
예제 #2
0
static void
update_plugin()
{
    Reader *reader;
    gchar  *text;
    u_long val, since_last;
    gint clock_style_id;
    //  GkrellmKrell       *k;
    //  gint i;

    /* See if we recieved SNMP responses */
    simpleSNMPupdate();

    /* Send new SNMP requests */
    for (reader = readers; reader ; reader = reader->next)
    {
        //      k = KRELL(panel);
	//      k->previous = 0;

	if ( (! reader->session) && (! reader->old_error) ) {
	    reader->session = simpleSNMPopen(reader->peer,
					     reader->port,
					     reader->community,
					     reader);
	    if (! reader->session) {
		text = reader->old_error;
		reader->old_error = render_error(reader);
		g_free(text);
	    }
	}

	/* Send new SNMP requests */
	if ( (reader->session) && ((GK.timer_ticks % reader->delay) == 0))
	    simpleSNMPsend(reader->session,
			   reader->objid,
			   reader->objid_length);


	if ( (reader->session) && (reader->sample) ) {
	    if ((reader->error) && (reader->panel != NULL)) {
	        if (!reader->old_error ||
		    strcmp(reader->error,
			   reader->old_error) ) {
		    text = reader->old_error;
		    reader->old_error = g_strdup(reader->error);
		    g_free(text);
		    reader->panel->textstyle = gkrellm_panel_alt_textstyle(DEFAULT_STYLE_ID);
		    text = render_error(reader);
		    gtk_tooltips_set_tip(reader->tooltip, reader->panel->drawing_area, text, "");
		    gtk_tooltips_enable(reader->tooltip);
		    g_free(text);
		}
	    } else {
		    if ((GK.timer_ticks % reader->delay) == 0)
			    if (reader->chart != NULL)
			    {
    /* 100: turn TimeTicks into seconds */
    since_last = (reader->sample_time - reader->old_sample_time) / 100;
    
    if (reader->delta)
	val = (reader->sample_n - reader->old_sample_n) /
		( (since_last < 1) ? 1 : since_last ) /
		( (reader->divisor == 0) ? 1 : reader->divisor );
    else
	val = reader->sample_n / 
		( (reader->divisor == 0) ? 1 : reader->divisor );
		
				    gkrellm_store_chartdata(reader->chart, 0, val);
				    cb_draw_chart(reader);

				    text = render_info(reader);
				    gtk_tooltips_set_tip(reader->tooltip, reader->chart->drawing_area, text, "");
				    gtk_tooltips_enable(reader->tooltip);
				    g_free(text);

		    		    reader->old_sample_n = reader->sample_n;
				    reader->old_sample_time = reader->sample_time;
			    }

		    /* if there are changes update label */
		if (reader->panel != NULL)
		{
			reader->panel->textstyle = gkrellm_panel_textstyle(DEFAULT_STYLE_ID);
		if ( !reader->old_sample || strcmp(reader->sample,
						   reader->old_sample) ||
		     (reader->sample_n != reader->old_sample_n) ) {

		    g_free(reader->old_sample);
		    reader->old_sample = g_strdup(reader->sample);

		    text = render_label(reader);
		    gkrellm_dup_string(&reader->panel->label->string, text);
		    g_free(text);
		    //	i = atoi(text);

		    text = render_info(reader);
		    gtk_tooltips_set_tip(reader->tooltip, reader->panel->drawing_area, text, "");
		    gtk_tooltips_enable(reader->tooltip);

		    g_free(text);
		    reader->old_sample_n = reader->sample_n;
		    reader->old_sample_time = reader->sample_time;
		}
		}
	    }

	} else {
		if (reader->panel != NULL)
	    reader->panel->textstyle = gkrellm_panel_alt_textstyle(DEFAULT_STYLE_ID);
		if (reader->panel != NULL)
	    gtk_tooltips_disable(reader->tooltip);
	    //	i = -1;
	}
      
	//      gkrellm_update_krell(panel, k, i);

	clock_style_id = gkrellm_lookup_meter_style_id(CLOCK_STYLE_NAME);

		if (reader->panel != NULL)
	gkrellm_draw_panel_label( reader->panel );
				//GTK2 gkrellm_bg_panel_piximage(clock_style_id) );
		if (reader->panel != NULL)
	gkrellm_draw_panel_layers(reader->panel);
    }

}