Beispiel #1
0
/*
 * Helper function to inject/clear a particular artificial temperature into the part
 */
int inject_temperature_error(NVM_UINT32 device_handle, NVM_UINT64 temperature,
	NVM_BOOL enable_injection)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_SUCCESS;

	// Set up input
	struct pt_payload_temp_err temp_err_input;
	memset(&temp_err_input, 0, sizeof (temp_err_input));
	temp_err_input.enable = enable_injection;
	temp_err_input.temperature = fw_convert_float_to_fw_celsius(
		nvm_decode_temperature(temperature));

	struct fw_cmd cmd;
	memset(&cmd, 0, sizeof (cmd));
	cmd.device_handle = device_handle;
	cmd.opcode = PT_INJECT_ERROR;
	cmd.sub_opcode = SUBOP_ERROR_TEMP;
	cmd.input_payload = &temp_err_input;
	cmd.input_payload_size = sizeof (temp_err_input);
	rc = ioctl_passthrough_cmd(&cmd);
	if (rc != NVM_SUCCESS)
	{
		COMMON_LOG_ERROR_F("Failed to set temperature on dimm %u",
			device_handle);
	}

	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}
Beispiel #2
0
/*
 * Check for device media temperature changes
 */
void monitor::EventMonitor::monitorDimmControllerTemperature(const std::string &uidStr,
		const struct device_discovery &discovery,
		struct db_dimm_state &storedState,
		bool &storedStateChanged,
		struct sensor &sensor)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);

	// temp has changed state
	if (sensor.current_state != storedState.controllertemperature_state)
	{
		// log an event
		enum event_code_health code = EVENT_CODE_HEALTH_CONTROLLER_TEMPERATURE_UNDER_THRESHOLD;
		enum event_severity severity = EVENT_SEVERITY_INFO;
		bool actionRequired = false;
		if (sensor.current_state == SENSOR_CRITICAL)
		{
			code = EVENT_CODE_HEALTH_CONTROLLER_TEMPERATURE_OVER_THRESHOLD;
			severity = EVENT_SEVERITY_WARN;
			actionRequired = true;
		}
		// auto-acknowledge any existing temperature over threshold events
		else if (sensor.current_state == SENSOR_NORMAL)
		{
			acknowledgeEvent(EVENT_CODE_HEALTH_CONTROLLER_TEMPERATURE_OVER_THRESHOLD, discovery.uid);
		}

		std::stringstream threshold, temperature;
		temperature << nvm_decode_temperature(sensor.reading);
		threshold << nvm_decode_temperature(sensor.settings.upper_critical_threshold);
		store_event_by_parts(EVENT_TYPE_HEALTH,
				severity,
				code,
				discovery.uid,
				actionRequired,
				uidStr.c_str(),
				temperature.str().c_str(),
				threshold.str().c_str(),
				DIAGNOSTIC_RESULT_UNKNOWN);

		// update stored state
		storedStateChanged = true;
		storedState.controllertemperature_state = sensor.current_state;
	}
}
/*
 * Retrieve a specific instance given an object path
 */
wbem::framework::Instance* wbem::support::NVDIMMSensorViewFactory::getInstance(
		framework::ObjectPath &path, framework::attribute_names_t &attributes)
		throw (wbem::framework::Exception)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);

	framework::Instance *pInstance = new framework::Instance(path);

	try
	{
		// Get the sensorViewAttributes
		checkAttributes(attributes);

		framework::Attribute attribute = path.getKeyValue(DEVICEID_KEY);

		std::string guidStr;
		enum sensor_type type;
		if(!NVDIMMSensorFactory::splitDeviceIdAttribute(attribute, guidStr, (int &)type))
		{
			throw framework::ExceptionBadParameter(DEVICEID_KEY.c_str());
		}

		NVM_GUID guid;
		str_to_guid(guidStr.c_str(), guid);

		struct sensor sensor;
		int rc = NVM_SUCCESS;
		if ((rc = nvm_get_sensor(guid, type, &sensor)) != NVM_SUCCESS)
		{
			throw exception::NvmExceptionLibError(rc);
		}

		// DimmID = handle or guid depending on user selection
		if (containsAttribute(DIMMID_KEY, attributes))
		{
				framework::Attribute attrDimmId = physical_asset::NVDIMMFactory::guidToDimmIdAttribute(guidStr);
				pInstance->setAttribute(DIMMID_KEY, attrDimmId, attributes);
		}
		// DimmGUID
		if (containsAttribute(DIMMGUID_KEY, attributes))
		{
			framework::Attribute attrDimmHandle(guidStr, false);
			pInstance->setAttribute(DIMMGUID_KEY, attrDimmHandle, attributes);
		}
		// DimmHandle = NFIT Handle
		if (containsAttribute(DIMMHANDLE_KEY, attributes))
		{
			NVM_UINT32 handle;
			physical_asset::NVDIMMFactory::guidToHandle(guidStr, handle);
			framework::Attribute attrDimmHandle(handle, false);
			pInstance->setAttribute(DIMMHANDLE_KEY, attrDimmHandle, attributes);
		}
		if (containsAttribute(TYPE_KEY, attributes))
		{
			framework::Attribute a(getSensorNameStr(type), false);
			pInstance->setAttribute(TYPE_KEY, a, attributes);
		}
		if (containsAttribute(CURRENTVALUE_KEY, attributes))
		{
			std::stringstream currentValue;
			if (sensor.units == UNIT_SECONDS)
			{
				// convert to HH:MM:SS, note HH can grow beyond 2 digits which is fine.
				NVM_UINT64 hours, minutes, seconds, remainder = 0;
				// 60 seconds in a minute, 60 minutes in an hour
				hours = sensor.reading / (60*60);
				remainder = sensor.reading % (60*60);
				minutes = remainder / 60;
				seconds = remainder % 60;
				currentValue << std::setfill('0') << std::setw(2) << hours << ":";
				currentValue << std::setfill('0') << std::setw(2) << minutes << ":";
				currentValue << std::setfill('0') << std::setw(2) << seconds;
			}
			else if (sensor.type == SENSOR_MEDIA_TEMPERATURE || sensor.type == SENSOR_CONTROLLER_TEMPERATURE)
			{
				float celsius = nvm_decode_temperature(sensor.reading);
				currentValue << celsius << baseUnitToString(sensor.units);
			}
			else
			{
				NVM_INT32 scaled = 0;
				NVM_INT32 scaler = 0;
				NVDIMMSensorFactory::scaleNumberBaseTen(sensor.reading, &scaled, &scaler);
				currentValue << scaled << baseUnitToString(sensor.units);
				if (scaler > 0)
				{
					currentValue << "* 10 ^" << scaler;
				}
			}

			framework::Attribute a(currentValue.str(), false);
			pInstance->setAttribute(CURRENTVALUE_KEY, a, attributes);
		}
		if (containsAttribute(ENABLEDSTATE_KEY, attributes))
		{
			std::string enabledState;
			if ((sensor.type == SENSOR_MEDIA_TEMPERATURE) || (sensor.type == SENSOR_SPARECAPACITY)
				|| (sensor.type == SENSOR_CONTROLLER_TEMPERATURE))
			{
				enabledState = getEnabledStateStr(
						sensor.settings.enabled ? SENSOR_ENABLEDSTATE_ENABLED : SENSOR_ENABLEDSTATE_DISABLED);
			}
			else
			{
				enabledState = getEnabledStateStr(SENSOR_ENABLEDSTATE_NA);
			}
			framework::Attribute a(enabledState, false);
			pInstance->setAttribute(ENABLEDSTATE_KEY, a, attributes);
		}
		if (containsAttribute(LOWERTHRESHOLDCRITICAL_KEY, attributes))
		{
			framework::Attribute a(sensor.settings.lower_critical_threshold, false);
			pInstance->setAttribute(LOWERTHRESHOLDCRITICAL_KEY, a, attributes);
		}
		if (containsAttribute(UPPERTHRESHOLDCRITICAL_KEY, attributes))
		{
			if (sensor.type == SENSOR_MEDIA_TEMPERATURE || sensor.type == SENSOR_CONTROLLER_TEMPERATURE)
			{
				float celsius = nvm_decode_temperature(sensor.settings.upper_critical_threshold);
				pInstance->setAttribute(UPPERTHRESHOLDCRITICAL_KEY,
						framework::Attribute (celsius, false),
						attributes);
			}
			else
			{
				pInstance->setAttribute(UPPERTHRESHOLDCRITICAL_KEY,
						framework::Attribute (sensor.settings.upper_critical_threshold, false),
						attributes);
			}

		}
		if (containsAttribute(CURRENTSTATE_KEY, attributes))
		{
			framework::Attribute a(NVDIMMSensorFactory::getSensorStateStr(sensor.current_state), false);
			pInstance->setAttribute(CURRENTSTATE_KEY, a, attributes);
		}
		if (containsAttribute(SUPPORTEDTHRESHOLDS_KEY, attributes))
		{
			framework::STR_LIST supportedThresholds;
			if (sensor.lower_critical_support)
			{
				supportedThresholds.push_back(getThresholdTypeStr(SENSOR_LOWER_CRITICAL_THRESHOLD));
			}
			if (sensor.upper_critical_support)
			{
				supportedThresholds.push_back(getThresholdTypeStr(SENSOR_UPPER_CRITICAL_THRESHOLD));
			}
			framework::Attribute a(supportedThresholds, false);
			pInstance->setAttribute(SUPPORTEDTHRESHOLDS_KEY, a, attributes);
		}
		if (containsAttribute(SETTABLETHRESHOLDS_KEY, attributes))
		{
			framework::STR_LIST settableThresholds;
			if (sensor.lower_critical_settable)
			{
				settableThresholds.push_back(getThresholdTypeStr(SENSOR_LOWER_CRITICAL_THRESHOLD));
			}
			if (sensor.upper_critical_settable)
			{
				settableThresholds.push_back(getThresholdTypeStr(SENSOR_UPPER_CRITICAL_THRESHOLD));
			}
			framework::Attribute a(settableThresholds, false);
			pInstance->setAttribute(SETTABLETHRESHOLDS_KEY, a, attributes);
		}
	}
	catch (framework::Exception &) // clean up and re-throw
	{
		if (pInstance != NULL)
		{
			delete pInstance;
		}
		throw;
	}

	return pInstance;
}