Created
June 1, 2016 00:28
-
-
Save tcotav/fcf305bb22be3136a5bd55f5ce9ca4e1 to your computer and use it in GitHub Desktop.
retrofit nrpe to CoreOS hosts
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 | |
| # pattern match for targeting | |
| MATCH="-kubenode-" | |
| # location of the google cloud sdk | |
| GCLOUD=~/google-cloud-sdk/bin/gcloud | |
| for i in $(${GCLOUD} compute instances list | grep ${MATCH} | cut -d " " -f 1);do | |
| # gcloud compute instances stop $i | |
| $GCLOUD compute ssh $i "sudo bash -c 'cat <<EOF > /etc/systemd/system/nrpe.service | |
| [Unit] | |
| Description=Nagios NRPE | |
| After=docker.service | |
| [Service] | |
| Restart=always | |
| ExecStartPre=-/usr/bin/docker stop totem/docker-nrpe | |
| ExecStartPre=-/usr/bin/docker rm totem/docker-nrpe | |
| ExecStartPre=/usr/bin/docker pull totem/docker-nrpe | |
| ExecStart=docker run --privileged -v /:/mnt/ROOT --rm --name nrpe -it -p 5666:5666 totem/docker-nrpe | |
| ExecStop=/usr/bin/docker stop -t 2 totem/docker-nrpe | |
| EOF' " | |
| $GCLOUD compute ssh $i "sudo systemctl start nrpe" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment