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. Support
  3. Is it me or does NetXMS have time travel capabilities?

Is it me or does NetXMS have time travel capabilities?

Scheduled Pinned Locked Moved Support
4 Posts 3 Posters 9.7k 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.
  • P
    P
    paul
    wrote on last edited by
    #1

    I have the following hook in my NodeUp and an equivalent in my node down. Apart from it being the longest way of doing this (first one I found when searching), I get a strange result.

    Everything is correct - except - the month is out by 1. It reports month as being last month, not this month. I know the local time is correct(or bein extracted correctly) because I am comparing the Node_Up and Node_Down event times to the custom attributes - and everything matches  - exactly - except the month - which is out by one.

    SetCustomAttribute($node, "timelastcameup",localtime(time())->mday.".".localtime(time())->mon.".".localtime(time())->year.", ".localtime(time())->hour.":".localtime(time())->min.":".localtime(time())->sec);

    Any ideas?

    1 Reply Last reply
    0
    • T
      T
      Tursiops
      wrote on last edited by
      #2

      As per http://www.cplusplus.com/reference/ctime/tm/, I believe months are "months since January" and therefore go from 0-11, not 1-12.

      1 Reply Last reply
      0
      • P
        P
        paul
        wrote on last edited by
        #3

        Tursiops - correct as usual 🙂
        https://wiki.netxms.org/wiki/NXSL:TIME

        Would be nice for NXSL TIME to also have mona as the actual month - adding 1 to mon so I don't have to.

        Adding that within SetCustomAttribute will be fun. Something like one of the following I hope - but probably not that lucky.

        SetCustomAttribute($node, "timelastcameup",localtime(time())->mday.".".((localtime(time())->mon)+1).".".localtime(time())->year.", ".localtime(time())->hour.":".localtime(time())->min.":".localtime(time())->sec);
        

        or

        SetCustomAttribute($node, "timelastcameup",localtime(time())->mday.".".localtime(time())->mon+1.".".localtime(time())->year.", ".localtime(time())->hour.":".localtime(time())->min.":".localtime(time())->sec);
        

        Or going the long way:

        day = localtime($1)->mday;
        
        mon = localtime($1)->mon+1;
        
        year = localtime($1)->year;
        
        hour = localtime($1)->hour;
        
        min = localtime($1)->min;
        
        SetCustomAttribute($node, "timelastcameup", day."-".mon."-".year.",".hour.":".min;
        

        One of these should work.

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

          You can simply use strftime (https://wiki.netxms.org/wiki/NXSL:strftime😞

          SetCustomAttribute($node, "timelastcameup", strftime("%d-%m-%Y, %H:%M:%S", $1));
          

          Best regards,
          Victor

          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