Skip to content

Commit

Permalink
about-me: Add detection of UDP ports
Browse files Browse the repository at this point in the history
  • Loading branch information
markuslf committed Apr 9, 2024
1 parent f07f9ba commit 35ffc7d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Monitoring Plugins:

* \*-version: Add new parameters `--insecure` `--no-proxy` `--timeout`
* about-me: Add detection of PHP Composer
* about-me: Add detection of UDP ports
* about-me: Add new parameters `--insecure` `--no-proxy` `--timeout`
* about-me: Pipes ("|") within the plugin output lead to broken perfdata ([#741](https://github.com/Linuxfabrik/monitoring-plugins/issues/741))
* apache-httpd-status: Add new parameters `--no-proxy` `--timeout`
Expand Down
24 changes: 15 additions & 9 deletions check-plugins/about-me/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Reports an overview about the host dimensions, its network interfaces, deployed
* System information (OS, CPUs, disks, ram, UEFI y/n etc.)
* Python modules: Reports version of installed Python modules some of our checks depend on
* Interfaces: All IPv4 network interfaces with their IP address
* Listening TCP ports
* Listening TCP and UDP ports
* Software installed: Lists well-known packages installed by your package manager
* Software found/guessed: Manually installed software that resides in ``/home``, ``/opt`` and ``/var/www/html``
* Tools: Admin-preferred tools like dig, vim, wget etc. - normally not installed on a minimal server system
Expand Down Expand Up @@ -78,18 +78,24 @@ Full output example:
myhostname: Fedora Linux 36 (Thirty Six) Kernel 6.2.10-100.fc36.x86_64 virtualized on kvm, OpenStack Foundation OpenStack Nova, Firmware: n/a, SerNo: 8259353c-789d-4c63-be49-e246ae23b31c, Proc: pc-i440fx-5.2, #Cores: 2, #Threads: 2, Current Speed: 2000 MHz, 4.0GiB RAM, Disk vda 20G, BIOS boot, born 2022-05-25. Features: iptables, lvm, nftables, selinux. Missing: firewalld. About-me v2023042301
Listening TCP Ports:
* 0.0.0.0:22/tcp4
Listening TCP/UDP Ports:
* [::]:22/tcp6
* 0.0.0.0:22/tcp4
* 127.0.0.1:25/tcp4
* 127.0.0.54:53/tcp4
* 127.0.0.53:53/tcp4
* 0.0.0.0:80/tcp4
* 0.0.0.0:443/tcp4
* [::]:80/tcp6
* [::]:111/tcp6
* 0.0.0.0:111/tcp4
* 0.0.0.0:111/udp4
* [::]:111/udp6
* 127.0.0.1:323/udp4
* [::1]:323/udp6
* [::]:443/tcp6
* 0.0.0.0:3306/tcp4
* [::]:3306/tcp6
* [::]:5355/tcp6
* 0.0.0.0:5355/tcp4
* [::]:5665/tcp6
* 127.0.0.1:6379/tcp4
* [::1]:6379/tcp6
* [::]:9980/tcp6
SW installed:
* Apache httpd 2.4.56
Expand Down
11 changes: 5 additions & 6 deletions check-plugins/about-me/about-me
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ except ImportError:


__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
__version__ = '2024032502'
__version__ = '2024040901'

DESCRIPTION = 'Reports a quick overview about the host dimensions and installed software.'

Expand Down Expand Up @@ -1843,11 +1843,10 @@ def get_listening_ports():
nc = psutil.net_connections('inet')
for c in nc:
ip, port = c.laddr
if c.type == socket.SOCK_DGRAM:
# ignore udp
continue
if c.type == socket.SOCK_STREAM and c.status == psutil.CONN_LISTEN:
proto = 'tcp'
elif c.type == socket.SOCK_DGRAM and c.status == psutil.CONN_NONE:
proto = 'udp'
else:
continue
if c.family == socket.AF_INET:
Expand All @@ -1856,7 +1855,7 @@ def get_listening_ports():
proto += '6'
result.append({
'proto': proto,
'ip': ip if ip != '::' else '[::]',
'ip': '[{}]'.format(ip) if ':' in ip and not ip.startswith('[') and not ip.endswith(']') else ip, # pylint: disable=C0301
'port': port,
})
return sorted(result, key=lambda d: d['port'])
Expand Down Expand Up @@ -2245,7 +2244,7 @@ def main():
msg += 'Interfaces (IPv4):\n{}\n'.format(interfaces)

if ports:
msg += 'Listening TCP Ports:\n'
msg += 'Listening TCP/UDP Ports (sorted by port):\n'
for p in ports:
msg += '* {}:{}/{}\n'.format(p['ip'], p['port'], p['proto'])
msg += '\n'
Expand Down

0 comments on commit 35ffc7d

Please sign in to comment.