Skip to content

Commit

Permalink
Software titles: add NetData & improve uptime-kuma
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Dec 2, 2024
1 parent 6fc59d1 commit 4d4c480
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 12 deletions.
Binary file added tools/include/images/MON005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tools/include/markdown/MON005-header.md
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.
30 changes: 30 additions & 0 deletions tools/json/config.software.json
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,36 @@
"status": "Stable",
"author": "@igorpecovnik",
"condition": "module_uptimekuma status"
},
{
"id": "MON005",
"description": "Netdata Install",
"command": [
"module_netdata install"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "! module_netdata status"
},
{
"id": "MON006",
"description": "Netdata remove",
"command": [
"module_netdata remove"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "module_netdata status"
},
{
"id": "MON007",
"description": "Netdata purge data folder",
"command": [
"module_netdata purge"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "! module_netdata status && [[ -d \"${SOFTWARE_FOLDER}/netdata\" ]]"
}
]
},
Expand Down
13 changes: 1 addition & 12 deletions tools/modules/runtime/config.runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,9 @@ fi

#
# Sub sub menu updates

cockpit_port="$(systemctl cat cockpit.socket | grep ListenStream | awk -F= '{print $2}' | awk '{print $1}')"
update_sub_submenu_data "Software" "Management" "M03" "https://localhost:$cockpit_port"

emby_media_port="$(lsof -i -P -n | grep TCP | grep LISTEN | grep 'emby' | awk -F: '{print $2}' | awk '{print $1}')"
update_sub_submenu_data "Software" "Media" "SW24" "https://localhost:$emby_media_port"

plex_media_port="$(lsof -i -P -n | grep TCP | grep LISTEN | grep 'plex' | awk -F: '{print $2}' | awk '{print $1}' | head -n 1)"
update_sub_submenu_data "Software" "Media" "SW22" "https://localhost:$plex_media_port"

update_sub_submenu_data "Software" "Containers" "CON006" "http://$LOCALIPADD:${module_options["module_portainer,port"]}"
update_sub_submenu_data "Software" "HomeAutomation" "HA004" "http://$LOCALIPADD:${module_options["module_haos,port"]}"


update_sub_submenu_data "Software" "Monitoring" "MON004" "http://$LOCALIPADD:${module_options["module_netdata,port"]}"
update_sub_submenu_data "Software" "Downloaders" "DOW002" "http://$LOCALIPADD:${module_options["module_qbittorrent,port"]}"
update_sub_submenu_data "Software" "Downloaders" "DOW004" "http://$LOCALIPADD:${module_options["module_deluge,port"]}"
update_sub_submenu_data "Software" "Downloaders" "DOW006" "http://$LOCALIPADD:${module_options["module_transmission,port"]}"
Expand Down
90 changes: 90 additions & 0 deletions tools/modules/software/install_netdata.sh
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
}

0 comments on commit 4d4c480

Please sign in to comment.