/ print "Checking to be sure the Network Time Protocol is running properly.\n"; if (('' eq 'fedora26') || ('' eq 'fedora27') || ('' eq 'fedora28') || ('' eq 'fedora29') || ('' eq 'fedora30') || ('' eq 'fedora31') || ('' eq 'fedora32') || ('' eq 'fedora33') || ('' eq 'fedora34') || ('' eq 'sles15') || ('' eq 'centos8') || ('' eq 'rhes8') || ('' eq 'oracle7') || ('' eq 'oracle8') || ('' eq 'ubuntu18') || ('' eq 'ubuntu20')) { print "For more information on chronyd please see https://chrony.tuxfamily.org/\n"; } else { print "For more information on ntpd please see http://www.ntp.org/\n"; } my $NTPD; my $name = 'ntp'; my $checkcmd = 'ps -ef |grep ntp |grep -v grep |grep -v ntpcheck'; my $startntpcmd; my $is_running; if (('' eq 'fedora15') || ('' eq 'fedora16') || ('' eq 'fedora17') || ('' eq 'fedora18') || ('' eq 'fedora19') || ('' eq 'fedora20') || ('' eq 'fedora21') || ('' eq 'fedora22') || ('' eq 'fedora23') || ('' eq 'fedora24') || ('' eq 'fedora25') || ('' eq 'fedora26') || ('' eq 'fedora27') || ('' eq 'fedora28') || ('' eq 'fedora29') || ('' eq 'fedora30') || ('' eq 'fedora31') || ('' eq 'fedora32') || ('' eq 'fedora33') || ('' eq 'fedora34') || ('' eq 'centos7') || ('' eq 'rhes7') || ('' eq 'scientific7') || ('' eq 'oracle7') || ('' eq 'sles12') || ('' eq 'sles15') || ('' eq 'ubuntu18') || ('' eq 'ubuntu20') || ('' eq 'rhes8') || ('' eq 'centos8') || ('' eq 'oracle8')) { $NTPD = 'ntpd'; my $binname = $NTPD; if (('' eq 'ubuntu18') || ('' eq 'ubuntu20')) { $NTPD = 'chrony'; $name = $NTPD; $binname = 'chronyd'; } elsif (('' eq 'fedora26') || ('' eq 'fedora27') || ('' eq 'fedora28') || ('' eq 'fedora29') || ('' eq 'fedora30') || ('' eq 'fedora31') || ('' eq 'fedora32') || ('' eq 'fedora33') || ('' eq 'fedora34') || ('' eq 'sles15') || ('' eq 'rhes8') || ('' eq 'centos8') || ('' eq 'oracle7') || ('' eq 'oracle8')) { $NTPD = 'chronyd'; $name = $NTPD; $binname = $NTPD; } $checkcmd = "systemctl is-enabled $NTPD.service"; $startntpcmd = "systemctl start $NTPD.service"; if (!-e "/usr/sbin/$binname") { print "$name is not installed.\n"; exit; } } else { if (-e "/etc/init.d/ntpd") { $NTPD = "ntpd"; } elsif (-e "/etc/init.d/xntpd") { $NTPD = "xntpd"; } elsif (-e "/etc/init.d/ntp") { $NTPD = "ntp"; } else { print "ntp is not installed.\n"; exit; } $startntpcmd = "/etc/init.d/$NTPD start"; } if (open(PIPE,'-|',$checkcmd)) { $is_running = <PIPE>; chomp($is_running); close(PIPE); if (!$is_running) { print "WARNING: $name is installed but is not currently running.\n"; if ($name eq 'ntp') { print "Please verify the configuration of ntp in /etc/ntp.conf and /etc/ntp/step-tickers\n"; } print "Start $name by executing\n $startntpcmd\n"; } else { print "$name is installed and running\n"; } } else { print "Could not determine $name status.\n"; } # chkconfig barfs to stderr if the target isn't set up right. if (('' eq 'fedora15') || ('' eq 'fedora16') || ('' eq 'fedora17') || ('' eq 'fedora18') || ('' eq 'fedora19') || ('' eq 'fedora20') || ('' eq 'fedora21') || ('' eq 'fedora22') || ('' eq 'fedora23') || ('' eq 'fedora24') || ('' eq 'fedora25') || ('' eq 'fedora26') || ('' eq 'fedora27') || ('' eq 'fedora28') || ('' eq 'fedora29') || ('' eq 'fedora30') || ('' eq 'fedora31') || ('' eq 'fedora32') || ('' eq 'fedora33') || ('' eq 'fedora34') || ('' eq 'scientific7') || ('' eq 'centos7') || ('' eq 'rhes7') || ('' eq 'oracle7') || ('' eq 'sles12') || ('' eq 'sles15') || ('' eq 'ubuntu18') || ('' eq 'ubuntu20') || ('' eq 'rhes8') || ('' eq 'centos8') || ('' eq 'oracle8')) { if (!-l "/etc/systemd/system/multi-user.target.wants/$NTPD.service") { print "**** WARNING: $NTPD is not configured to run at boot. To correct this run:\nsystemctl enable $NTPD.service\n"; } exit; } else { my $checking_bin; my $restartchk; if (('' eq 'debian5') || ('' eq 'debian6') || ('' eq 'ubuntu6') || ('' eq 'ubuntu8') || ('' eq 'ubuntu10') || ('' eq 'ubuntu12') || ('' eq 'ubuntu14') || ('' eq 'ubuntu16')) { $checking_bin = '/usr/sbin/sysv-rc-conf'; } else { $checking_bin = '/sbin/chkconfig'; } $restartchk = `$checking_bin --list $NTPD 2>/dev/null`; if ($restartchk eq '') { print "**** WARNING: ntpd is either not installed or not configured to run at boot.\n"; exit; } if ($restartchk =~ /^error reading information on service / || $restartchk !~ /\d:(on|off)/) { print "**** WARNING: Unable to check status $NTPD with $checking_bin.\n"; exit; } if ($restartchk !~ /\s3:on/) { print "**** WARNING: ntpd is not set to start at runlevel 3. To correct this run:\n$checking_bin --level 345 $NTPD on\n"; exit; } if ($restartchk !~ /\s5:on/) { print "**** WARNING: ntpd is not set to start at runlevel 5. To correct this run:\n$checking_bin --level 345 $NTPD on\n"; exit; } }