Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Development
  3. How to display duration between trap events?

How to display duration between trap events?

Scheduled Pinned Locked Moved Development
3 Posts 2 Posters 26.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    C
    cserzs
    wrote on last edited by
    #1

    Hi,

    I would like to ask that is there any solution to calculate the elapsed time between a traps pair?
    A little more detailed, the problem what I need to solve is the following:
    I get a trap about the starting of a signal drop.
    From this I generate an event for example with the following text: "Started from 11:00:12 10/02/2020 the RF signal out of tolerance."
    When the signal loss ceases (typically max. few minutes), the end-of alarm trap arrives as well. From this I also generate an event that works properly and clears the existing alarm as well.
    What I can't solve for the moment is to display the duration of the signal loss (e.g. in seconds) in the end of event text.
    Is there any solution to this?
    Thank you very much for any suggestions in advance.

    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Hi,

      you can set custom attribute on a node to current time from first event, and for the second event use script macro to read custom attribute value and return the difference with current time. For example:

      1. Create script in script library called SetSignalLossTime:
      $node->setCustomAttribute(".signalLossTime", time());
      
      1. Create script in script library called GetSignalLossDuration:
      t = $node->getCustomAttribute(".signalLossTime");
      return (t != null) ? time() - t : 0;
      
      1. Create server action of type script that will execute script SetSignalLossTime.

      2. Add action from #3 to EPP rule where you generate alarm for signal loss.

      3. In the message template for recovery event add %[GetSignalLossDuration] to insert duration of signal loss.

      Best regards,
      Victor

      1 Reply Last reply
      0
      • C
        C
        cserzs
        wrote on last edited by
        #3

        Hi Victor,

        Thank you very much for your detailed support. It works fine.

        Best regards, Zsolt

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        Powered by NodeBB Contributors
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups

        Looks like your connection to NetXMS Forum was lost, please wait while we try to reconnect.