Unsolved
This post is more than 5 years old
2 Intern
•
138 Posts
0
1018
November 20th, 2008 21:00
APC Smart UPS 5000 model
Hello all.
I started to devel model for monitoring APC Smart UPS.
I share this because I will not continue to develop this mechanism more
THIS IS NOT COMPLETE SOLUTION
And sorry about my English,
You can change this model as you want, the principle in all UPS is same.
Comments in some parts of code.
/*
interface UPS_ThresholdSetting : ICF_ASLSetting {
refine stored Displayname = "UPS thresholds settings";
refine stored RuleSet = "";
refine stored TargetClass = "ICIM_UnitaryComputerSystem";
// Power thresholds
attribute unsigned [0 .. 100] xUpsPowerLoadHighThreshold
"Acceptable upper threshold for Load Power "
"expressed as a percentage of the total load"
= 90;
attribute unsigned [0 .. 100] xUpsPowerLoadLowThreshold
"Acceptable lower threshold for Load Power "
"expressed as a percentage of the total load"
= 10;
// Voltage thresholds
// Input Voltages
attribute unsigned [150 .. 250] xUpsInputVoltageLowThreshold
"Acceptable lower threshold for Input Voltage "
"expressed as a volts"
= 200;
attribute unsigned [150 .. 250] xUpsInputVoltageHighThreshold
"Acceptable upper threshold for Input Voltage "
"expressed as a volts"
= 230;
//OutPut Voltages
attribute unsigned [150 .. 250] xUpsOutPutVoltageLowThreshold
"Acceptable lower threshold for OutPut Voltage "
"expressed as a volts"
= 200;
attribute unsigned [150 .. 250] xUpsOutPutVoltageHighThreshold
"Acceptable upper threshold for OutPut Voltage "
"expressed as a volts"
= 230;
// UPS Status
attribute unsigned [1 .. 12] xUpsStatusThresh
"Threshold for calculate ups status"
"Ups noraml status is 2 - onLine"
= 2;
// UPS App Load Power
attribute unsigned [0 .. 100] xUpsAppLoadHighThreshold
"Acceptable upper threshold for App Load Power "
"expressed as a percentage of the total load"
= 90;
attribute unsigned [0 .. 100] xUpsAppLoadLowThreshold
"Acceptable lower threshold for App Load Power "
"expressed as a percentage of the total load"
= 10;
}
*/
/*
interface UPS_PollingSetting : ICF_PollingSetting {
refine stored DisplayName = "UPS polling Settings";
refine stored RuleSet = "";
refine stored TargetClass = "ICIM_UnitaryComputerSystem";
};
*/
interface AppProcInstrument : ICIM_Instrumentation
{
instrument SNMP {
Status = ".1.3.6.1.4.1.318.1.1.1.4.1.1",
upsBatteryStatus = ".1.3.6.1.4.1.318.1.1.1.2.1.1",
OutPutVoltage = ".1.3.6.1.4.1.318.1.1.1.4.2.1",
AppLoadPower = ".1.3.6.1.4.1.318.1.1.1.4.2.3",
LoadCurrent = ".1.3.6.1.4.1.318.1.1.1.4.2.4"
};
// Instrumented attributes
enum bat_state { UNKNOWN = 1, NORMAL, LOW };
instrumented attribute int Status
"The current state of the UPS."
" 1: unknown(1)."
" 2: onLine(2)"
" 3: onBattery(3)"
" 7: off(7)";
instrumented attribute int upsBatteryStatus
"UPS battery load";
instrumented attribute int OutPutVoltage;
instrumented attribute int LoadCurrent;
instrumented attribute int AppLoadPower;
}
interface UPS : ICIM_PhysicalElement
"Generic UPS class."
{
// General charactiristics
attribute string Model
"UPS Model";
attribute string Vendor
"UPS Vendor Name";
// Ups status
propagate attribute int prod ups_Status
"Value of ups status oid"
<= AppProcInstrument, InstrumentedBy, Status;
enum ups_state { Unknown = 1, OnLine, OnBattery };
computed attribute ups_state xUps_Status
"UPS status value"
=ups_state(ups_Status);
// event
/*
event xUpsNotOnline
"The ups seems to be OnLine"
= ups_Status != xUpsStatusThresh;
event xUpsOnBattery
"Ups on battery!!!"
= ups_Status== 3;
export xUpsNotOnline;
export xUpsOnBattery;
*/
// Ups current load
/*
propagate attribute float prod ups_LoadCurrent
"Load Current: Amps"
<= AppProcInstrument, InstrumentedBy, LoadCurrent;
//event
event xUpsCurentLoad
= ups_LoadCurrent>=10;
export xUpsCurentLoad;
*/
// Ups AppLoadPower
propagate attribute float prod ups_AppLoadPower
"Apparent Load Power %VA"
<= AppProcInstrument, InstrumentedBy, AppLoadPower;
//event
/*
event xUpsHighAppLoadPower
"Ups app load power is too high"
= ups_AppLoadPower>=xUpsAppLoadHighThreshold;
event xUpsLowAppLoadPower
"Ups app load power is too low"
= ups_AppLoadPower>=xUpsAppLoadLowThreshold;
export xUpsHighAppLoadPower;
export xUpsLowAppLoadPower;
*/
// Computed attribute, calculate per formula
//Ups Load Power
// computed attribute int prod ups_PowerLoad
//" Ups power load % Watts"
// event xUpsLoadWarn
// "Ups load warning threshold"
// = ups_LoadCurrent>= 60;
// event xUpsLoadCritical
// "Ups load critical threshold"
// = ups_LoadCurrent>= 95;
// export xUpsLoadWarn;
// export xUpsLoadCritical;
//OutPut Voltages
propagate attribute float prod ups_OutPutVoltage
"Current OutPut voltage V"
<= AppProcInstrument, InstrumentedBy, OutPutVoltage;
//event
/*
event xUpsHighOutPutVolt
"Ups output voltage is too high"
= ups_OutPutVoltage>=xUpsOutPutVoltageHighThreshold;
event xUpsLowOutPutVolt
"Ups output voltage is too low"
= ups_OutPutVoltage<=xUpsOutPutVoltageLowThreshold;
export xUpsLowOutPutVolt;
export xUpsHighOutPutVolt;
attribute string Community
"Device community string";
*/
// UPS
}
// Phase of UPS
interface UPS_Phase : ICIM_PhysicalElement
"UPS Phases"
{
stored attribute int InputVoltage
"Current Input voltage V";
stored attribute int Frequency
"Current input Frequency Hz";
// attribute string Description
// "Phase Description";
}
// UPS Battery
interface UPS_Battery : ICIM_PhysicalElement
"Battery of UPS"
{
stored attribute int BatteryTemp
"UPS battery temperature";
stored attribute int BatteryCapacity
"Battery capacity percantage";
stored attribute int ExternalBatteries
"Number of external batteries";
stored attribute int BatteriesVoltage
"Battery Voltages VDC";
//readonly attribute bat_state BatteryStatus;
propagate attribute int prod BatteryStatus
"UPS battery Status"
<= AppProcInstrument, InstrumentedBy, upsBatteryStatus;
//propagate attribute int prod Status
//"Value of ups status oid"
//<= AppProcInstrument, InstrumentedBy, upsStatus;
}
// UPS Enviroments probe sensor class
interface UPS_Env_Probe : TemperatureSensor
"UPS Enviroments probe sensor class"
{
attribute int HumLowThresh
"Humidity Low threshold";
attribute int HumHighThresh
"Humidity High threshold";
attribute int TempLowThresh
"Temperature Low threshold";
attribute int HighLowThresh
"Temperature High threshold";
stored attribute int CurrentTemp
"Current temperature";
stored attribute int CurrentHum
"Current humidity";
// relationship
//relationship PartOf, UPS, Contains;
}
2) In accessor.asl need to change device name or add getInstances from UPS class
Load accessor command sm_adapter -s accessor.asl
///////////////////////////////////////////////////////////////////////////
//
// System Management ARTS (SMARTS)
// Copyright � 2004 - All Rights Reserved
//
// DevKit
//
// ASL Adapter script for Example 3 - Dynamic Model Polling Use Case
//
///////////////////////////////////////////////////////////////////////////
/*
* Rule Set for applying Utilization Settings
*/
/*
* Initialization actions (called once only).
*/
//Debug = TRUE;
default Timeout = "700" ;
default Retries = "3";
//default Device = "192.168.82.230"; // this variable can be passed in via the sm_adapter -D option
default InstrumentationName="AppProcInstrument"; // this variable can be passed in via the sm_adapter -D option
// SNMP Polling Parameters
default ReadCommunity = "public"; // this will be ignored for SNMP v3
default WriteCommunity = "public"; // this will be ignored for SNMP v3
default AgentVersion = "V1"; // V3 Specific Polling Parameters
default EngineID = ""; // Can be left blank
default EngineBoots = 0; // Leave as 0
default EngineBootTime = 0; // Leave as 0
default UserName = ""; // If authentication enabled, set to a valid user name
default AuthProtocol=""; //To enable authentication, set to "MD5" or "SHA"
default AuthPassword = ""; //If authentication enabled, set to the user's password
default Context = ""; // Can be left blank
default PollingInterval =30;
default index="";
poller = object(getInstances("SNMP_AccessorInterface")[0]);
START() {
eol
}
do
{
// Convert the time to milli-seconds
Timeout = numeric(Timeout) / 1000;
// Validate all inputs.
//
// ASSUMPTION: before running this script, the device has already been created by the discovery process
//Here we just need a reference handle to the device represented by deviceHandle
appObject = object("UPS", "UPS-192.168.82.230");
print("Application object is ".appObject);
if (!appObject->isNull())
{
print("app is PartOf ".appObject->PartOf);
hostObject = object("Host", "192.168.82.230");
print("HostObject is ".hostObject);
print("Host name is ". hostObject->DisplayName);
SNMPAddress = hostObject->SNMPAddress;
print("SNMPAddress is : ".SNMPAddress);
//For this particulat
deviceInstrumentation = appObject->makeInstrumentation(InstrumentationName);
// deviceHandle->makeInstrumentation(InstrumentationName);
print("Instrumentation: ".InstrumentationName);
ReservedForFutureUse = "";
poller->instance_instrumentations +=
list(deviceInstrumentation->Name,
SNMPAddress,
index,
ReadCommunity,
WriteCommunity,
EngineID,
EngineBoots,
EngineBootTime,
UserName,
AuthProtocol,
ReservedForFutureUse,
AuthPassword,
ReservedForFutureUse,
Context,
AgentVersion) ? LOG,FAIL;
poller->polling_parameters +=
list(deviceInstrumentation->Name,
numeric(PollingInterval),
-1,
numeric(Timeout),
numeric(Retries),
TRUE) ? LOG, NEXT; //change -1 to TRUE for SNMP trace logging
print("Completed adding instance to accesor");
}
stop();
}
DEFAULT {
line:{..eol}
}
do {
print("Bad input: ".line." Format is ' '");
}
3) This is Discovery Script.
//ic-apc-ups-battery.asl
default AgentName = "";
// Changed by Skribnik evgeniy for debug
//Write to external log file apc.txt
myFile = create("ACT_File", this->Name."_File");
myFile->fileName = "apc.txt";
myFile->write("Start APC UPS process\n");
blanks = " ";
agentObj = object(AgentName);
upsTable = table();
nodeObj = agentObj->getSystem();
if (nodeObj->isNull()) {
print(me.": Can't find node object for ".agentObj->DisplayName);
stop();
}
me = this->ReadsRulesFrom->fileName;
factory = object(getInstances("ICIM_ObjectFactory")[0]);
topo_manager = object(getInstances("ICF_TopologyManager")[0]);
// create UPS class
upsObj = create("UPS", "UPS-".nodeObj->DisplayName);
if (upsObj->isNull()) {
stop();
}
upsObj->Model = nodeObj->Model;
upsObj->Vendor = nodeObj->Vendor;
upsObj->Location = nodeObj->Location;
upsObj->Community = nodeObj->ReadCommunity;
upsObj->PartOf += nodeObj;
//DEBUG = topo_manager->DebugEnabled;
DEBUG = TRUE;
dispName = nodeObj->DisplayName;
historyTable = table();
//tmpObj = getInstances("UPS_Battery");
// Rewrite getInstances function with new own operation, getUpsBattery
// Battery
foreach battery (getInstances("UPS_Battery")) {
batObj = object("UPS_Battery", battery);
if (DEBUG) {
myFile->write("Battery History table: ".battery."\n");
myFile->write("History object for repo:".batObj."\n");
}
historyTable[batObj->Name] = battery;
}
//Phases
foreach phase (getInstances("UPS_Phase")) {
phaseObj = object("UPS_Phase", phase);
if (DEBUG) {
myFile->write("UPS_Phase History table: ".phase."\n");
myFile->write("History object for repo:".phaseObj."\n");
}
historyTable[phaseObj->Name] = phase;
}
foreach probe (getInstances("UPS_Env_Probe")) {
probeObj = object("UPS_Env_Probe", probe);
if (DEBUG) {
myFile->write("UPS_Env_Probe History table: ".probe."\n");
myFile->write("History object for repo:".probeObj."\n");
}
historyTable[probeObj->Name] = probe;
}
/*
* No word delimiter
*/
delim = "";
/*
* Convenience rules for matching OID pieces
*/
upsBatteryNumOID {".1.3.6.1.4.1.318.1.1.1.2.2.5"}
upsBasicInputPhaseOID {".1.3.6.1.4.1.318.1.1.1.3.1.1"}
emStatusProbeNumberOID {".1.3.6.1.4.1.318.1.1.10.2.3.1"}
emStatusProbeStatusOID {".1.3.6.1.4.1.318.1.1.10.2.3.2.1.3"}
//emStatusProbeCurrenTempOID {".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4"}
//emStatusProbeCurrentHumOID {".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6"}
/*
{5, ".1.3.6.1.4.1.318.1.1.1.2.2.5"}, # upsAdvBatteryNumOfBattPacks
{10, ".1.3.6.1.4.1.318.1.1.1.2.2.2" }, # upsAdvBatteryTemperature
{20, ".1.3.6.1.4.1.318.1.1.1.2.2.8" }, # upsAdvBatteryActualVoltage V
{30, ".1.3.6.1.4.1.318.1.1.1.2.2.9" }, # upsAdvBatteryCurrent Amps
{40, ".1.3.6.1.4.1.318.1.1.1.2.1.1" }, # upsAdvTotalDCCurrent
{ 60, ".1.3.6.1.4.1.318.1.1.1.3.1.1" } # upsBasicInputPhase
{ 30, ".1.3.6.1.4.1.318.1.1.10.2.3.1" } # emStatusProbeNumber
{ 40, ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.3" } # emStatusProbeStatus
{ 50, ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4" } # emStatusProbeCurrenTemp
{ 60, ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6" } # emStatusProbeCurrentHum
/*****************************************************************************/
START {
CONT | eol
}
EOF do {
if (feError() == FALSE) {
myFile->write("Insert to EOF rule\n");
myFile->write(feErrorMsg()."\n");
foreach name (historyTable) {
obj = historyTable[name];
topo_manager->log("DSCV_DELETE_COMPONENT",
obj->DisplayName,
nodeObj->Name,
nodeObj->Name);
obj->remove();
}
}
}
DEFAULT {
data:{ .. eol }
} do {
if (DEBUG) {
myFile->write("DSCV_PROBE_FAILED - APC UPS". dispName."\n");
myFile->write(data."\n");
myFile->write(feErrorMsg()."\n");
topo_manager->log("DSCV_PROBE_FAILED", "APC UPS", dispName);
print(data);
}
}
CONT {
ENTITY_BATTERY | ENTITY_PHASE | ENTITY_PROBE
}
ENTITY_BATTERY {
local batIndex;
local oid;
oid:upsBatteryNumOID "." key:word fs
batIndex:word fs
do {
if (DEBUG) {
myFile->write("parser result is ".batIndex."\n");
myFile->write(me.":Battery: ".nodeObj->DisplayName."\n");
myFile->write(" ".oid."[".batIndex."] = ".
"Battery-".batIndex."\n");
}
if (sizeof(batIndex) > 0) {
// Create Battery object
batObj = create("UPS_Battery", "BATTERY-".batIndex."-".nodeObj->DisplayName);
if (batObj->isNull()) {
stop();
}
batObj->Description = "Battery ".batIndex;
batObj->PartOf += upsObj;
undef(historyTable[batObj->Name])?IGNORE;
//Relation to UPS Class
if (DEBUG) {
myFile->write("Creating battery\n");
}
}
}
}
ENTITY_PHASE {
local phaseIndex;
local oid;
oid:upsBasicInputPhaseOID "." key:word fs
phaseIndex:word fs
do {
if (DEBUG) {
myFile->write("parser result is ".phaseIndex."\n");
myFile->write(me.":Phase: ".nodeObj->DisplayName."\n");
myFile->write(" ".oid."[".phaseIndex."] = ".
"Battery-".phaseIndex."\n");
}
if (sizeof(phaseIndex) > 0) {
// Create Battery object
pObj = create("UPS_Phase", "PHASE-".phaseIndex."-".nodeObj->DisplayName);
if (pObj->isNull()) {
stop();
}
pObj->Description = "Phase ".phaseIndex;
undef(historyTable[pObj->Name])?IGNORE;
//put relation object to APC_UPS Class
pObj->PartOf += upsObj;
if (DEBUG) {
myFile->write("Creating Phase\n");
}
}
}
}
ENTITY_PROBE {
ENTITY_PROBE_NUMBER | ENTITY_PROBE_STATUS
}
ENTITY_PROBE_NUMBER {
local probeIndex;
local probeOid;
local statusValue;
local tempVal;
local tempOid;
local humOid;
local humVal;
probeOid:emStatusProbeNumberOID "." key:word fs
probeIndex:word fs
do {
if (DEBUG) {
myFile->write("Number of probes : ".probeIndex."\n");
myFile->write(me.":Probe: ".nodeObj->DisplayName."\n");
myFile->write(" ".probeOid."[".probeIndex."] = ".
"Probe-".probeIndex."\n");
myFile->write("Number probe Key is: ".probeIndex."\n");
}
upsTable[probeIndex] = "";
}
}
ENTITY_PROBE_STATUS {
local statusOid;
local statusValue;
statusOid:emStatusProbeStatusOID "." key:word fs
statusValue:word fs
do {
upsTable[key] = statusValue;
if (DEBUG) {
myFile->write("Probe status is: ".statusValue."\n");
myFile->write("Status probe Key is: ".key."\n");
myFile->write("ups table is: ".upsTable[key]."\n");
}
myFile->write("Table: ".upsTable."\n");
if ((defined(upsTable[key]) && (upsTable[key] != 1))) {
probeObj = create("UPS_Env_Probe", "PROBE-".nodeObj->DisplayName);
if (probeObj->isNull()) {
stop();
}
probeObj->Description = "UPS Enviroments Probe";
undef(historyTable[probeObj->Name])?IGNORE;
// Relation to UPS class
probeObj->PartOf += upsObj;
if (DEBUG) {
myFile->write("Creating Probe ".nodeObj->DisplayName."\n");
}
}
else {
if (DEBUG) {
myFile->write("Probe not connected - ".nodeObj->DisplayName."\n");
}
}
}
}
/*
* Local Variables:
* mode: C++
* End:
*/
I started to devel model for monitoring APC Smart UPS.
I share this because I will not continue to develop this mechanism more
THIS IS NOT COMPLETE SOLUTION
And sorry about my English,
You can change this model as you want, the principle in all UPS is same.
Comments in some parts of code.
/*
interface UPS_ThresholdSetting : ICF_ASLSetting {
refine stored Displayname = "UPS thresholds settings";
refine stored RuleSet = "";
refine stored TargetClass = "ICIM_UnitaryComputerSystem";
// Power thresholds
attribute unsigned [0 .. 100] xUpsPowerLoadHighThreshold
"Acceptable upper threshold for Load Power "
"expressed as a percentage of the total load"
= 90;
attribute unsigned [0 .. 100] xUpsPowerLoadLowThreshold
"Acceptable lower threshold for Load Power "
"expressed as a percentage of the total load"
= 10;
// Voltage thresholds
// Input Voltages
attribute unsigned [150 .. 250] xUpsInputVoltageLowThreshold
"Acceptable lower threshold for Input Voltage "
"expressed as a volts"
= 200;
attribute unsigned [150 .. 250] xUpsInputVoltageHighThreshold
"Acceptable upper threshold for Input Voltage "
"expressed as a volts"
= 230;
//OutPut Voltages
attribute unsigned [150 .. 250] xUpsOutPutVoltageLowThreshold
"Acceptable lower threshold for OutPut Voltage "
"expressed as a volts"
= 200;
attribute unsigned [150 .. 250] xUpsOutPutVoltageHighThreshold
"Acceptable upper threshold for OutPut Voltage "
"expressed as a volts"
= 230;
// UPS Status
attribute unsigned [1 .. 12] xUpsStatusThresh
"Threshold for calculate ups status"
"Ups noraml status is 2 - onLine"
= 2;
// UPS App Load Power
attribute unsigned [0 .. 100] xUpsAppLoadHighThreshold
"Acceptable upper threshold for App Load Power "
"expressed as a percentage of the total load"
= 90;
attribute unsigned [0 .. 100] xUpsAppLoadLowThreshold
"Acceptable lower threshold for App Load Power "
"expressed as a percentage of the total load"
= 10;
}
*/
/*
interface UPS_PollingSetting : ICF_PollingSetting {
refine stored DisplayName = "UPS polling Settings";
refine stored RuleSet = "";
refine stored TargetClass = "ICIM_UnitaryComputerSystem";
};
*/
interface AppProcInstrument : ICIM_Instrumentation
{
instrument SNMP {
Status = ".1.3.6.1.4.1.318.1.1.1.4.1.1",
upsBatteryStatus = ".1.3.6.1.4.1.318.1.1.1.2.1.1",
OutPutVoltage = ".1.3.6.1.4.1.318.1.1.1.4.2.1",
AppLoadPower = ".1.3.6.1.4.1.318.1.1.1.4.2.3",
LoadCurrent = ".1.3.6.1.4.1.318.1.1.1.4.2.4"
};
// Instrumented attributes
enum bat_state { UNKNOWN = 1, NORMAL, LOW };
instrumented attribute int Status
"The current state of the UPS."
" 1: unknown(1)."
" 2: onLine(2)"
" 3: onBattery(3)"
" 7: off(7)";
instrumented attribute int upsBatteryStatus
"UPS battery load";
instrumented attribute int OutPutVoltage;
instrumented attribute int LoadCurrent;
instrumented attribute int AppLoadPower;
}
interface UPS : ICIM_PhysicalElement
"Generic UPS class."
{
// General charactiristics
attribute string Model
"UPS Model";
attribute string Vendor
"UPS Vendor Name";
// Ups status
propagate attribute int prod ups_Status
"Value of ups status oid"
<= AppProcInstrument, InstrumentedBy, Status;
enum ups_state { Unknown = 1, OnLine, OnBattery };
computed attribute ups_state xUps_Status
"UPS status value"
=ups_state(ups_Status);
// event
/*
event xUpsNotOnline
"The ups seems to be OnLine"
= ups_Status != xUpsStatusThresh;
event xUpsOnBattery
"Ups on battery!!!"
= ups_Status== 3;
export xUpsNotOnline;
export xUpsOnBattery;
*/
// Ups current load
/*
propagate attribute float prod ups_LoadCurrent
"Load Current: Amps"
<= AppProcInstrument, InstrumentedBy, LoadCurrent;
//event
event xUpsCurentLoad
= ups_LoadCurrent>=10;
export xUpsCurentLoad;
*/
// Ups AppLoadPower
propagate attribute float prod ups_AppLoadPower
"Apparent Load Power %VA"
<= AppProcInstrument, InstrumentedBy, AppLoadPower;
//event
/*
event xUpsHighAppLoadPower
"Ups app load power is too high"
= ups_AppLoadPower>=xUpsAppLoadHighThreshold;
event xUpsLowAppLoadPower
"Ups app load power is too low"
= ups_AppLoadPower>=xUpsAppLoadLowThreshold;
export xUpsHighAppLoadPower;
export xUpsLowAppLoadPower;
*/
// Computed attribute, calculate per formula
//Ups Load Power
// computed attribute int prod ups_PowerLoad
//" Ups power load % Watts"
// event xUpsLoadWarn
// "Ups load warning threshold"
// = ups_LoadCurrent>= 60;
// event xUpsLoadCritical
// "Ups load critical threshold"
// = ups_LoadCurrent>= 95;
// export xUpsLoadWarn;
// export xUpsLoadCritical;
//OutPut Voltages
propagate attribute float prod ups_OutPutVoltage
"Current OutPut voltage V"
<= AppProcInstrument, InstrumentedBy, OutPutVoltage;
//event
/*
event xUpsHighOutPutVolt
"Ups output voltage is too high"
= ups_OutPutVoltage>=xUpsOutPutVoltageHighThreshold;
event xUpsLowOutPutVolt
"Ups output voltage is too low"
= ups_OutPutVoltage<=xUpsOutPutVoltageLowThreshold;
export xUpsLowOutPutVolt;
export xUpsHighOutPutVolt;
attribute string Community
"Device community string";
*/
// UPS
}
// Phase of UPS
interface UPS_Phase : ICIM_PhysicalElement
"UPS Phases"
{
stored attribute int InputVoltage
"Current Input voltage V";
stored attribute int Frequency
"Current input Frequency Hz";
// attribute string Description
// "Phase Description";
}
// UPS Battery
interface UPS_Battery : ICIM_PhysicalElement
"Battery of UPS"
{
stored attribute int BatteryTemp
"UPS battery temperature";
stored attribute int BatteryCapacity
"Battery capacity percantage";
stored attribute int ExternalBatteries
"Number of external batteries";
stored attribute int BatteriesVoltage
"Battery Voltages VDC";
//readonly attribute bat_state BatteryStatus;
propagate attribute int prod BatteryStatus
"UPS battery Status"
<= AppProcInstrument, InstrumentedBy, upsBatteryStatus;
//propagate attribute int prod Status
//"Value of ups status oid"
//<= AppProcInstrument, InstrumentedBy, upsStatus;
}
// UPS Enviroments probe sensor class
interface UPS_Env_Probe : TemperatureSensor
"UPS Enviroments probe sensor class"
{
attribute int HumLowThresh
"Humidity Low threshold";
attribute int HumHighThresh
"Humidity High threshold";
attribute int TempLowThresh
"Temperature Low threshold";
attribute int HighLowThresh
"Temperature High threshold";
stored attribute int CurrentTemp
"Current temperature";
stored attribute int CurrentHum
"Current humidity";
// relationship
//relationship PartOf, UPS, Contains;
}
2) In accessor.asl need to change device name or add getInstances from UPS class
Load accessor command sm_adapter -s accessor.asl
///////////////////////////////////////////////////////////////////////////
//
// System Management ARTS (SMARTS)
// Copyright � 2004 - All Rights Reserved
//
// DevKit
//
// ASL Adapter script for Example 3 - Dynamic Model Polling Use Case
//
///////////////////////////////////////////////////////////////////////////
/*
* Rule Set for applying Utilization Settings
*/
/*
* Initialization actions (called once only).
*/
//Debug = TRUE;
default Timeout = "700" ;
default Retries = "3";
//default Device = "192.168.82.230"; // this variable can be passed in via the sm_adapter -D option
default InstrumentationName="AppProcInstrument"; // this variable can be passed in via the sm_adapter -D option
// SNMP Polling Parameters
default ReadCommunity = "public"; // this will be ignored for SNMP v3
default WriteCommunity = "public"; // this will be ignored for SNMP v3
default AgentVersion = "V1"; // V3 Specific Polling Parameters
default EngineID = ""; // Can be left blank
default EngineBoots = 0; // Leave as 0
default EngineBootTime = 0; // Leave as 0
default UserName = ""; // If authentication enabled, set to a valid user name
default AuthProtocol=""; //To enable authentication, set to "MD5" or "SHA"
default AuthPassword = ""; //If authentication enabled, set to the user's password
default Context = ""; // Can be left blank
default PollingInterval =30;
default index="";
poller = object(getInstances("SNMP_AccessorInterface")[0]);
START() {
eol
}
do
{
// Convert the time to milli-seconds
Timeout = numeric(Timeout) / 1000;
// Validate all inputs.
//
// ASSUMPTION: before running this script, the device has already been created by the discovery process
//Here we just need a reference handle to the device represented by deviceHandle
appObject = object("UPS", "UPS-192.168.82.230");
print("Application object is ".appObject);
if (!appObject->isNull())
{
print("app is PartOf ".appObject->PartOf);
hostObject = object("Host", "192.168.82.230");
print("HostObject is ".hostObject);
print("Host name is ". hostObject->DisplayName);
SNMPAddress = hostObject->SNMPAddress;
print("SNMPAddress is : ".SNMPAddress);
//For this particulat
deviceInstrumentation = appObject->makeInstrumentation(InstrumentationName);
// deviceHandle->makeInstrumentation(InstrumentationName);
print("Instrumentation: ".InstrumentationName);
ReservedForFutureUse = "";
poller->instance_instrumentations +=
list(deviceInstrumentation->Name,
SNMPAddress,
index,
ReadCommunity,
WriteCommunity,
EngineID,
EngineBoots,
EngineBootTime,
UserName,
AuthProtocol,
ReservedForFutureUse,
AuthPassword,
ReservedForFutureUse,
Context,
AgentVersion) ? LOG,FAIL;
poller->polling_parameters +=
list(deviceInstrumentation->Name,
numeric(PollingInterval),
-1,
numeric(Timeout),
numeric(Retries),
TRUE) ? LOG, NEXT; //change -1 to TRUE for SNMP trace logging
print("Completed adding instance to accesor");
}
stop();
}
DEFAULT {
line:{..eol}
}
do {
print("Bad input: ".line." Format is ' '");
}
3) This is Discovery Script.
//ic-apc-ups-battery.asl
default AgentName = "";
// Changed by Skribnik evgeniy for debug
//Write to external log file apc.txt
myFile = create("ACT_File", this->Name."_File");
myFile->fileName = "apc.txt";
myFile->write("Start APC UPS process\n");
blanks = " ";
agentObj = object(AgentName);
upsTable = table();
nodeObj = agentObj->getSystem();
if (nodeObj->isNull()) {
print(me.": Can't find node object for ".agentObj->DisplayName);
stop();
}
me = this->ReadsRulesFrom->fileName;
factory = object(getInstances("ICIM_ObjectFactory")[0]);
topo_manager = object(getInstances("ICF_TopologyManager")[0]);
// create UPS class
upsObj = create("UPS", "UPS-".nodeObj->DisplayName);
if (upsObj->isNull()) {
stop();
}
upsObj->Model = nodeObj->Model;
upsObj->Vendor = nodeObj->Vendor;
upsObj->Location = nodeObj->Location;
upsObj->Community = nodeObj->ReadCommunity;
upsObj->PartOf += nodeObj;
//DEBUG = topo_manager->DebugEnabled;
DEBUG = TRUE;
dispName = nodeObj->DisplayName;
historyTable = table();
//tmpObj = getInstances("UPS_Battery");
// Rewrite getInstances function with new own operation, getUpsBattery
// Battery
foreach battery (getInstances("UPS_Battery")) {
batObj = object("UPS_Battery", battery);
if (DEBUG) {
myFile->write("Battery History table: ".battery."\n");
myFile->write("History object for repo:".batObj."\n");
}
historyTable[batObj->Name] = battery;
}
//Phases
foreach phase (getInstances("UPS_Phase")) {
phaseObj = object("UPS_Phase", phase);
if (DEBUG) {
myFile->write("UPS_Phase History table: ".phase."\n");
myFile->write("History object for repo:".phaseObj."\n");
}
historyTable[phaseObj->Name] = phase;
}
foreach probe (getInstances("UPS_Env_Probe")) {
probeObj = object("UPS_Env_Probe", probe);
if (DEBUG) {
myFile->write("UPS_Env_Probe History table: ".probe."\n");
myFile->write("History object for repo:".probeObj."\n");
}
historyTable[probeObj->Name] = probe;
}
/*
* No word delimiter
*/
delim = "";
/*
* Convenience rules for matching OID pieces
*/
upsBatteryNumOID {".1.3.6.1.4.1.318.1.1.1.2.2.5"}
upsBasicInputPhaseOID {".1.3.6.1.4.1.318.1.1.1.3.1.1"}
emStatusProbeNumberOID {".1.3.6.1.4.1.318.1.1.10.2.3.1"}
emStatusProbeStatusOID {".1.3.6.1.4.1.318.1.1.10.2.3.2.1.3"}
//emStatusProbeCurrenTempOID {".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4"}
//emStatusProbeCurrentHumOID {".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6"}
/*
{5, ".1.3.6.1.4.1.318.1.1.1.2.2.5"}, # upsAdvBatteryNumOfBattPacks
{10, ".1.3.6.1.4.1.318.1.1.1.2.2.2" }, # upsAdvBatteryTemperature
{20, ".1.3.6.1.4.1.318.1.1.1.2.2.8" }, # upsAdvBatteryActualVoltage V
{30, ".1.3.6.1.4.1.318.1.1.1.2.2.9" }, # upsAdvBatteryCurrent Amps
{40, ".1.3.6.1.4.1.318.1.1.1.2.1.1" }, # upsAdvTotalDCCurrent
{ 60, ".1.3.6.1.4.1.318.1.1.1.3.1.1" } # upsBasicInputPhase
{ 30, ".1.3.6.1.4.1.318.1.1.10.2.3.1" } # emStatusProbeNumber
{ 40, ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.3" } # emStatusProbeStatus
{ 50, ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4" } # emStatusProbeCurrenTemp
{ 60, ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6" } # emStatusProbeCurrentHum
/*****************************************************************************/
START {
CONT | eol
}
EOF do {
if (feError() == FALSE) {
myFile->write("Insert to EOF rule\n");
myFile->write(feErrorMsg()."\n");
foreach name (historyTable) {
obj = historyTable[name];
topo_manager->log("DSCV_DELETE_COMPONENT",
obj->DisplayName,
nodeObj->Name,
nodeObj->Name);
obj->remove();
}
}
}
DEFAULT {
data:{ .. eol }
} do {
if (DEBUG) {
myFile->write("DSCV_PROBE_FAILED - APC UPS". dispName."\n");
myFile->write(data."\n");
myFile->write(feErrorMsg()."\n");
topo_manager->log("DSCV_PROBE_FAILED", "APC UPS", dispName);
print(data);
}
}
CONT {
ENTITY_BATTERY | ENTITY_PHASE | ENTITY_PROBE
}
ENTITY_BATTERY {
local batIndex;
local oid;
oid:upsBatteryNumOID "." key:word fs
batIndex:word fs
do {
if (DEBUG) {
myFile->write("parser result is ".batIndex."\n");
myFile->write(me.":Battery: ".nodeObj->DisplayName."\n");
myFile->write(" ".oid."[".batIndex."] = ".
"Battery-".batIndex."\n");
}
if (sizeof(batIndex) > 0) {
// Create Battery object
batObj = create("UPS_Battery", "BATTERY-".batIndex."-".nodeObj->DisplayName);
if (batObj->isNull()) {
stop();
}
batObj->Description = "Battery ".batIndex;
batObj->PartOf += upsObj;
undef(historyTable[batObj->Name])?IGNORE;
//Relation to UPS Class
if (DEBUG) {
myFile->write("Creating battery\n");
}
}
}
}
ENTITY_PHASE {
local phaseIndex;
local oid;
oid:upsBasicInputPhaseOID "." key:word fs
phaseIndex:word fs
do {
if (DEBUG) {
myFile->write("parser result is ".phaseIndex."\n");
myFile->write(me.":Phase: ".nodeObj->DisplayName."\n");
myFile->write(" ".oid."[".phaseIndex."] = ".
"Battery-".phaseIndex."\n");
}
if (sizeof(phaseIndex) > 0) {
// Create Battery object
pObj = create("UPS_Phase", "PHASE-".phaseIndex."-".nodeObj->DisplayName);
if (pObj->isNull()) {
stop();
}
pObj->Description = "Phase ".phaseIndex;
undef(historyTable[pObj->Name])?IGNORE;
//put relation object to APC_UPS Class
pObj->PartOf += upsObj;
if (DEBUG) {
myFile->write("Creating Phase\n");
}
}
}
}
ENTITY_PROBE {
ENTITY_PROBE_NUMBER | ENTITY_PROBE_STATUS
}
ENTITY_PROBE_NUMBER {
local probeIndex;
local probeOid;
local statusValue;
local tempVal;
local tempOid;
local humOid;
local humVal;
probeOid:emStatusProbeNumberOID "." key:word fs
probeIndex:word fs
do {
if (DEBUG) {
myFile->write("Number of probes : ".probeIndex."\n");
myFile->write(me.":Probe: ".nodeObj->DisplayName."\n");
myFile->write(" ".probeOid."[".probeIndex."] = ".
"Probe-".probeIndex."\n");
myFile->write("Number probe Key is: ".probeIndex."\n");
}
upsTable[probeIndex] = "";
}
}
ENTITY_PROBE_STATUS {
local statusOid;
local statusValue;
statusOid:emStatusProbeStatusOID "." key:word fs
statusValue:word fs
do {
upsTable[key] = statusValue;
if (DEBUG) {
myFile->write("Probe status is: ".statusValue."\n");
myFile->write("Status probe Key is: ".key."\n");
myFile->write("ups table is: ".upsTable[key]."\n");
}
myFile->write("Table: ".upsTable."\n");
if ((defined(upsTable[key]) && (upsTable[key] != 1))) {
probeObj = create("UPS_Env_Probe", "PROBE-".nodeObj->DisplayName);
if (probeObj->isNull()) {
stop();
}
probeObj->Description = "UPS Enviroments Probe";
undef(historyTable[probeObj->Name])?IGNORE;
// Relation to UPS class
probeObj->PartOf += upsObj;
if (DEBUG) {
myFile->write("Creating Probe ".nodeObj->DisplayName."\n");
}
}
else {
if (DEBUG) {
myFile->write("Probe not connected - ".nodeObj->DisplayName."\n");
}
}
}
}
/*
* Local Variables:
* mode: C++
* End:
*/
No Events found!


Hemulll
2 Intern
•
138 Posts
0
November 20th, 2008 21:00
I shared this code because powerlink have no examples with model and discovery scripts