[ZBX-22678] Agent2 item system.sw.packages.get is unsupported Created: 2023 Apr 14  Updated: 2024 Apr 10  Resolved: 2023 Dec 19

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G), Agent2 plugin (G)
Affects Version/s: 6.4.1
Fix Version/s: 6.4.9rc1, 7.0.0alpha8, 7.0 (plan)

Type: Problem report Priority: Major
Reporter: Svyatoslav Ignatev Assignee: Juris Lambda
Resolution: Fixed Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian Buster 10 (4.19.0-17-amd64 #1 SMP Debian 4.19.194-2 (2021-06-21) x86_64 GNU/Linux)
Ubuntu Focal 20.04 (5.4.0-146-generic #163-Ubuntu SMP Fri Mar 17 18:26:02 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux)


Attachments: File debian-10-buster_2023Apr20.log     HTML File debian-10-buster_bash_history     File debian_dpkg-query.list     File debian_dpkg-selections.list     Text File debian_system_sw_packages_get.log     File ubuntu-20.04-focal_2023Apr20.log     File ubuntu-20.04-focal_bash_history     Text File ubuntu22_agent2_system_sw_packages_get.log     Text File ubuntu22_agentd_system_sw_packages_get.log     File ubuntu22_dpkg-query.list     File ubuntu22_dpkg-query_with_grep.list     File ubuntu22_dpkg-selections.list     File ubuntu_dpkg-query.list     File ubuntu_dpkg-selections.list     Text File ubuntu_system_sw_packages_get.log    
Issue Links:
Causes
caused by ZBXNEXT-7569 Allow to use system.sw.packages on ge... Closed
Duplicate
Team: Team B
Sprint: Product delivery backlog
Story Points: 1

 Description   

On some linux servers system.sw.packages.get is unsupported with error "[Sw] Failed to parse 'dpkg --get-selections' output, err: strconv.ParseUint: parsing "": invalid syntax"

Steps to reproduce:

  1. Login via ssh to linux server
  2. Switch to root
  3. Execute "zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf -t system.sw.packages.get -v"

Result:
See log files ubuntu_system_sw_packages_get.log / debian_system_sw_packages_get.log
Output of "dpkg --get-selections" and "LC_ALL=C dpkg-query -W -f='${Status},${Package},${Version},${Architecture},${Installed-Size}\n'", from sw module (sw_linux.go) in attachments.
Item also not supported in monitoring via latest linux os template.
However, item system.sw.packages is working fine.

Expected:
The item is supported and work fine.



 Comments   
Comment by Jurijs Klopovskis [ 2023 Apr 17 ]

Seems like a regression caused by ZBXNEXT-7569

Comment by Juris Lambda [ 2023 Apr 20 ]

Hi, signatev!

I tried reproducing this on both systems with a build from packages, and everything appears to work as expected. See the command and info logs below:

Are these agents you're using from packages?

CLOSING for now. If you do identify a scenario in which this occurs reliably, or the cause, and believe it to be a bug in Zabbix, feel free to reopen this issue.

Comment by Svyatoslav Ignatev [ 2023 Apr 21 ]

Found a package that will break system.sw.packages.get functionality so hopefully you will be able to reproduce it. It's a mongodb-org from mongo repository https://www.mongodb.com/docs/v6.0/tutorial/install-mongodb-on-ubuntu/

Change in environment:

Ubuntu 22.04.2 LTS (5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux), mongodb-org 6.0.5 amd64.

Change in reproduce steps:

  1. Login via ssh to ubuntu 22.04.02;
  2. Switch to root;
  3. Execute "zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf -t system.sw.packages.get -v";
  4. Make sure it is working fine;
  5. Install mongodb-org by tutorial;
  6. Execute "zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf -t system.sw.packages.get -v".

The result is same.

Also noticed two things.

First, in those dpkg-query lists that I've sent you before some packages does not have "Installed-Size" value. You can look them up by regular expression ",$". You can also find that kind of packages by running a command:

LC_ALL=C dpkg-query -W -f='${Status},${Package},${Version},${Architecture},${Installed-Size}\n' | grep -e ',$'

from shell. One of those packages is supposed to be "mongodb-database-tools".
++

Second, that package does not break that functionality on zabbix_agentd - it just ignores that package from result output

Comment by Juris Lambda [ 2023 Apr 24 ]

I managed to reproduce this, as per signatev's last comment, last Friday (April 21st, 2023), and it did fail as described, but today I can no longer get the mongodb packages to install as they previously did, because a dependency on libssl3 cannot be fulfilled.

The packages this is failing for are meta-packages (there are a few such packages provided by the upstream developer, mongodb-org-unstable, mongodb-org-unstable-tools, mongodb-org-unstable-database-tools-extra and others), which do not have an Installed-Size attribute, hence the dpkg output field is either "unknown" or just absent, and we fail to parse it as a number.

root@aa63c8d7d963:~# apt info mongodb-database-tools
Package: mongodb-database-tools
Version: 100.7.0
Priority: optional
Section: database
Maintainer: MongoDB Connectors Team <[email protected]>
Installed-Size: unknown
Provides: mongodb-database-tools
Depends: libc6, libgssapi-krb5-2, libkrb5-3, libk5crypto3, libcomerr2, libkrb5support0, libkeyutils1
Conflicts: mongodb-database-tools
Breaks: mongodb-org-tools (<= 4.3.2), mongodb-org-tools-unstable (<= 4.3.2), mongodb-enterprise-tools (<= 4.3.2), mongodb-enterprise-tools-unstable (<= 4.3.2)
Replaces: mongodb-database-tools (<= 100.7.0), mongodb-org-tools (<= 4.3.2), mongodb-org-tools-unstable (<= 4.3.2), mongodb-enterprise-tools (<= 4.3.2), mongodb-enterprise-tools-unstable (<= 4.3.2)
Homepage: http://www.mongodb.com
Download-Size: 50.6 MB
APT-Sources: https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0/multiverse amd64 Packages
Description: ...

Generally, metapackages from Debian contain at least a Debian changelog (changelog.Debian.gz), which allows calculating their Installed-Size. This doesn't appear to be the case for the packages in the MongoDB repository, where the meta-packages only declare dependencies. For example, the emacs metapackage looks like this:

root@aa63c8d7d963:~# apt info emacs
Package: emacs
Version: 1:26.3+1-1ubuntu2
Priority: optional
Section: universe/editors
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Rob Browning <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 77.8 kB
Depends: emacs-gtk (>= 1:26.3) | emacs-lucid (>= 1:26.3) | emacs-nox (>= 1:26.3)
Homepage: https://www.gnu.org/software/emacs/
Download-Size: 12.7 kB
APT-Manual-Installed: yes
APT-Sources: http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
Description: GNU Emacs editor (metapackage)

Although uncommon, this is a valid package and valid behaviour. We should probably verify if we have the data before converting them into values. Due to the recent addition of Portage support (ZBXNEXT-7569), the size attributes have become optional, making this less breaking than expected.

I didn't immediately find a way to ignore meta-packages in dpkg's usage.

Comment by Jason [ 2023 May 15 ]

I'd like to add some additional details from my environment. I am encountering this exact bug on 2 of my 25 linux servers, specifically on Zabbix Agent 2 (6.4.2) on Debian 11 (5.10.0-22-amd64 #1 SMP Debian 5.10.178-3 (2023-04-22).

I am using the system.sw.packages.get key in my discover rule, which means the entire discovery process fails because of this bug.

In addition to the mongodb-database-tools package, the matrix keyring package also has the problem.

 

# LC_ALL=C dpkg-query -W -f='${Status},${Package},${Version},${Architecture},${Installed-Size}\n' | grep -e ',$'
install ok installed,matrix-org-archive-keyring,1.3,all,

 

Details about the matrix server install in my environment:

ii  matrix-org-archive-keyring    1.3                            all          The matrix.org package repository keyring
ii  matrix-synapse-py3            1.83.0+bullseye1               amd64        Open federated Instant Messaging and VoIP server

Just to add the mongo line as well.

# LC_ALL=C dpkg-query -W -f='${Status},${Package},${Version},${Architecture},${Installed-Size}\n' | grep -e ',$'
install ok installed,mongodb-database-tools,100.7.0,amd64,

 

Hope this gets fixed in the next release!

 

 

Comment by Oleg Gawriloff [ 2023 Sep 13 ]

Experiencing the same error on appliance (debian 9 based) with some 'vendor custom' packages:
root@belvpn:~# LC_ALL=C dpkg-query -W -f='${Status},${Package},${Version},${Architecture},${Installed-Size}\n' | grep -e ',$'
install ok installed,belvpngate,4.5.200414av+c3,amd64,
install ok installed,sterra-l2,4.1.14711,amd64,
install ok installed,sterrasystem-vmware,4.1-37,all,
install ok installed,vpnupagent,4.5.200304,amd64,

So it seems that not all packages have 'installed-size' field, but as it is an appliance we can not fix that packages.

Comment by James Howe [ 2023 Nov 06 ]

Can confirm a missing Installed-Size appears to be the cause. In my case it's due to dcism-osc from Dell.

Comment by Juris Lambda [ 2023 Nov 08 ]

Fix for 7.0.0alpha8 available in feature/ZBX-22678-6.5. This patch applies without issues to 6.4.

Comment by Juris Lambda [ 2023 Dec 18 ]

Available in:

Comment by Arturs Dancis [ 2023 Dec 19 ]

Documentation updated:

  • Installation > Upgrade notes (6.4.11)
  • Appendixes > Items > Return values (6.4, 7.0)
Generated at Sat May 03 07:18:16 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.