status.netstats: add OpenBSD support

the previously freebsd-specific function is now an alias for the generic
bsd function.

while here fix a formatting nit where keys would contain a trailing ':':

    udp::
        ----------
        [...]

now properly becomes:

    udp:
        ----------
        [...]
This commit is contained in:
Jasper Lievisse Adriaanse 2017-12-04 21:36:06 +01:00 committed by Jasper Lievisse Adriaanse
parent 374d1ef4f8
commit 2fb61edbdf
No known key found for this signature in database
GPG Key ID: 3C7E42C828FDBDB5

View File

@ -1054,6 +1054,9 @@ def netstats():
.. versionchanged:: 2016.11.4
Added support for AIX
.. versionchanged:: Oxygen
Added support for OpenBSD
CLI Example:
.. code-block:: bash
@ -1091,15 +1094,18 @@ def netstats():
return ret
def freebsd_netstats():
return bsd_netstats()
def bsd_netstats():
'''
freebsd specific netstats implementation
bsd specific netstats implementation
'''
ret = {}
for line in __salt__['cmd.run']('netstat -s').splitlines():
if line.startswith('\t\t'):
continue # Skip, too detailed
if not line.startswith('\t'):
key = line.split()[0]
key = line.split()[0].replace(':', '')
ret[key] = {}
else:
comps = line.split()
@ -1159,7 +1165,8 @@ def netstats():
# dict that returns a function that does the right thing per platform
get_version = {
'Linux': linux_netstats,
'FreeBSD': freebsd_netstats,
'FreeBSD': bsd_netstats,
'OpenBSD': bsd_netstats,
'SunOS': sunos_netstats,
'AIX': aix_netstats,
}