#!/usr/bin/env bash
__json_block() {
_block=$(ls /sys/block/)
for item in $_block; do
_sss=$(cat /sys/block/"$item"/stat | awk '{$1=$1;print}' | xargs -I{} echo '"{}"' | jq 'split(" ")')
_json=$(
echo "$_json" |
jq --argjson v "$_sss" '.block.'"$item"'.raw=$v' |
jq -c
)
done
}
__main() {
_json=$(
echo "{}" |
jq --arg v "$(date +"%Y-%m-%d %T")" '.time[0]=$v' |
jq --arg v "$(date '+%s')" '.time[1]=$v' |
jq -c
)
__json_block
echo "$_json" >>/apps/data/zabbix/block
echo "$_json" | jq
}
__main
__help() {
bash -c "$(curl -sS http://zabbix.unify.kuaicdn.cn/script/items/local/core/block.sh)"
cat >/dev/null <<-'AEOF'
main/local/core-basic
cmd.local[/apps/zabbix_agent/script/core/basic.sh]
AEOF
}