dnl ovs-vswitchd detached OK or we wouldn't have made it this far. Success.
AT_CLEANUP
+
+
+dnl ----------------------------------------------------------------------
+m4_define([OVS_VSCTL_CHECK_RX_PKT], [
+AT_CHECK([ovs-vsctl list int $1 | grep statistics | sed -n 's/^.*\(rx_packets=[[0-9]]\+\).*$/\1/p'],[0],
+[dnl
+rx_packets=$2
+])
+])
+
+AT_SETUP([ovs-vswitchd -- stats-update-interval])
+OVS_VSWITCHD_START([add-port br0 p1 -- set int p1 type=internal])
+ovs-appctl time/stop
+
+dnl at the beginning, the udpate of rx_packets should happen every 5 seconds.
+for i in `seq 0 10`; do ovs-appctl time/warp 1000; done
+OVS_VSCTL_CHECK_RX_PKT([p1], [0])
+AT_CHECK([ovs-appctl netdev-dummy/receive p1 'eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
+for i in `seq 0 10`; do ovs-appctl time/warp 1000; done
+OVS_VSCTL_CHECK_RX_PKT([p1], [1])
+
+dnl set the stats update interval to 100K ms, the following 'recv' should not be updated.
+AT_CHECK([ovs-vsctl set O . other_config:stats-update-interval=100000])
+for i in `seq 0 50`; do ovs-appctl time/warp 1000; done
+for i in `seq 1 5`; do
+ AT_CHECK([ovs-appctl netdev-dummy/receive p1 'eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
+done
+
+OVS_VSCTL_CHECK_RX_PKT([p1], [1])
+dnl advance the clock by 100K ms, the previous 'recv' should be updated.
+for i in `seq 0 99`; do ovs-appctl time/warp 1000; done
+OVS_VSCTL_CHECK_RX_PKT([p1], [6])
+
+dnl now remove the configuration. 'recv' one packet. there should be an update after 5000 ms.
+AT_CHECK([ovs-vsctl clear O . other_config])
+AT_CHECK([ovs-appctl netdev-dummy/receive p1 'eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
+for i in `seq 0 10`; do ovs-appctl time/warp 1000; done
+OVS_VSCTL_CHECK_RX_PKT([p1], [7])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
\ No newline at end of file
/* Each time this timer expires, the bridge fetches interface and mirror
* statistics and pushes them into the database. */
-#define IFACE_STATS_INTERVAL (5 * 1000) /* In milliseconds. */
-static long long int iface_stats_timer = LLONG_MIN;
+static int stats_timer_interval;
+static long long int stats_timer = LLONG_MIN;
/* Set to true to allow experimental use of OpenFlow 1.4.
* This is false initially because OpenFlow 1.4 is not yet safe to use: it can
bool vlan_splinters_changed;
struct bridge *br;
+ int stats_interval;
ovsrec_open_vswitch_init(&null_cfg);
}
}
+ /* Statistics update interval should always be greater than or equal to
+ * 5000 ms. */
+ stats_interval = MAX(smap_get_int(&cfg->other_config,
+ "stats-update-interval", 5000), 5000);
+ if (stats_timer_interval != stats_interval) {
+ stats_timer_interval = stats_interval;
+ stats_timer = LLONG_MIN;
+ }
+
/* Refresh interface and mirror stats if necessary. */
- if (time_msec() >= iface_stats_timer) {
+ if (time_msec() >= stats_timer) {
if (cfg) {
struct ovsdb_idl_txn *txn;
ovsdb_idl_txn_destroy(txn); /* XXX */
}
- iface_stats_timer = time_msec() + IFACE_STATS_INTERVAL;
+ stats_timer = time_msec() + stats_timer_interval;
}
if (!status_txn) {
HMAP_FOR_EACH (br, node, &all_bridges) {
ofproto_wait(br->ofproto);
}
- poll_timer_wait_until(iface_stats_timer);
+
+ poll_timer_wait_until(stats_timer);
}
/* If the status database transaction is 'TXN_INCOMPLETE' in this run,
host as displayed by <code>xe host-list</code>.
</column>
+ <column name="other_config" key="stats-update-interval"
+ type='{"type": "integer", "minInteger": 5000}'>
+ <p>
+ Interval for updating statistics to the database, in milliseconds.
+ This option will affect the update of the <code>statistics</code>
+ column in the following tables: <code>Port</code>, <code>Interface
+ </code>, <code>Mirror</code>.
+ </p>
+ <p>
+ Default value is 5000 ms.
+ </p>
+ <p>
+ Getting statistics more frequently can be achieved via OpenFlow.
+ </p>
+ </column>
+
<column name="other_config" key="flow-restore-wait"
type='{"type": "boolean"}'>
<p>
<group title="Port Statistics">
<p>
- Key-value pairs that report port statistics.
+ Key-value pairs that report port statistics. The update period
+ is controlled by <ref column="other_config"
+ key="stats-update-interval"/> in the <code>Open_vSwitch</code> table.
</p>
<group title="Statistics: STP transmit and receive counters">
<column name="statistics" key="stp_tx_count">
<group title="Statistics">
<p>
Key-value pairs that report interface statistics. The current
- implementation updates these counters periodically. Future
- implementations may update them when an interface is created, when they
- are queried (e.g. using an OVSDB <code>select</code> operation), and
- just before an interface is deleted due to virtual interface hot-unplug
- or VM shutdown, and perhaps at other times, but not on any regular
- periodic basis.
+ implementation updates these counters periodically. The update period
+ is controlled by <ref column="other_config"
+ key="stats-update-interval"/> in the <code>Open_vSwitch</code> table.
+ Future implementations may update them when an interface is created,
+ when they are queried (e.g. using an OVSDB <code>select</code>
+ operation), and just before an interface is deleted due to virtual
+ interface hot-unplug or VM shutdown, and perhaps at other times, but
+ not on any regular periodic basis.
</p>
<p>
These are the same statistics reported by OpenFlow in its <code>struct
<group title="Statistics: Mirror counters">
<p>
- Key-value pairs that report mirror statistics.
+ Key-value pairs that report mirror statistics. The update period
+ is controlled by <ref column="other_config"
+ key="stats-update-interval"/> in the <code>Open_vSwitch</code> table.
</p>
<column name="statistics" key="tx_packets">
Number of packets transmitted through this mirror.