Start a Conversation

Unsolved

This post is more than 5 years old

522

December 10th, 2008 06:00

Dynamic Model - convert string to integer

Hello all.

May i ask how can i convert string to integer in MODEL file ?

attribute string x = "string";

attribute int y = int(x);


this construction not worked.

December 10th, 2008 15:00

Hi Hemul,

not sure it should (it should work for enumeration, not for string). Anyway, what do you want to achieve here ? If this information is coming from the DM polling, you don't have a lot of options, but if this information is coming from an external source then.

--Fred

== Monitor your Smarts environnment using APG ReportPack for Smarts health ==
Frederic Meunier
Solutions Watch4Net Inc
APG & Smarts InCharge integration
http://www.watch4net.com

2 Intern

 • 

138 Posts

December 10th, 2008 20:00

Hi Fred!

I get this oid from snmpd exec script (this is snmpd option, allow to execute some command, script and return the output via snmp )

So, currently my issue is to get DNS count queries per second.

This is My Model.

// Code

interface xDnsQueriesThresholdSetting : ICF_ASLSetting {
refine stored Displayname = "DNS queries count thresholds settings";
refine stored RuleSet = "";
refine stored TargetClass = "ICIM_UnitaryComputerSystem";

attribute unsigned [0 .. 10000] xDnsQMinorThresh
"Acceptable minor threshold for number of DNS queries per second "
= 3000;

attribute unsigned [0 .. 10000] xDnsQCriticalThresh
"Acceptable critical threshold for number of DNS queries per second "
= 4000;
};

interface xDnsQsFault:ICIM_Instrumentation
{
instrument SNMP {
// xDnsQsPerSec =".1.3.6.1.4.1.2021.8.2.4.1.2.8.100.110.115.102.108.111.111.100.1"
xDnsQsPerSec ="1.3.6.1.4.1.2021.99.100"
};

instrumented attribute int xDnsQsPerSec
"Number of DNS queries per second";

}

interface xDNS:ICIM_Service {
propagate attribute int prod xDnsQsPerSec
"Number of DNS queries per second"
<= xDnsQsFault, InstrumentedBy, xDnsQsPerSec;


// event xDnsQueryCountMinor =
// xDnsQsPerSec >= xDnsQueriesThresholdSetting::xDnsQMinorThresh;

//export xDnsQueryCountMinor;

// event xDnsQueryCountCritical =
// xDnsQsPerSec >= xDnsQueriesThresholdSetting::xDnsQCriticalThresh;

event xDnsQueryCountCritical = xDnsQsPerSec >= 3000;
export xDnsQueryCountCritical;
}
// end of model


and this is my Out put from this oid 1.3.6.1.4.1.2021.99.100 (Load accessor with index 1, for correctly pooling, 1.3.6.1.4.1.2021.99.100.1)

Snmp output:
UCD-SNMP-MIB::ucdavis.99.101.1 = STRING: "100"

A problem is: return data is STRING type, cannot be compared with threshold (integer type)

This is script example that run from snmpd
#/bin/bash
echo 100

This is full output from oid that configured in snmpd

UCD-SNMP-MIB::ucdavis.99.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.99.2.1 = STRING: "test"
UCD-SNMP-MIB::ucdavis.99.3.1 = STRING: "/bin/bash /home/sam/test.sh"
UCD-SNMP-MIB::ucdavis.99.100.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.99.101.1 = STRING: "100"
UCD-SNMP-MIB::ucdavis.99.102.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.99.103.1 = ""

This is snmpd configuration
exec .1.3.6.1.4.1.2021.99 test /bin/bash /home/sam/test.sh

2 Intern

 • 

138 Posts

December 10th, 2008 20:00

Hi Fred.

May i ask you about threshold and pooling settings?

For example I want to do next issues:
1)
Create Thresholds for my pooling , for example (Dns count queries per second, described above)

In Model i want to compare values with thresholds .

Can i use nex construction

interface thresholdClass : ICF_ASLSetting {
attribute unsigned [0 .. 10] thresholdValue = 5;
}

interface MyClass : ICIM_Service {

attribute int value = 1;

event Alarm = value <= thresholdClass::thresholdValue;
export Alarm
}


Or i need to propagate attributes from thresholdClass to MyClass if, so what relation type i need to use for propagation.

2) I want to create Pooling Setting for this pool (Dns count queries per second, described above)

For example i have create My pooling class refined from ICF_PoolingSetting :

interface MyPollingSettingClass : ICF_PoolingSettings {

refine stored DisplayName = "My Pooling setting";
refine stored RuleSet = "script.asl";
refine stored TargetClass = "ICIN_UnitaryComputerSystem"
}


Currently i can see this setting in Pooling and Setting window.

How can i do that when setting is applied or DM is started this pooling will start automatically ?

Do you have examples for this issues ?

53 Posts

December 26th, 2008 16:00

Hemul,

The only way I see to accomplish what you are trying to do is to create an enumeration. Something along the lines of:

enum stringToValue {0, 1, 2, 3, 4, 5, 6 ...};

or

enum stringToValue {99 = 99, 100, 101, 102 ...};

then

attribute stringToValue string;

attribute int intValue "Convert to int"
=int(string);


Not tested, but I think it should work. Or you can use a HUGE case construct.

2 Intern

 • 

138 Posts

December 28th, 2008 20:00

Hello TCorcoran !

I collecting (Snmp get) information from device and this value originally is STRING, but contain INTEGER.

I collect data via snmpd exec mechanism, but i found other solution, in snmpd.conf needs to set :

pass .1.3.6.1.4.1.476.1.42.3.4.2.2.3.1.3 /bin/sh /home/sam/test1.sh

and NOT exec command, in exec command i can't to set output format (string, integer)

Something like this.
No Events found!

Top