Last active
August 29, 2015 14:03
-
-
Save kogir/251c4a25e4e0dd31403f to your computer and use it in GitHub Desktop.
ZFS StatHat
This file contains 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
BEGIN { | |
FS = "\t"; | |
print "{\n \"ezkey\": \"<key>\",\n \"data\": ["; | |
} | |
{ COMMA = ""; } | |
NR > 1 { COMMA = ","; } | |
$2 == "available" && match($1, "/") == 0 { | |
print " " COMMA "{ \"stat\": \"ZFS " $1 " Available\", \"value\": " $3/(1024 * 1024 * 1024) " }"; | |
} | |
$2 == "used" { | |
print " " COMMA "{ \"stat\": \"ZFS " $1 " Used\", \"value\": " $3/(1024 * 1024 * 1024) " }"; | |
} | |
$2 == "usedbysnapshots" && $3 != "0" { | |
print " " COMMA "{ \"stat\": \"ZFS " $1 " Used By Snapshots\", \"value\": " $3/(1024 * 1024 * 1024) " }"; | |
} | |
$2 == "usedbydataset" { | |
print " " COMMA "{ \"stat\": \"ZFS " $1 " Used By Dataset\", \"value\": " $3/(1024 * 1024 * 1024) " }"; | |
} | |
$2 == "compressratio" && $3 != "1.00x" { | |
gsub("x", "", $3); | |
print " " COMMA "{ \"stat\": \"ZFS " $1 " Compression Ratio\", \"value\": " $3 " }"; | |
} | |
END { | |
print " ]\n}" | |
} |
This file contains 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
#! /bin/bash | |
zfs get -t filesystem -Hpo name,property,value available,used,usedbysnapshots,usedbydataset,compressratio \ | |
| awk -f zfs-stathat.awk \ | |
| curl -H "Content-Type: application/json" -d @- "https://api.stathat.com/ez" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment