Hi everyone,
Is there a way to define a line or part of a line as a variable in the config files, then use that variable in other places, other than the .default line? I know it's possible in alerts, but how about hosts.cfg and hosts.d/*, or analysis.cfg and analysis.d/*?
For example, like this:
$DOWNTIME='DOWNTIME=*:6:2200:2359:Scheduled maintenance,*:0:0000:0400:Scheduled maintenance'
0.0.0.0 test1.lzb.hq # $DOWNTIME
0.0.0.0 test2.lzb.hq # $DOWNTIME
Yes, I realize I could use the .default line, but I can't set that once then have that available everywhere. If I change it later in the config then it won't be available to the rest of the config yet to come. For the variables I'd like to be able to set the variable and have it available throughout the entire config. That way I only have to change it in one place. Right now I have the .default line duplicated many times in my config, and if I have to make a change to them all it starts to become a lot of work.
Thanks!
Scot Kreienkamp | Senior Systems Engineer | La-Z-Boy Corporate One La-Z-Boy Drive | Monroe, Michigan 48162 | * 734-384-6403 | | * 7349151444 | * Scot.Kreienkamp at la-z-boy.com<mailto:%7BE-mail%7D> www<http://www.la-z-boy.com/>.la-z-boy.com<http://www.la-z-boy.com/> | facebook.<https://www.facebook.com/lazboy>com<https://www.facebook.com/lazboy>/<https://www.facebook.com/lazboy>lazboy<http://facebook.com/lazboy> | twitter.com/lazboy<https://twitter.com/lazboy> | youtube.com/<https://www.youtube.com/user/lazboy>lazboy<https://www.youtube.com/user/lazboy>
[cid:lzbVertical_hres.jpg]
This message is intended only for the individual or entity to which it is addressed. It may contain privileged, confidential information which is exempt from disclosure under applicable laws. If you are not the intended recipient, you are strictly prohibited from disseminating or distributing this information (other than to the intended recipient) or copying this information. If you have received this communication in error, please notify us immediately by e-mail or by telephone at the above number. Thank you.
As a followup, the other problem with the .default line is that it ignores any custom tags that I have on the hosts. I have custom tags on many hosts that I use with custom tests and xymongrep, and the custom tags on .default lines are never matched.
Scot Kreienkamp |Senior Systems Engineer | La-Z-Boy Corporate One La-Z-Boy Drive| Monroe, Michigan 48162 | Office: 734-384-6403 | | Mobile: 7349151444 | Email: Scot.Kreienkamp at la-z-boy.com From: Scot Kreienkamp Sent: Wednesday, May 16, 2018 1:54 PM To: 'xymon >> xymon at xymon.com' <xymon at xymon.com> Subject: Variables in config files
Hi everyone,
Is there a way to define a line or part of a line as a variable in the config files, then use that variable in other places, other than the .default line? I know it's possible in alerts, but how about hosts.cfg and hosts.d/*, or analysis.cfg and analysis.d/*?
For example, like this:
$DOWNTIME='DOWNTIME=*:6:2200:2359:Scheduled maintenance,*:0:0000:0400:Scheduled maintenance'
0.0.0.0 test1.lzb.hq # $DOWNTIME
0.0.0.0 test2.lzb.hq # $DOWNTIME
Yes, I realize I could use the .default line, but I can't set that once then have that available everywhere. If I change it later in the config then it won't be available to the rest of the config yet to come. For the variables I'd like to be able to set the variable and have it available throughout the entire config. That way I only have to change it in one place. Right now I have the .default line duplicated many times in my config, and if I have to make a change to them all it starts to become a lot of work.
Thanks!
Scot Kreienkamp | Senior Systems Engineer | La-Z-Boy Corporate One La-Z-Boy Drive | Monroe, Michigan 48162 | * 734-384-6403 | | * 7349151444 | * Scot.Kreienkamp at la-z-boy.com<mailto:%7BE-mail%7D> www<http://www.la-z-boy.com/>.la-z-boy.com<http://www.la-z-boy.com/> | facebook.<https://www.facebook.com/lazboy>com<https://www.facebook.com/lazboy>/<https://www.facebook.com/lazboy>lazboy<http://facebook.com/lazboy> | twitter.com/lazboy<https://twitter.com/lazboy> | youtube.com/<https://www.youtube.com/user/lazboy>lazboy<https://www.youtube.com/user/lazboy>
[cid:image001.jpg at 01D3ED20.1BE22C20]
This message is intended only for the individual or entity to which it is addressed. It may contain privileged, confidential information which is exempt from disclosure under applicable laws. If you are not the intended recipient, you are strictly prohibited from disseminating or distributing this information (other than to the intended recipient) or copying this information. If you have received this communication in error, please notify us immediately by e-mail or by telephone at the above number. Thank you.
On 5/16/2018 9:53 AM, Scot Kreienkamp wrote:
Yes, I realize I could use the .default line, but I can’t set that once then have that available everywhere. If I change it later in the config then it won’t be available to the rest of the config yet to come.
I'm not contesting your desire for a variable (or 'macro'), but ponder your statement about .default. lines.
Something set in a .default. line remains the 'default' until changed in a later .default. line. It can be altered per-host without affecting its status as a 'default'.
0.0.0.0 .default. # nopropred:+msgs
0.0.0.0 foo.xyz.com # nopropred:-msgs 0.0.0.0 bar.xyz.com #
0.0.0.0 .default. # 0.0.0.0 baz.xyz.com #
In the above example, hosts foo and baz will propagate their red msgs results. Foo, because the default value has been overridden with a specific tag. Baz, because the default value has been changed.
Answering your specific question about variables. The 'macro' capability available in alerts.cfg is not available in hosts.cfg
If I had to solve the problem you are describing, I'd probably create create a meta-hosts.cfg and a post-edit-processing script to implement a macro function similar to what is available in alerts.cfg. It wouldn't be too hard to: grep all lines leading with $ build a sed command file with search/replace from those lines sed the meta-hosts.cfg to create an active hosts.cfg
-- Do things because you should, not just because you can.
John Thurston 907-465-8591 John.Thurston at alaska.gov Department of Administration State of Alaska
That's what I was afraid of. If the macro functionality could be extended to all the config files that would make things much simpler.
JC, can I put in a feature request for extending the macro to all the config files?
Scot Kreienkamp |Senior Systems Engineer | La-Z-Boy Corporate One La-Z-Boy Drive| Monroe, Michigan 48162 | Office: 734-384-6403 | | Mobile: 7349151444 | Email: Scot.Kreienkamp at la-z-boy.com -----Original Message----- From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of John Thurston Sent: Wednesday, May 16, 2018 2:18 PM To: xymon at xymon.com Subject: Re: [Xymon] Variables in config files
On 5/16/2018 9:53 AM, Scot Kreienkamp wrote:
Yes, I realize I could use the .default line, but I can’t set that once then have that available everywhere. If I change it later in the config then it won’t be available to the rest of the config yet to come.
I'm not contesting your desire for a variable (or 'macro'), but ponder your statement about .default. lines.
Something set in a .default. line remains the 'default' until changed in a later .default. line. It can be altered per-host without affecting its status as a 'default'.
0.0.0.0 .default. # nopropred:+msgs
0.0.0.0 foo.xyz.com # nopropred:-msgs 0.0.0.0 bar.xyz.com #
0.0.0.0 .default. # 0.0.0.0 baz.xyz.com #
In the above example, hosts foo and baz will propagate their red msgs results. Foo, because the default value has been overridden with a specific tag. Baz, because the default value has been changed.
Answering your specific question about variables. The 'macro' capability available in alerts.cfg is not available in hosts.cfg
If I had to solve the problem you are describing, I'd probably create create a meta-hosts.cfg and a post-edit-processing script to implement a macro function similar to what is available in alerts.cfg. It wouldn't be too hard to: grep all lines leading with $ build a sed command file with search/replace from those lines sed the meta-hosts.cfg to create an active hosts.cfg
-- Do things because you should, not just because you can.
John Thurston 907-465-8591 John.Thurston at alaska.gov Department of Administration State of Alaska
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
This message is intended only for the individual or entity to which it is addressed. It may contain privileged, confidential information which is exempt from disclosure under applicable laws. If you are not the intended recipient, you are strictly prohibited from disseminating or distributing this information (other than to the intended recipient) or copying this information. If you have received this communication in error, please notify us immediately by e-mail or by telephone at the above number. Thank you.
participants (2)
-
john.thurston@alaska.gov
-
Scot.Kreienkamp@la-z-boy.com