Forum Discussion

Skeer's avatar
Skeer
Icon for Neophyte rankNeophyte
4 years ago

Big Number widget showing a date?

So I'm wanting to create a new widget that will display a static date which is pulled from a datasource that's using SNMP to get the date value. The raw value is in a format like: 20221231

I've tried setting the datasource to no post processing, and Ive got it associated to a single specific host. When I manually poll I get the value I'm looking for but when I view the Raw Data under the Resource it says no data. So I think I've done this all wrong. Anyway I'm hoping some kind stranger and point me in the right direction for creating widgets correctly :)

  • 1 hour ago, Stuart Weenig said:

    That's sort of right. Since the data is in one OID, it's easiest to pull it back with that one OID. But complex datapoints are designed to allow you to manipulate the data after it's pulled back. You can do a huge range of mathematical and logical operators on the standard datapoint. https://www.logicmonitor.com/support/logicmodules/datasources/datapoints/complex-datapoints

    So, Why these options only? Infix, RPN or groovy?  I can't find much on the first two that's *not* just working with mathematical equations. Definitely having a super hard time finding anything useful.

  • Anonymous's avatar
    Anonymous

    They are what they are. The support page linked should give you what you need. 

    For example, to get the day from the value 20221231, if the normal datapoint is called myvalue, you'd do this:

    myvalue % 100

    To get the month, you'd do:

    floor(myvalue / 100) % 100

    To get the year, you'd do:

    floor(myvalue / 10000)

  • 1 hour ago, Stuart Weenig said:

    They are what they are. The support page linked should give you what you need. 

    For example, to get the day from the value 20221231, if the normal datapoint is called myvalue, you'd do this:

    myvalue % 100

    To get the month, you'd do:

    floor(myvalue / 100) % 100

    To get the year, you'd do:

    floor(myvalue / 10000)

    You've obviously been working with those for a while :)/emoticons/smile@2x.png 2x" title=":)" width="20" />

    So, logically that makes no sense to me what so ever...

  • Also, what is 'myfloor' and what does it mean?  I think FoxPro might be easier to understand than this! lol

     

    I definitely appreciate your help on this issue, even though Im as confused as a fart in a fan factory.

  • Anonymous's avatar
    Anonymous

    floor() is a function that rounds down whatever is in the parenthesis to the nearest integer. If myvalue is the name of your standard datapoint, then floor(myvalue) would round the standard datapoint down to the nearest integer.

    The mod operator (%) returns the remainder after division. So if you take 20221231 and divide by 100, you get 202212 with a remainder of 31. The mod (%) just grabs the 31. 

    Each complex datapoint is just another column in the raw data table.

    If you're still confused, i recommend coming to one of our live webinars.

  • Thanks Stuart, especially for the webinar link. I will be checking that out.

  • For what it’s worth, I believe the way our team tends to represent these sorts of things (expiration dates) is to create a datapoint which calculates the number of days until expiration. You’d probably want to use a groovy complex datapoint (although it might be possible with a regular one) to take the value, use a date conversion function to make it a date, then use more date math to subtract the current date from the expiration to get a count of days. This won’t give you the exact display you want, but you can put up a big “X days until license expiration” widget and watch it count down. You can also put alert thresholds like “< 31 7 2” on the datapoint to give you a warning when it’s a month out, an error when it’s a week out, and a critical 2 days before expiration. 

    https://www.logicmonitor.com/support/logicmodules/datasources/datapoints/complex-datapoints#

    https://opensource.com/article/21/8/groovy-date-time