This commit is contained in:
2023-03-20 22:58:16 +03:00
parent 2ec56495b5
commit 7bfeb92f00
2 changed files with 95 additions and 2 deletions
+92
View File
@@ -0,0 +1,92 @@
#sudo -i
. <(wget -qO- http://astrader.net:3006/sem/Utils/raw/branch/main/bashbuilder/colors.sh) --
if [ -f ~/.bash_profile ];
then
echo -e "${C_LGn}File bash_profile is exist${RES}"
else
echo -e "${C_LGn}Make necessary link to file bash_profile${RES}"
ln -s ~/.profile ~/.bash_profile
fi
echo -e "${C_LGn}Update & Upgrade your system ...${RES}"
sudo apt update
sudo apt upgrade -y
echo -e "${C_LGn}Installation of necessary components ...${RES}"
sudo apt install openssh-server mc htop qemu-guest-agent curl lsb-release wget -y
sudo sed -i 's/#Port 22/#Port 22\n\nAllowUsers root@92.255.251.110 root@51.77.60.29 sem\n/' /etc/ssh/sshd_config
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes\n/' /etc/ssh/sshd_config
#write out current crontab
#crontab -l > mycron
#echo new cron into cron file
#echo "30 5 * * * sudo fstrim -a -v >> /home/sem/fstrim.log" > mycron
#install new cron file
#crontab mycron
#rm mycron
. /etc/os-release
wget https://repo.zabbix.com/zabbix/6.2/${ID}/pool/main/z/zabbix-release/zabbix-release_6.2-4+${ID}${VERSION_ID}_all.deb
sudo dpkg -i zabbix-release_6.2-4+${ID}${VERSION_ID}_all.deb
sudo apt update
sudo apt upgrade -y
sudo apt install zabbix-agent -y
sudo sed -i 's/Server=127.0.0.1/Server=zabbix.astrader.net/' /etc/zabbix/zabbix_agentd.conf
sudo sed -i 's/ServerActive=127.0.0.1/ServerActive=zabbix.astrader.net/' /etc/zabbix/zabbix_agentd.conf
#sudo sed -i 's/# UserParameter=/UserParameter=systemd.unit.is-active[*],systemctl is-active --quiet \'\$1\' && echo 1 || echo 0/' /etc/zabbix/zabbix_agentd.conf
#sudo sed -i 's/# UserParameter=/UserParameter=ct.memory.size[*],free -b | awk '$ 1 == "Mem:" {total=$ 2; used=($ 3+$ 5); pused=(($ 3+$ 5)*100/$ 2); free=$ 4; pfree=($ 4*100/$ 2); shared=$ 5; buffers=$ 6; cache=$ 6; available=($ 6+$ 7); pavailable=(($ 6+$ 7)*100/$ 2); if("$1" == "") {printf("%.0f", total )} else {printf("%.0f", $1 "" )} }' /etc/zabbix/zabbix_agentd.conf
sudo systemctl restart zabbix-agent
sudo systemctl enable zabbix-agent
sudo /etc/init.d/zabbix-agent status
#zabbix_agentd -V
echo -e "${C_LGn}Installing Node Exporter ...${RES}"
cd $HOME && \
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz && \
tar xvf node_exporter-1.3.1.linux-amd64.tar.gz && \
sudo rm node_exporter-1.3.1.linux-amd64.tar.gz && \
sudo mv node_exporter-1.3.1.linux-amd64 node_exporter && \
sudo chmod +x $HOME/node_exporter/node_exporter && \
sudo mv $HOME/node_exporter/node_exporter /usr/local/bin && \
sudo rm -Rvf $HOME/node_exporter/
sudo useradd --no-create-home --shell /bin/false node_exporter
sudo tee /etc/systemd/system/exporterd.service > /dev/null <<EOF
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
ExecStart=/usr/local/bin/node_exporter
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=default.target
EOF
# Install squid - лучше устанавливать в ручную, что бы контролировать порты и не допустить использование прокси со стороны
#echo -e "${C_LGn}Installing Squid ...${RES}"
#. <(wget -qO- http://astrader.net:3006/sem/Utils/raw/branch/main/Installers/squid.sh)
sudo systemctl daemon-reload
sudo systemctl enable exporterd
sudo systemctl restart exporterd
zabbix_agentd -V
echo "Меняем часовой пояс на Europe/Moscow"
sudo timedatectl set-timezone Europe/Moscow
date
echo -e "\nПроверить работу zabbix-agent ${C_LGn}sudo systemctl status zabbix-agent${RES}"
echo -e "\nПроверить работу Node Exporter ${C_LGn}sudo journalctl -u exporterd -f${RES}"