Skip to content

Instantly share code, notes, and snippets.

View Opa-'s full-sized avatar
😼

Opa Opa-

😼
View GitHub Profile
@Opa-
Opa- / endlessh-winner.sh
Last active February 27, 2024 15:26
endlessh winner table
#!/bin/bash
TOP=$(journalctl -u endlessh.service | grep "time=" | awk '{split($11, time, "="); split($8, ip, ":"); print ip[4], time[2]}' | awk '{arr[$1]+=$2} END {for (i in arr) {print i,arr[i]}}' | sort -n -k2)
format_duration() {
local seconds=$(printf "%.3f" $1) # Convert seconds to 3 decimal places
local milliseconds=$(echo "scale=0; $seconds * 1000" | bc) # Convert seconds to milliseconds
local milliseconds=${milliseconds%.*} # Remove decimal part
# Calculate days, hours, minutes, and seconds