#!/bin/sh #Creating node_exporter service file sudo touch /etc/systemd/system/cadvisor.service cat <<EOF >/etc/systemd/system/cadvisor.service [Unit] Description=cadvisor Wants=network-online.target After=network-online.target [Service] ExecStart= /usr/bin/docker run --rm --name cadvisor -p 8080:8080 -v "/:/rootfs:ro" -v "/var/run:/var/run:rw" -v "/sys:/sys:ro" -v "/var/lib/docker/:/var/lib/docker:ro" google/cadvisor:latest [Install] WantedBy=multi-user.target EOF echo "cAdvisor service is created" #Adding grafana port to firewall cat /etc/novell-release | grep "VERSION = 2023" if [ $? -eq 0 ]; then DEFAULT_ZONE=`firewall-cmd --get-default-zone` for port in 8080; do firewall-cmd --permanent --zone=$DEFAULT_ZONE --add-port=${port}/tcp > /dev/null 2>&1 done firewall-cmd --add-masquerade --permanent --zone=$DEFAULT_ZONE > /dev/null 2>&1 firewall-cmd --reload > /dev/null 2>&1 else sed -i 's/FW_SERVICES_EXT_TCP="/FW_SERVICES_EXT_TCP="8080 /g' /etc/sysconfig/SuSEfirewall2 systemctl restart SuSEfirewall2.service fi sleep 5 #After creating and modifying service file need to restart daemom sudo systemctl daemon-reload sudo systemctl start cadvisor.service sleep 5 systemctl is-active --quiet cadvisor.service if [ $? -eq 0 ]; then echo cadvisor service is running else echo cadvisor service is not running fi exit