From cee1891753fa9e915f63fd421ccb778cb015630f Mon Sep 17 00:00:00 2001 From: Steven Cooney Date: Fri, 2 Feb 2018 20:39:23 +0000 Subject: [PATCH] Add monitoring flag for Digital Ocean droplets Digital Ocean now has the functionality for more extensive monitoring of droplets, which includes the ability to set alerts for droplets. These new features only work if a monitoring script is run on the droplet upon startup, fortunately the Digital Ocean API allows for a flag to be passed through (similar to how `private networking` is switched on) that pre-installs the monitoring script allowing the more in-depth monitoring. I have simply added this flag to `docker-machine`. Signed-off-by: Steven Cooney --- drivers/digitalocean/digitalocean.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/digitalocean/digitalocean.go b/drivers/digitalocean/digitalocean.go index d42c936f..8b8d89d2 100644 --- a/drivers/digitalocean/digitalocean.go +++ b/drivers/digitalocean/digitalocean.go @@ -35,6 +35,7 @@ type Driver struct { Backups bool PrivateNetworking bool UserDataFile string + Monitoring bool Tags string } @@ -115,6 +116,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Name: "digitalocean-userdata", Usage: "path to file with cloud-init user-data", }, + mcnflag.BoolFlag{ + EnvVar: "DIGITALOCEAN_MONITORING", + Name: "digitalocean-monitoring", + Usage: "enable monitoring for droplet", + }, mcnflag.StringFlag{ EnvVar: "DIGITALOCEAN_TAGS", Name: "digitalocean-tags", @@ -157,6 +163,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.SSHPort = flags.Int("digitalocean-ssh-port") d.SSHKeyFingerprint = flags.String("digitalocean-ssh-key-fingerprint") d.SSHKey = flags.String("digitalocean-ssh-key-path") + d.Monitoring = flags.Bool("digitalocean-monitoring") d.Tags = flags.String("digitalocean-tags") d.SetSwarmConfigFromFlags(flags) @@ -232,6 +239,7 @@ func (d *Driver) Create() error { Backups: d.Backups, UserData: userdata, SSHKeys: []godo.DropletCreateSSHKey{{ID: d.SSHKeyID}}, + Monitoring: d.Monitoring, Tags: d.getTags(), }