diff --git a/CHANGELOG.md b/CHANGELOG.md index ba242f2e..b4f309a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,8 +48,7 @@ Icinga Director: 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 detection of non-default software, udp ports, hardware and much more * 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` diff --git a/check-plugins/about-me/README.rst b/check-plugins/about-me/README.rst index ffa8e522..4be17ee8 100644 --- a/check-plugins/about-me/README.rst +++ b/check-plugins/about-me/README.rst @@ -6,20 +6,17 @@ Overview Reports an overview about the host dimensions, its network interfaces, deployed software and recurring jobs: -* 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 +* System and hardware information (OS, CPUs, disks, ram, UEFI y/n etc.) +* Interfaces: All network interfaces with their IP address * 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 +* Non-default software (software that was added later) * Non-default system users * systemctl get-default: Default systemd target that will be booted into -* systemctl List-unit-files: List of all systemd system units (excluding user units) -* systemctl List-timers: List of all system systemd timers (excluding user timers) -* crontab: List of crontabs that are found in the usual locations. note that this list is not complete +* systemctl list-unit-files: List of all systemd services, mounts and automounts (excluding user units) +* systemctl list-timers: List of all system systemd timers (excluding user timers) +* crontab: List of crontabs that are found in the usual locations. Note that this might not be complete. -Have a look at the output examples below. +Have a look at the output example below. Plugin execution may take up to 30 seconds, depending on the amount or type of installed software. @@ -72,168 +69,79 @@ Usage Examples ./about-me -Full output example: +Shortened output example: .. code-block:: text - 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 + Plugin Output + server.example.com: Rocky Linux 8.9 (Green Obsidian) Kernel 4.18.0-513.24.1.el8_9.x86_64 virtualized on kvm, Hetzner vServer, Firmware: n/a, SerNo: 53d68114, Proc: n/a, #Cores: 2, #Threads: 1, Current Speed: 2000 MHz, 3.9GiB RAM, Disk sda 38.2G, BIOS boot, tuned profile "virtual-guest kernel_settings", born 2022-08-29. About-me v2024041001 - Listening TCP/UDP Ports: - * [::]:22/tcp6 - * 0.0.0.0:22/tcp4 + Hardware Info: + * BIOS: Hetzner, Ver 20171111 (released 11/11/2017), ROM 64 kB + * SysInfo: Hetzner vServer, SerNo 53d68114, SKU N/A, Wake-up Type "Power Switch", + UUID 9f1b2152-78bc-4b49-9c7b-ea441e9edd41 + * Base Board: Type Motherboard KVM Standard PC (i440FX + PIIX, 1996), SerNo Not Specified, Ver pc-i440fx-4.2 + * Chassis: QEMU, Type Other, SKU N/A, SerNo Not Specified + States: boot-up=Safe, pwr-supply=Safe, thermal=Safe, security=Unknown + * Proc: QEMU, Ver NotSpecified, + Speed 2000 MHz/2000 MHz max., 2/2 Cores enabled, 1 Thread, Voltage Unknown + * System Boot: No errors detected + + Interfaces (IPv4): + * ens10 192.0.2.6/32 + + Listening TCP/UDP Ports (ordered by port, proto, ip): * 127.0.0.1:25/tcp4 * [::]:80/tcp6 - * [::]:111/tcp6 * 0.0.0.0:111/tcp4 + * [::]:111/tcp6 * 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 - * [::]:5665/tcp6 - * 127.0.0.1:6379/tcp4 - * [::1]:6379/tcp6 - * [::]:9980/tcp6 - - SW installed: - * Apache httpd 2.4.56 - * chronyd 4.3 - * duplicity 0.8.23 - * FreeIPA 4.9.11 - * gcc 12.2.1 - * Git 2.39.2 - * Glances 3.3.1 - * gpg (GnuPG) 2.3.7 - * Icinga2 r2.13.6-1 - * Linux Kernel 6.2.10-100.fc36.x86_64 - * MariaDB 10.5.18-MariaDB - * Node 16.17.1 - * npm 8.15.0 - * OpenSSL 3.0.8 - * Perl 5.34.1 - * PHP 7.4.33 - * PHP-FPM 7.4.33 - * pip 21.3.1 - * Postfix 3.6.4 - * Python 3.10.10 - * `python` cmd mapped to 3.10.10 - * `python3` cmd mapped to 3.10.10 - * QEMU Guest Agent 6.2.0 - * ssh 8.8p1 - * sudo 1.9.13p2 - * systemd 250 - - SW found/guessed: - * Firewall Builder - * mod_security - - Tools: - * dig - * hdparm - * iftop - * lsof - * nano - * rsync - * tmux - * vim - * wget + + Non-default Software (ordered by name): + name ! version ! from_repo ! installtime + -------------------+------------+----------------------------------------+------------------ + at ! 3.1.20 ! baseos ! 2022-12-07 07:18 + bash-completion ! 2.7 ! baseos ! 2022-10-04 09:59 + bzip2 ! 1.0.6 ! baseos ! 2022-10-04 11:40 + chrony ! 4.2 ! baseos ! 2022-12-07 07:17 + yum-utils ! 4.0.21 ! baseos ! 2023-11-28 03:21 + zstd ! 1.4.4 ! appstream ! 2023-08-29 08:02 Non-default Users: - user ! pw ! uid ! gid ! comment ! home_dir ! user_shell - ------------+----+------+------+-------------------+--------------------+--------------- - apache ! x ! 48 ! 48 ! Apache ! /usr/share/httpd ! /sbin/nologin - icinga ! x ! 993 ! 991 ! icinga ! /var/spool/icinga2 ! /sbin/nologin - linuxfabrik ! x ! 1000 ! 1000 ! fedora Cloud User ! /home/linuxfabrik ! /bin/bash - mysql ! x ! 27 ! 27 ! MySQL Server ! /var/lib/mysql ! /sbin/nologin - nginx ! x ! 992 ! 988 ! Nginx web server ! /var/lib/nginx ! /sbin/nologin - postfix ! x ! 89 ! 89 ! ! /var/spool/postfix ! /sbin/nologin + user ! pw ! uid ! gid ! comment ! home_dir ! user_shell + ------------+----+------+------+---------------------------+--------------------+--------------- + apache ! x ! 48 ! 48 ! Apache ! /usr/share/httpd ! /sbin/nologin + postfix ! x ! 89 ! 89 ! ! /var/spool/postfix ! /sbin/nologin + redis ! x ! 991 ! 986 ! Redis Database Server ! /var/lib/redis ! /sbin/nologin systemctl get-default: * multi-user.target - systemctl list-unit-files --type service --state enabled: + systemctl list-unit-files --type=service --state=enabled: * atd.service * auditd.service - * bluetooth.service + * autovt@.service * chronyd.service - * dbus-broker.service - * fwb.service - * getty@.service - * httpd.service - * icinga2.service - * import-state.service - * lvm2-monitor.service - * mariadb.service - * mdmonitor.service - * NetworkManager-dispatcher.service - * NetworkManager-wait-online.service - * NetworkManager.service - * nfs-convert.service - * nis-domainname.service - * oddjobd.service - * php-fpm.service - * postfix.service - * qemu-guest-agent.service - * rngd.service - * rpmdb-rebuild.service - * selinux-autorelabel-mark.service - * sshd.service - * sssd.service - * supervisord.service - * systemd-homed-activate.service - * systemd-homed.service - * systemd-oomd.service - * systemd-resolved.service - * udisks2.service - - systemctl list-unit-files --type mount --state static --state generated: + + systemctl list-unit-files --type=mount --state=static --state=generated: * -.mount - * boot.mount - * data.mount + * boot-efi.mount * dev-hugepages.mount - * dev-mqueue.mount - * home.mount - * proc-fs-nfsd.mount - * sys-fs-fuse-connections.mount - * sys-kernel-config.mount - * sys-kernel-debug.mount - * sys-kernel-tracing.mount - * tmp.mount - * var-lib-nfs-rpc_pipefs.mount - * var-log-audit.mount - * var-log.mount - * var-tmp.mount - * var.mount - - systemctl list-unit-files --type automount --state enabled --state static: + + systemctl list-unit-files --type=automount --state=enabled --state=static: * proc-sys-fs-binfmt_misc.automount systemctl list-timers: - unit ! activates ! next - -----------------------------+--------------------------------+------------------------------ - systemd-tmpfiles-clean.timer ! systemd-tmpfiles-clean.service ! Sat 2023-09-02 05:22:46 CEST - unbound-anchor.timer ! unbound-anchor.service ! Sat 2023-09-02 00:00:00 CEST - wordpress-cron.timer ! wordpress-cron.service ! Fri 2023-09-01 10:15:00 CEST - - 3rd-party Python libs required by any of the plugins when running in source code variant: - * Installed: psutil 5.8.0, pymysql.cursors 0.10.1 - * Missing: bs4, pysmbclient, smbprotocol.exceptions, vici - - Guessed Tags: - * apache-httpd - * chronyd - * duplicity - * fwbuilder - * OS: Fedora Linux 36 (Thirty Six), family "RedHat" - * mariadb* / mysql* - * mod_qos - * php - * php-fpm - * pip - * postfix-mta - * system-update + unit ! activates ! next + -----------------------------------+--------------------------------+------------------------------ + fstrim.timer ! fstrim.service ! Mon 2024-04-15 01:07:55 CEST + systemd-tmpfiles-clean.timer ! systemd-tmpfiles-clean.service ! Thu 2024-04-11 04:35:37 CEST + unbound-anchor.timer ! unbound-anchor.service ! Thu 2024-04-11 00:00:00 CEST + + crontab: + 01 * * * * root run-parts /etc/cron.hourly + 0 1 * * Sun root /usr/sbin/raid-check States diff --git a/check-plugins/about-me/about-me b/check-plugins/about-me/about-me index f2309c79..a48c454f 100755 --- a/check-plugins/about-me/about-me +++ b/check-plugins/about-me/about-me @@ -40,9 +40,9 @@ except ImportError: __author__ = 'Linuxfabrik GmbH, Zurich/Switzerland' -__version__ = '2024040901' +__version__ = '2024041001' -DESCRIPTION = 'Reports a quick overview about the host dimensions and installed software.' +DESCRIPTION = 'Reports a quick overview about the host dimensions and ยง software.' DEFAULT_INSECURE = False DEFAULT_NO_PROXY = False @@ -111,1670 +111,15 @@ def parse_args(): return parser.parse_args() -def find_software(): # pylint: disable=R0915 - """Find software and some capabilities on the system. - * display-name: Display name. If you omit display-name, it means that you just want the tags. - * tag-name: Host Tag for your monitoring software - * guessed: Location found, but can't say anything more - * installed: System call was successful, so software has been somehow installed - * version: the version string - """ - s = {} # sorted by s['keyname'] - - output = run_cmd('/opt/acme.sh/acme.sh --version') - s['acme.sh'] = { - 'display-name': 'acme.sh', - 'tag-name': 'acme.sh', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'v(.*)') if output is not False else None, - } - - output = run_cmd('aide --version') - s['aide'] = { - 'display-name': 'Aide', - 'tag-name': 'aide', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'de (.*)') if output is not False else None, - } - - output = run_cmd('anydesk --version') - s['anydesk'] = { - 'display-name': 'AnyDesk', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'(.*)') if output is not False else None, - } - - output = run_cmd('command -v cockpit-bridge') - s['cockpit'] = { - 'display-name': 'Cockpit', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - output = run_cmd('httpd -v') - s['apache-httpd'] = { - 'display-name': 'Apache httpd', - 'tag-name': 'apache-httpd', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'/(\d+\.\d+\.\d+)') if output is not False else None, - } - - if 'apache-httpd' not in s: - output = run_cmd('apache2 -v') - s['apache-httpd'] = { - 'display-name': 'Apache httpd', - 'tag-name': 'apache-httpd', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'/(\d+\.\d+\.\d+)') if output is not False else None, - } - - output = run_cmd('solr version') - s['apache-solr'] = { - 'display-name': 'Apache Solr', - 'tag-name': 'apache-solr', - 'guessed': os.path.isdir('/opt/apache-solr') or os.path.isdir('/opt/solr'), - 'installed': output is not False, - 'version': run_regex(output, r': (.*)') if output is not False else None, # pylint: disable=C0301 - } - - output = run_cmd('tomcat version') - s['apache-tomcat'] = { - 'display-name': 'Apache Tomcat', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/apache-tomcat') or os.path.isdir('/opt/tomcat'), - 'installed': output is not False, - 'version': run_regex(output, r'Server version: Apache Tomcat/(.*)') if output is not False else None, # pylint: disable=C0301 - } - - s['atlassian-bitbucket'] = { - 'display-name': 'Atlassian Bitbucket', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/atlassian/bitbucket'), - 'installed': False, - 'version': None, - } - - s['atlassian-confluence'] = { - 'display-name': 'Atlassian Confluence', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/atlassian/confluence'), - 'installed': False, - 'version': None, - } - - s['atlassian-jira'] = { - 'display-name': 'Atlassian Jira', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/atlassian/jira'), - 'installed': False, - 'version': None, - } - - s['atomicorp'] = { - 'display-name': 'Atomicorp', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/atomicorp'), - 'installed': False, - 'version': None, - } - - s['baccus'] = { - 'display-name': 'Bacchus', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/bacchus'), - 'installed': False, - 'version': None, - } - - output = run_cmd('named -v') - s['bind'] = { - 'display-name': 'BIND', - 'tag-name': 'bind', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'^BIND (.*?)-') if output is not False else None, - } - - output = run_cmd('borg --version') - s['borg'] = { - 'display-name': 'Borg', - 'tag-name': 'borgbackup', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - s['brother-printer-sw'] = { - 'display-name': 'Brother Printer SW', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/brother'), - 'installed': False, - 'version': None, - } - - output = run_cmd('certbot --version') - s['certbot'] = { - 'display-name': 'certbot', - 'tag-name': 'certbot', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('chronyd --version') - s['chronyd'] = { - 'display-name': 'chronyd', - 'tag-name': 'chronyd', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n ([\d\.]+)') if output is not False else None, - } - - output = run_cmd('clamd --version') - s['clamd'] = { - 'display-name': 'ClamAV', - 'tag-name': 'clamav', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*) ') if output is not False else None, - } - - output = run_cmd('/usr/libexec/cockpit-ws --version') - s['cockpit'] = { - 'display-name': 'cockpit', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r': ([\d\.]+)') if output is not False else None, - } - - s['collaboraoffice'] = { - 'display-name': 'Collabora Office', - 'tag-name': 'collabora-online', - 'guessed': os.path.isdir('/opt/collaboraoffice'), - 'installed': False, - 'version': None, - } - - s['collaboraoffice50'] = { - 'display-name': 'Collabora Office 5.0', - 'tag-name': 'collabora-online', - 'guessed': os.path.isdir('/opt/collaboraoffice5.0'), - 'installed': False, - 'version': None, - } - - s['collaboraoffice51'] = { - 'display-name': 'Collabora Office 5.1', - 'tag-name': 'collabora-online', - 'guessed': os.path.isdir('/opt/collaboraoffice5.1'), - 'installed': False, - 'version': None, - } - - s['collaboraoffice53'] = { - 'display-name': 'Collabora Office 5.3', - 'tag-name': 'collabora-online', - 'guessed': os.path.isdir('/opt/collaboraoffice5.3'), - 'installed': False, - 'version': None, - } - - s['collaboraoffice60'] = { - 'display-name': 'Collabora Office 6.0', - 'tag-name': 'collabora-online', - 'guessed': os.path.isdir('/opt/collaboraoffice6.0'), - 'installed': False, - 'version': None, - } - - s['collaboraoffice62'] = { - 'display-name': 'Collabora Office 6.2', - 'tag-name': 'collabora-online', - 'guessed': os.path.isdir('/opt/collaboraoffice6.2'), - 'installed': False, - 'version': None, - } - - s['collaboraoffice64'] = { - 'display-name': 'Collabora Office 6.4', - 'tag-name': 'collabora-online', - 'guessed': os.path.isdir('/opt/collaboraoffice6.4'), - 'installed': False, - 'version': None, - } - - output = run_cmd('composer --version --no-interaction') - s['composer'] = { - 'display-name': 'Composer (PHP)', - 'tag-name': 'composer', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n (\d+\.\d+\.?\d*)') if output is not False else None, - } - - output = run_cmd('containerd --version') - s['containerd'] = { - 'display-name': 'Containerd', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'\.io (.*) ') if output is not False else None, - } - - s['contao'] = { - 'display-name': 'Contao', - 'tag-name': None, - 'guessed': os.path.isdir('/var/www/html/contao'), - 'installed': False, - 'version': None, - } - - output = run_cmd('systemctl is-active coturn.service') - s['coturn'] = { - 'display-name': 'coturn', - 'tag-name': 'coturn', - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - s['dcm4chee'] = { - 'display-name': 'DCM4CHEE', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/dcm4chee'), - 'installed': False, - 'version': None, - } - - s['django'] = { - 'display-name': 'Django', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/django'), - 'installed': False, - 'version': None, - } - - output = run_cmd('docker --version') - s['docker'] = { - 'display-name': 'Docker/Podman', - 'tag-name': 'docker', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (\d+\d?\.\d+\d?.\d+\d?)') if output is not False else None, - } - - output = run_cmd('docker-compose --version') - s['docker-compose'] = { - 'display-name': 'Docker Compose', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' version (.*?),') if output is not False else None, - } - - output = run_cmd('duplicity --version') - s['duplicity'] = { - 'display-name': 'duplicity', - 'tag-name': 'duplicity', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' ([\d\.]+)') if output is not False else None, - } - - output = run_cmd('filebeat version') - s['elastic-filebeat'] = { - 'display-name': 'Elastic-Filebeat', - 'tag-name': 'elasticsearch', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n ([\d\.]+)') if output is not False else None, - } - - s['elasticsearch'] = { - 'display-name': 'Elasticsearch', - 'tag-name': 'elasticsearch', - 'guessed': os.path.isfile('/usr/share/elasticsearch/bin/elasticsearch'), - 'installed': False, - 'version': None, - } - - output = run_cmd("erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell") # pylint: disable=C0301 - s['erlang'] = { - 'display-name': 'Erlang', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'\"(.*)\"') if output is not False else None, - } - - output = run_cmd('exim --version') - s['exim'] = { - 'display-name': 'Exim', - 'tag-name': 'exim', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n ([\d\.]+) ') if output is not False else None, - } - - s['f5vpn'] = { - 'display-name': 'F5 VPN SW', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/f5/vpn'), - 'installed': False, - 'version': None, - } - - output = run_cmd('fail2ban-server --version') - s['fail2ban'] = { - 'display-name': 'Fail2ban Server', - 'tag-name': 'fail2ban', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' v(.*)') if output is not False else None, - } - - output = run_cmd('firefox --version') - s['firefox'] = { - 'display-name': 'Firefox', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' Firefox (.*)') if output is not False else None, - } - - output = run_cmd('command -v firewalld') - s['firewalld'] = { - #'display-name': 'firewalld', - 'tag-name': 'firewalld', - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - output = run_cmd('ipa --version') - s['freeipa'] = { - 'display-name': 'FreeIPA', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*?),') if output is not False else None, - } - - s['fwbuilder'] = { - 'display-name': 'Firewall Builder', - 'tag-name': 'fwbuilder', - 'guessed': os.path.isfile('/etc/fwb.sh'), - 'installed': False, - 'version': None, - } - - output = run_cmd('g++ --version') - s['g++'] = { - 'display-name': 'g++', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'\) ([\d\.]+)') if output is not False else None, - } - - output = run_cmd('gcc --version') - s['gcc'] = { - 'display-name': 'gcc', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'\) ([\d\.]+)') if output is not False else None, - } - - output = run_cmd('gdm --version') - s['gdm'] = { - 'display-name': 'GNOME Display Manager', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'\S*$', 0) if output is not False else None, - } - - output = run_cmd('git --version') - s['git'] = { - 'display-name': 'Git', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'git version (.*)') if output is not False else None, - } - - s['gitlab'] = { - 'display-name': 'GitLab', - 'tag-name': 'gitlab', - 'guessed': os.path.isdir('/opt/gitlab'), - 'installed': False, - 'version': None, - } - - output = run_cmd('glances --version') - s['glances'] = { - 'display-name': 'Glances', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'Glances v(.*?) ') if output is not False else None, - } - - output = run_cmd('gnome-shell --version') - s['gnome-shell'] = { - 'display-name': 'GNOME Shell', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'l (\S*)') if output is not False else None, - } - - s['google-chrome'] = { - 'display-name': 'Google Chrome', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/google/chrome'), - 'installed': False, - 'version': None, - } - - output = run_cmd('gpg --version') - s['gpg'] = { - 'display-name': 'gpg', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'gpg (.*)') if output is not False else None, - } - - output = run_cmd('grafana-server -v') - s['grafana'] = { - 'display-name': 'Grafana Server', - 'tag-name': 'grafana', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'Version (.*?) ') if output is not False else None, - } - - s['graylog'] = { - 'display-name': 'Graylog Server', - 'tag-name': 'graylog-server', - 'guessed': os.path.isfile('/usr/share/graylog-server/bin/graylog-server'), - 'installed': False, - 'version': None, - } - - output = run_cmd('haproxy -v') - s['haproxy'] = { - 'display-name': 'HAPrxoy', - 'tag-name': 'haproxy', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'version (.*) -') if output is not False else None, - } - - s['hnet-efaktura'] = { - 'display-name': 'H-Net SecureService (eFaktura)', - 'tag-name': 'hnet-efaktura', - 'guessed': os.path.isdir('/home/hnet/HnetSecureService'), - 'installed': False, - 'version': None, - } - - s['hostbill'] = { - 'display-name': 'Hostbill', - 'tag-name': None, - 'guessed': os.path.isdir('/home/hostbill'), - 'installed': False, - 'version': None, - } - - s['htmly'] = { - 'display-name': 'HTMLy', - 'tag-name': None, - 'guessed': os.path.isdir('/var/www/html/htmly'), - 'installed': False, - 'version': None, - } - - output = run_cmd('i3 --version') - s['i3'] = { - 'display-name': 'i3', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'version (\S+)') if output is not False else None, - } - - output = run_cmd('icinga2 --version') - s['icinga2'] = { - 'display-name': 'Icinga2', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'\(version: (.*)\)') if output is not False else None, - } - - output = run_cmd('influx --version') - s['influxdb'] = { - 'display-name': 'InfluxDB', - 'tag-name': 'influxdb', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r': (.*)') if output is not False else None, - } - - output = run_cmd('ipmitool -V') - s['ipmitool'] = { - 'display-name': 'ipmitool', - 'tag-name': 'ipmi', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (\S*)$') if output is not False else None, - } - - output = run_cmd('command -v iptables') - s['iptables'] = { - #'display-name': 'iptables', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - output = run_cmd('systemctl is-active iscsi.service') - s['iscsi'] = { - #'display-name': 'iscsi', - 'tag-name': 'iscsi', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - output = run_cmd('java -version') - s['java'] = { - 'display-name': 'Java', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'(.*)').replace('version ', '').replace('"', '') if output is not False else None, # pylint: disable=C0301 - } - - s['jboss'] = { - 'display-name': 'JBoss', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/jboss'), - 'installed': False, - 'version': None, - } - - s['jumpcloud'] = { - 'display-name': 'JumpCloud', - 'tag-name': 'jcagent', - 'guessed': os.path.isdir('/opt/jc'), - 'installed': False, - 'version': None, - } - - s['keeweb'] = { - 'display-name': 'KeeWeb', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/KeeWeb'), - 'installed': False, - 'version': None, - } - - s['keycloak'] = { - 'display-name': 'Keycloak', - 'tag-name': 'keycloak', - 'guessed': os.path.isdir('/opt/keycloak'), - 'installed': False, - 'version': None, - } - - s['librenms'] = { - 'display-name': 'LibreNMS', - 'tag-name': 'librenms', - 'guessed': os.path.isdir('/opt/librenms'), - 'installed': False, - 'version': None, - } - - output = run_cmd('libreoffice --version') - s['libreoffice'] = { - 'display-name': 'LibreOffice', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*?) ') if output is not False else None, - } - - output = run_cmd('lighttpd -v') - s['lighttpd'] = { - 'display-name': 'Lighttpd', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'lighttpd/(.*) -') if output is not False else None, - } - - output = run_cmd('uname -r') - s['linux'] = { - 'display-name': 'Linux Kernel', - 'tag-name': 'OS: {}, family "{}"'.format( - lib.version.get_os_info(), - lib.distro.get_distribution_facts()['os_family'] - ), - 'guessed': False, - 'installed': output is not False, - 'version': output if output is not False else None, - } - - output = run_cmd('command -v loolwsd') - s['loolwsd'] = { - 'display-name': 'LibreOffice Online (LOOL)', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - output = run_cmd('command -v lvdisplay') - s['lvm'] = { - #'display-name': 'lvdisplay', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - output = run_cmd('mysqld --version') - if output: - s['mariadb'] = { - 'display-name': 'MariaDB' if output is not False and 'MariaDB' in output else 'MySQL', - 'tag-name': 'mariadb* / mysql*', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'Ver (.*?) ') if output is not False else None, - } - else: - output = run_cmd('mysql --version') - if output: - s['mariadb'] = { - 'display-name': 'MariaDB' if output is not False and 'MariaDB' in output else 'MySQL', - 'tag-name': 'mariadb* / mysql*', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'(?i)b (.*?),') if output is not False else None, - } - - s['mariadb-columnstore'] = { - 'display-name': 'MariaDB ColumnStore', - 'tag-name': None, - 'guessed': os.path.isdir('/usr/local/mariadb/columnstore'), - 'installed': False, - 'version': None, - } - - s['matomo'] = { - 'display-name': 'Matomo', - 'tag-name': 'matomo', - 'guessed': os.path.isdir('/var/www/html/matomo'), - 'installed': False, - 'version': None, - } - - s['mediawiki'] = { - 'display-name': 'MediaWiki', - 'tag-name': None, - 'guessed': os.path.isdir('/var/www/html/mediawiki'), - 'installed': False, - 'version': None, - } - - s['medidata'] = { - 'display-name': 'Medidata (eFaktura)', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/MPCommunicator'), - 'installed': False, - 'version': None, - } - - s['metabase'] = { - 'display-name': 'Metabase', - 'tag-name': 'metabase', - 'guessed': os.path.isdir('/opt/metabase'), - 'installed': False, - 'version': None, - } - - s['mod_security'] = { - 'display-name': 'mod_security', - 'tag-name': 'mod_qos', - 'guessed': os.path.isdir('/var/lib/mod_security'), - 'installed': False, - 'version': None, - } - - output = run_cmd('mongod --version') - s['mongodb'] = { - 'display-name': 'MongoDB', - 'tag-name': 'mongodb', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'db version v(.*?)\n') if output is not False else None, - } - - output = run_cmd('mydumper --version') - s['mydumper'] = { - 'display-name': 'mydumper/myloader', - 'tag-name': 'mydumper', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*?),') if output is not False else None, - } - - s['nextcloud'] = { - 'display-name': 'Nextcloud', - 'tag-name': 'nextcloud', - 'guessed': os.path.isdir('/var/www/nextcloud') or os.path.isdir('/var/www/html/nextcloud'), - 'installed': False, - 'version': None, - } - - output = run_cmd('systemctl is-active nfs-server.service') - s['nfs-server'] = { - #'display-name': 'nfs-server', - 'tag-name': 'nfs-server', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - output = run_cmd('command -v nft') - s['nftables'] = { - #'display-name': 'nftables', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - output = run_cmd('nginx -v') - s['nginx'] = { - 'display-name': 'Nginx', - 'tag-name': 'nginx', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'nginx version: nginx/(.*)') if output is not False else None, - } - - output = run_cmd('nikto -Version') - s['nikto'] = { - 'display-name': 'Nikto', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'main\s*(.*)') if output is not False else None, - } - - output = run_cmd('node --version') - s['node'] = { - 'display-name': 'Node', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'v(.*)') if output is not False else None, - } - - s['nodebb'] = { - 'display-name': 'NodeBB', - 'tag-name': 'nodebb', - 'guessed': os.path.isdir('/opt/nodebb'), - 'installed': False, - 'version': None, - } - - output = run_cmd('nodejs --version') - s['nodejs'] = { - 'display-name': 'NodeJS', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'v(.*)') if output is not False else None, - } - - output = run_cmd('npm --version') - s['npm'] = { - 'display-name': 'npm', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'(.*)') if output is not False else None, - } - - output = run_cmd('ntpq -c version') - s['ntpd'] = { - 'display-name': 'ntpd', - 'tag-name': 'ntpd', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' ([\d\.p]+)@') if output is not False else None, - } - - s['onlyoffice'] = { - 'display-name': 'Onlyoffice', - 'tag-name': 'onlyoffice', - 'guessed': os.path.isdir('/var/log/onlyoffice'), - 'installed': False, - 'version': None, - } - - output = run_cmd('openssl version') - s['openssl'] = { - 'display-name': 'OpenSSL', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*?) ') if output is not False else None, - } - - output = run_cmd('openvas version') - if not output or (isinstance(output, str) and not output.startswith('OpenVAS')): - # starting with OpenVAS 22.7.9: - output = run_cmd('openvas --version') - s['openvas'] = { - 'display-name': 'OpenVAS', - 'tag-name': 'openvas', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*?)$') if output is not False else None, - } - - output = run_cmd('vmtoolsd --version') - s['openvmt'] = { - 'display-name': 'Open Virtual Machine Tools are installed, but throw an error. Maybe tools virtualization condition "vmware" is not met.\n' if output is not False and 'error' in output.lower() else 'Open Virtual Machine Tools', # pylint: disable=C0301 - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n ([\d\.]+)') if output is not False else None, - } - - output = run_cmd('openvpn --version') - if not output: - output = run_cmd('command -v openvpn') - s['openvpn'] = { - 'display-name': 'OpenVPN', - 'tag-name': 'openvpn-server', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'N (\d+\.\d+(\.\d+)?)') if output is not False else None, - } - - s['owncloud'] = { - 'display-name': 'ownCloud', - 'tag-name': None, - 'guessed': os.path.isdir('/var/www/owncloud') or os.path.isdir('/var/www/html/owncloud'), - 'installed': False, - 'version': None, - } - - output = run_cmd('perl --version') - s['perl'] = { - 'display-name': 'Perl', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' \(v(.*?)\) ') if output is not False else None, - } - - output = run_cmd('php --version') - s['php'] = { - 'display-name': 'PHP', - 'tag-name': 'php', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'PHP (.*?) \(.*') if output is not False else None, - } - - output = run_cmd('php-fpm --version') - s['php-fpm'] = { - 'display-name': 'PHP-FPM', - 'tag-name': 'php-fpm', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'PHP (.*?) \(.*') if output is not False else None, - } - - s['php54'] = { - 'display-name': 'PHP 5.4 (RH)', - 'tag-name': 'php', - 'guessed': os.path.isdir('/opt/rh/rh-php54'), - 'installed': False, - 'version': None, - } - - s['php55'] = { - 'display-name': 'PHP 5.5 (RH)', - 'tag-name': 'php', - 'guessed': os.path.isdir('/opt/rh/rh-php55'), - 'installed': False, - 'version': None, - } - - s['php56'] = { - 'display-name': 'PHP 5.6 (RH)', - 'tag-name': 'php', - 'guessed': os.path.isdir('/opt/rh/rh-php56'), - 'installed': False, - 'version': None, - } - - s['php70'] = { - 'display-name': 'PHP 7.0 (RH)', - 'tag-name': 'php', - 'guessed': os.path.isdir('/opt/rh/rh-php70'), - 'installed': False, - 'version': None, - } - - s['php71'] = { - 'display-name': 'PHP 7.1 (RH)', - 'tag-name': 'php', - 'guessed': os.path.isdir('/opt/rh/rh-php71'), - 'installed': False, - 'version': None, - } - - s['php72'] = { - 'display-name': 'PHP 7.2 (RH)', - 'tag-name': 'php', - 'guessed': os.path.isdir('/opt/rh/rh-php72'), - 'installed': False, - 'version': None, - } - - output = run_cmd('pip --version') - s['pip'] = { - 'display-name': 'pip', - 'tag-name': 'pip', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'pip (.*) from') if output is not False else None, - } - - s['piwik'] = { - 'display-name': 'Piwik', - 'tag-name': 'matomo', - 'guessed': os.path.isdir('/var/www/html/piwik'), - 'installed': False, - 'version': None, - } - - output = run_cmd('postconf -d mail_version') - s['postfix'] = { - 'display-name': 'Postfix', - 'tag-name': 'postfix-mta', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'= ([\d\.]+)') if output is not False else None, - } - - output = run_cmd('psql --version') - s['postgresql'] = { - 'display-name': 'PostgreSQL', - 'tag-name': 'postgresql', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'\(PostgreSQL\) (.*)') if output is not False else None, - } - - s['postgresql92'] = { - 'display-name': 'PostgreSQL 9.2 (RH)', - 'tag-name': 'postgresql', - 'guessed': os.path.isdir('/opt/rh/rh-postgresql92'), - 'installed': False, - 'version': None, - } - - s['postgresql94'] = { - 'display-name': 'PostgreSQL 9.4 (RH)', - 'tag-name': 'postgresql', - 'guessed': os.path.isdir('/opt/rh/rh-postgresql94'), - 'installed': False, - 'version': None, - } - - s['postgresql95'] = { - 'display-name': 'PostgreSQL 9.5 (RH)', - 'tag-name': 'postgresql', - 'guessed': os.path.isdir('/opt/rh/rh-postgresql95'), - 'installed': False, - 'version': None, - } - - s['postgresql96'] = { - 'display-name': 'PostgreSQL 9.6 (RH)', - 'tag-name': 'postgresql-96', - 'guessed': os.path.isdir('/opt/rh/rh-postgresql96'), - 'installed': False, - 'version': None, - } - - s['postgresql100'] = { - 'display-name': 'PostgreSQL 10.0 (RH)', - 'tag-name': 'postgresql', - 'guessed': os.path.isdir('/opt/rh/rh-postgresql10'), - 'installed': False, - 'version': None, - } - - output = run_cmd('python2.6 --version') - s['python26'] = { - 'display-name': 'Python', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('python2.7 --version') - s['python27'] = { - 'display-name': 'Python', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('python3.4 --version') - s['python34'] = { - 'display-name': 'Python', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('python3.6 --version') - s['python36'] = { - 'display-name': 'Python', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('python3.8 --version') - s['python38'] = { - 'display-name': 'Python', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('python3.9 --version') - s['python39'] = { - 'display-name': 'Python', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('python3.10 --version') - s['python310'] = { - 'display-name': 'Python', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('python3.11 --version') - s['python311'] = { - 'display-name': 'Python', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('python --version') - s['python'] = { - 'display-name': '`python`', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': 'cmd mapped to ' + run_regex(output, r' (.*)') if output is not False else None, # pylint: disable=C0301 - } - - output = run_cmd('python2 --version') - s['python2'] = { - 'display-name': '`python2`', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': 'cmd mapped to ' + run_regex(output, r' (.*)') if output is not False else None, # pylint: disable=C0301 - } - - output = run_cmd('python3 --version') - s['python3'] = { - 'display-name': '`python3`', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': 'cmd mapped to ' + run_regex(output, r' (.*)') if output is not False else None, # pylint: disable=C0301 - } - - output = run_cmd('qemu-ga --version') - s['qemu-ga'] = { - 'display-name': 'QEMU Guest Agent', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'([\d\.]+)') if output is not False else None, - } - - output = run_cmd('rabbitmqctl version') - s['rabbitmq-server'] = { - 'display-name': 'RabbitMQ Server', - 'tag-name': 'rabbitmq-server', - 'guessed': False, - 'installed': output is not False, - 'version': output if output is not False else None, - } - - s['rambox'] = { - 'display-name': 'Rambox', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/Rambox'), - 'installed': False, - 'version': None, - } - - output = run_cmd('rasdaemon --version') - s['rasdaemon'] = { - 'display-name': 'rasdaemon', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n (.*)') if output is not False else None, - } - - output = run_cmd('redis-server --version') - s['redis-server'] = { - 'display-name': 'Redis Server', - 'tag-name': 'redis', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' v=(.*?) ') if output is not False else None, - } - - output = run_cmd('restic version') - s['restic'] = { - 'display-name': 'restic', - 'tag-name': 'restic', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'c (.*) c') if output is not False else None, - } - - s['rocket.chat'] = { - 'display-name': 'Rocket.Chat', - 'tag-name': 'rocketchat', - 'guessed': os.path.isdir('/opt/Rocket.Chat'), - 'installed': False, - 'version': None, - } - - s['roundcube'] = { - 'display-name': 'Roundcube', - 'tag-name': None, - 'guessed': os.path.isdir('/var/www/html/roundcubemail'), - 'installed': False, - 'version': None, - } - - output = run_cmd('systemctl is-active rsyncd.service') - s['rsyncd'] = { - #'display-name': 'rsyncd', - 'tag-name': 'rsyncd', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - output = run_cmd('command -v sestatus') - s['selinux'] = { - #'display-name': 'selinux', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - output = run_cmd('smbd --version') - s['smbd'] = { - 'display-name': 'Samba', - 'tag-name': 'samba', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n ([\d\.]+)') if output is not False else None, - } - - output = run_cmd('snap --version') - s['snap'] = { - 'display-name': 'Snap', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'p\W(.*)') if output is not False else None, - } - - output = run_cmd('systemctl is-active snmpd.service') - s['snmpd'] = { - #'display-name': 'snmpd', - 'tag-name': 'snmpd', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - output = run_cmd('command -v spice-vdagentd') - s['spice-vdagentd'] = { - 'display-name': 'SPICE Agent', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': None, - } - - output = run_cmd('systemctl is-active splunk.service') - s['splunk'] = { - #'display-name': 'splunk', - 'tag-name': 'splunk', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - output = run_cmd('ssh -V') - s['ssh'] = { - 'display-name': 'ssh', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'_(.+),') if output is not False else None, - } - - output = run_cmd('subl --version') - s['subl'] = { - 'display-name': 'Sublime Text', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'.* (.*)$') if output is not False else None, - } - - output = run_cmd('sudo --version') - s['sudo'] = { - 'display-name': 'sudo', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n (.+)') if output is not False else None, - } - - output = run_cmd('swanctl --version') - s['swanctl'] = { - 'display-name': 'swanctl', - 'tag-name': 'strongswan', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'(.*)') if output is not False else None, - } - - output = run_cmd('systemctl is-active syslog-ng.service') - s['syslog-ng'] = { - #'display-name': 'syslog-ng', - 'tag-name': 'syslog-ng', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - output = run_cmd('systemctl is-active notify-and-schedule.timer') - s['system-update'] = { - #'display-name': 'system-update', - 'tag-name': 'system-update', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - output = run_cmd('systemctl --version') - s['systemd'] = { - 'display-name': 'systemd', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'systemd (\d+)') if output is not False else None, - } - - output = run_cmd('systemctl is-active systemd-timesyncd.service') - s['systemd-timesyncd'] = { - #'display-name': 'systemd-timesyncd', - 'tag-name': 'systemd-timesyncd', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - output = run_cmd('stap --version') - s['stap'] = { - 'display-name': 'SystemTap', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'n (.*)\)') if output is not False else None, - } - - s['tarifpool'] = { - 'display-name': 'Tarifpool', - 'tag-name': 'tarifppol-v2', - 'guessed': os.path.isdir('/opt/tarifpool'), - 'installed': False, - 'version': None, - } - - output = run_cmd('teamviewer --version') - s['teamviewer'] = { - 'display-name': 'TeamViewer', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'.* (\S*) ') if output is not False else None, - } - - output = run_cmd('tmate -V') - s['tmate'] = { - 'display-name': 'tmate', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('vagrant --version') - s['vagrant'] = { - 'display-name': 'Vagrant', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r' (.*)') if output is not False else None, - } - - output = run_cmd('veeamagent --version') - s['veeam'] = { - 'display-name': 'Veeam', - 'tag-name': 'veeam-backup-replication-windows', - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'(.*)') if output is not False else None, - } - - output = run_cmd('virsh --version') - s['virsh'] = { - 'display-name': 'virsh', - 'tag-name': 'kvm-host', - 'guessed': False, - 'installed': output is not False, - 'version': output, - } - - s['vmware-tools'] = { - 'display-name': 'VMware Tools', - 'tag-name': None, - 'guessed': os.path.isdir('/etc/vmware-tools'), - 'installed': False, - 'version': None, - } - - output = run_cmd('systemctl is-active vsftpd.service') - s['vsftpd'] = { - #'display-name': 'vsftpd', - 'tag-name': 'vsftpd', - 'guessed': False, - 'installed': output == 'active', - 'version': None, - } - - s['vtiger'] = { - 'display-name': 'Vtiger', - 'tag-name': None, - 'guessed': os.path.isdir('/var/www/html/vtigercrm'), - 'installed': False, - 'version': None, - } - - s['wildfly'] = { - 'display-name': 'WildFly', - 'tag-name': 'wildfly', - 'guessed': os.path.isdir('/opt/wildfly'), - 'installed': False, - 'version': None, - } - - s['wordpress'] = { - 'display-name': 'WordPress', - 'tag-name': 'wordpress', - 'guessed': os.path.isdir('/var/www/html/wordpress/wp-config.php') or os.path.isdir('/var/www/html/wp-config.php'), # pylint: disable=C0301 - 'installed': False, - 'version': None, - } - - output = run_cmd('yarn --version') - s['yarn'] = { - 'display-name': 'yarn', - 'tag-name': None, - 'guessed': False, - 'installed': output is not False, - 'version': run_regex(output, r'(.*)') if output is not False else None, - } - - s['yii2'] = { - 'display-name': 'Yii2', - 'tag-name': None, - 'guessed': os.path.isdir('/var/www/html/yii2') or os.path.isdir('/var/www/html/yii2-advanced') or os.path.isdir('/var/www/html/yii2-basic') or os.path.isdir('/var/www/html/yii'), # pylint: disable=C0301 - 'installed': False, - 'version': None, - } - - s['zimbra'] = { - 'display-name': 'Zimbra', - 'tag-name': None, - 'guessed': os.path.isdir('/opt/zimbra'), - 'installed': False, - 'version': None, - } - - return s - - -def find_tools(): # pylint: disable=R0915 - """Find simple admin tools, same procedure as above. - """ - s = {} # sorted by s['keyname'] - - output = run_cmd('command -v dig') - s['dig'] = { - 'display-name': 'dig', - 'installed': output is not False, - } - - output = run_cmd('command -v dot') - s['dot'] = { - 'display-name': 'dot (graphviz)', - 'installed': output is not False, - } - - output = run_cmd('command -v hdparm') - s['hdparm'] = { - 'display-name': 'hdparm', - 'installed': output is not False, - } - - output = run_cmd('command -v iftop') - s['iftop'] = { - 'display-name': 'iftop', - 'installed': output is not False, - } - - output = run_cmd('command -v iptraf-ng') - s['iptraf-ng'] = { - 'display-name': 'iptraf-ng', - 'installed': output is not False, - } - - output = run_cmd('command -v lsof') - s['lsof'] = { - 'display-name': 'lsof', - 'installed': output is not False, - } - - output = run_cmd('command -v ltrace') - s['ltrace'] = { - 'display-name': 'ltrace', - 'installed': output is not False, - } - - output = run_cmd('command -v memtest-setup') - s['memtest86+'] = { - 'display-name': 'memtest86+', - 'installed': output is not False, - } - - output = run_cmd('command -v nano') - s['nano'] = { - 'display-name': 'nano', - 'installed': output is not False, - } - - output = run_cmd('command -v ncat') - s['ncat'] = { - 'display-name': 'ncat', - 'installed': output is not False, - } - - output = run_cmd('command -v ncdu') - s['ncdu'] = { - 'display-name': 'ncdu', - 'installed': output is not False, - } - - output = run_cmd('command -v nmap') - s['nmap'] = { - 'display-name': 'nmap', - 'installed': output is not False, - } - - output = run_cmd('command -v rsync') - s['rsync'] = { - 'display-name': 'rsync', - 'installed': output is not False, - } - - output = run_cmd('command -v staprun') - s['staprun'] = { - 'display-name': 'staprun', - 'installed': output is not False, - } - - output = run_cmd('command -v strace') - s['strace'] = { - 'display-name': 'strace', - 'installed': output is not False, - } - - output = run_cmd('command -v tcpdump') - s['tcpdump'] = { - 'display-name': 'tcpdump', - 'installed': output is not False, - } - - output = run_cmd('command -v telnet') - s['telnet'] = { - 'display-name': 'telnet', - 'installed': output is not False, - } - - output = run_cmd('command -v tmux') - s['tmux'] = { - 'display-name': 'tmux', - 'installed': output is not False, - } - - output = run_cmd('command -v unzip') - s['unzip'] = { - 'display-name': 'unzip', - 'installed': output is not False, - } - - output = run_cmd('command -v vim') - s['vim'] = { - 'display-name': 'vim', - 'installed': output is not False, - } - - output = run_cmd('command -v wget') - s['wget'] = { - 'display-name': 'wget', - 'installed': output is not False, - } - - output = run_cmd('command -v whois') - s['whois'] = { - 'display-name': 'whois', - 'installed': output is not False, - } - - output = run_cmd('command -v valgrind') - s['valgrind'] = { - 'display-name': 'valgrind', - 'installed': output is not False, - } - - output = run_cmd('command -v wireshark') - s['wireshark'] = { - 'display-name': 'wireshark', - 'installed': output is not False, - } - - return s - - -def get_birthdate(): +def get_birthday(): """Using various methods to determine install date. """ - birthdate = '-' # Using stat cmd = 'stat / | grep "Birth" | sed "s/Birth: //g" | cut -b 2-11' success, result = lib.shell.shell_exec(cmd) - if success: - birthdate, stderr, retc = result - if birthdate == '-': - # nothing found so far, but not all of those are very accurate + birthday, _, _ = result + if not success or birthday == '-': + # nothing found so far, try more - but not all of those are very accurate if os.path.isfile('/usr/bin/pacman'): # Arch Linux, and Arch based distros using pacman cmd = 'head -n 1 $PACMAN_LOG | cut -b 2-11' @@ -1785,67 +130,154 @@ def get_birthdate(): # Fedora, RedHat, and RPM based distros cmd = 'rpm -qi basesystem | grep "Install Date" | sed "s/Install Date: //g"' success, result = lib.shell.shell_exec(cmd) - if success: - birthdate, stderr, retc = result - return birthdate.strip() + if success: + birthday, _, _ = result + if birthday and birthday != '-': + return 'born {}. '.format(birthday.strip()) + return '' def get_boot_mode(): - return 'UEFI' if os.path.isdir('/sys/firmware/efi') else 'BIOS' + return 'UEFI boot, ' if os.path.isdir('/sys/firmware/efi') else 'BIOS boot, ' def get_crontab(): - cmd = r"grep --dereference-recursive --no-filename --invert-match '\s*#' /etc/crontab /etc/cron.d/ /etc/anacrontab /var/spool/cron" - stdout, stderr, retc = lib.base.coe(lib.shell.shell_exec(cmd)) - msg = '' + """Returns all crontab items. + """ + cmd = r"grep --dereference-recursive --no-filename --invert-match '\s*#' /etc/crontab /etc/cron.d/ /etc/anacrontab /var/spool/cron" # pylint: disable=C0301 + success, result = lib.shell.shell_exec(cmd) + if not success: + return '' + stdout, _, _ = result + output = '' line_regex = re.compile(r'\S+=') for line in stdout.splitlines(): line = line.strip() if len(line) > 0 and re.match(line_regex, line) is None: - msg = '{}{}\n'.format(msg, line) - return msg + output = '{}{}\n'.format(output, line) + if output: + output = 'crontab:\n{}\n'.format(output) + return output def get_disks(): - result = '' - stdout, stderr, retc = lib.base.coe(lib.shell.shell_exec('lsblk --nodeps --output NAME,SIZE --noheadings --include 8,252,259')) # pylint: disable=C0301 + """Returns system disks tuple "text, count": `'Disk nvme0n1 1.8T', 1` + """ + success, result = lib.shell.shell_exec( + 'lsblk --nodeps --output NAME,SIZE --noheadings --include 8,252,259' + ) + if not success: + return '', 0 + stdout, _, _ = result + output = [] for disk in stdout.strip().splitlines(): - # zRAM devices can appear in the output of lsblk, but - # we cannot do anything useful with them + # zRAM devices can appear in the output of lsblk, but we cannot do anything useful with them if disk.startswith('zram'): continue - result += '{}, '.format(re.sub('\\s+', ' ', disk)) - return result[:-2] + output.append(re.sub('\\s+', ' ', disk)) + return '{} {}, '.format( + lib.txt.pluralize('Disk', len(output)), + ', '.join(output), + ), len(output) def get_hw_info(): - msg = lib.dmidecode.dmidecode() - return msg + result = lib.dmidecode.get_data() + output = '' + for _, value in result.items(): + if value['dminame'] == 'Base Board Information': + output += '* Base Board: Type {} {} {}, SerNo {}, Ver {}\n'.format( + value.get('Type', 'N/A'), + value.get('Manufacturer', 'N/A'), + value.get('Product Name', 'N/A'), + value.get('Serial Number', 'N/A'), + value.get('Version', 'N/A'), + ) + if value['dminame'] == 'BIOS Information': + output += '* BIOS: {}, Ver {} (released {}), ROM {}\n'.format( + value.get('Vendor', 'N/A'), + value.get('Version', 'N/A'), + value.get('Release Date', 'N/A'), + value.get('ROM Size', 'N/A'), + ) + if value['dminame'] == 'Chassis Information': + output += '* Chassis: {}, Type {}, SKU {}, SerNo {}\n'.format( + value.get('Manufacturer', 'N/A'), + value.get('Type', 'N/A'), + value.get('SKU', 'N/A'), + value.get('Serial Number', 'N/A'), + ) + output += ' States: boot-up={}, pwr-supply={}, thermal={}, security={}\n'.format( + value.get('Boot-up State', 'N/A'), + value.get('Power Supply State', 'N/A'), + value.get('Thermal State', 'N/A'), + value.get('Security Status', 'N/A'), + ) + if value['dminame'] == 'Processor Information': + output += '* Proc: {}, Ver {},\n'.format( + value.get('Manufacturer', 'N/A'), + value.get('Version', 'N/A'), + ) + output += ' Speed {}/{} max., {}/{} Cores enabled, {} {}, Voltage {}\n'.format( + value.get('Current Speed', 'N/A'), + value.get('Max Speed', 'N/A'), + value.get('Core Enabled', 'N/A'), + value.get('Core Count', 'N/A'), + value.get('Thread Count', 'N/A'), + lib.txt.pluralize('Thread', value.get('Thread Count', 0)), + value.get('Voltage', 'N/A'), + ) + if value['dminame'] == 'System Boot Information': + output += '* System Boot: {}\n'.format( + value.get('Status', 'N/A'), + ) + if value['dminame'] == 'System Information': + output += '* SysInfo: {} {}, SerNo {}, SKU {}, Wake-up Type "{}",\n'.format( + value.get('Manufacturer', 'N/A'), + value.get('Product Name', 'N/A'), + value.get('Serial Number', 'N/A'), + value.get('SKU', 'N/A'), + value.get('Wake-up Type', 'N/A'), + ) + output += ' UUID {}\n'.format( + value.get('UUID', 'N/A'), + ) + if output: + return 'Hardware Info:\n{}\n'.format(output) + return output def get_interfaces(): - msg = '' + output = '' try: for name, interface in sorted(psutil.net_if_addrs().items()): if name == 'lo': continue for addr in interface: if addr.family == lib.net.AF_INET: - msg = '{}* {} {}/{}\n'.format(msg, name, addr.address, lib.net.ip_to_cidr(addr.netmask)) + output += '* {} {}/{}\n'.format( + name, + addr.address, + lib.net.ip_to_cidr(addr.netmask), + ) except: pass - return msg + if output: + return 'Interfaces (IPv4):\n{}\n'.format(output) + return output def get_listening_ports(): - result = [] + ports = {} + output = [] try: nc = psutil.net_connections('inet') for c in nc: - ip, port = c.laddr - if c.type == socket.SOCK_STREAM and c.status == psutil.CONN_LISTEN: + if c.status != psutil.CONN_LISTEN and c.status != psutil.CONN_NONE: + continue + if c.type == socket.SOCK_STREAM: proto = 'tcp' - elif c.type == socket.SOCK_DGRAM and c.status == psutil.CONN_NONE: + elif c.type == socket.SOCK_DGRAM: proto = 'udp' else: continue @@ -1853,15 +285,46 @@ def get_listening_ports(): proto += '4' else: proto += '6' - result.append({ + ip, port = c.laddr + ports['{}#{}#{}'.format(ip, port, proto)] = { 'proto': proto, - 'ip': '[{}]'.format(ip) if ':' in ip and not ip.startswith('[') and not ip.endswith(']') else ip, # pylint: disable=C0301 + 'ip': '[{}]'.format(ip) if c.family == socket.AF_INET6 and not ip.startswith('[') and not ip.endswith(']') else ip, # pylint: disable=C0301 'port': port, - }) - return sorted(result, key=lambda d: d['port']) + } + for _, value in ports.items(): + output.append(value) + output = sorted(output, key=lambda d: (d['port'], d['proto'], d['ip'])) except: pass - return result + if output: + msg = 'Listening TCP/UDP Ports (ordered by port, proto, ip):\n' + for p in output: + msg += '* {}:{}/{}\n'.format(p['ip'], p['port'], p['proto']) + msg += '\n' + return msg + return '' + + +def get_nondefault_software(): + success, result = lib.shell.shell_exec( + 'dnf repoquery --userinstalled --queryformat "%{name};%{version};%{from_repo};%{installtime}"' # pylint: disable=C0301 + ) + if not success: + return [] + stdout, _, _ = result + table_data = [] + header = ['name', 'version', 'from_repo', 'installtime'] + for line in stdout.splitlines(): + data = dict(zip(header, line.split(';'))) + table_data.append(data) + output = lib.base.get_table( + table_data, + header, + header=header, + ) + if output: + return 'Non-default Software (ordered by name):\n{}\n'.format(output) + return '' def get_nondefault_users(): @@ -1922,60 +385,27 @@ def get_nondefault_users(): if data['user'] not in default_linux_users: table_data.append(data) - return lib.base.get_table( + output = lib.base.get_table( table_data, header, header=header, sort_by_key='user', ) + if output: + return 'Non-default Users:\n{}\n'.format(output) + return '' -def get_python_modules(): - """Return a list for each of the installed and missing libraries used in total by all plugins - (except built-in libraries, which are used, but always there and therefore commented). - """ - installed, missing = [], [] - modules = [ - #'argparse', - #'base64', - 'bs4', - #'collections', - #'csv', - #'datetime', - #'fnmatch', - 'flatdict', - #'glob', - #'json', - #'locale', - #'os', - #'pathlib', - #'platform', - 'psutil', - 'pymysql.cursors', - 'pysmbclient', - #'re', - 'smbprotocol.exceptions', - #'socket', - #'sys', - #'tempfile', - #'time', - #'unittest', - #'urllib.parse', - 'vici', - #'warnings', - #'xml.etree.ElementTree', - #'xmltodict', - ] - for m in modules: - try: - mymod = __import__(m) - try: - installed.append('{} {}'.format(m, mymod.__version__)) - except AttributeError: - installed.append(m) - except ImportError: - missing.append(m) - return installed, missing +def get_public_ip(args): + success, pub_ip = lib.net.get_public_ip( + args.PUBLIC_IP_URL, + insecure=args.INSECURE, + no_proxy=args.NO_PROXY, + timeout=args.TIMEOUT, + ) + if success: + return 'Public IP {}, '.format(pub_ip) + return '' def get_sys_dimensions(): @@ -1992,40 +422,38 @@ def get_sys_dimensions(): def get_systemd_default_target(): cmd = 'systemctl get-default' - stdout, stderr, retc = lib.base.coe(lib.shell.shell_exec(cmd)) + success, result = lib.shell.shell_exec(cmd) + if not success: + return '' + stdout, stderr, retc = result if stderr or retc != 0: return '' - - return '* {}\n'.format(stdout.strip()) + return 'systemctl get-default:\n* {}\n\n'.format(stdout.strip()) def get_systemd_timers(): # using `--output=json` sadly does not work with older systemd versions - # (eg systemd 239 on CentOS 7), therefore we have to parse the human output. + # (eg systemd 219 on CentOS 7 or systemd 239 on RHEL 8), therefore we have to parse + # the human output. # in order to list for a different user (`--user`), we would need to sudo to that user # first - we will skip that for now - - # NEXT LEFT LAST PASSED UNIT ACTIVATES - # Fri 2023-09-01 10:32:28 CEST 34min left Fri 2023-09-01 09:08:17 CEST 49min ago dnf-makecache.timer dnf-makecache.service - cmd = 'systemctl list-timers' - stdout, stderr, retc = lib.base.coe(lib.shell.shell_exec(cmd)) + success, result = lib.shell.shell_exec('systemctl list-timers') + if not success: + return '' + stdout, stderr, retc = result if stderr or retc != 0: return '' table_data = [] next_pos = None left_pos = None - last_pos = None - passed_pos = None unit_pos = None activates_pos = None - for line in stdout.splitlines(): if next_pos is None: + # clutters a little bit on modern systemd (Fedora) because of right-aligned LEFT next_pos = line.find('NEXT') left_pos = line.find('LEFT') - last_pos = line.find('LAST') - passed_pos = line.find('PASSED') unit_pos = line.find('UNIT') activates_pos = line.find('ACTIVATES') if '.timer' in line: @@ -2035,41 +463,52 @@ def get_systemd_timers(): 'next': line[next_pos:left_pos].strip(), }) - return lib.base.get_table( + output = lib.base.get_table( table_data, ['unit', 'activates', 'next'], header=['unit', 'activates', 'next'], sort_by_key='unit', ) + if output: + return 'systemctl list-timers:\n{}\n'.format(output) + return '' def get_systemd_units(cmd): # using `--output=json` sadly does not work with older systemd versions - # (eg systemd 239 on CentOS 7), therefore we have to parse the human output. + # (eg systemd 219 on CentOS 7 or systemd 239 on RHEL 8), therefore we have to parse + # the human output. # in order to list for a different user (`--user`), we would need to sudo to that user # first - we will skip that for now - stdout, stderr, retc = lib.base.coe(lib.shell.shell_exec(cmd)) + success, result = lib.shell.shell_exec(cmd) + if not success: + return '' + stdout, stderr, retc = result if stderr or retc != 0: return '' + if not stdout: + return '' - msg = '' + output = '{}:\n'.format(cmd.replace(' --no-legend', '')) for line in stdout.splitlines(): - msg = '{}* {}\n'.format(msg, line.split()[0]) - return msg + output += '* {}\n'.format(line.split()[0]) + return output + '\n' def get_tuned_active_profile(): """ Return current active tuned profile (if any). """ output = run_cmd('tuned-adm active') - return run_regex(output, r': (.*)').strip().replace('* ', '') if output is not False else None + if output: + return 'tuned profile "{}", '.format(run_regex(output, r': (.*)').strip().replace('* ', '')) + return '' def get_virt_info(): # alternative would be `/usr/sbin/virt-what` (POSIX shell script) success, result = lib.shell.shell_exec('systemd-detect-virt') if success: - stdout, stderr, retc = result + stdout, _, _ = result return stdout.strip() return 'Unknown' @@ -2121,75 +560,36 @@ def main(): # init some vars perfdata = '' - guessed = '' - features_installed = '' - features_missing = '' - installed = '' tags = '' - tools = '' - - # fetch and analyze data - for key, value in find_software().items(): - if 'display-name' in value and value['guessed']: - guessed += '* {}\n'.format(value['display-name']) - if 'display-name' in value and value['installed']: - installed += '* {} {}\n'.format(value['display-name'], value['version'] if value['version'] else '') # pylint: disable=C0301 - if (value['guessed'] or value['installed']) and value['tag-name']: - tags += '* {}\n'.format(value['tag-name']) - if value['installed'] and key in ['firewalld', 'iptables', 'lvm', 'nftables', 'selinux']: - features_installed += '{}, '.format(key) - if not value['installed'] and key in ['firewalld', 'iptables', 'lvm', 'nftables', 'selinux']: # pylint: disable=C0301 - features_missing += '{}, '.format(key) # only tags wanted, so it's ok to stop here if args.TAGS: lib.base.oao(tags, STATE_OK) - # fetch more data - automounts = get_systemd_units('systemctl list-unit-files --type automount --state enabled --state static --no-legend') # pylint: disable=C0301 - birthday = get_birthdate() - boot_mode = get_boot_mode() - crontab = get_crontab() - disks = get_disks() - dmi = lib.dmidecode.get_data() - enabled_units = get_systemd_units('systemctl list-unit-files --type service --state enabled --no-legend') # pylint: disable=C0301 - success, firmware_device_model = lib.disk.read_file('/sys/firmware/devicetree/base/model') - if not success: - firmware_device_model = '' - interfaces = get_interfaces() - mounts = get_systemd_units('systemctl list-unit-files --type mount --state static --state generated --no-legend') # pylint: disable=C0301 - nondefault_users = get_nondefault_users() - os_info = lib.version.get_os_info() - pm_installed, pm_missing = get_python_modules() - ports = get_listening_ports() - sys_dimensions = get_sys_dimensions() - systemd_default_target = get_systemd_default_target() - timers = get_systemd_timers() - tuned = get_tuned_active_profile() - virt = get_virt_info() - - for key, value in find_tools().items(): - if value['installed']: - tools += '* {}\n'.format(value['display-name']) - # build the message - # first header line - + # first header line ---------------------------------------------------------------------------- msg = '{}: '.format(socket.gethostname()) + os_info = lib.version.get_os_info() if os_info: msg += '{} '.format(os_info) msg += 'Kernel {} '.format(run_cmd('uname -r')) + virt = get_virt_info() if virt == 'none': msg += 'on Bare-Metal, ' else: msg += 'virtualized on {}, '.format(virt) + success, firmware_device_model = lib.disk.read_file('/sys/firmware/devicetree/base/model') + if not success: + firmware_device_model = '' if firmware_device_model: msg += '{}, '.format(firmware_device_model) + dmi = lib.dmidecode.get_data() + sys_dimensions = get_sys_dimensions() if dmi: msg += '{} {}, '.format(lib.dmidecode.manufacturer(dmi), lib.dmidecode.model(dmi)) msg += 'Firmware: {}, '.format(lib.dmidecode.firmware(dmi)) @@ -2208,90 +608,33 @@ def main(): else: msg += 'sys dimensions n/a (consider installing psutil), ' - if disks: - msg += '{} {}, '.format( - lib.txt.pluralize('Disk', disks.count(',')+1), - disks, - ) - - msg += '{} boot, '.format(boot_mode) - - if tuned: - msg += 'tuned profile "{}", '.format(tuned) - - success, pub_ip = lib.net.get_public_ip( - args.PUBLIC_IP_URL, - insecure=args.INSECURE, - no_proxy=args.NO_PROXY, - timeout=args.TIMEOUT, - ) - if success: - msg += 'Public IP {}, '.format(pub_ip) - - if birthday and birthday != '-': - msg += 'born {}. '.format(birthday) - - if features_installed: - msg += 'Features: {}. '.format(features_installed[:-2]) - if features_missing: - msg += 'Missing: {}. '.format(features_missing[:-2]) - + disk_msg, disk_count = get_disks() + msg += disk_msg + msg += get_boot_mode() + msg += get_tuned_active_profile() + msg += get_public_ip(args) + msg += get_birthday() msg += 'About-me v{}\n\n'.format(__version__) - # multi-line content - print further lines - - if interfaces: - msg += 'Interfaces (IPv4):\n{}\n'.format(interfaces) - - if ports: - msg += 'Listening TCP/UDP Ports (sorted by port):\n' - for p in ports: - msg += '* {}:{}/{}\n'.format(p['ip'], p['port'], p['proto']) - msg += '\n' - - if installed: - msg += 'SW installed:\n{}\n'.format(installed) - if guessed: - msg += 'SW found/guessed:\n{}\n'.format(guessed) - - if tools: - msg += 'Tools:\n{}\n'.format(tools) - - if nondefault_users: - msg += 'Non-default Users:\n{}\n'.format(nondefault_users) - - if systemd_default_target: - msg += 'systemctl get-default:\n{}\n'.format(systemd_default_target) - - if enabled_units: - msg += 'systemctl list-unit-files --type service --state enabled:\n{}\n'.format(enabled_units) # pylint: disable=C0301 - - if mounts: - msg += 'systemctl list-unit-files --type mount --state static --state generated:\n{}\n'.format(mounts) # pylint: disable=C0301 - - if automounts: - msg += 'systemctl list-unit-files --type automount --state enabled --state static:\n{}\n'.format(automounts) # pylint: disable=C0301 - - if timers: - msg += 'systemctl list-timers:\n{}\n'.format(timers) - - if crontab: - msg += 'crontab:\n{}\n'.format(crontab) - - msg += '3rd-party Python libs required by any of the plugins when running in source code variant:\n' - if pm_installed: - msg += '* Installed: {}\n'.format(', '.join(pm_installed)) - else: - msg += '* Installed: none\n' - if pm_missing: - msg += '* Missing: {}\n'.format(', '.join(pm_missing)) - else: - msg += '* Missing: none\n' - msg += '\n' - - if tags: - msg += 'Guessed Tags:\n{}\n'.format(tags) + # multi-line content - print further lines ----------------------------------------------------- + msg += get_hw_info() + msg += get_interfaces() + msg += get_listening_ports() + msg += get_nondefault_software() + msg += get_nondefault_users() + msg += get_systemd_default_target() + msg += get_systemd_units( + 'systemctl list-unit-files --type=service --state=enabled --no-legend', + ) + msg += get_systemd_units( + 'systemctl list-unit-files --type=mount --state=static --state=generated --no-legend', + ) + msg += get_systemd_units( + 'systemctl list-unit-files --type=automount --state=enabled --state=static --no-legend', + ) + msg += get_systemd_timers() + msg += get_crontab() # perfdata if os_info: @@ -2306,7 +649,7 @@ def main(): elif sys_dimensions: perfdata += lib.base.get_perfdata('cpu', sys_dimensions['cpu'], None, None, None, 0, None) perfdata += lib.base.get_perfdata('ram', sys_dimensions['ram'], 'B', None, None, 0, None) - perfdata += lib.base.get_perfdata('disks', disks.count(',')+1, None, None, None, 0, None) + perfdata += lib.base.get_perfdata('disks', disk_count, None, None, None, 0, None) # over and out lib.base.oao(msg, STATE_OK, perfdata)