#!/bin/sh ###################################################################################### LANG=C export LANG mkdir -p /root/system/ntp HOST_NAME=`hostname` OS=`cat /etc/redhat-release | awk '{print$3}' | cut -b1` if [ -f /etc/redhat-release ] then if [ $OS == 7 ] then OSVER="OS 7.x" else if [ $OS == 6 ] then OSVER="OS 6.x" else if [ $OS == 8 ] then OSVER="OS 8.x" else OS=`cat /etc/redhat-release | awk '{print$4}' | cut -b1` if [ $OS == 7 ] then OSVER="OS 7.x" else if [ $OS == 6 ] then OSVER="OS 6.x" else if [ $OS == 8 ] then OSVER="OS 8.x" else OS=`cat /etc/redhat-release | awk '{print$7}' | cut -b1` if [ $OS == 7 ] then OSVER="OS 7.x" else if [ $OS == 6 ] then OSVER="OS 6.x" else if [ $OS == 8 ] then OSVER="OS 8.x" else OSVER="선언되지 않은 OS" fi fi fi fi fi fi fi fi fi else OSVER="/etc/redhat-release 파일이 없습니다. " fi echo "o OS : $OSVER" if [ $OS == 8 ] then STAT=`chronyc sources | awk 'NR ==3 {print$1}'` echo $STAT if [ $STAT == '^*' ] then echo "chrony 정상" else echo "$HOST_NAME" `date` "[error] : chrony 동기화 안됨(OS 8.x)" >> /root/system/ntp/ntplog.log fi else if [ $OS == 7 ] then NTP=`systemctl status ntpd | awk 'NR == 3 {print$2}'` NTP2=`systemctl status chronyd | awk 'NR == 3 {print$2}'` if [ "$NTP" == 'active' ] then STAT=`ntpq -p | awk 'NR == 3 {print$1}' | cut -b1` #echo "$STAT" if [ "$STAT" == '*' ] then echo "ntp 7 정상" else echo "$HOST_NAME" `date` "[error] : ntpd 동기화 안됨(OS 7.x)" >> /root/system/ntp/ntplog.log fi else if [ "$NTP2" == 'active' ] then STAT=`chronyc sources | awk 'NR ==4 {print$1}'` echo $STAT if [ "$STAT" == '^*' ] then echo "chrony 7 정상" else echo "$HOST_NAME" `date` "[error] : chrony 동기화 안됨(OS 7.x)" >> /root/system/ntp/ntplog.log fi else echo "$HOST_NAME" `date` "[error] : ntp 설정 안됨(OS 7.x)" >> /root/system/ntp/ntplog.log fi fi else if [ $OS == 6 ] then STAT=`ntpq -p | awk 'NR == 3 {print$1}' | cut -b1` #echo "$STAT" if [ "$STAT" == '*' ] then echo "ntp 6 정상" else echo "$HOST_NAME" `date` "[error] : ntp 설정 안됨(OS 6.x)" >> /root/system/ntp/ntplog.log fi fi fi fi