-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Software titles: add NetData & improve uptime-kuma
- Loading branch information
1 parent
6fc59d1
commit 4d4c480
Showing
5 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Netdata is a partially open source tool designed to collect real-time metrics, such as CPU usage, disk activity, bandwidth usage, website visits, etc., and then display them in live, easy-to-interpret charts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
module_options+=( | ||
["module_netdata,author"]="@armbian" | ||
["module_netdata,feature"]="module_netdata" | ||
["module_netdata,desc"]="Install netdata container" | ||
["module_netdata,example"]="install remove purge status help" | ||
["module_netdata,port"]="19999" | ||
["module_netdata,status"]="Active" | ||
["module_netdata,arch"]="x86-64,arm64" | ||
) | ||
# | ||
# Module netdata | ||
# | ||
function module_netdata () { | ||
local title="netdata" | ||
local condition=$(which "$title" 2>/dev/null) | ||
|
||
if check_if_installed docker-ce; then | ||
local container=$(docker container ls -a | mawk '/netdata?( |$)/{print $1}') | ||
local image=$(docker image ls -a | mawk '/netdata?( |$)/{print $3}') | ||
fi | ||
|
||
local commands | ||
IFS=' ' read -r -a commands <<< "${module_options["module_netdata,example"]}" | ||
|
||
NETDATA_BASE="${SOFTWARE_FOLDER}/netdata" | ||
|
||
case "$1" in | ||
"${commands[0]}") | ||
check_if_installed docker-ce || install_docker | ||
[[ -d "$NETDATA_BASE" ]] || mkdir -p "$NETDATA_BASE" || { echo "Couldn't create storage directory: $NETDATA_BASE"; exit 1; } | ||
docker run -d --name=netdata \ | ||
--pid=host \ | ||
--network=host \ | ||
-v "${NETDATA_BASE}/netdataconfig:/etc/netdata" \ | ||
-v "${NETDATA_BASE}/netdatalib:/var/lib/netdata" \ | ||
-v "${NETDATA_BASE}/netdatacache:/var/cache/netdata" \ | ||
-v /:/host/root:ro,rslave \ | ||
-v /etc/passwd:/host/etc/passwd:ro \ | ||
-v /etc/group:/host/etc/group:ro \ | ||
-v /etc/localtime:/etc/localtime:ro \ | ||
-v /proc:/host/proc:ro \ | ||
-v /sys:/host/sys:ro \ | ||
-v /etc/os-release:/host/etc/os-release:ro \ | ||
-v /var/log:/host/var/log:ro \ | ||
-v /var/run/docker.sock:/var/run/docker.sock:ro \ | ||
--restart unless-stopped \ | ||
--cap-add SYS_PTRACE \ | ||
--cap-add SYS_ADMIN \ | ||
--security-opt apparmor=unconfined \ | ||
netdata/netdata | ||
for i in $(seq 1 20); do | ||
if docker inspect -f '{{ index .Config.Labels "build_version" }}' netdata >/dev/null 2>&1 ; then | ||
break | ||
else | ||
sleep 3 | ||
fi | ||
if [ $i -eq 20 ] ; then | ||
echo -e "\nTimed out waiting for ${title} to start, consult your container logs for more info (\`docker logs netdata\`)" | ||
exit 1 | ||
fi | ||
done | ||
;; | ||
"${commands[1]}") | ||
[[ "${container}" ]] && docker container rm -f "$container" >/dev/null | ||
[[ "${image}" ]] && docker image rm "$image" >/dev/null | ||
;; | ||
"${commands[2]}") | ||
[[ -n "${NETDATA_BASE}" && "${NETDATA_BASE}" != "/" ]] && rm -rf "${NETDATA_BASE}" | ||
;; | ||
"${commands[3]}") | ||
if [[ "${container}" && "${image}" ]]; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
;; | ||
"${commands[4]}") | ||
echo -e "\nUsage: ${module_options["module_netdata,feature"]} <command>" | ||
echo -e "Commands: ${module_options["module_netdata,example"]}" | ||
echo "Available commands:" | ||
echo -e "\tinstall\t- Install $title." | ||
echo -e "\tstatus\t- Installation status $title." | ||
echo -e "\tremove\t- Remove $title." | ||
echo | ||
;; | ||
*) | ||
${module_options["module_netdata,feature"]} ${commands[4]} | ||
;; | ||
esac | ||
} |