Neutron Metering as a Service
1, /etc/neutron/neutron.conf
service_plugins = router,metering
notification_driver=neutron.openstack.common.notifier.rpc_notifier
2, /etc/neutron/metering_agent.ini
debug = True
driver = neutron.services.metering.drivers.iptables.iptables_driver.IptablesMeteringDriver
measure_interval = 10
report_interval = 3330
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
use_namespaces = True
3, restart neutron-server and neutron-metering-agent
neutron meter-label-rule-create outgoingnet 10.8.0.0/24 --direction egress
neutron meter-label-rule-create incomingnet 10.8.0.0/24 --direction ingress --excluded
这样会生成下列iptables规则,然后可以使用sudo iptables -L -vn -x查看。
-I FORWARD -s 10.8.0.0 #egress
-I FORWARD -d 10.8.0.0 -j RETURN # ingress
注意,在neutron里需要在namespace里查看:
ip netns exec qrouter-77dcb0af-2743-46ce-bf91-a41ac3f3afc1 iptables -t filter -L neutron-meter-FORWARD -vn -x
4, ceilometer,
ceilometer statistics --meter bandwidth --period 60 -q 'resource_id=<meter-label-rule-id>'
本文转载自http://blog.csdn.net/quqi99
-------------------------
No pains, no gains