Skip to content

Instantly share code, notes, and snippets.

@n0coast
Last active December 8, 2015 23:10
Show Gist options
  • Select an option

  • Save n0coast/b079999f67dd35d42347 to your computer and use it in GitHub Desktop.

Select an option

Save n0coast/b079999f67dd35d42347 to your computer and use it in GitHub Desktop.
Newrelic docker rollup doesn't happen unless the newrelic server agent is restarted, this super basic script creates checks if the running containers differ from a previous run and restarts newrelic-sysmond if they have. Only tested on RHEL, not all errors handled.
#!/bin/bash
# define location to dump docker/md5sum output
dockerSum="/tmp/dockerSum.out"
# Verify that docker and newrelic agent are running
isRunning=$(systemctl is-active newrelic-sysmond.service docker.service)
active="active
active"
[[ $isRunning != $active ]] && exit 1;
# get md5sum from last run, ignore errors if the file doesn't exist
dockerLast=$(cat $dockerSum 2> /dev/null)
# create md5sum from list of docker containers, put it in the dockerSum
# file for use on next run, and assign it do the dockerNow variable
dockerNow=$(docker ps -q|md5sum|tee ${dockerSum})
# compare md5sums
[ "$dockerLast" != "$dockerNow" ] && { systemctl restart newrelic-sysmond.service || exit; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment