[solved] Lancom SNMP monitoring - source code string cannot contain null bytes

Hi,

Ich versuche einige Lancom Router (LANCOM 1783VAW) via SNMP zu Monitoren. Das kuriose ist, bei 5 Routern funktioniert es einwandfrei, bei anderen 5 Routern leider nicht. Alle Router sind identisch konfiguriert.

Ein snmpwalk gibt mir die OID aus.

Ich bekomme folgende Fehlermeldung bei denen wo es nicht funktioniert:

OMD[xxx]:~$ time cmk -nv Lancom10
Checkmk version 2.0.0p9

  • FETCHING DATA
    [SNMPFetcher] Execute data source
  • PARSE FETCHER RESULTS
    Received no piggyback data
    [snmp] source code string cannot contain null bytes(?), execution time 0.0 sec | execution_time=0.020 user_time=0.020 system_time=0.000 children_user_time=0.000 children_system_time=0.000 cmk_time_snmp=0.000

real 0m2.231s
user 0m1.992s
sys 0m0.234s

Hat einer ne Idee woran das liegt?

Grüße…

Hallo @mc83,

Bitte mal cmk -II -vvp --debug Lancom10 aufrufen, dann sollte mehr zu sehen sein.

1 Like

Hallo @r.sander,

danke fΓΌr deine Antwort, tatsΓ€chlich bekomme ich mehr ausgegeben:

OMD[xxx]:~$ time cmk --debug -vvp Lancom10
Checkmk version 2.0.0p9
Try license usage history update.
Trying to acquire lock on /omd/sites/xxx/var/check_mk/license_usage/next_run
Got lock on /omd/sites/xxx/var/check_mk/license_usage/next_run
Trying to acquire lock on /omd/sites/xxx/var/check_mk/license_usage/history.json
Got lock on /omd/sites/xxx/var/check_mk/license_usage/history.json
Next run time has not been reached yet. Abort.
Releasing lock on /omd/sites/xxx/var/check_mk/license_usage/history.json
Released lock on /omd/sites/xxx/var/check_mk/license_usage/history.json
Releasing lock on /omd/sites/xxx/var/check_mk/license_usage/next_run
Released lock on /omd/sites/xxx/var/check_mk/license_usage/next_run
Loading autochecks from /omd/sites/xxx/var/check_mk/autochecks/Lancom10.mk
+ FETCHING DATA
  Source: SourceType.HOST/FetcherType.SNMP
[cpu_tracking] Start [7fe979ccdf10]
[SNMPFetcher] Fetch with cache settings: SNMPFileCache(base_path=PosixPath('/omd/sites/xxx/tmp/check_mk/data_source_cache/snmp/Lancom10'), max_age=MaxAge(checking=0, discovery=120, inventory=120), disabled=False, use_outdated=False, simulation=False)
Not using cache (Does not exist)
[SNMPFetcher] Execute data source
[cpu_tracking] Stop [7fe979ccdf10 - Snapshot(process=posix.times_result(user=0.010000000000000009, system=0.0, children_user=0.0, children_system=0.0, elapsed=0.010000001639127731))]
Trying to acquire lock on /omd/sites/xxx/var/check_mk/crashes/base/ad04ab7c-1136-11ec-aba2-26ca43a40802/crash.info
Got lock on /omd/sites/xxx/var/check_mk/crashes/base/ad04ab7c-1136-11ec-aba2-26ca43a40802/crash.info
Releasing lock on /omd/sites/xxx/var/check_mk/crashes/base/ad04ab7c-1136-11ec-aba2-26ca43a40802/crash.info
Released lock on /omd/sites/xxx/var/check_mk/crashes/base/ad04ab7c-1136-11ec-aba2-26ca43a40802/crash.info
Traceback (most recent call last):
  File "/omd/sites/xxx/bin/cmk", line 98, in <module>
    exit_status = modes.call("--check", None, opts, args)
  File "/omd/sites/xxx/lib/python3/cmk/base/modes/__init__.py", line 69, in call
    return handler(*handler_args)
  File "/omd/sites/xxx/lib/python3/cmk/base/modes/check_mk.py", line 1643, in mode_check
    return checking.do_check(
  File "/omd/sites/xxx/lib/python3/cmk/base/decorator.py", line 37, in wrapped_check_func
    status, infotexts, long_infotexts, perfdata = check_func(hostname, *args, **kwargs)
  File "/omd/sites/xxx/lib/python3/cmk/base/checking.py", line 195, in do_check
    fetcher_messages = list(
  File "/omd/sites/xxx/lib/python3/cmk/base/checkers/_checkers.py", line 247, in fetch_all
    raw_data = source.fetch()
  File "/omd/sites/xxx/lib/python3/cmk/base/checkers/_abstract.py", line 163, in fetch
    return fetcher.fetch(self.mode)
  File "/omd/sites/xxx/lib/python3/cmk/fetchers/_base.py", line 263, in fetch
    return result.OK(self._fetch(mode))
  File "/omd/sites/xxx/lib/python3/cmk/fetchers/_base.py", line 281, in _fetch
    raw_data = self._fetch_from_io(mode)
  File "/omd/sites/xxx/lib/python3/cmk/fetchers/snmp.py", line 323, in _fetch_from_io
    persisted_sections = (self._section_store.load() if mode is Mode.CHECKING else
  File "/omd/sites/xxx/lib/python3/cmk/fetchers/cache.py", line 95, in load
    raw_sections_data = _store.load_object_from_file(self.path, default={})
  File "/omd/sites/xxx/lib/python3/cmk/utils/store.py", line 204, in load_object_from_file
    return ast.literal_eval(content)
  File "/omd/sites/xxx/lib/python3.8/ast.py", line 59, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "/omd/sites/xxx/lib/python3.8/ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
ValueError: source code string cannot contain null bytes

real    0m2.821s
user    0m2.441s
sys     0m0.370s

Wirklich weiter bringt mich die Ausgabe aber leider nicht.

Edit: Hier noch der Inhalt der crash.info

OMD[xxx]:~/var/check_mk/crashes/base/ad04ab7c-1136-11ec-aba2-26ca43a40802$ cat crash.info | jq
{
  "time": 1631168706.6755056,
  "os": "Ubuntu 18.04.5 LTS",
  "version": "2.0.0p9",
  "edition": "cee",
  "core": "cmc",
  "python_version": "3.8.7 (default, Feb  3 2021, 02:50:03) \n[GCC 10.1.0]",
  "python_paths": [
    "/opt/omd/versions/2.0.0p9.cee/bin",
    "/omd/sites/xxx/local/lib/python3",
    "/omd/sites/xxx/lib/python38.zip",
    "/omd/sites/xxx/lib/python3.8",
    "/omd/sites/xxx/lib/python3.8/lib-dynload",
    "/omd/sites/xxx/lib/python3.8/site-packages",
    "/omd/sites/xxx/lib/python3"
  ],
  "id": "ad04ab7c-1136-11ec-aba2-26ca43a40802",
  "crash_type": "base",
  "exc_type": "ValueError",
  "exc_value": "source code string cannot contain null bytes",
  "exc_traceback": [
    [
      "/omd/sites/xxx/bin/cmk",
      98,
      "<module>",
      "exit_status = modes.call(\"--check\", None, opts, args)"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/base/modes/__init__.py",
      69,
      "call",
      "return handler(*handler_args)"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/base/modes/check_mk.py",
      1643,
      "mode_check",
      "return checking.do_check("
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/base/decorator.py",
      37,
      "wrapped_check_func",
      "status, infotexts, long_infotexts, perfdata = check_func(hostname, *args, **kwargs)"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/base/checking.py",
      195,
      "do_check",
      "fetcher_messages = list("
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/base/checkers/_checkers.py",
      247,
      "fetch_all",
      "raw_data = source.fetch()"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/base/checkers/_abstract.py",
      163,
      "fetch",
      "return fetcher.fetch(self.mode)"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/fetchers/_base.py",
      263,
      "fetch",
      "return result.OK(self._fetch(mode))"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/fetchers/_base.py",
      281,
      "_fetch",
      "raw_data = self._fetch_from_io(mode)"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/fetchers/snmp.py",
      323,
      "_fetch_from_io",
      "persisted_sections = (self._section_store.load() if mode is Mode.CHECKING else"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/fetchers/cache.py",
      95,
      "load",
      "raw_sections_data = _store.load_object_from_file(self.path, default={})"
    ],
    [
      "/omd/sites/xxx/lib/python3/cmk/utils/store.py",
      204,
      "load_object_from_file",
      "return ast.literal_eval(content)"
    ],
    [
      "/omd/sites/xxx/lib/python3.8/ast.py",
      59,
      "literal_eval",
      "node_or_string = parse(node_or_string, mode='eval')"
    ],
    [
      "/omd/sites/xxx/lib/python3.8/ast.py",
      47,
      "parse",
      "return compile(source, filename, mode, flags,"
    ]
  ],
  "local_vars": "eydmZWF0dXJlX3ZlcnNpb24nOiAtMSwKICdmaWxlbmFtZSc6ICc8dW5rbm93bj4nLAogJ2ZsYWdzJzogM...geht endlos lang weiter",
  "details": {
    "argv": [
      "/omd/sites/xxx/bin/cmk",
      "--debug",
      "-vvp",
      "Lancom10"
    ],
    "env": {
      "LC_ALL": "C.UTF-8",
      "LD_LIBRARY_PATH": "/omd/sites/xxx/local/lib:/omd/sites/xxx/lib",
      "REQUESTS_CA_BUNDLE": "/omd/sites/xxx/var/ssl/ca-certificates.crt",
      "LANG": "C.UTF-8",
      "MODULEBUILDRC": "/omd/sites/xxx/.modulebuildrc",
      "USER": "xxx",
      "PWD": "/omd/sites/xxx",
      "HOME": "/omd/sites/xxx",
      "NAGIOS_PLUGIN_STATE_DIRECTORY": "/omd/sites/xxx/var/monitoring-plugins",
      "XDG_DATA_DIRS": "/usr/local/share:/usr/share:/var/lib/snapd/desktop",
      "PERL_MM_OPT": "INSTALL_BASE=/omd/sites/xxx/local/lib/perl5/",
      "MP_STATE_DIRECTORY": "/omd/sites/xxx/var/monitoring-plugins",
      "MAIL": "/var/mail/xxx",
      "SHELL": "/bin/bash",
      "TERM": "xterm-256color",
      "PERL5LIB": "/omd/sites/xxx/local/lib/perl5/lib/perl5:/omd/sites/xxx/lib/perl5/lib/perl5:",
      "SHLVL": "1",
      "MANPATH": "/omd/sites/xxx/share/man:",
      "OMD_ROOT": "/omd/sites/xxx",
      "MAILRC": "/omd/sites/xxx/etc/mail.rc",
      "LOGNAME": "xxx",
      "PATH": "/omd/sites/xxx/lib/perl5/bin:/omd/sites/xxx/local/bin:/omd/sites/xxx/bin:/omd/sites/xxx/local/lib/perl5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
      "OMD_SITE": "xxx",
      "_": "/omd/sites/xxx/bin/cmk"
    }
  }
}

Beste Grüße

Die Fehlermeldung β€œValueError: source code string cannot contain null bytes” deutet auf ein Null-Byte in einem Python-Plugin hin. Liegt da irgendetwas komisches unterhalb von $OMD_ROOT/local?

Also ich finde da gerade nichts komisches.

OMD[xxx]:~$ tree $OMD_ROOT/local
/omd/sites/xxx/local
β”œβ”€β”€ bin
β”œβ”€β”€ lib
β”‚   β”œβ”€β”€ apache
β”‚   β”œβ”€β”€ check_mk -> python3/cmk
β”‚   β”œβ”€β”€ nagios
β”‚   β”‚   └── plugins
β”‚   β”‚       └── README.txt
β”‚   β”œβ”€β”€ python
β”‚   └── python3
β”‚       └── cmk
β”‚           β”œβ”€β”€ base
β”‚           β”‚   └── plugins
β”‚           β”‚       └── agent_based
β”‚           └── cee
β”‚               └── dcd
β”‚                   └── plugins
β”‚                       └── connectors
└── share
    β”œβ”€β”€ check_mk
    β”‚   β”œβ”€β”€ agents
    β”‚   β”‚   β”œβ”€β”€ bakery
    β”‚   β”‚   β”œβ”€β”€ linux
    β”‚   β”‚   β”‚   └── alert_handlers
    β”‚   β”‚   β”œβ”€β”€ plugins
    β”‚   β”‚   └── special
    β”‚   β”œβ”€β”€ alert_handlers
    β”‚   β”œβ”€β”€ checkman
    β”‚   β”œβ”€β”€ checks
    β”‚   β”œβ”€β”€ inventory
    β”‚   β”œβ”€β”€ locale
    β”‚   β”œβ”€β”€ mibs
    β”‚   β”œβ”€β”€ notifications
    β”‚   β”œβ”€β”€ pnp-rraconf
    β”‚   β”œβ”€β”€ pnp-templates
    β”‚   β”œβ”€β”€ reporting
    β”‚   β”‚   └── images
    β”‚   └── web
    β”‚       β”œβ”€β”€ htdocs
    β”‚       β”‚   β”œβ”€β”€ images
    β”‚       β”‚   └── themes
    β”‚       └── plugins
    β”‚           β”œβ”€β”€ config
    β”‚           β”œβ”€β”€ dashboard
    β”‚           β”œβ”€β”€ icons
    β”‚           β”œβ”€β”€ metrics
    β”‚           β”œβ”€β”€ pages
    β”‚           β”œβ”€β”€ perfometer
    β”‚           β”œβ”€β”€ sidebar
    β”‚           β”œβ”€β”€ views
    β”‚           β”œβ”€β”€ visuals
    β”‚           └── wato
    β”œβ”€β”€ diskspace
    β”œβ”€β”€ doc
    β”‚   └── check_mk
    β”œβ”€β”€ dokuwiki
    β”‚   └── htdocs
    β”œβ”€β”€ nagios
    β”‚   └── htdocs
    β”‚       └── theme
    β”‚           β”œβ”€β”€ images -> ../../../../../share/nagios/htdocs/themes/classicui/images
    β”‚           └── stylesheets -> ../../../../../share/nagios/htdocs/themes/classicui/stylesheets
    β”œβ”€β”€ nagvis
    β”‚   └── htdocs
    β”‚       β”œβ”€β”€ server
    β”‚       β”‚   └── core
    β”‚       β”‚       └── classes
    β”‚       β”‚           └── objects
    β”‚       └── userfiles
    β”‚           β”œβ”€β”€ gadgets
    β”‚           β”œβ”€β”€ images
    β”‚           β”‚   β”œβ”€β”€ iconsets
    β”‚           β”‚   β”œβ”€β”€ maps
    β”‚           β”‚   └── shapes
    β”‚           β”œβ”€β”€ scripts
    β”‚           β”œβ”€β”€ styles
    β”‚           └── templates
    └── snmp
        └── mibs

75 directories, 3 files

Ist in

ein Nullbyte enthalten?

In dem File ist nur folgender Inhalt:

[
]

In den Files anderer Router sieht das ganze so aus:

[
  {'check_plugin_name': 'hr_cpu', 'item': None, 'parameters': {}, 'service_labels': {}},
  {'check_plugin_name': 'interfaces', 'item': '001', 'parameters': {'discovered_oper_status': ['1'], 'discovered_speed': 1000000000}, 'service_labels': {}},
  {'check_plugin_name': 'interfaces', 'item': '006', 'parameters': {'discovered_oper_status': ['1'], 'discovered_speed': 1000000000}, 'service_labels': {}},
  {'check_plugin_name': 'mem_used', 'item': None, 'parameters': {}, 'service_labels': {}},
  {'check_plugin_name': 'snmp_info', 'item': None, 'parameters': {}, 'service_labels': {}},
  {'check_plugin_name': 'uptime', 'item': None, 'parameters': {}, 'service_labels': {}},
]

Ich habe einen β€œworkaround” gefunden.

Ich hatte schon mehrfach die fehlerhaften Hosts gelΓΆscht und neu angelegt.

Jetzt habe ich mit:
find /opt/omd/sites/ | grep "Lancom10"
die betroffenen Router files gesucht und gelâscht. Anschließend habe ich sie neu hinzugefügt und siehe da, der SNMP Check funktioniert nu. Woohoo.

Danke fΓΌr deine Hilfe @r.sander , du hast mich erst auf die Idee gebracht :wink:

Beste Grüße

1 Like