nah fr tho this time
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
motd_list =
|
motd_list =
|
||||||
mapAttrsToList (_: v: v.motd)
|
mapAttrsToList (_: v: v.motd)
|
||||||
(filterAttrs (_: v: v ? motd && v.motd != null) config.homelab);
|
(filterAttrs (_: v: v ? motd && v.motd != null) config.homelab);
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options.homelab.motd = {
|
options.homelab.motd = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
@@ -30,33 +29,15 @@ in {
|
|||||||
headings="\033[0;36m"
|
headings="\033[0;36m"
|
||||||
bold="\e[1m"
|
bold="\e[1m"
|
||||||
reset="\033[0m"
|
reset="\033[0m"
|
||||||
|
|
||||||
memory=`free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100 / $2 }'`
|
memory=`free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100 / $2 }'`
|
||||||
|
load1=`cat /proc/loadavg | awk {'print $1'}`
|
||||||
|
load5=`cat /proc/loadavg | awk {'print $2'}`
|
||||||
|
load15=`cat /proc/loadavg | awk {'print $3'}`
|
||||||
uptime=`cat /proc/uptime | cut -f1 -d.`
|
uptime=`cat /proc/uptime | cut -f1 -d.`
|
||||||
up_days=$((uptime/60/60/24))
|
up_days=$((uptime/60/60/24))
|
||||||
up_hours=$((uptime/60/60%24))
|
up_hours=$((uptime/60/60%24))
|
||||||
up_mins=$((uptime/60%60))
|
up_mins=$((uptime/60%60))
|
||||||
up_secs=$((uptime%60))
|
up_secs=$((uptime%60))
|
||||||
|
|
||||||
printf "$bold Welcome to $(hostname)!$reset\n"
|
|
||||||
printf "\n"
|
|
||||||
printf "$bold * %-20s$reset %s\n" "Release" "$PRETTY_NAME"
|
|
||||||
printf "$bold * %-20s$reset %s\n" "Kernel" "$(uname -rs)"
|
|
||||||
printf "\n"
|
|
||||||
printf "$bold * %-20s$reset %s\n" "CPU usage" "$LOAD1, $LOAD5, $LOAD15 (1, 5, 15 min)"
|
|
||||||
printf "$bold * %-20s$reset %s\n" "Memory" "$memory"
|
|
||||||
printf "$bold * %-20s$reset %s\n" "System uptime" "$up_days days $up_hours hours $up_mins minutes $up_secs seconds"
|
|
||||||
|
|
||||||
printf "\n"
|
|
||||||
printf "$bold Service status$reset\n"
|
|
||||||
|
|
||||||
# --- System Info ---
|
|
||||||
default_iface=$(ip route | awk '/default/ {print $5; exit}')
|
|
||||||
ip_addr=$(ip -4 addr show "''${default_iface}" | awk '/inet / {print $2}' | cut -d/ -f1)
|
|
||||||
nixos_version=$(grep '^VERSION=' /etc/os-release | cut -d'"' -f2 | tr -d '\n')
|
|
||||||
kernel_version=$(uname -r)
|
|
||||||
|
|
||||||
# --- Resource Stats ---
|
|
||||||
cpu_usage=$(top -bn1 | grep "Cpu(s)" | awk '{print 100 - $8 "%"}')
|
cpu_usage=$(top -bn1 | grep "Cpu(s)" | awk '{print 100 - $8 "%"}')
|
||||||
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||||
mem_avail=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
|
mem_avail=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
|
||||||
@@ -64,14 +45,17 @@ in {
|
|||||||
mem_percent=$((100 * mem_used / mem_total))
|
mem_percent=$((100 * mem_used / mem_total))
|
||||||
uptime_fmt=$(uptime -p 2>/dev/null || cat /proc/uptime | awk '{print int($1/3600)"h "int(($1%3600)/60)"m"}')
|
uptime_fmt=$(uptime -p 2>/dev/null || cat /proc/uptime | awk '{print int($1/3600)"h "int(($1%3600)/60)"m"}')
|
||||||
|
|
||||||
echo -e "''${headings}Resources''${reset}"
|
printf "$bold Welcome to $(hostname)!$reset\n"
|
||||||
echo -e " CPU Usage: ''${cpu_usage}"
|
printf "\n"
|
||||||
echo -e " Memory: ''${mem_percent}% used"
|
printf "$bold * %-20s$reset %s\n" "Release" "$nixos_version"
|
||||||
echo -e " Uptime: ''${uptime_fmt}"
|
printf "$bold * %-20s$reset %s\n" "Kernel" "$(uname -rs)"
|
||||||
echo
|
printf "\n"
|
||||||
|
printf "$bold * %-20s$reset %s\n" "CPU usage" "$load1, $load5, $load15 (1, 5, 15 min)"
|
||||||
|
printf "$bold * %-20s$reset %s\n" "Memory" "$memory"
|
||||||
|
printf "$bold * %-20s$reset %s\n" "System uptime" "$up_days days $up_hours hours $up_mins minutes $up_secs seconds"
|
||||||
|
|
||||||
# --- services ---
|
# --- services ---
|
||||||
echo -e "''${headings}Homelab Services''${reset}"
|
echo -e "''${headings}homelab services''${reset}"
|
||||||
|
|
||||||
${lib.concatStringsSep "\n" (map (service: ''
|
${lib.concatStringsSep "\n" (map (service: ''
|
||||||
if systemctl list-units --type=service --all | grep -q "${service}"; then
|
if systemctl list-units --type=service --all | grep -q "${service}"; then
|
||||||
|
|||||||
Reference in New Issue
Block a user