@gstolz, thanks for sharing your patched version.
I compared it with the latest 2.4 and the code is still very much the same.
@akoopal, I just reviewed this issue and I now think the easiest would be to
just create the /etc/check_mk/filestats.cfg from time to time by cron.
Assume, you have a folder and file structure like this:
root@72dd784540ca:~# tree /folder/
/folder/
|-- A
| |-- 1
| |-- 2
| `-- 3
|-- B
| |-- 1
| |-- 2
| `-- 3
`-- C
|-- 1
|-- 2
`-- 3
A,B,C are folder and 1,2,3 are files.
Now, with a script like this:
root@72dd784540ca:~# cat make-filestats-cfg.sh
#!/usr/bin/env bash
find /folder/* -type d | sort \
| while read dir
do
cat<<EOT
[extremes of ${dir}]
input_patterns: ${dir}/*
output: extremes_only
EOT
done
you can create your “dynamic” /etc/check_mk/filestats.cfg
root@72dd784540ca:~# ./make-filestats-cfg.sh > /etc/check_mk/filestats.cfg
The resulting agent output is then:
root@72dd784540ca:~# /opt/omd/sites/mysite24/share/check_mk/agents/plugins/mk_filestats.py -c /etc/check_mk/filestats.cfg
<<<filestats:sep(0)>>>
[[[extremes_only extremes of /folder/A]]]
{'type': 'file', 'path': '/folder/A/1', 'stat_status': 'ok', 'size': 4096, 'age': 797, 'mtime': 1754485116}
{'type': 'file', 'path': '/folder/A/2', 'stat_status': 'ok', 'size': 40960, 'age': 774, 'mtime': 1754485139}
{'type': 'file', 'path': '/folder/A/3', 'stat_status': 'ok', 'size': 409600, 'age': 781, 'mtime': 1754485132}
{'type': 'summary', 'count': 3}
[[[extremes_only extremes of /folder/B]]]
{'type': 'file', 'path': '/folder/B/2', 'stat_status': 'ok', 'size': 40960, 'age': 765, 'mtime': 1754485148}
{'type': 'file', 'path': '/folder/B/3', 'stat_status': 'ok', 'size': 409600, 'age': 765, 'mtime': 1754485148}
{'type': 'file', 'path': '/folder/B/1', 'stat_status': 'ok', 'size': 4096, 'age': 765, 'mtime': 1754485148}
{'type': 'summary', 'count': 3}
[[[extremes_only extremes of /folder/C]]]
{'type': 'file', 'path': '/folder/C/2', 'stat_status': 'ok', 'size': 40960, 'age': 763, 'mtime': 1754485150}
{'type': 'file', 'path': '/folder/C/3', 'stat_status': 'ok', 'size': 409600, 'age': 763, 'mtime': 1754485150}
{'type': 'file', 'path': '/folder/C/1', 'stat_status': 'ok', 'size': 4096, 'age': 763, 'mtime': 1754485150}
{'type': 'summary', 'count': 3}
KR mimimi