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 ‘gaugedb’ for 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 = {'db': None, 'interval': 30, 'db_ip': '', 'influx_pwd': '', 'db_update_counter': 0, 'db_password': '', 'prometheus_port': 9303, 'type': None, 'compress': False, 'influx_host': 'localhost', 'file': None, 'driver': '', 'name': None, 'db_type': 'text', 'db_port': 0, 'influx_db': 'faucet', 'influx_timeout': 10, 'dps': None, 'influx_retries': 3, 'db_username': '', 'prometheus_addr': '127.0.0.1', 'gdb_type': '', 'all_dps': False, 'views': {}, 'switches_doc': '', 'flows_doc': '', 'influx_port': 8086, 'influx_user': '', 'nosql_db': ''}
dp = None
prom_client = None