it-novum / openitcockpit-agent-go

Cross-Platform Monitoring Agent for openITCOCKPIT written in Go
https://openitcockpit.io/download_agent/
Apache License 2.0
5 stars 2 forks source link

Customcheck result data is ignored by server (maybe special character escape problem) #52

Closed exa-mk closed 3 years ago

exa-mk commented 3 years ago

Agent Mode:

Versions

Operating system Server: Ubuntu 20.04 Agent: CentOS, Fedora

Describe the bug I have some agent custom checks that include path names in the check identifier. After the upgrade from agent 1.x to 3.x I recognized these are now escaped by a \ before each path seperator /. I fixed the check names within the server but they still don't seem to be recognized:

Check output: grafik

Agent push data:

[...]
    "customchecks": {
        "check_megaraid_sas": {
            "stdout": "OK: 0:0:RAID-1:2 drives:465.25GB:Optimal 0:1:RAID-6:24 drives:371.5GB:Optimal Drives:26 \n",
            "rc": 0,
            "execution_unix_timestamp_sec": 1623051310
        },
        "check_systemtime": {
            "stdout": "LEAP STATUS OK - System clock is in sync. | leap_status=0;0;2;;2 root_deviation=0.0059870385;0;;;\n",
            "rc": 0,
            "execution_unix_timestamp_sec": 1623051310
        },
        "nfs_io__\/nfs\/home": {
            "stdout": "NFS I\/O OK:  on all shares. [Mount points: \/nfs\/home]|'fs04.dev.exasol.com:\/nfs\/home_r_avg_exe'=0ms;;;0; 'fs04.dev.exasol.com:\/nfs\/home_rkBs'=0KB;;;0; 'fs04.dev.exasol.com:\/nfs\/home_r_avg_rtt'=0ms;;;0; 'fs04.dev.exasol.com:\/nfs\/home_rs'=0;;;0; 'fs04.dev.exasol.com:\/nfs\/home_w_avg_exe'=0ms;;;0; 'fs04.dev.exasol.com:\/nfs\/home_wkBs'=0KB;;;0; 'fs04.dev.exasol.com:\/nfs\/home_w_avg_rtt'=0ms;;;0; 'fs04.dev.exasol.com:\/nfs\/home_ws'=0;;;0; \n",
            "rc": 0,
            "execution_unix_timestamp_sec": 1623051310
        },
[...]

Agent customcheck config:

[nfs_io__/nfs/home]
  command = /usr/lib/nagios/plugins/check_nfs_io.pl -a --include=/nfs/home 
  interval = 180
  timeout = 10
  enabled = True

To Reproduce Include above customcheck config in agent and add service to monitoring.

Expected behavior Service check result data is recognized properly. In best case I don't need to escape the customcheck name in the server at all.

Screenshots see above

nook24 commented 3 years ago

I was unable to reproduce this issue. I tried PUSH and PULL mode. Both worked as expected. Please do not add any escaping manually, it is not required! I would recommend to delete the service and recreate it again through the wizard.

My customchecks.ini:

[nfs_io__/nfs/home]
  command = /usr/bin/echo "This is the command nfs_io__/nfs/home"
  interval = 10
  timeout = 5
  enabled = True

Create Service: Bildschirmfoto 2021-06-07 um 10 18 41

Monitoring results: Bildschirmfoto 2021-06-07 um 10 19 19

My Service defenition: Bildschirmfoto 2021-06-07 um 10 38 17

It is worth mentioning that the escaping is done by the JSON library and should be transparent to the end user

Bildschirmfoto 2021-06-07 um 10 19 38

root@1fa7afc81cda:/# php -v
PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

root@1fa7afc81cda:/# php -a
Interactive mode enabled

php > $test = ['nfs_io__/nfs/home' => 'data'];
php > $json = json_encode($test);
php > print_r($json);
{"nfs_io__\/nfs\/home":"data"}         // Has escaping in json
php > print_r(json_decode($json, true));
Array
(
    [nfs_io__/nfs/home] => data        // Escaping is gone as soon as JSON string got processed by PHP
)
php >
exa-mk commented 3 years ago

Re-creating the check seems to work. It's a bit stange a the checks don't look differently from before where they refused to work. That's why I tried to escape the path in the first time.

nook24 commented 3 years ago

Perfect, I'll close the issue. Feel free to reopen if you have any further issues.