Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / agents / plugins / mk_apt
blob31f930ba3ddc3110a1ff28af2bbb707ccdc552d9
1 #!/bin/bash
2 # Check for APT updates (Debian, Ubuntu)
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # TODO:
28 # Einstellungen:
29 # - upgrade oder dist-upgrade
30 # - vorher ein update machen
31 # Bakery:
32 # - Bakelet anlegen
33 # - Async-Zeit einstellbar machen und das Ding immer async laufen lassen
34 # Check programmieren:
35 # * Schwellwerte auf Anzahlen
36 # * Regexen auf Pakete, die zu CRIT/WARN führen
37 # - Graph malen mit zwei Kurven
39 # This variable can either be "upgrade" or "dist-upgrade"
40 UPGRADE=upgrade
41 DO_UPDATE=yes
44 function check_apt_update {
45 if [ "$DO_UPDATE" = yes ] ; then
46 # NOTE: Even with -qq, apt-get update can output several lines to
47 # stderr, e.g.:
49 # W: There is no public key available for the following key IDs:
50 # 1397BC53640DB551
51 apt-get update -qq 2> /dev/null
53 apt-get -o 'Debug::NoLocking=true' -o 'APT::Get::Show-User-Simulation-Note=false' -s -qq "$UPGRADE" | grep -v '^Conf'
57 if type apt-get > /dev/null ; then
58 echo '<<<apt:sep(0)>>>'
59 out=$(check_apt_update)
60 if [ -z "$out" ]; then
61 echo "No updates pending for installation"
62 else
63 echo "$out"