Created
March 28, 2025 02:06
-
-
Save iced-nero/52b8e38f2c1a5ad264bffcaebd50afac to your computer and use it in GitHub Desktop.
Parsing some columns from leaselist
This file contains hidden or 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
# Providing console output from https://github.com/notthetup/leaselist | |
# v1: hard way from web page source | |
scrapelease() { | |
curl -sS my.leaselist.host |\ | |
tail -2 |\ | |
head -1 |\ | |
sed 's/>/>\n/g' |\ | |
grep Reactive |\ | |
sed 's/{/{\n/g' |\ | |
grep ".id" |\ | |
cut -d'}' -f2 |\ | |
cut -d',' -f3- |\ | |
sed 's/"//g;s/{//' |\ | |
column -s, -t |\ | |
sort; | |
} |
This file contains hidden or 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
# Providing console output from https://github.com/notthetup/leaselist | |
# v2: easier way from API | |
# assumes jq is installed | |
getlease() { | |
curl -sS http://my.leaselist.host:port/api/leases |\ | |
jq -r '["IP","Hostname","MAC","Since"], (.[] | [.address,."host-name",."active-mac-address",.age]) | @csv' |\ | |
tr -d '"' |\ | |
sort -h |\ | |
column -s, -t; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment