[Check_mk (english)] Windows agent plugin output shown via telnet but not detected in web gui?

Hi,

Since I can’t get the openhardwaremonitor stuff working, I’m now trying another approach. From the monitoring agents page, I grabbed “wmic_if.bat” which contains:

···

@echo off

echo ^<^<^<winperf_if:sep^(44^)^>^>^>

wmic path Win32_NetworkAdapter get speed,macaddress,name,netconnectionid,netconnectionstatus /format:csv


I made a copy of that file and named it wmic_disks.bat and edited its contents like so:


@echo off

echo ^<^<^<winperf_disks:sep^(44^)^>^>^>

wmic diskdrive get model,status /format:csv


And I dropped it in the plugins directory. In telnet, I see the output near the end (bolded here):


[mbates@checkmkhost ~]$ telnet theclient 6556

Trying 10.66.1.27…

Connected to theclient.

Escape character is ‘^]’.

<<<check_mk>>>

Version: 1.2.8p11

BuildDate: Jul 5 2016

Architecture: 32bit

AgentOS: windows

Hostname: theclient

WorkingDirectory: C:\WINDOWS\system32

ConfigFile: C:\Program Files\check_mk\check_mk.ini

LocalConfigFile: C:\Program Files\check_mk\check_mk_local.ini

AgentDirectory: C:\Program Files\check_mk

PluginsDirectory: C:\Program Files\check_mk\plugins

StateDirectory: C:\Program Files\check_mk\state

ConfigDirectory: C:\Program Files\check_mk\config

TempDirectory: C:\Program Files\check_mk\temp

LogDirectory: C:\Program Files\check_mk\log

SpoolDirectory: C:\Program Files\check_mk\spool

LocalDirectory: C:\Program Files\check_mk\local

ScriptStatistics: Plugin C:1 E:0 T:0 Local C:0 E:0 T:0

OnlyFrom: 0.0.0.0/0

<<>>

[snipped]

<<>>

[snipped]

<<>>

[snipped]

<<fileinfo:sep(124)>>

[snipped]

<<>>

[snipped]

<<<winperf_if>>>

[snipped]

[snipped]

<<>>

[snipped]

<<<dotnet_clrmemory:sep(44)>>>

[snipped]

<<<wmi_cpuload:sep(44)>>>

[snipped]

<<<>>>

<<<winperf_disks:sep(44)>>>

Node,Model,Status

theclient,ST3500413AS,OK

<<<>>>

<<>>

<<>>

<<>>

1477500519

Connection closed by foreign host.


Lovely! But, when I go to add the host in the check_mk web GUI, it does not show. Screenshot here:

http://whoopis.com/misc/where%20is%20the%20plugin%20service%20output.png

What step(s) am I missing? This is check_mk version 1.2.8p13.

Thank you,

– MB

Hi Marion,

for need a piece of code on the monitoring server as well, otherwise the check isn't recognized in Wato. Look at share/check_mk/checks as site user, these are the builtin checks. If you want want to write one by yourself, you have to place it in local/share/check_mk/checks/.

Kind Regards,

Dominik Eismann

http://www.wieland-electric.com/de/aktuelles/messen-und-termine

Wieland Electric GmbH
Sitz: Brennerstrasse 10-14, D-96052 Bamberg
Geschaeftsfuehrer: Dr. Oliver Eitrich, Dr. Ulrich Schaarschmidt
Registergericht: AG Bamberg HRB 105

Der Inhalt dieser Mail enthaelt moeglicherweise vertrauliche Informationen und ist ausschliesslich fuer den bezeichneten Adressaten bestimmt.
Wenn Sie nicht der richtige Adressat sind, teilen Sie dem Absender bitte den Erhalt der Mail mit und loeschen Sie die Mail.

The content of this mail may contain confidential information and is intended solely for the designated addressee.
If you are not the intended addressee, then please inform the sender the receipt of this mail and delete the E-Mail.

Thank you, Dominik (and Jam in a similar, off-list reply.) NOW I understand that there are many more moving parts to this process! Here is what I’ve done in light of that, and where I’ve gotten stuck in a new way:

  1. I put a dummy agent named “mbwindisk” in the check_mk server’s /usr/lib/check_mk_agent/plugins and made it executable. Source:

#!/bin/sh

echo ‘<<<winperf_disks>>>’

echo ‘ST3500413AS OK’

For testing, this is to emulate the output of what I’ll ACTUALLY use on the Windows hosts – mbwindisk.bat:

@ECHO OFF

echo ^<^<^<mbwindisk^>^>^>

for /F “skip=1 tokens=*” %%a in (‘wmic diskdrive get model’) do if not defined model set model=%%a

for /F “skip=1 tokens=*” %%b in (‘wmic diskdrive get status’) do if not defined status set status=%%b

echo %model% %status%

  1. I created “mbwindisk” in the check_mk server’s /omd/sites/mysite/share/check_mk/checks, with the sample dummy code from https://mathias-kettner.de/checkmk_devel_agentbased.html (“real” source below)

  2. I tested to see if check_mk saw the new check:

check_mk -L | grep mbwindisk

mbwindisk.status tcp (no man page present)

(I don’t know why it doesn’t have the no/yes/etc. output like his example, but I proceeded anyway.)

  1. I continued testing:

OMD[mysite]:~/share/check_mk/checks$ check_mk --checks=mbwindisk.status -I localhost

and that returned

[[u’ST3500413AS’, u’OK’]]

  1. I then attempted to make the check code actually do something:

the inventory function

def inventory_mbwindisk_status(info):

for line in info:

yield line[0], None

the check function

def check_disk_status(item, params, info):

for line in info:

status = line[1]

if status == “OK”:

return 0, "Status is satisfactory: " % status

else:

return 2, "Status is UNsatisfactory: " % status

declare the check to Check_MK

check_info[“mbwindisk.status”] = {

‘check_function’: check_disk_status,

‘inventory_function’: inventory_mbwindisk_status,

‘service_description’: ‘MBWinDisk Status %s’,

}

  1. I cleaned up the environment and did a test:

check_mk --flush localhost

localhost : counters cache autochecks(1)

check_mk --checks=mbwindisk.status -I localhost

(no output)

check_mk -nv localhost

Check_mk version 1.2.8p13

MBWinDisk Status ST3500413AS UNKNOWN - check failed - please submit a crash report!

OK - Agent version 1.2.8p9, execution time 0.2 sec|execution_time=0.240 user_time=1.050 system_time=0.090 children_user_time=0.000 children_system_time=0.000

I feel like I’m getting close, but am still missing something obvious! Thanks in advance for any clues…

– MB

···

On Thu, Oct 27, 2016 at 5:23 AM, Eismann Dominik Dominik.Eismann@wieland-electric.com wrote:

Hi Marion,

for need a piece of code on the monitoring server as well, otherwise the check isn’t recognized in Wato. Look at share/check_mk/checks as site user, these are the builtin checks. If you want want to write one by yourself, you have to place it in local/share/check_mk/checks/.

Kind Regards,

Dominik Eismann

Hi Marion,

I’m not sure but I think you have to remove the check from the host in Wato and restart Check_MK, since –flush doesn’t delete the precompiled checks.
Then you can do a clean discovery of the service. If that doesn’t solve the issue, you should see an icon along the check in the browser that shows detailed debug information when clicked. It should be possible to fix the error with that information.

mail_footer_neu2016_wieplan_505x150.jpg

···

Kind Regards,

Dominik Eismann