Giter VIP home page Giter VIP logo

zabbix-apt's Introduction

Zabbix template for monitoring APT package updates.

This template uses -s simulation option when invoking apt-get, so no root access is needed for Zabbix user during polling.

Notes

However, root access is required for updating APT repositories. Since Zabbix runs under a dedicated user, it can be done either by using sudo in agent configuration script below, using a dedicated crontab entry to invoke apt-get update periodically or use APT::Periodic functionality bundled inside the APT system itself. Support for the APT::Periodic is included in this setup.

Since APT::Periodic is executed via already existing APT maintenace script located in cron.daily, the minimum period of updating repositories is once a day. If shorter period is required, a spearate cron.hourly script is needed instead.

Installation

  1. Copy apt.conf.d/02periodic script to /etc/apt/apt.conf.d directory to configure daily automatic package repository updates using APT::Periodic.
  2. Copy zabbix_agentd.d/apt.conf to the Zabbix agent's configuration directory (usually located in /etc/zabbix).
  3. Import templates/apt-updates.xml to Zabbix frontend.

zabbix-apt's People

Contributors

theranger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

zabbix-apt's Issues

Feature: Add additional items with package names

Hi!

FWIW, since this is working great even with Zabbix 6.2, I made some modifications to get the package names besides only the counters, so that I can decide, if there is an important update or not.

  1. Change apt.conf:
# Treat security and regular updates differently
# This is just a simulation, that can be run under zabbix user
# Since updating packages lists (apt-get update) requires root user,
# use APT::Periodic or some other functionality for that
UserParameter=apt.security,apt-get -s upgrade | grep -ci ^inst.*security | tr -d '\n'
UserParameter=apt.updates,apt-get -s upgrade | grep -iPc '^Inst((?!security).)*$' | tr -d '\n'
UserParameter=apt.sec_text,apt-get -s upgrade | grep -io ^inst.*security | grep -oiP "([a-z0-9\.\-]+) \[([a-z0-9:~\-\+.]+)\] \(([a-z0-9:~\-\+.]+)" | sed 's#] (# -> #' | sed 's/$/]/'
UserParameter=apt.upd_text,apt-get -s upgrade | grep -iP '^Inst((?!security).)*$' | grep -oiP "([a-z0-9\.\-]+) \[([a-z0-9:~\-\+.]+)\] \(([a-z0-9:~\-\+.]+)" | sed 's#] (# -> #' | sed 's/$/]/'
  1. Modify Template:
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>6.2</version>
    <date>2022-11-30T12:35:37Z</date>
    <template_groups>
        <template_group>
            <uuid>a571c0d144b14fd4a87a9d9b2aa9fcd6</uuid>
            <name>Templates/Applications</name>
        </template_group>
    </template_groups>
    <templates>
        <template>
            <uuid>ab900107205f48a5a79f6e83aaf610b9</uuid>
            <template>Template App APT Updates</template>
            <name>Template App APT Updates</name>
            <groups>
                <group>
                    <name>Templates/Applications</name>
                </group>
            </groups>
            <items>
                <item>
                    <uuid>7e25def970a84995b72a546bdb02c5c5</uuid>
                    <name>Security Updates</name>
                    <key>apt.security</key>
                    <delay>900</delay>
                    <trends>0</trends>
                    <tags>
                        <tag>
                            <tag>Application</tag>
                            <value>APT</value>
                        </tag>
                    </tags>
                </item>
                <item>
                    <uuid>0e4be9aa803340f99435f3784e735289</uuid>
                    <name>Security Content</name>
                    <key>apt.sec_text</key>
                    <delay>900</delay>
                    <trends>0</trends>
                    <value_type>TEXT</value_type>
                    <tags>
                        <tag>
                            <tag>Application</tag>
                            <value>APT</value>
                        </tag>
                        <tag>
                            <tag>APT</tag>
                            <value>Security</value>
                        </tag>
                    </tags>
                </item>
                <item>
                    <uuid>61b656de95544835984db066a375465a</uuid>
                    <name>Non-Critical Updates</name>
                    <key>apt.updates</key>
                    <delay>900</delay>
                    <trends>0</trends>
                    <tags>
                        <tag>
                            <tag>Application</tag>
                            <value>APT</value>
                        </tag>
                    </tags>
                </item>
                <item>
                    <uuid>726ce535bbe44f3080b0e6140636e3fc</uuid>
                    <name>Non-Critical Content</name>
                    <key>apt.upd_text</key>
                    <delay>900</delay>
                    <trends>0</trends>
                    <value_type>TEXT</value_type>
                    <tags>
                        <tag>
                            <tag>Application</tag>
                            <value>APT</value>
                        </tag>
                        <tag>
                            <tag>APT</tag>
                            <value>Non-Critical</value>
                        </tag>
                    </tags>
                </item>
            </items>
            <tags>
                <tag>
                    <tag>Application</tag>
                    <value>APT</value>
                </tag>
            </tags>
        </template>
    </templates>
    <triggers>
        <trigger>
            <uuid>e2fdafc15f5b4d5da61b2bbdadcb1735</uuid>
            <expression>last(/Template App APT Updates/apt.security)&gt;0 and last(/Template App APT Updates/apt.updates)&gt;0</expression>
            <name>{ITEM.LASTVALUE1} security and {ITEM.LASTVALUE2} regular updates on {HOST.NAME}</name>
            <priority>WARNING</priority>
            <manual_close>YES</manual_close>
        </trigger>
        <trigger>
            <uuid>c1083010fed846a199220a0685a7e998</uuid>
            <expression>last(/Template App APT Updates/apt.security)&gt;0 and last(/Template App APT Updates/apt.updates)=0</expression>
            <name>{ITEM.LASTVALUE} of security updates on {HOST.NAME}:</name>
            <priority>WARNING</priority>
            <manual_close>YES</manual_close>
        </trigger>
        <trigger>
            <uuid>61d9a47e71914a21ab18499d2fe1f4c2</uuid>
            <expression>last(/Template App APT Updates/apt.updates)&gt;0 and last(/Template App APT Updates/apt.security)=0</expression>
            <name>{ITEM.LASTVALUE} regular updates on {HOST.NAME}</name>
            <priority>INFO</priority>
            <manual_close>YES</manual_close>
        </trigger>
    </triggers>
</zabbix_export>

You will get two new items Security Content and Non-Critical Content, which will show the package names of pending upgrades.

I, additionally, added a table widget to my Zabbix Dashboard, with the content of all 4 variables, so that I have a quick overview of what is pending.

Regards,
Holger

missing some updates

Thanks for this Zabbix template!

I'm running Ubuntu 18.04 LTS, Zabbix 4.0 and the latest version of this template. Some updates were not detected.

The attached log file apt-upgrade-log.txt shows the output of apt-get -s upgrade and apt-get -s dist-upgrade on my machine.

To fix this, in apt.conf, I had to change the apt command to apt-get -s dist-upgrade to detect the missed updates.

#/etc/zabbix/zabbix_agentd.d/apt.conf
UserParameter=apt.security,apt-get -s dist-upgrade | grep -ci ^inst.*security | tr -d '\n'
UserParameter=apt.updates,apt-get -s dist-upgrade | grep -iPc '^Inst((?!security).)*$' | tr -d '\n'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.