Howto establish a check for a single file

Hello,

I’m trying to establish checks for certain single files, but I’m stuck quite at the beginning:
following the instructions on https://mathias-kettner.de/checkmk_check_fileinfo.html I created /etc/check_mk/fileinfo.cfg at agent site with content (as an example):
/etc/hosts

This provides following ouput with server-function “Download agent output”:

    ...    
<<<fileinfo:sep(124)>>>
    1524214198
    /etc/hosts
    |missing|1524214198
    ...

My (first) problem: of course this file EXISTS at client site, same result happens for every other file spec I tried…

My second problem: "MK_CHECK DISCOVERY doesn’t generate any service for this agent output

My third problem: I created a single file check manually, but this service doesn’t appear for the host (which supplies the above posted fileinfo output)
Definition of the service as “Size and age of single files”-rule in Main Directory:

Any suggestions for further investigations?

Thanks in advance

Which user is the check_mk_agent running on?
To check this do the following on the host (or as you call it, agent side) and post the output here:

cat /etc/xinetd.d/check_mk

PS:

Please put code and similar stuff within three backticks to format it in a readable manner. E.g.:

```
yourcode
```

Wow, a very fast reply!

The agent runs as root:

...
service check_mk
{
        type           = UNLISTED
        port           = 6556
        socket_type    = stream
        protocol       = tcp
        wait           = no
        user           = root
        server         = /usr/bin/check_mk_agent
...

Ok, so no rights problem.

Does the output really has this line break in it or was it just a copy/paste issue?
Please show the content of the /etc/check_mk/fileinfo.cfg.

1 Like

it’s no copy/paste issue:
grafik

Ok that definitely should not look like this. Did you create the fileinfo.cfg on a Windows machine and then transmit it over ftp? If you did so you probably have windows newline character in there. To get rid of it there is the linux command dos2unix where you can transform this.

1 Like

Yes, I check this out…

OK!!

The config file had windows format (CR & LF)!
Removing the CRs solved ALL the problems:

  • the output per file now is in ONE line
  • the discovery offers me new unmonitored services

The show can go on. :-))

Thank you and have a nice weekend!!

1 Like

Nice, please mark one answer as solution.

Have a nice weekend too.