automated svcs listing with xymon ps client and analysis.d
Hi,
I want to automatically identify and configure test for all services of win servers which has the startup setting ?automatic?
Getting the analysis.cfg entries is quite easy:
for servername in $LIST
do
echo ?HOST=$servername? > $servername.cfg
xymon localhost "xymondlog $servername.svcs"|awk '/ automatic /{printf(" SVC %-30s startup=automatic\n",$1)}' >> $servername.cfg
done
This will create an individual cfg file for every server just for the SVC check (with ~60 entries each).
I thought I can just create these cfg files in $XYMONHOME/etc/analysis.d and it will be used similar to hosts.d or tasks.d directories. But obviously this does not work (and also there is no mention of analysis.d in the manuals).
Of course I can add all these lines directly into analysis.cfg, but this would create a very huge file.
Is there a way to use a subdir for those settings?
Any other ideas to combine the normal analysis.cfg with let?s say 100 extra server cfg files?
Xymon 4.3.30 self compiled and latest xymon PS client.
Any ideas welcome
regards
Norbert
On 03/06/2022 09:49, nor krie wrote:
I thought I can just create these cfg files in $XYMONHOME/etc/analysis.d and it will be used similar to hosts.d or tasks.d directories. But obviously this does not work (and also there is no mention of analysis.d in the manuals).
Of course I can add all these lines directly into analysis.cfg, but this would create a very huge file.
analysis.cfg is read by xymond_client. Having looked quickly at the xymond_client.c source, it is definitely written to only load config from a single config file, which defaults to $XYMONHOME/etc/analysis.cfg
I've a somewhat experimental small gitlab project that I've never really used for anything in production:
https://github.com/alt36/cgifs
which lets you use Fuse to "mount" an arbitrary script at a directory of your choice. So, if you used it to..
./cgifs.pl /etc/xymon/foo/ /path/to/script.sh
and then adjusted your tasks.cfg entry for xymond_client to use --config=/etc/xymon/foo/analysis.cfg rather than the default, then reading the specified config file would return the output of
/path/to/script.sh analysis.cfg
script.sh could then just be something like
#!/bin/bash cat /etc/xymon/analysis.d/*.cfg
Of course, you'd achieve a very similar effect (and probably a lot more robustly than my slightly hacky perl!) by having a cron job generate your analysis.cfg from fragments you've put in an analysis.d directory. Although, with my cgifs.pl version you could have script.sh instead run the bash loop you posted (but echoing to stdout rather than writing to servername.cfg) and always have the "live" version available...
Adam
Thx Adam,
that was fast. Your perl snippet looks interesting, but, as you said, it is maybe a bit oversophisticated for my needs. But anyway, you pointed me to a suitable idea: not to collect all data and add to a (then lengthy and hard to manage) analysis.cfg, but to create single files, have a analysis_master.cfg, and combine all of these regularly (nightly cronjob) into a working analysis.cfg. If I have to edit the master cfg this must be done manually.
I wonder why there is the host.d and tasks.d functionality implemented (never needed or used this), but no analysis.d or alerts.d, as those files can become very large and complex. Maybe a small feature request for the next version?
regards Norbert
Am Fr., 3. Juni 2022 um 11:19 Uhr schrieb Adam Thorn <alt36 at cam.ac.uk>:
On 03/06/2022 09:49, nor krie wrote:
I thought I can just create these cfg files in $XYMONHOME/etc/analysis.d and it will be used similar to hosts.d or tasks.d directories. But obviously this does not work (and also there is no mention of analysis.d in the manuals).
Of course I can add all these lines directly into analysis.cfg, but this would create a very huge file.
analysis.cfg is read by xymond_client. Having looked quickly at the xymond_client.c source, it is definitely written to only load config from a single config file, which defaults to $XYMONHOME/etc/analysis.cfg
I've a somewhat experimental small gitlab project that I've never really used for anything in production:
https://github.com/alt36/cgifs
which lets you use Fuse to "mount" an arbitrary script at a directory of your choice. So, if you used it to..
./cgifs.pl /etc/xymon/foo/ /path/to/script.sh
and then adjusted your tasks.cfg entry for xymond_client to use --config=/etc/xymon/foo/analysis.cfg rather than the default, then reading the specified config file would return the output of
/path/to/script.sh analysis.cfg
script.sh could then just be something like
#!/bin/bash cat /etc/xymon/analysis.d/*.cfg
Of course, you'd achieve a very similar effect (and probably a lot more robustly than my slightly hacky perl!) by having a cron job generate your analysis.cfg from fragments you've put in an analysis.d directory. Although, with my cgifs.pl version you could have script.sh instead run the bash loop you posted (but echoing to stdout rather than writing to servername.cfg) and always have the "live" version available...
Adam
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
Hi,
including directories does work for analysis.cfg, but unlike e.g. hosts.cfg, analysis.cfg does not include a 'directory'-statement by default.
Add the following directive above your 'DEFAULT' section in analysis.cfg and restart xymon:
directory /path/to/analysis.d/
Regards, Fabian
Von: Xymon <xymon-bounces at xymon.com> Im Auftrag von nor krie Gesendet: Freitag, 3. Juni 2022 10:50 An: xymon at xymon.com Betreff: [Xymon] automated svcs listing with xymon ps client and analysis.d
Hi, ? I want to automatically identify and configure test for all services of win servers which has the startup setting ?automatic? ? Getting the analysis.cfg entries is quite easy: ? for servername in $LIST do ? echo ?HOST=$servername? > $servername.cfg ??xymon localhost "xymondlog $servername.svcs"|awk '/ automatic /{printf("?? SVC %-30s startup=automatic\n",$1)}' >> $servername.cfg done ? This will create an individual cfg file for every server just for the SVC check (with ~60 entries each). I thought I can just create these cfg files in $XYMONHOME/etc/analysis.d and it will be used similar to hosts.d or tasks.d directories. But obviously this does not work (and also there is no mention of analysis.d in the manuals). Of course I can add all these lines directly into analysis.cfg, but this would create a very huge file. ? Is there a way to use a subdir for those settings? Any other ideas to combine the normal analysis.cfg with let?s say 100 extra server cfg files? ? Xymon 4.3.30 self compiled and latest xymon PS client. ? Any ideas welcome ? regards ? Norbert?
Excellent!
That was it I was looking for. Works exactly as expected. I added a
directory /home/xymon/server/etc/analysis.d
into my analysis.cfg, and now:
- i can throw in any kind of cfg files into this dir, and all the settings become active within some minutes (no restart necessary)
- even a mix of settings (for one server) in analysis.cfg and a servername.cfg in analysis.d works, both settings are considered
This makes it very easy to handle the global settings in analysis.cfg, and all the individual checks in several extra files.
Thanks for the hint, Fabian!
I saw the directory statement for tasks.d in my servers tasks.cfg as well, but never realized that this is also possible in the other cfg files. Next time I will try this in my alerts.cfg as well.
As always a very fast and sufficient solution from this list, great!
Have a nice weekend
Norbert
Am Fr., 3. Juni 2022 um 11:44 Uhr schrieb Fabian Wendlandt < fabian.wendlandt at innowerk-it.de>:
Hi,
including directories does work for analysis.cfg, but unlike e.g. hosts.cfg, analysis.cfg does not include a 'directory'-statement by default.
Add the following directive above your 'DEFAULT' section in analysis.cfg and restart xymon:
directory /path/to/analysis.d/
Regards, Fabian
Von: Xymon <xymon-bounces at xymon.com> Im Auftrag von nor krie Gesendet: Freitag, 3. Juni 2022 10:50 An: xymon at xymon.com Betreff: [Xymon] automated svcs listing with xymon ps client and analysis.d
Hi,
I want to automatically identify and configure test for all services of win servers which has the startup setting ?automatic?
Getting the analysis.cfg entries is quite easy:
for servername in $LIST do echo ?HOST=$servername? > $servername.cfg xymon localhost "xymondlog $servername.svcs"|awk '/ automatic /{printf(" SVC %-30s startup=automatic\n",$1)}' >> $servername.cfg done
This will create an individual cfg file for every server just for the SVC check (with ~60 entries each). I thought I can just create these cfg files in $XYMONHOME/etc/analysis.d and it will be used similar to hosts.d or tasks.d directories. But obviously this does not work (and also there is no mention of analysis.d in the manuals). Of course I can add all these lines directly into analysis.cfg, but this would create a very huge file.
Is there a way to use a subdir for those settings? Any other ideas to combine the normal analysis.cfg with let?s say 100 extra server cfg files?
Xymon 4.3.30 self compiled and latest xymon PS client.
Any ideas welcome
regards
Norbert
participants (3)
-
alt36@cam.ac.uk
-
fabian.wendlandt@innowerk-it.de
-
norkrie@gmail.com