一键部署脚本如下:
#!/bin/bash
#用于安装ntp_exporter
#author:johnl time:2023-11-01
NTPEXPOR_DIR=/usr/local/ntp_exporter
NTP_SERVER=10.10.12.76
[ ! -d $NTPEXPOR_DIR ] && mkdir -p $NTPEXPOR_DIR
install_process() {
cd $NTPEXPOR_DIR
[ ! -f ntp_exporter ] && wget --ftp-user=software --ftp-password='k4jjjksjesM5R' ftp://10.10.15.7:/install/ntp_exporter/ntp_exporter
chmod 755 $NTPEXPOR_DIR/ntp_exporter
if [[ "$(uname -r)" == *el7* ]]; then
cat > /usr/lib/systemd/system/ntp_exporter.service << EOF
[Unit]
Description=ntp exporter
Documentation=ntp exporter
[Service]
ExecStart=$NTPEXPOR_DIR/ntp_exporter -ntp.measurement-duration=1s -ntp.server=$NTP_SERVER -web.