Browse Source

final docker.sh

master
flynn 2 years ago
parent
commit
9fd33725d3
2 changed files with 42 additions and 60 deletions
  1. +0
    -24
      containers.ini
  2. +42
    -36
      docker.sh

+ 0
- 24
containers.ini View File

@ -1,24 +0,0 @@
proxy
camp
term
deluge
maria_stack
maria_psm
jackett
sonarr
lidarr
radarr
reqs
dash
mc
linx
core
gate
warden
warrior
psm
git
znc
lounge
searx
stack

+ 42
- 36
docker.sh View File

@ -7,22 +7,6 @@ title="Dev0 Netdata"
desc="Docker Dashboard"
theme="'slate'"
# read hosts.ini as array
readarray ARRAY < docker.ini
# erase containers.ini
rm containers.ini
# curl the docker hosts to get container names
for i in "${ARRAY[@]}"
do
i=$(tr -d ' ' <<< "$i")
curl http://$i:19999/api/v1/charts | grep -oP 'chart=cgroup_\K\w+(?=.cpu_limit)' >> containers.ini
done
# read in our containers as an array
readarray CONTAINERS < containers.ini
# put our file head in place
echo '<!DOCTYPE html>
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
@ -52,14 +36,35 @@ echo '<!DOCTYPE html>
<body>
<div style="width: 100%; text-align: center; padding-top: 1%;">' > docker.html
# iterate over the dashboard for each host, adding it to the docker.html
for i in "${CONTAINERS[@]}"
# We need to read each docker host into its own process, this is so we can append both the host and the containers it contains to the right blocks
# read hosts.ini as the HOSTS array
readarray HOSTS < docker.ini
# erase existing containers.ini so we can populate accurate ones
rm *.containers.ini
# curl the docker hosts to get container names. They will be named host.containers.ini. We will take these ini files and work them as their own loops. I use the net_packets filter to pull unique containers from each host, this may need to be adjusted (cpu_limit didnt pull any hosts from one of my dockers)
for h in "${HOSTS[@]}"
do
h=$(tr -d ' ' <<< "$h")
curl http://$h:19999/api/v1/charts | grep -oP 'chart=cgroup_\K\w+(?=.net_packets)' >> $h.containers.ini
done
## read in a container list and append it to our page before moving on to the next host
for h in "${HOSTS[@]}"
do
i=$(tr -d ' ' <<< "$i")
h=$(tr -d ' ' <<< "$h")
readarray CONTAINERS < $h.containers.ini
# iterate over the dashboard for each host, adding it to the docker.html
for c in "${CONTAINERS[@]}"
do
c=$(tr -d ' ' <<< "$c")
echo ' <div style="margin-right: 10px; width: 20%;"
class="netdata-container-easypiechart"
data-host="http://'$i':19999"
data-netdata="cgroup_camp.mem_usage"
data-host="http://'$h':19999"
data-netdata="cgroup_'$c'.mem_usage"
data-dimensions="ram"
data-chart-library="easypiechart"
data-title="Memory"
@ -72,8 +77,8 @@ echo ' <div style="margin-right: 10px; width: 20%;"
</div>
<div style="margin-right: 10px; width: 20%;"
class="netdata-container-easypiechart"
data-host="http://'$i':19999"
data-netdata="cgroup_camp.net_eth0"
data-host="http://'$h':19999"
data-netdata="cgroup_'$c'.net_eth0"
data-dimensions="received"
data-chart-library="easypiechart"
data-title="NetIn"
@ -85,8 +90,8 @@ echo ' <div style="margin-right: 10px; width: 20%;"
</div>
<div style="margin-right: 10px; width: 20%;"
class="netdata-container-easypiechart"
data-host="http://'$i':19999"
data-netdata="cgroup_camp.net_eth0"
data-host="http://'$h':19999"
data-netdata="cgroup_'$c'.net_eth0"
data-dimensions="sent"
data-chart-library="easypiechart"
data-title="NetOut"
@ -98,10 +103,10 @@ echo ' <div style="margin-right: 10px; width: 20%;"
</div>
<div style="margin-right: 10px; width: 20%;"
class="netdata-container-gauge"
data-host="http://'$i':19999"
data-netdata="cgroup_camp.cpu"
data-host="http://'$h':19999"
data-netdata="cgroup_'$c'.cpu"
data-chart-library="gauge"
data-title="Gummi0[camp]" data-units="%"
data-title="'$h'['$c']" data-units="%"
data-gauge-max-value="100"
data-width="15%"
data-after="-360"
@ -111,8 +116,8 @@ echo ' <div style="margin-right: 10px; width: 20%;"
</div>
<div style="margin-right: 10px; width: 20%;"
class="netdata-container-easypiechart"
data-host="http://'$i':19999"
data-netdata="cgroup_camp.throttle_io"
data-host="http://'$h':19999"
data-netdata="cgroup_'$c'.throttle_io"
data-dimensions="write"
data-append-options="percentage"
data-chart-library="easypiechart"
@ -126,10 +131,9 @@ echo ' <div style="margin-right: 10px; width: 20%;"
</div>
<div style="margin-right: 10px; width: 20%;"
class="netdata-container-easypiechart"
data-host="http://'$i':19999"
data-netdata="cgroup_camp.throttle_io"
data-host="http://'$h':19999"
data-netdata="cgroup_'$c'.throttle_io"
data-dimensions="read"
data-append-options="percentage"
data-chart-library="easypiechart"
data-easypiechart-max-value="10240"
data-title="Disk Read"
@ -139,10 +143,12 @@ echo ' <div style="margin-right: 10px; width: 20%;"
data-colors="#16A086"
role="application">
</div>
<br>' >> docker.html
<br>'>> docker.html
done
done
echo "
# finish up the file
echo '
</div>
</body>
</html>" >> docker.html
</html>' >> docker.html

Loading…
Cancel
Save