Fileinfo on Linux does not show "lost+found" directory - bug with plus character in 1.6 Linux agent?

Hi,

on our Linux systems, I am using fileinfo to check the /lost+found directory, to be notified in case there are orphaned inodes from an fsck run (possibly automatic). This has worked fine in 1.5, but after updating the Linux agent (from 1.5.0p25 to 1.6.0p24), the fileinfo output for this directory is missing. Other paths are still there.

Here’s the contents of my /etc/check_mk/fileinfo.cfg with different pathnames and quotes added for testing:

/lost+found/*
/lost+found/.
/lost+found
/lost?found
/lost*found
/lost+found/
/lost\+found
/lost\\+found
'/lost+found'
"/lost+found"
/var/spool/mail/root
/run/reboot-required

And here’s the relevant part of the 1.6 agent output:

<<<check_mk>>>
Version: 1.6.0p24
AgentOS: linux
[...]
<<<fileinfo:sep(124)>>>
1623419642
[[[header]]]
name|status|size|time
[[[content]]]
/lost\+found|missing
'/lost+found'|missing
"/lost+found"|missing
/var/spool/mail/root|missing
/run/reboot-required|missing
<<<job>>>
[...]

No occurence at all for the real /lost+found directory. Which does exist, of course:

deb10:~$ sudo ls -la /lost+found
total 20
drwx------  2 root root 16384 Jul 17  2019 .
drwxr-xr-x 18 root root  4096 Apr  1 11:29 ..
deb10:~$ 

(Debian 10 Buster, in case that matters)

In comparison, here’s the good output from the 1.5 agent (just reinstalled it on the same system, same fileinfo.cfg):

<<<check_mk>>>
Version: 1.5.0p25
AgentOS: linux
[...]
<<<fileinfo:sep(124)>>>
1623420168
/lost+found/*|missing|1623420168
/lost+found/.|16384|1563346155
/lost+found|16384|1563346155
/lost+found|16384|1563346155
/lost+found|16384|1563346155
/lost+found/|16384|1563346155
/lost+found|16384|1563346155
/lost\\+found|missing|1623420168
/var/spool/mail/root|missing|1623420168
/run/reboot-required|missing|1623420168
<<<job>>>
[...]

I assume the plus character causes the trouble here, but I’m afraid my Perl skills are rather weak.
Probably related to werk #12363: fileinfo: files with special characters not discovered
I can’t find the 1.6.0p22 werk it refers to. There must have been changes to the handling of special characters, so the fix from #12363 probably needs to be extended to cover the plus sign as well, not only umlauts.

Can someone confirm this?

Thanks
Martin

I think the problem is this embedded Perl in the Linux agent for the fileinfo function.
A similar problem was here File Info not working on linux?
But my Perl knowledge is very limited. :slight_smile:
1.5 was the old bash function
starting with 1.6 it is the Perl function
I tested with “/lost+found/*” as pattern und it shows me something if there is a file inside the folder.
If the folder is empty then i also get no output. But this happens for all empty folders. There the Windows version is better as you get the output that the folder is empty.

That’s why my original fileinfo pattern is

/lost+found/*
/lost+found/.

and for an empty folder, this shows up in the 1.5 agent output as:

/lost+found/*|missing|1623420168
/lost+found/.|16384|1563346155

On the Checmk server, I then group all “/lost+found/*” paths and ignore the directory (“.”) itself. This gives a check for the file group which then can go WARN or CRIT when the count is > 0.
Or at least that’s how I did it in 1.5 :frowning:

So, probably time to brush up my miserable perl skills … or hope that some expert (or tribe29 even) can have a look :wink:

Thanks
Martin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.