On 10/31/24 22:51, Jeremy Laidman wrote:
What happens if you just make it a file: entry, even though it's a directory? My guess is that EXISTS simply reports whether the [file://run/log/journal] section has any content matching the "file" name. The fact that it happens to be a directory probably doesn't matter for EXISTS.
I tried that, and found that if the directory existed when Xymon was treating it like a file, I'd get a different error that would cause the page to change colors and report a false error message.
This is most apparent when you're wanting a file / directory to exist but you test it as the wrong type; directory / file respectively.
But I found the error message to be uninformative and easy to misinterpret.
There's a chance that the [dir:<dirname>] is significantly different in structure from [file:<filename>] to the point that Xymon gets weirded out and complains that the "file" doesn't look like a file.
Yes, that's a way to describe what I saw in my testing.
If that's the case, use backticks to make the dir look like a file. Something like:
file:
D=/run/log/journal; [ -d $D ] && stat --printf "type:100000 (file)\nmode:%a (%A)\nlinkcount:%h\nowner:%u (%U)\ngroup:%g (%G)\nsize:%s\nclock:$(date +'%s (%F %T.%N %z)')\natime:%X (%x)\nctime:%Z (%z)\nmtime:%Y (%y)\n" /run/log/journal
Oh. ... If I'm reading that correctly, you're testing if the directory ${D} exists and reporting a synthetic file entry back to Xymon.
If the dir exists, this gives me:
type:100000 (file) mode:2755 (drwxr-sr-x) linkcount:3 owner:0 (root) group:190 (systemd-journal) size:60 clock:1730432083 (2024-11-01 14:34:43.189892664 +1100) atime:1730392322 (2024-11-01 03:32:02.629206150 +1100) ctime:1714705493 (2024-05-03 13:04:53.832001476 +1000) mtime:1714705472 (2024-05-03 13:04:32.778000198 +1000)
That is an interesting hack. I'll have to try it.
so Xymon should see this as a file, and things like EXISTS should work, and show this as OK.
If the dir doesn't exist, this gives me no output, so EXISTS should flag this as an error with an appropriate message.
I actually want the /run/log/journal directory^W file to NOT exist. But that's a small edit. ;-)
Ugly, but should work, Yes ... but maybe borderline elegant. }:-)
if you have GNUstat and date.
Seeing as how the context is systemd-journald's storage location, thus a
Linux system, I think that it's fair to assume that GNU stat and
date are available. :-)
If you like, you could put this (or equivalent) into a script and use file:
testdir /run/log/journal.
Yep, I was already thinking about that.
I'll want to do some playing and see what the PATH or working directory
is when running such a file:script /directory is. I think it would be
nice if I could store the script in Xymon's bin directory. Hopefully I
wouldn't need to worry about hard coded paths to scripts that way.
Aside: I've got multiple different systems running Xymon and there are a few different installations, depending on distro & version there of vs compiled from source.
What I've got seems to be working, but I do want to try your elegant hack.
Time permitting I'll do so and follow up. Eventually.
-- Grant. . . .