Last active
December 8, 2015 23:10
-
-
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.
This file contains hidden or 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 | |
| # 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