Skip to content

Instantly share code, notes, and snippets.

@davidonet
Created December 21, 2016 09:26
Show Gist options
  • Save davidonet/6d7554bd8bbb0a263a2d41d5b7481f3c to your computer and use it in GitHub Desktop.
Save davidonet/6d7554bd8bbb0a263a2d41d5b7481f3c to your computer and use it in GitHub Desktop.
Log cpuload and memory usage to graylog2 server using udp
#!/bin/bash
load=`cat /proc/loadavg | awk '{print $1}'`
mem=`free -o | awk 'NR==2{print $3}'`
echo '{"version": "1.1","host":"'$HOSTNAME'","short_message":"cpumem","level":4,"_load":'$load',"_mem":'$mem'}' | nc -c -w1 -u graylog.server 12201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment