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. Checking if time on different servers is identical

Checking if time on different servers is identical

Scheduled Pinned Locked Moved Support
14 Posts 2 Posters 22.9k 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.
  • D
    D
    DanG
    wrote on last edited by
    #1

    Hi,

    It’s easy to collect time on servers individually, but where do I compare the times of the different servers to create an event should they be unequal (within a margin of course)?

    Thanks,

    Dan

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

      Hi!

      You can create a condition object, add DCIs collecting current time from different servers, and write a script which will calculate deviation.

      Best regards,
      Victor

      1 Reply Last reply
      0
      • D
        D
        DanG
        wrote on last edited by
        #3

        Hi Vicror,

        I must have missed the "condition objects" in the documentation, thanks.

        I'm not sure however how I should reference the DCI's in that object.
        Normaly one would use FindDCIByName($node, "System.CurrentTime")
        but in the condition object $node represen the the condition object  and there are serveral System.CurrentTime DCI's for the different servers.

        Regards,

        Dan

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

          You miss "conditions" in documentation because it is not documented 🙂

          Working with the conditions is as follows:

          1. Create condition object somewhere in the infrastructure (services) tree.
          2. Open properties, and on "Data" page, add DCIs
          3. The, on "Script" page, write checking script. DCIs can be referred using variables $1, $2, etc., or via $values array. Script should return true if condition is active, and false otherwise. On status change, appropriate event being generated (configured on "Events and Status" page).

          Starting with version 1.1.5, you can use foreach operator for enumerating DCIs, for example:

          sum = 0;
          foreach(v : $values)
          {
          	trace(1, "+++ value = " . v . " +++");
          	sum += v;
          }
          trace(1, "+++ sum = " . sum . " +++");
          

          Best regards,
          Victor

          1 Reply Last reply
          0
          • D
            D
            DanG
            wrote on last edited by
            #5

            Hi Victor,

            Not having 1.1.5 (yet) I tried 1..1.4:

            for(i=0; $values[i] != null; i++)
            {
            ...
            }

            is still giving an error. What's wrong?

            Regards,

            Dan

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

              This is because you use array instead of referencing it's elements. Correct version should looks like this:

              for(i=0; $values[i] != null; i++)
              {
                 trace(0,"+++" . $values[i] . "+++");
              
                 minTime = min(minTime, $values[i]);
                 maxTime = max(minTime, $values[i]);
              }
              

              Best regards,
              Victor

              1 Reply Last reply
              0
              • D
                D
                DanG
                wrote on last edited by
                #7

                Victor

                My script above was mistyped (sorry), the script on the server has the same text as your suggestion.

                The error returned is for following line:
                for(i=0; $values[i] != null; i++)

                Could it be something else?

                Dan

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

                  Oops, that's my failure 😞 Prior to 1.1.5 DCI values only accessible via $1, $2, etc. variables. Array $values also was added in 1.1.5. I suggest to do upgrade first 🙂

                  Best regards,
                  Victor

                  1 Reply Last reply
                  0
                  • D
                    D
                    DanG
                    wrote on last edited by
                    #9

                    Victor,

                    I wanted to ask when 1.1.5 will be released, but noticed it was released today (JIT).
                    I'll upgrade and try again. Thanks.

                    Regards,

                    Dan

                    1 Reply Last reply
                    0
                    • D
                      D
                      DanG
                      wrote on last edited by
                      #10

                      Victor,
                      I upgraded to 1.1.5, this time with no problems. Great!

                      I set the new syntax for obtaining the values and it works.

                      In my specific case the result is not what I had expected. I use the DCI System.CurrentTime to get the time on several servers, As they’re using NTP their time is within a few milliseconds of each other yet the my script calculates a different deviations each time (up to a minute apart). As the pooling interval of both DCI’s was 60 seconds I guess this has to do with the moment NetXMS grabs the value from each of the servers. This bring me to the question of where is the condition object calculated, is it each time one of the DCI’s in the list of DCI’s of the condition object pool changes?
                      I changed to pooling interval to 10 seconds and the deviation got to under 10 seconds, I could set is to once every seconds which probably resolve the problem, however it will be using a lot of resources for just knowing if my servers are still in sync.
                      If I change the pooling to custom schedule, will they be pooled on the same time?

                      Using the condition object for the first time, I’ve noticed it behaves differently than a DCI. Would it not be better to make it closer to a DCI? It retains the “Data tab” where one set the different DCI’s to be used, the “script tab” should allow calculate any type of  value, a “Thresholds tab” where triggers can be set. This will also allow to have historical result with “last value” and the ability to draw graphs (in my case the max deviation of the time on the severs)

                      Regards,

                      Dan

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

                        Hi!

                        Condition uses last collected value of DCIs - checking condition does not cause DCI poll. You can switch to custom schedule - if you will have schedule like * * * * *, you DCI will be collected at the beginning of each minute. Scheduler check DCI schedules once per 2 second, so you will not be able to achieve better than 2 second accuracy.

                        Converting conditions to something similar to nodes with DCIs makes sense. I'll think about it.

                        Also, I thought about another way of checking server time sync: you can collect server's system time once per minute and compare it with monitoring server's time. To check that monitoring server's time is accurate, you can check ntp status on monitoring server. That way should be easier probably while still accurate.

                        Best regards,
                        Victor

                        1 Reply Last reply
                        0
                        • D
                          D
                          DanG
                          wrote on last edited by
                          #12

                          Hi Victor,

                          I set the schedule to * * * * * and up to now receive derivation of a second. Having a two second tolerance is more than acceptable in my case.
                          Your other solution is indeed even better, it’s just that while searching for a solution to the problem at hand I learned an interesting NetXMS feature that will without a doubt serve me in the future. Thanks!

                          Regards,

                          Dan

                          1 Reply Last reply
                          0
                          • D
                            D
                            DanG
                            wrote on last edited by
                            #13

                            Hi,

                            I thought I could avoid examining the log file by adding a a custom attribute on the Condition object and set is within the script

                            The following line:
                            SetCustomAttribute($node,"MaxTimeDeviation",maxDeviation);
                            returns the following error:
                            Failed to execute evaluation script for condition object 1234 "TimeDeviation": Error 14 in line 13: Left argument of -> must be a reference to object

                            Using the following test line gives the same error:
                            SetCustomAttribute($node,"MaxTimeDeviation","test");

                            What am I doing wrong?

                            Regards,

                            Dan

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

                              Hi!

                              Variable $node is unset in condition scripts, because it's not a node. Currently it's not possible to access condition's custom attributes from script. I'll add some method to access them.

                              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