NTPサーバの監視
とりあえずてけとうに。
NTPサーバからとってきた時間とローカルで持ってる時間も比較してみる
なので監視で見るNTPは監視するNTPとは別のサーバを見たほうがいいでしょう。
んーあとでRFCちゃんとよまんと。
別のNTPでとった時間と比較してもいいかな。どうだろ。
http://ftp.isi.edu/in-notes/rfc1305.txt
package MadEye::Plugin::Agent::NTP; use strict; use warnings; use base qw/MadEye::Plugin/; use Net::NTP; use DateTime; sub is_alive { my ( $self, $context, $target ) = @_; my $host = $target->{host}; my $port = $target->{port} || 'ntp'; $context->log( debug => "$host:$port" ); my %res; eval { %res = get_ntp_response($host,$port); }; unless (%res || !$@) { return +{ message => "$host:$port is no found.", agent => ref($self), target => $target, }; } my $ntp_dt = DateTime->from_epoch(epoch => $res{'Receive Timestamp'}); my $cmp_dt = DateTime->now; unless ( $ntp_dt->ymd eq $cmp_dt->ymd ) { return +{ message => "ntp get time is strange", agent => ref($self), target => $target, }; } return; } 1; __END__ =head1 SYNOPSIS - module: Agent::NTP config: target: - host: ntp1.example.com port: ntp - host: ntp2.example.com
Net::NTPのつくりが超微妙だす。
(追記)
これ別にDateTimeオブジェクトにして比較する必要ないなぁ。