5 Replies Latest reply on Dec 19, 2014 11:39 AM by thyrsus

    SNMP String to Float

    thyrsus

      I have an SNMP agent delivering a string, which I need to treat as a float.  For example, it's reporting "0.000000017", and I need to treat it as 1.7*10^-8, so that I can generate warning/critical notices when it goes outside numerical bounds.

       

      When I looked at the "conversion" "Available Data Transformations", they all assumed that the data was numeric to start with.

       

      What do folks suggest?

        • Re: SNMP String to Float
          thyrsus

          Looking closer, the parse() function takes a string, but then it appears to return a string.  Am I wrong?  Is there a different document I should look at?  E.g., something describing just how much C# I can stuff into the parse() arguments (I'll learn C# if I have to)?  Something that would describe how to store the result in the database as a float?  Or is best practice to scale the value into an integer?

            • Re: SNMP String to Float
              thyrsus

              To this point, I've been using the web console to create the poller; it appears there may be more options available in the native application Universal Device Poller creation; I'll update once I get access to that.

                • Re: SNMP String to Float
                  thyrsus

                  The "Universal Device Poller" program on the SolarWinds server did not provide any further alternatives.  I've also found a thread UnDP: Parsing Substrings? indicating that the *only* valid parse function is "(?<result>\d+)" (the variable "result" may differ) and that it must therefore process an integer.  That doesn't get me to a float.  It means, even assuming the SNMP string value *always* started with "0.", I wouldn't be able to distinguish "0.003" from "0.00003".

                    • Re: SNMP String to Float
                      thyrsus

                      I think I'm getting closer: after studying the SolarWinds Lab video #7, one can transform the result of a Universal Device Poller using SQL, so when my SNMP poller delivers a string like "-0.000000039 s", I can do something like

                       

                      ${SQL:select cast(substring(CustomPollerStatus.Status, 1, length(CustomPollerStatus.Status) - 2) as float) as result from (CustomPollerStatus inner join CustomPollerAssignmentView on (CustomPollerStatus.CustomPollerAssignmentID = CustomPollerAssignmentView.CustomPollerAssignmentID)) where CustomPollerAssignmentView.AssignmentName like 'cntpOffsetToCDMAReference on %' and NodeID = 1942)} + (0*{cntpStratum})

                       

                      Right now, what I'm having two problems:  although the above syntax works in Microsoft SQL Server Management Studio, whenever I include the function "substring(...)" in the ${SQL: ...} contents, the transform comes back as Error.  I'm pretty baffled at that.

                       

                      Second, I don't know how to substitute into the transform SQL query string the value for NodeID.  My attempt to use "NodeID = {NodeID}" just came back as an unspecified error.


                        • Re: SNMP String to Float
                          thyrsus

                          I am well and truly baffled by my inability to use SQL string functions.  I can replace "cast(substring(CustomPollerStatus.Status, 1, length(CustomPollerStatus.Status) - 2) as float)" with "count(CustomPollerStatus.Status)" and it works, but if I try to do "count(replace(CustomPollerStatus.Status, ' s', ''))" - which, like all the variants mentioned, works just fine in Microsoft SQL Server Manager Studio -  in UnDP Transform, I get an unspecified "Error".