Quantcast
Channel: THWACK: Discussion List - All Communities
Viewing all articles
Browse latest Browse all 16365

Need some help getting my Perl Monitor working- LINUX Clock Drift

$
0
0

I'm writing my own perl clock drift monitor because the canned monitor is randomly throwing super high values into the statistic, and I need to be able to source a local time server's clock due to PCI zone restrictions.

 

I have the following script that works running it local, and (mostly) works in SAM. For some reason SAM is losing a part of the messaging, but I can't figure out why.

 

When I run it local, these are my results:

Statistic: 0

Message: According to 0.north-america.pool.ntp.org, this server has a deviation of 0 seconds. 0.north-america.pool.ntp.org server time: 5 Aug 15:49:50. MyServer server time: 05 Aug 15:49:50.

 

When plugging into an Orion monitor, the message looks like this:

According to 0.north-america.pool.ntp.org, this server has a deviation of 0 seconds. 0.north-america.pool.ntp.org server time: . MyServer server time: 05 Aug 16:42:13.

(Notice the missing datetime...)



When I initially tried this in Orion, I had to change...


my $drift = $2;

to

my $drift = int($2);

 

...so that I could get a statistic, so I'm guessing it has something with the way Orion is interpreting $1 / $timeServerTime. I don't work with perl very much, so I could be dead wrong.

 

Any pointers would be greatly appreciated. I would really like to have both time stamps in the message for comparison.


#!/usr/bin/perl

 

 

use strict;

use Sys::Hostname;

my($timeServer) = $ARGV[0];

my $host = hostname;

 

# !get offset

my $rawDrift = `ntpdate -q @ARGV[0]|grep ntpdate`;

$rawDrift =~ /(\d+[ ]\w{3}[ ][\d:]{8}) .*? offset[ ]-?(\d+)[.].*? /xms;

 

# !get the time server time

my $timeServerTime = $1;

 

# !get the drift in seconds

my $drift = int($2);

 

# !get the local server time (for the message only)

my $localServerTime = `date +"%d %b %T"`;

chomp $localServerTime;

 

 

print "Statistic: $drift\n";

print "Message: According to $timeServer, this server has a deviation of $drift seconds. $timeServer server time: $timeServerTime. $host server time: $localServerTime.\n";


Viewing all articles
Browse latest Browse all 16365

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>