faucet.watcher_conf module

Gauge watcher configuration.

class faucet.watcher_conf.WatcherConf(_id, dp_id, conf, prom_client)[source]

Bases: faucet.conf.Conf

Stores the state and configuration to monitor a single stat.

Watcher Config

Watchers are configured in the watchers config block in the config for gauge.

The following elements can be configured for each watcher, at the level of /watchers/<watcher name>/:

  • type (string): The type of watcher (IE what stat this watcher monitors). The types are ‘port_state’, ‘port_stats’ or ‘flow_table’.
  • dps (list): A list of dps that should be monitored with this watcher.
  • db (string): The db that will be used to store the data once it is retreived.
  • interval (int): if this watcher requires polling the switch, it will monitor at this interval.

The config for a db should be created in the gauge config file under the dbs config block.

The following elements can be configured for each db, at the level of /dbs/<db name>/:

  • type (string): the type of db. The available types are ‘text’ and ‘influx’ for port_state, ‘text’, ‘influx’and ‘prometheus’ for port_stats and ‘text’ and flow_table.

The following config elements then depend on the type. For text:

  • file (string): the filename of the file to write output to.
  • compress (bool): compress (with gzip) flow_table output while writing it
For influx:
  • influx_db (str): The name of the influxdb database. Defaults to ‘faucet’.
  • influx_host (str): The host where the influxdb is reachable. Defaults to ‘localhost’.
  • influx_port (int): The port that the influxdb host will listen on. Defaults to 8086.
  • influx_user (str): The username for accessing influxdb. Defaults to ‘’.
  • influx_pwd (str): The password for accessing influxdb. Defaults to ‘’.
  • influx_timeout (int): The timeout in seconds for connecting to influxdb. Defaults to 10.
  • influx_retries (int): The number of times to retry connecting to influxdb after failure. Defaults to 3.
For Prometheus:
  • prometheus_port (int): The port used to export prometheus data. Defaults to 9303.
  • prometheus_addr (ip addr str): The address used to export prometheus data. Defaults to ‘127.0.0.1’.
add_db(db_conf)[source]

Add database config to this watcher.

add_dp(dp)[source]

Add a datapath to this watcher.

all_dps = None
db = None
defaults = {'all_dps': False, 'compress': False, 'db': None, 'db_type': 'text', 'dbs': None, 'dps': None, 'file': None, 'influx_db': 'faucet', 'influx_host': 'localhost', 'influx_port': 8086, 'influx_pwd': '', 'influx_retries': 3, 'influx_timeout': 10, 'influx_user': '', 'interval': 30, 'name': None, 'prometheus_addr': '127.0.0.1', 'prometheus_port': 9303, 'prometheus_test_thread': False, 'type': None}
defaults_types = {'all_dps': <class 'bool'>, 'compress': <class 'bool'>, 'db': <class 'str'>, 'db_type': <class 'str'>, 'dbs': <class 'list'>, 'dps': <class 'list'>, 'file': <class 'str'>, 'influx_db': <class 'str'>, 'influx_host': <class 'str'>, 'influx_port': <class 'int'>, 'influx_pwd': <class 'str'>, 'influx_retries': <class 'int'>, 'influx_timeout': <class 'int'>, 'influx_user': <class 'str'>, 'interval': <class 'int'>, 'name': <class 'str'>, 'prometheus_addr': <class 'str'>, 'prometheus_port': <class 'int'>, 'prometheus_test_thread': <class 'bool'>, 'type': <class 'str'>}
dp = None
prom_client = None