Skip to content

Instantly share code, notes, and snippets.

@lostsnow
Last active December 13, 2015 19:58
Show Gist options
  • Save lostsnow/4966007 to your computer and use it in GitHub Desktop.
Save lostsnow/4966007 to your computer and use it in GitHub Desktop.
#!/bin/sh
HOST=$(hostname | awk -F'.' '{print $1}')
IDC=$(hostname | awk -F'.' '{print $3}')
SYSTEM_LOAD=$(awk '{print $1}' /proc/loadavg)
SYSTEM_MEMORY=$(free -m | grep 'buffers/cache' | awk '{print $NF}')
NGINX_CONNECTIONS=$(curl -s http://127.0.0.1/server-status | head -n 1 | awk '{print $NF}')
REDIS_CONNECTIONS=$(/usr/local/redis/bin/redis-cli info | grep connected_clients | awk -F: '{print $NF}' | sed 's/.$//')
TIMESTAMP=$(date +%s)
echo mobile.openbox.$IDC.$HOST.system.load $SYSTEM_LOAD $TIMESTAMP | nc <host> <port>
echo mobile.openbox.$IDC.$HOST.system.memory $SYSTEM_MEMORY $TIMESTAMP | nc <host> <port>
echo mobile.openbox.$IDC.$HOST.nginx.connections $NGINX_CONNECTIONS $TIMESTAMP | nc <host> <port>
echo mobile.openbox.$IDC.$HOST.redis.connections $REDIS_CONNECTIONS $TIMESTAMP | nc <host> <port>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment