#!/bin/bash
start() {
cat <<EOF
1.需要用到的命令wget apt-get tar
EOF
}
install_1() {
ss -ntulp |grep alertmanager
VERSION=alertmanager-0.24.0.linux-amd64.tar.gz
if [ $? = 0 ]; then
echo "alertmanager 已安装"
else
echo "开始安装 ${VERSION}"
wget https://github.com/prometheus/alertmanager/releases/download/v0.24.0/${VERSION}
tar -xvzf ${VERSION} -C /opt/alertmanager
vim /etc/systemd/system/alertmanager.service
cat <<EOF >/etc/systemd/system/alertmanager.service
[Unit]
Description="alertmanager"
After=network.target
[Service]
ExecStart=/opt/alertmanger/alertmanager-0.24.0.linux-amd64/alertmanager --config.file=/opt/alertmanger/alertmanager-0.24.0.linux-amd64/alertmanager.yml --storage.path=/opt/alertmanger/alertmanager-0.24.0.linux-amd64/data --web.listen-address=:9093 --data.retention=120h
WorkingDirectory=/opt/alertmanger/alertmanager-0.24.0.linux-amd64
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable alertmanager
systemctl restart alertmanager
systemctl status alertmanager
}
main() {
start
install_1
}
main