Skip to content

Instantly share code, notes, and snippets.

@lhns
Last active November 18, 2025 16:53
Show Gist options
  • Select an option

  • Save lhns/4d6c5c1f7fc209d0b91730339f81f4f9 to your computer and use it in GitHub Desktop.

Select an option

Save lhns/4d6c5c1f7fc209d0b91730339f81f4f9 to your computer and use it in GitHub Desktop.
casadm -L -o csv | grep -oP '(?<=^cache,)\d+' | while IFS= read -r cache_id; do casadm -P -i "$cache_id" -d -o csv | jq -sR 'split("\n")|map(split(","))|.[0] as $headers|.[1:]|map(select(length > 0)|with_entries({key: $headers[.key]|ascii_downcase|gsub("[^a-z%]+"; "_")|trimstr("_"), value: .value}))' | jq -r --arg cache_id "$cache_id" 'map(. as $obj|del(.io_class_id, .io_class_name)|to_entries|map("opencas.\(.key){opencas.cache_id=\"\($cache_id)\",opencas.io_class_id=\"\($obj.io_class_id)\",opencas.io_class_name=\"\($obj.io_class_name)\"} \(.value|rtrimstr("%")|tonumber)")[])[]'; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment