#!/usr/bin/perl

# check netapp ntp time
# alex@noris.de - 2013-01-23

use lib "/usr/lib/netapp-manageability-sdk-5.0/lib/perl/NetApp";
use NaServer;
use NaElement;
use strict;
use warnings;
use Data::Dumper;

my $s = NaServer->new ($ARGV[0], 1, 3);

$s->set_transport_type("HTTPS");
$s->set_style("LOGIN");
$s->set_admin_user($ARGV[1], $ARGV[2]);
$s->set_timeout(60);

my $output = $s->invoke("clock-get-clock");

if ($output->results_errno != 0) {
	my $r = $output->results_reason();
	print "UNKNOWN - Timeout: $r\n";
	exit 3;
}

my $time_netapp = $output->child_get_string("local-time");

my $time_now = time();

my $diff = $time_now-$time_netapp;

if($diff >= "60"){
	print "NetApp time is $diff seconds different - check NTP";
	exit 2;
} else {
	print "NetApp time is OK";
	exit 0;
}


