Skip to content

Instantly share code, notes, and snippets.

@sunrise2575
Last active November 25, 2021 16:40
Show Gist options
  • Save sunrise2575/1ef12303c9ff7bb624be1e4260609119 to your computer and use it in GitHub Desktop.
Save sunrise2575/1ef12303c9ff7bb624be1e4260609119 to your computer and use it in GitHub Desktop.
Prometheus Node Exporter 설치 bash 한방 스크립트 (Ubuntu / CentOS 겸용)
DIST=$(
. /etc/os-release
echo $ID
)
if [[ $DIST == "ubuntu" ]]; then
VERSION=$(lsb_release -r | awk '{print $2}' | awk -F . '{print $1$2}')
apt install prometheus-node-exporter -y
systemctl --now enable prometheus-node-exporter
systemctl --now start prometheus-node-exporter
fi
if [[ $DIST == "centos" ]]; then
{
echo '[prometheus]'
echo 'name=prometheus'
echo 'baseurl=https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch'
echo 'repo_gpgcheck=1'
echo 'enabled=1'
echo 'gpgkey=https://packagecloud.io/prometheus-rpm/release/gpgkey'
echo ' https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm'
echo 'gpgcheck=1'
echo 'metadata_expire=300'
} >/etc/yum.repos.d/prometheus.repo
yum install -y node_exporter
systemctl --now enable node_exporter
systemctl --now start node_exporter
fi
@sunrise2575
Copy link
Author

sunrise2575 commented Nov 25, 2021

prometheus는 /etc/prometheus/prometheus.yml 에서 target 을 여러개로 만들 수 있습니다.
즉 각 서버에는 prometheus node exporter를 설치하고, 모니터링 서버 1대에만 prometheus를 설치하면 됩니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment