summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-12-26 10:01:22 +0100
committerChristian Poessinger <christian@poessinger.com>2021-12-26 10:01:32 +0100
commitde28cb2036af6e7786ff54f1732d3a33439442e8 (patch)
treef4da920b3bfdc7ba37c37c4174fd66644476d406
parent3854031667c397412d04697509f02b097e401e9a (diff)
downloadvyos-1x-de28cb2036af6e7786ff54f1732d3a33439442e8.tar.gz
vyos-1x-de28cb2036af6e7786ff54f1732d3a33439442e8.zip
flow-accounting: T4097: move configuration file to /run
-rw-r--r--data/templates/netflow/uacctd.conf.tmpl4
-rwxr-xr-xsmoketest/scripts/cli/test_system_flow-accounting.py2
-rwxr-xr-xsrc/conf_mode/flow_accounting_conf.py6
-rw-r--r--src/etc/systemd/system/uacctd.service.d/override.conf14
4 files changed, 22 insertions, 4 deletions
diff --git a/data/templates/netflow/uacctd.conf.tmpl b/data/templates/netflow/uacctd.conf.tmpl
index b6d31746f..f81002dc1 100644
--- a/data/templates/netflow/uacctd.conf.tmpl
+++ b/data/templates/netflow/uacctd.conf.tmpl
@@ -1,7 +1,7 @@
# Genereated from VyOS configuration
daemonize: true
promisc: false
-pidfile: /var/run/uacctd.pid
+pidfile: /run/pmacct/uacctd.pid
uacctd_group: 2
uacctd_nl_size: 2097152
snaplen: {{ packet_length }}
@@ -54,6 +54,7 @@ nfprobe_source_ip[nf_{{ server }}]: {{ netflow.source_address }}
{% if netflow.timeout is defined and netflow.timeout is not none %}
nfprobe_timeouts[nf_{{ server }}]: expint={{ netflow.timeout.expiry_interval }}:general={{ netflow.timeout.flow_generic }}:icmp={{ netflow.timeout.icmp }}:maxlife={{ netflow.timeout.max_active_life }}:tcp.fin={{ netflow.timeout.tcp_fin }}:tcp={{ netflow.timeout.tcp_generic }}:tcp.rst={{ netflow.timeout.tcp_rst }}:udp={{ netflow.timeout.udp }}
{% endif %}
+
{% endfor %}
{% endif %}
@@ -68,5 +69,6 @@ sampling_rate[sf_{{ server }}]: {{ sflow.sampling_rate }}
{% if sflow.source_address is defined and sflow.source_address is not none %}
sfprobe_source_ip[sf_{{ server }}]: {{ sflow.source_address }}
{% endif %}
+
{% endfor %}
{% endif %}
diff --git a/smoketest/scripts/cli/test_system_flow-accounting.py b/smoketest/scripts/cli/test_system_flow-accounting.py
index b8639954b..a53999461 100755
--- a/smoketest/scripts/cli/test_system_flow-accounting.py
+++ b/smoketest/scripts/cli/test_system_flow-accounting.py
@@ -27,7 +27,7 @@ from vyos.util import read_file
PROCESS_NAME = 'uacctd'
base_path = ['system', 'flow-accounting']
-uacctd_conf = '/etc/pmacct/uacctd.conf'
+uacctd_conf = '/run/pmacct/uacctd.conf'
class TestSystemFlowAccounting(VyOSUnitTestSHIM.TestCase):
@classmethod
diff --git a/src/conf_mode/flow_accounting_conf.py b/src/conf_mode/flow_accounting_conf.py
index 74d304493..e01f3066b 100755
--- a/src/conf_mode/flow_accounting_conf.py
+++ b/src/conf_mode/flow_accounting_conf.py
@@ -34,7 +34,7 @@ from vyos import ConfigError
from vyos import airbag
airbag.enable()
-uacctd_conf_path = '/etc/pmacct/uacctd.conf'
+uacctd_conf_path = '/run/pmacct/uacctd.conf'
iptables_nflog_table = 'raw'
iptables_nflog_chain = 'VYATTA_CT_PREROUTING_HOOK'
egress_iptables_nflog_table = 'mangle'
@@ -252,8 +252,10 @@ def apply(flow_config):
_iptables_config([], 'ingress')
_iptables_config([], 'egress')
- # Stop flow-accounting daemon
+ # Stop flow-accounting daemon and remove configuration file
cmd('systemctl stop uacctd.service')
+ if os.path.exists(uacctd_conf_path):
+ os.unlink(uacctd_conf_path)
return
# Start/reload flow-accounting daemon
diff --git a/src/etc/systemd/system/uacctd.service.d/override.conf b/src/etc/systemd/system/uacctd.service.d/override.conf
new file mode 100644
index 000000000..38bcce515
--- /dev/null
+++ b/src/etc/systemd/system/uacctd.service.d/override.conf
@@ -0,0 +1,14 @@
+[Unit]
+After=
+After=vyos-router.service
+ConditionPathExists=
+ConditionPathExists=/run/pmacct/uacctd.conf
+
+[Service]
+EnvironmentFile=
+ExecStart=
+ExecStart=/usr/sbin/uacctd -f /run/pmacct/uacctd.conf
+WorkingDirectory=
+WorkingDirectory=/run/pmacct
+PIDFile=
+PIDFile=/run/pmacct/uacctd.pid