[ZBXNEXT-2580] Agent item "system.sw.packages" detail mode Created: 2014 Nov 10  Updated: 2024 Apr 10  Resolved: 2023 Jan 23

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Agent (G)
Affects Version/s: None
Fix Version/s: 6.4.0beta5, 6.4 (plan)

Type: Change Request Priority: Trivial
Reporter: Arthur Ivanov Assignee: dimir
Resolution: Fixed Votes: 12
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBXNEXT-1647 allow to specify format for system.sw... Closed
Sub-Tasks:
Key
Summary
Type
Status
Assignee
ZBXNEXT-8055 Add in frontend item "system.sw.packa... Specification change (Sub-task) Closed Roberts Lataria  
ZBXNEXT-8115 Update template Specification change (Sub-task) Closed Alexander Bakaldin  
Epic Link: DEV-680
Team: Team A
Sprint: Sprint 60 (Jan 2020), Sprint 61 (Feb 2020), Sprint 62 (Mar 2020), Sprint 63 (Apr 2020), Sprint 64 (May 2020), Sprint 65 (Jun 2020), Sprint 66 (Jul 2020), Sprint 67 (Aug 2020), Sprint 68 (Sep 2020), Sprint 69 (Oct 2020), Sprint 70 (Nov 2020), Sprint 93 (Oct 2022), Sprint 94 (Nov 2022), Sprint 95 (Dec 2022), Sprint 96 (Jan 2023)
Story Points: 9

 Description   

Please add format "detail" mode to system.sw.packages[<package>,<manager>,<format>]

Would be greate if detail mode will send packages with thier versions.

for example,
i want to know that tzdata on my 300+ linux servers >= 2014h, if not trigger.



 Comments   
Comment by richlv [ 2014 Nov 10 ]

hmm, that might not be easy to trigger on, though - there isn't really any substring extraction and subsequent matching in triggers

Comment by Arthur Ivanov [ 2014 Nov 10 ]

trigger based on regexp is not problem, for example i can check "if version regexp 2014[a-i] then alarm" or "if version regexp 201[0-3][a-z] then alarm"

Comment by Arthur Ivanov [ 2014 Nov 18 ]

Looks like "dpkg --get-selections" is used for check installed packages:
/src/libs/zbxsysinfo/linux/software.c

static ZBX_PACKAGE_MANAGER package_managers[] =
/* NAME TEST_CMD LIST_CMD PARSER */
{

{"dpkg", "dpkg --version 2> /dev/null", "dpkg --get-selections", dpkg_parser}

,

{"pkgtools", "[ -d /var/log/packages ] && echo true", "ls /var/log/packages", NULL}

,

{"rpm", "rpm --version 2> /dev/null", "rpm -qa", NULL}

,

{"pacman", "pacman --version 2> /dev/null", "pacman -Q", NULL}

,

{NULL}

};

my suggest is to use "dpkg-query --show " because respoanse include version of package

Comment by Arthur Ivanov [ 2014 Nov 18 ]

RHEL/OL/CENTOS

  1. rpm -qa tzdata
    tzdata-2014h-1.el6.noarch

DEBIAN/UBUNTU

  1. dpkg --get-selections tzdata
    tzdata install

my suggestion:

  1. dpkg-query --show tzdata
    tzdata 2014h-0ubuntu0.12.04

in this case UBUNTU response will be more similar to RHEL/OL/CENTOS

Comment by Arthur Ivanov [ 2015 Jan 28 ]

any news?

dpkg --get-selections
change to
dpkg-query --show

and some small modification of dpkg_parser

as result you can see [package]-[version] in response. right now only [package] returned from ubuntu. all other OSes return [package]-[version]

Comment by Arthur Ivanov [ 2015 Jan 28 ]

or just implement system.sw.packageversion[package] that return version of package

it can be used for lot of things.

for example -
today linux vulnerability - GHOST

i just want to catch all hosts that have this weakness by checking package version

Comment by Robert McLay [ 2017 Jan 05 ]

Is there a possibility of using an alternative function on Debian based systems until this is fixed...? I have templates which cannot collect package versions due to this bu/issue.

Presently, I've had to enable a lot of external scripts in order to make this work. My preference for Zabbix over Nagios is partially due to not having to run a lot of external scripts to get functionality such as this.

Happy to provide templates and logs if needed.

Comment by Самосват Николай [ 2018 Jul 02 ]

For rpm-based distrо - return the package version:

[rpm] GeoIP-1.5.0-11.el7.x86_64, NetworkManager-1.4.0-17.el7_3.x86_64...

For debian-based Linux does not return the package version:

[dpkg] acl, acpi, acpi-support-base, acpid, adduser...

It would be cool to be able to specify the format of the returned package list. Or just have versions of deb-packages, for example in this format:

dpkg-query -W -f='${Package} ${Version} ${Architecture}'

Comment by Vladislavs Sokurenko [ 2022 Oct 31 ]

Required functionality could also be achieved by user parameter and CSV to JSON preprocessing step.

UserParameter=system.sw.packages.get,echo 'Package,Version,Architecture' ; dpkg-query -W -f='${Package},${Version},${Architecture}\n'
Comment by dimir [ 2022 Nov 22 ]

C Agent ready for code review in development branch.

New item key system.sw.packages.get[<regexp>,<manager>] available on GNU/Linux systems. It returns JSON in format:

[
    {
        "name": "util-linux-core",
        "manager": "rpm",
        "version": "2.37.4-3.el9",
        "size": 1296335,
        "arch": "x86_64",
        "buildtime": {
            "timestamp" : 1653552239,
            "value" : "Sep 20 01:39:40 2021 UTC"
        },
        "installtime": {
            "timestamp" : 1660780885,
            "value" : "Aug 18 00:01:25 2022 UTC"
        }
    },
    [...]
] 
Comment by dimir [ 2022 Dec 07 ]

Go agent part implemented in development branch (PR)

Comment by dimir [ 2022 Dec 13 ]

Fixed in

New agent and agent2 metric system.sw.packages.get[<regex>, <manager>] (both parameters optional) can be used to monitor details of the installed packages.

After this change current template Template Module Linux generic by Zabbix agent will be modified:

  1. Change item system.sw.packages to system.sw.packages.get .
  2. Add new trigger that fires when number of installed packages change.

For those that want to try the feature until it's documented, the output is in JSON format, containing array of objects, each object describing a package. E. g.

[
    {
        "name": "util-linux-core",
        "manager": "rpm",
        "version": "2.37.4-3.el9",
        "size": 1296335,
        "arch": "x86_64",
        "buildtime": {
            "timestamp" : 1653552239,
            "value" : "Sep 20 01:39:40 2021 UTC"
        },
        "installtime": {
            "timestamp" : 1660780885,
            "value" : "Aug 18 00:01:25 2022 UTC"
        }
    },
    {
        "name": "xfonts-base",
        "manager": "dpkg",
        "version": "1:1.0.5",
        "arch": "all",
        "size": 7337984,
        "buildtime": {
            "timestamp": 0,
            "value": ""
        },
        "installtime": {
            "timestamp": 0,
            "value": ""
        }
    }
]

If build time or install time is not available, their timestamp is 0 and the value (human-readable representation of the datetime) is empty string. Size is in bytes.

Comment by Martins Valkovskis [ 2022 Dec 16 ]

Updated documentation:

Generated at Fri May 16 10:30:34 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.