Code Monkey home page Code Monkey logo

check_pakfire's Introduction

check_pakfire

check_pakfire is a Nagios / Icinga plugin for checking IPFire Pakfire updates and required reboots.

Requirements

I successfully tested the plugin with IPFire 2.x. I'm not sure whether IPFire 3.x comes with a new Pakfire architecture - so, use this on newer versions at your own risk. ;-)

No additional Python packages are required - just deploy the script and use it.

Note: Beginning with plugin version 1.4, Python 3 is the only supported version. If you're using an older IPFire release, you will need to use plugin version 1.3.

Usage

By default, the script checks for core updates and also packages upgrades - it is also possible to only check core updates (-e / --exclude-packages parameters). Gathering performance data (outdated packages) can be useful when monitoring a big amount of IPFire systems.

The following parameters can be specified:

Parameter Description
-d / --debug enable debugging outputs (default: no)
-h / --help shows help and quits
-e / --exclude-packages disables checking for package updates (default: no)
-m / --mirror defines one or multiple mirrors (default: system mirror list)
-n / --need-reboot defines exit level if reboot is required (default: w)
-P / --show-perfdata enables performance data (default: no)
-w / --packages-warning defines warning threshold for outdated packages (default: 1)
-c / --packages-critical defines warning threshold for outdated packages (default: 5)
-W / --core-warning defines warning threshold for outdated core (default: 1)
-C / --core-critical defines warning threshold for outdated core (default: 3)
--version prints programm version and quits

Examples

The following example checks for core updates only:

$ ./check_pakfire.py -e
OK: Core update (124) up2date

A IPFire host with some outdated packages:

$ ./check_pakfire.py
WARNING: Core update (124) up2date, packages outdated (linue-pae, lcd4linux)

An updated IPFire host with performance data:

$ ./check_pakfire.py
WARNING: Core update (124) up2date, packages outdated (linue-pae, lcd4linux) | 'system_updates'=0;;;; 'outdated_packages'=2.0;1.0;5.0;;

An outdated host with a pending reboot:

$ ./check_pakfire.py
CRITICAL: Core update (128) outdated (130), packages up2date, system reboot required

Installation

To install the plugin, move the Python script into the appropriate directory and create a configuration.

Configuration

Nagios / Icinga 1.x

Within Nagios / Icinga you will need to configure a remote check command, e.g. for NRPE:

# check_nrpe_pakfire
define command{
    command_name        check_nrpe_pakfire
    command_line        $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_pakfire -a $ARG1$
}

Configure the check for a particular host, e.g.:

# DIAG: Updates
define service{
        use                             generic-service
        host_name                       st-ipfire03
        service_description             DIAG: Updates
        check_command                   check_nrpe_pakfire!-P
}

Icinga2

Define a service like this:

apply Service "DIAG: Updates" {
  import "generic-service"
  check_command = "by_ssh"
  vars.by_ssh_command = [ "/opt/check_pakfire.py", "-P" ]
  vars.by_ssh_port = host.vars.ssh_port
  vars.by_ssh_logname = "icinga"
  assign where host.vars.os == "Linux" && host.vars.app == "router"
}

Define SSH port and application for your IPFire host:

object Host "st-ipfire03.stankowic.loc" {
  import "generic-host"

  address = "xxx"

  vars.os = "Linux"
  vars.app = "router"

  vars.ssh_port = 222
}

Validate the configuration and reload the Icinga2 daemon:

# icinga2 daemon -C
# service icinga2 reload

check_pakfire's People

Contributors

stdevel avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

check_pakfire's Issues

Plugin is checking all the mirrors

The plugin currently checks all the mirrors instead of picking the first working one:

$ ./check_pakfire.py
ERROR:check_pakfire:Unable to validate mirror 'https://ftp.gwdg.de/pub/linux/ipfire/pakfire2/2.21': '<urlopen error [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:661)>'
ERROR:check_pakfire:Unable to validate mirror 'https://mirror1.ipfire.org/pakfire2/2.21': '<urlopen error [Errno -2] Name or service not known>'
OK: Core update (125) up2date, packages up2date

