May 8, 2022
Что я накатываю на новую ось
#!/bin/bash apt update && apt upgrade -y I=`dpkg -s wget | grep "Status" ` if [ -n "$I" ] then echo "wget installed" else apt install wget -y fi I=`dpkg -s git | grep "Status" ` if [ -n "$I" ] then echo "git installed" else apt install git -y fi I=`dpkg -s tmux | grep "Status" ` if [ -n "$I" ] then echo "tmux installed" else apt install tmux -y fi # install tmux addon cd $HOME git clone https://github.com/gpakosz/.tmux.git ln -s -f .tmux/.tmux.conf cp .tmux/.tmux.conf.local . #install telegraf mkdir -p $HOME/.monitoring/telegraf/ . /etc/*-release; \ echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | tee >/dev/null /etc/apt/sources.list.d/influxdb.list; \ wget -qO- https://repos.influxdata.com/influxdb.key | apt-key add - apt install bc jq telegraf subversion -y server_name="s" influxdb_url="http://x:8086" admin_password="@1" tee <<EOF >/dev/null /etc/telegraf/telegraf.conf [agent] interval = "20s" round_interval = true metric_batch_size = 1000 metric_buffer_limit = 10000 collection_jitter = "0s" flush_interval = "10s" flush_jitter = "0s" precision = "" hostname = "$server_name" omit_hostname = false [[outputs.influxdb]] urls = ["$influxdb_url"] database = "telegraf" timeout = "5s" username = "admin" password = "$admin_password" [[inputs.cpu]] interval = "5s" percpu = true totalcpu = true collect_cpu_time = false report_active = false [[inputs.mem]] interval = "5s" [[inputs.disk]] ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] [[inputs.net]] interfaces = ["eth0"] [[inputs.docker]] container_state_include = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] perdevice = false #[[inputs.procstat]] #pid_tag = true #pattern = "massa*|minima*|evmos*" #[[inputs.systemd_units]] #pattern = "massad.service minima_9001.service evmosd.service" [[inputs.exec]] interval = "5s" commands = ["sudo su -c /root/.monitoring/telegraf/for_table.sh -s /bin/bash root"] data_format = "influx" [[inputs.netstat]] [[inputs.diskio]] [[inputs.kernel]] [[inputs.processes]] [[inputs.swap]] [[inputs.system]] EOF svn export --force https://github.com/SecorD0/Monitoring/trunk/dashboards/for_table.sh $HOME/.monitoring/telegraf/ chmod +x $HOME/.monitoring/telegraf/for_table.sh ln -s /etc/telegraf/telegraf.conf $HOME/.monitoring/telegraf/telegraf.conf sudo -- bash -c 'echo "telegraf ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers' sudo systemctl restart telegraf . <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n telegraf_log -v "sudo journalctl -fn 100 -u telegraf" -a