Created
February 21, 2018 04:46
-
-
Save tksugimoto/154029772f41b547d642690acb487a34 to your computer and use it in GitHub Desktop.
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 | |
host=$(hostname --short) | |
catbon_host=localhost | |
catbon_port=2003 | |
echo "send metric of '$host' to $catbon_host:$catbon_port" | |
metric_name="sample" | |
send() | |
{ | |
# echo "$1" | |
echo "$1" | nc $catbon_host $catbon_port -w1 | |
} | |
while : | |
do | |
time=$(date +%s) | |
avg1=$(awk '{ print $1 }' < /proc/loadavg) | |
send "stats.$metric_name.$host.load1 $avg1 $time" | |
mem=$(free | | |
grep --line-buffered Mem: | | |
awk --assign=host=${host} '{ print $3 }') | |
send "stats.$metric_name.$host.memory.used $mem $time" | |
sleep 2s | |
done |
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
# ssh target -N | |
Host target | |
# remote側port 転送先port(localから見える場所) | |
RemoteForward 2003 graphite.intra.example.com:2003 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment