Start a Conversation

Unsolved

This post is more than 5 years old

S

1684

February 10th, 2017 10:00

Smarts model and snmp instrumentation questions...

Hey, are there still any smarts model gurus out there?

I'm looking for some insights on a few SNMP_AccessorInterface mysteries, and as the documentation is well, non-existent, the community is my only hope.

1. Can SNMP instrumentation launch some kind of hook script? Model is just so limited that even basic string manipulation is out of the question.

2. How to convert data types - string to float or float to int? If you don't map the model attribute type to the snmp oid type correctly, the SNMP_AccessorInterface will spit out an error. So there needs to be a way to convert data types once captured in the instrumentation object. Model has a so-called conversion function: type_name(

3. How do you access model table and struct types? The model reference guide has an example of how to declare them, but there's no mention on how to access them from within model. The ASL reference guide gives mappings for how to access them from ASL, but if instrumenting thru model this doesn't help.

4. Can an SNMP table be instrumented using a model table in a single model instance? I know this is not the "preferred" method for instrumenting snmp tables, but for a simple two row table it would be a lot simpler to just map the desired oids to a single model class::instance than to go through the trouble of creating separate model classes for each row.

Any and all wisdom welcome.

Cheers, Scott.

53 Posts

February 16th, 2017 11:00

Scott,

Great questions regarding Smarts modeling and SNMP instrumentation.  I am looking into these questions for you.

53 Posts

February 22nd, 2017 07:00

In answer to your questions.

1. Can SNMP instrumentation launch some kind of hook script?

     Unfortunately not, instrumentation doesn't provide a mechanism to invoke any hook script.  All of the MIB values that      are polled over as string and then converted to a value of type defined by the OID itself.  Each OID value type is      already   defined by the standard so the polled string will  be automatically converted to the defined value type in      C++ code.

2. How to convert data type - string to float or float to int?

     For model attribute that is instrumented, the attribute type should match the OID type defined by the standard.  We      would need an example to assess if anything is broken on your end

3. How to you access model table and struct types?

     These defined model tables and structures can be accessed in C++ code using MR-DynamicAccess API.  If      accessed from asl, the table rows can be accessed as list variables.

4. Can an SNMP table be instrumented using a model table in a single model instance?

     There is no way to access table rows within the model, therefore there is no need to instrument the entire model as      described here.  Smarts instrumentation always maps individual variables with a specific OID entry for dynamic      polled      values.  we don't support mapping an entire snmp table to a table defined in model.  Can you provide an      example of      the use case so we can properly assess if this can be implemented?

2 Posts

February 26th, 2017 21:00

Hi Nate,

Thanks for responding to my questions.

On the data conversion issues, the scenarios are very simple.

a) One SNMP OID we are fetching has the data stored as a string b/c it has a percent sign in it, but otherwise it's a float - eg. "2.00%". I need to be able to convert it to an int or float so that I can threshold it and create an event if it exceeds an acceptable range. This does not appear to be possible in dynamic model.

b) Another even simpler scenario is propagating the OperStatus value from a device interface in order to compute an ipsec tunnel status on the device. Interface::OperStatus is, for some some strange reason, stored as a string. I need it to be an enum (or integer). Eventually, after much trial and error I was able to solve this one by writing an operation like this:

    readonly int ToperStatusToInt()

        definition:

            return (TunnelOperStatus == "UP"? 0: 10) +

                  (TunnelOperStatus == "DOWN"? 1: 10) - 10;

This might not be the most elegant solution, but it works. I'm open to any suggestions on how to improve this or whether it's very inefficient - it gets called for 6 attributes every time the device object is fetched.

Regards, Scott.

5 Practitioner

 • 

274.2K Posts

April 3rd, 2017 00:00

Hi Scott,

The way I have handled the "string" numeric value is to use a subscription adapter.  Use a GA_PropertyChoiceSubscription with an ASL.  Each time you get ATTRIBUTE_CHANGE you can take the polled string value and convert it into a numeric value then place the new value into an other attribute in the class.  The value from the subscription looks like:

ATTRIBUTE_MESSAGE {

    timeStamp: integer            fs

    action:    "ATTRIBUTE_CHANGE" fs

    className: word               fs

    instName:  word               fs

    propName:  word               fs

    propValue: integer            fs

               .. eol

} do {

A sample of the import for creating this subscription adapter would look like:

GA_DaemonDriver::ICIM-Listener-Driver

{

    ReadsRulesFrom = GA_RuleSet::ICIM-Listener-RS

    {

    fileName = "icim/icim-listener.asl"

    }

    ReadsInputFrom = GA_SubscriberFE::ICIM-Listener-Subscriber-FE

    {

    SubscribesTo = {

            GA_PropertyChoiceSubscription:: -SUB

        {

            classPattern = "*"

            instancePattern = "*"

            propertyPattern = " "

            glob = TRUE

            quiet = FALSE

        },

        GA_PropertyChoiceSubscription:: -SUB

        {

            classPattern = "*"

            instancePattern = "*"

            propertyPattern = " "

            glob = TRUE

            quiet = FALSE

        }

    }

    }

}

Each time the string property changes the named ASL driver will be passed the data.  You just do what you have to.

For your problem 2 I have never seen where the raw polled value is not an integer enum so you should be able to propagate that value rather than the string value.

1 Message

October 20th, 2023 01:52

@Anonymous​ 

Thanks Anon for the property subscription suggestion. Very helpful. After 6 years, this I finally got around to implementing this! I'm happy to share my listener code if anyone needs some assistance.

No Events found!

Top