Last active
February 28, 2023 00:03
-
-
Save itchyny/03bcc3ad50b3e4a157ec61d023e39900 to your computer and use it in GitHub Desktop.
Mackerel plugin for file count
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
#!/bin/zsh | |
if [[ "$MACKEREL_AGENT_PLUGIN_META" == 1 ]]; then | |
cat <<EOF | |
# mackerel-agent-plugin | |
{ | |
"graphs": { | |
"filecount.#": { | |
"label": "File count", | |
"unit": "integer", | |
"metrics": [ | |
{ | |
"label": "total", | |
"name": "total" | |
} | |
] | |
} | |
} | |
} | |
EOF | |
exit 0 | |
fi | |
for f in ~/{,Documents,Downloads,Desktop,Dropbox}; do | |
printf 'filecount.%s.total\t%s\t%s\n' \ | |
"${(L)${${${${f/#$HOME/home}//\//_}#_}%_}#home_}" \ | |
"$(set -- "$f"/*(DN) && echo "$#")" \ | |
"$(date +%s)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment