docs: def _monitor(last_ping, stop_plugin, is_shutting_down, timeout=5):
      """Monitors health checks (pings) from the Snap framework.
  
      If the plugin doesn't receive 3 consecutive health checks from Snap the
      plugin will shutdown.  The default timeout is set to 5 seconds.
      """
      _timeout_count = 0
      _last_check = time.time()
      _sleep_interval = 1
      # set _sleep_interval if less than the timeout
      if timeout < _sleep_interval:
          _sleep_interval = timeout
      while True:
          time.sleep(_sleep_interval)
          # Signals that stop_plugin has been called
          if is_shutting_down():
              return
          # have we missed a ping during the last timeout duration
          if ((time.time() - _last_check) > timeout) and ((time.time() - last_ping()) > timeout):
              # reset last_check
              _last_check = time.time()
              _timeout_count += 1
              LOG.warning("Missed ping health check from the framework. " +
                          "({} of 3)".format(_timeout_count))
              if _timeout_count >= 3:
                  stop_plugin()
                  return
          elif (time.time() - last_ping()) <= timeout:
              _timeout_count = 0