Skip to content

Instantly share code, notes, and snippets.

@iced-nero
Created March 28, 2025 02:06
Show Gist options
  • Save iced-nero/52b8e38f2c1a5ad264bffcaebd50afac to your computer and use it in GitHub Desktop.
Save iced-nero/52b8e38f2c1a5ad264bffcaebd50afac to your computer and use it in GitHub Desktop.
Parsing some columns from leaselist
# 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;
}
# 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