As a result, the plugin takes quite long to check the system state and Nagios/Icinga might return a timeout:

$ time ./check_pakfire.py
...
real    0m36.631s
user    0m10.301s
sys     0m0.163s

Implement possibility to blacklist mirrors

It would be nice to have a possibility to blacklist or skip mirrors as some of them are overloaded sometimes:

DIAG: Updates on pinkepank.giertz.loc is WARNING!

Info:    Remote command execution failed: ERROR:check_pakfire:Unable to validate mirror 'https://firemirror.scp-systems.ch/pakfire2/2.21': '<urlopen error [Errno -2] Name or service not known>'

Error on Ipfire 2.21 Core 122

Hi there,

on the new version of Ipfire (2.21 Core 122) comes a error when i run the check_pakfire.py script.

[root@router ~]# /usr/lib/nagios/check_pakfire.py -d
OPTIONS: {'mirrors': [], 'pkgs_warn': 5, 'show_perfdata': False, 'exclude_pkgs': False, 'pkgs_crit': 10, 'debug': True, 'list_pkgs': False}
RELEASE: 2.21, UPDATE: 122
Traceback (most recent call last):
  File "/usr/lib/nagios/check_pakfire.py", line 213, in <module>
    sys_pkgs = get_local_pkg_versions()
  File "/usr/lib/nagios/check_pakfire.py", line 103, in get_local_pkg_versions
    if my_name != "core-upgrade":
UnboundLocalError: local variable 'my_name' referenced before assignment

is there a chance for a fix ?

Thx

Smooky

Utilize nagiosplugin python module and refactor code

Utilizing the nagiosplugin python module would simplify maintaining the code.
Also, some things in the code are pretty ugly:

        # get outdated packages
        outdated = [key for key, value in sys_pkgs.items() if value != cur_pkgs.get(key)]
        # TODO: wtf
        if len(outdated) > 0:
            bool_pkgs = False
        else:
            bool_pkgs = True

-W / -C not working

Hi Christian,

if I add command line options -W 0 or -C 0 check_pakfire.py (a39c539) allways reports "OK"

I added some changes in handling the integer values, print out performance output for core updates and also added a feature to check if a system reboot is needed when updates are done (see attached file "check_pakfire-diffs.txt")

Maybe you can incorporate the extensions into your code?

Greetings from Dortmund/Germany

Edgar

check_pakfire_v1.3.0.py.txt
check_pakfire-diff.txt

Checking packages crashes

Checking for outdated packages is not possible due to a typo in the code:

# ./check_pakfire.py -i
Traceback (most recent call last):
  File "./check_pakfire.py", line 195, in <module>
    checkUpdates()
  File "./check_pakfire.py", line 134, in checkUpdates
    if boolCore == True and boolPKgs == False:
NameError: global name 'boolPKgs' is not defined

Checking the core update works without any issues:

# ./check_pakfire.py 
OK: Core Update '103' for release '2.19' up2date!

Ipfire were switched from http to https

Hi Christian.

The Ipfire mirrors were switched from http to https.

I think your script need an update on line 43 from

if "HTTP;" in line.rstrip():

to

if "HTTPS;" in line.rstrip():

Thx for your great work.

Best wishes,
Marcel

-c / -w are not evaluated

Currently, -c and -w are not evaluated:

# ./check_pakfire.py -w 1
WARNING: Core Update '113' for release '2.19' up2date, but 2 package(s) outdated!
# ./check_pakfire.py -w 5
WARNING: Core Update '113' for release '2.19' up2date, but 2 package(s) outdated!
# ./check_pakfire.py -c 1
WARNING: Core Update '113' for release '2.19' up2date, but 2 package(s) outdated!

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.