checkmk-agent mit Fabric aktualisieren

Der installierte checkmk-agent sollte auf den überwachten Systemen auch ab und zu mal aktualisiert werden.
In der Enterprise Edition lässt sich das mit der Agent Bakery automatisieren, in der freien Raw Edition ist diese aber nicht enthalten.

Um meine Linux Server nicht alle einzeln updaten zu müssen, nutze ich jetzt Fabric. In einem Rutsch werden alle aktualisiert.

  • Checkmk Raw Edition 1.6.0
  • Fabric 1.14.1 (Linux Server mit Fabric verwalten)
  • 17 Linux Server
  • jeder Server hat einen monitoring user (cmk) mit sudo Rechten ohne Passwort

Für das verteilte Update mit Fabric erstelle ich ein eigenes checkmk-agent-update.py fabfile.

from fabric.api import *

# linux server
env.hosts = [
    'cmk@server01',
    'cmk@server02',
    'cmk@server03',
    'cmk@server04',
    'cmk@server05',
    'cmk@server06',
    'cmk@server07',
    'cmk@server08',
    'cmk@server09',
    'cmk@server10',
    'cmk@server11',
    'cmk@server12',
    'cmk@server13',
    'cmk@server14',
    'cmk@server15',
    'cmk@server16',
    'cmk@server17',
]

# global vars
env.colorize_errors = True

# update check-mk-agent (*.deb)
def cmkagent_update():
    run('wget http://nms.bachmann.lan/blan/check_mk/agents/check-mk-agent_1.6.0p11-1_all.deb')
    run('sudo dpkg -i ~/check-mk-agent_1.6.0p11-1_all.deb')
    run('rm ~/check-mk-agent_1.6.0p11-1_all.deb')

Das check-mk-agent_1.6.0*.deb file wird mit wget vom Checkmk Server heruntergeladen, mit sudo installiert und danach wieder gelöscht.

root@nms:/opt/fabric# fab -f checkmk-agent-update.py cmkagent_update

[cmk@server01] Executing task 'cmkagent_update'
[cmk@server01] run: wget http://nms.bachmann.lan/blan/check_mk/agents/check-mk-agent_1.6.0p11-1_all.deb
[cmk@server01] Login password for 'cmk':
[cmk@server01] out: --2020-05-21 19:13:40--  http://nms.bachmann.lan/blan/check_mk/agents/check-mk-agent_1.6.0p11-1_all.deb
[cmk@server01] out: Resolving nms.bachmann.lan (nms.bachmann.lan)... 192.168.150.134
[cmk@server01] out: Connecting to nms.bachmann.lan (nms.bachmann.lan)|192.168.150.134|:80... connected.
[cmk@server01] out: HTTP request sent, awaiting response... 200 OK
[cmk@server01] out: Length: 26616 (26K) [application/x-debian-package]
[cmk@server01] out: Saving to: ‘check-mk-agent_1.6.0p11-1_all.deb’
[cmk@server01] out:
[cmk@server01] out: check-mk-agent_1.6.0p11-1_all.deb  100%[=================================================>]  25.99K  --.-KB/s  in 0s
[cmk@server01] out:
[cmk@server01] out: 2020-05-21 19:13:40 (275 MB/s) - ‘check-mk-agent_1.6.0p11-1_all.deb’ saved [26616/26616]
[cmk@server01] out:

[cmk@server01] run: sudo dpkg -i ~/check-mk-agent_1.6.0p11-1_all.deb
[cmk@server01] out: (Reading database ...
[cmk@server01] out: (Reading database ... 5%
[cmk@server01] out: (Reading database ... 10%
[cmk@server01] out: (Reading database ... 15%
[cmk@server01] out: (Reading database ... 20%
[cmk@server01] out: (Reading database ... 25%
[cmk@server01] out: (Reading database ... 30%
[cmk@server01] out: (Reading database ... 35%
[cmk@server01] out: (Reading database ... 40%
[cmk@server01] out: (Reading database ... 45%
[cmk@server01] out: (Reading database ... 50%
[cmk@server01] out: (Reading database ... 55%
[cmk@server01] out: (Reading database ... 60%
[cmk@server01] out: (Reading database ... 65%
[cmk@server01] out: (Reading database ... 70%
[cmk@server01] out: (Reading database ... 75%
[cmk@server01] out: (Reading database ... 80%
[cmk@server01] out: (Reading database ... 85%
[cmk@server01] out: (Reading database ... 90%
[cmk@server01] out: (Reading database ... 95%
[cmk@server01] out: (Reading database ... 100%
[cmk@server01] out: (Reading database ... 49637 files and directories currently installed.)
[cmk@server01] out: Preparing to unpack .../check-mk-agent_1.6.0p11-1_all.deb ...
[cmk@server01] out: Unpacking check-mk-agent (1.6.0p11-1) over (1.6.0p10-1) ...
[cmk@server01] out: Setting up check-mk-agent (1.6.0p11-1) ...
[cmk@server01] out: Enable Checkmk Agent in systemd...
[cmk@server01] out:

[cmk@server01] run: rm ~/check-mk-agent_1.6.0p11-1_all.deb

[cmk@server02] Executing task 'cmkagent_update'
[cmk@server02] run: wget http://nms.bachmann.lan/blan/check_mk/agents/check-mk-agent_1.6.0p11-1_all.deb

--- SNIP ---

Done.
Disconnecting from cmk@server01... done.
Disconnecting from cmk@server02... done.
Disconnecting from cmk@server03... done.
Disconnecting from cmk@server04... done.
Disconnecting from cmk@server05... done.
Disconnecting from cmk@server06... done.
Disconnecting from cmk@server07... done.
Disconnecting from cmk@server08... done.
Disconnecting from cmk@server09... done.
Disconnecting from cmk@server10... done.
Disconnecting from cmk@server11... done.
Disconnecting from cmk@server12... done.
Disconnecting from cmk@server13... done.
Disconnecting from cmk@server14... done.
Disconnecting from cmk@server15... done.
Disconnecting from cmk@server16... done.
Disconnecting from cmk@server17... done.

So schnell hatte ich noch nie auf meinen Linux Servern den Agent aktualisiert. :)

Schreibe einen Kommentar