Exemple #1
0
static SaErrorT get_thresholds(ipmi_sensor_t	*sensor,
			       struct ohoi_sensor_thresholds	*thres_data)
{
	int		rv;

	rv = ipmi_sensor_get_thresholds(sensor, thresholds_read, thres_data);
	if (rv) 
		dbg("Unable to get sensor thresholds: 0x%x\n", rv);
	return (rv? SA_ERR_HPI_INVALID_CMD : SA_OK);
}
Exemple #2
0
static void
sensor_get_thresholds(ipmi_sensor_t *sensor, void *cb_data)
{
    ipmi_cmd_info_t    *cmd_info = cb_data;
    ipmi_cmdlang_t     *cmdlang = ipmi_cmdinfo_get_cmdlang(cmd_info);
    int                rv;

    ipmi_cmdlang_cmd_info_get(cmd_info);
    rv = ipmi_sensor_get_thresholds(sensor, sensor_get_thresholds_done,
				    cmd_info);
    if (rv) {
	ipmi_cmdlang_cmd_info_put(cmd_info);
	cmdlang->err = rv;
	cmdlang->errstr = "Error getting thresholds";
	ipmi_sensor_get_name(sensor, cmdlang->objstr,
			     cmdlang->objstr_len);
	cmdlang->location = "cmd_sensor.c(sensor_get_thresholds)";
    }
}
Exemple #3
0
/* Whenever the status of a sensor changes, the function is called
   We display the information of the sensor if we find a new sensor */
static void
sensor_change(enum ipmi_update_e op,
	      ipmi_entity_t      *ent,
	      ipmi_sensor_t      *sensor,
	      void               *cb_data)
{
    sdata_t *sdata;
    int     rv;

    if (op == IPMI_ADDED) {
	sdata = alloc_sdata(sensor);
	if (!sdata) {
	    printf("Unable to allocate sensor name memory\n");
	    return;
	}

	printf("Sensor added: %s\n", sdata->name);

	/* Get the current reading. */
	if (ipmi_sensor_get_event_reading_type(sensor)
	    == IPMI_EVENT_READING_TYPE_THRESHOLD)
	{
	    use_sdata(sdata);
	    rv = ipmi_sensor_get_reading(sensor, got_thresh_reading, sdata);
	    if (rv) {
		printf("ipmi_reading_get returned error 0x%x for sensor %s\n",
		       rv, sdata->name);
		release_sdata(sdata);
	    }
	} else {
	    use_sdata(sdata);
	    rv = ipmi_sensor_get_states(sensor, got_discrete_states, sdata);
	    if (rv) {
		printf("ipmi_states_get returned error 0x%x for sensor %s\n",
		       rv, sdata->name);
		release_sdata(sdata);
	    }
	}

	/* Set up events. */
	sdata->state_sup = ipmi_sensor_get_event_support(sensor);
	switch (sdata->state_sup)
	{
	    case IPMI_EVENT_SUPPORT_NONE:
	    case IPMI_EVENT_SUPPORT_GLOBAL_ENABLE:
		/* No events to set up. */
		printf("Sensor %s has no event support\n", sdata->name);
		goto get_thresh;
	}

	use_sdata(sdata);
	rv = ipmi_sensor_get_event_enables(sensor, got_events, sdata);
	if (rv) {
	    printf("ipmi_sensor_events_enable_get returned error 0x%x"
		   " for sensor %s\n",
		   rv, sdata->name);
	    release_sdata(sdata);
	}

    get_thresh:
	/* Handle the threshold settings. */

	if (ipmi_sensor_get_event_reading_type(sensor)
	    != IPMI_EVENT_READING_TYPE_THRESHOLD)
	    /* Thresholds only for threshold sensors (duh) */
	    goto out;

	sdata->thresh_sup = ipmi_sensor_get_threshold_access(sensor);

	switch (sdata->thresh_sup)
	{
	case IPMI_THRESHOLD_ACCESS_SUPPORT_NONE:
	    printf("Sensor %s has no threshold support\n", sdata->name);
	    goto out;

	case IPMI_THRESHOLD_ACCESS_SUPPORT_FIXED:
	    printf("Sensor %s has fixed threshold support\n", sdata->name);
	    goto out;
	}

	use_sdata(sdata);
	rv = ipmi_sensor_get_thresholds(sensor, got_thresholds, sdata);
	if (rv) {
	    printf("ipmi_thresholds_get returned error 0x%x"
		   " for sensor %s\n",
		   rv, sdata->name);
	    release_sdata(sdata);
	}
    } else if (op == IPMI_DELETED) {
	sdata = find_sdata(sensor);
	if (!sdata) {
	    char name[120];
	    ipmi_sensor_get_name(sensor, name, sizeof(name));

	    printf("sensor %s was deleted but not found in the sensor db\n",
		   name);
	    goto out;
	}

	printf("sensor %s was deleted\n", sdata->name);
	release_sdata(sdata);
    }

 out:
    return;
}