Enable HTTPS on influxdb for debian

To enable HTTPS on influxdb for debian do the following.

Get a certificate. Easy way is to let debian do it for you. The ssl-cert package will generate a self signed cert.

apt-get install ssl-cert

Now pipe the key and pem to somewhere influxdb can get to it.ย 

cat /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem > /etc/influxdb/influxdb.pem

Then turn on https in your /etc/influxdb/influxdb.conf and point to your new pem.

vi /etc/influxdb/influxdb.conf
[admin]
  enabled = true
  bind-address = ":8083"
  https-enabled = true
  https-certificate = "/etc/influxdb/influxdb.pem"

[http]
  enabled = true
  bind-address = ":8086"
  auth-enabled = true
  log-enabled = true
  write-tracing = false
  pprof-enabled = false
  https-enabled = true
  https-certificate = "/etc/influxdb/influxdb.pem"

Start up influxdb and you’re done.

service influxdb restart

 

Bash: Run command if exists, else echo blank

Useful if you want to only output something if aย command exists.

if $(type YOUR_COMMAND &> /dev/null); then RUN_YOUR_COMMAND; else echo ""; fi

For example, I use this on my Proxmox hypervisors with ZFS to get status. Not all my hypervisors have zfs arrays. Makes it easy to blanket ssh to all hypervisors and get zfs status if it exists. For a custom status page I wrote.

if $(type zpool &> /dev/null); then zpool list; else echo ""; fi