[Xymon] MAPE: tweak for display of servers, fix for uninitialized values from hash. Timestamp errors
Deiss, Mark
Mark.Deiss at xerox.com
Mon Feb 18 14:45:53 CET 2013
On an intermittent/sporadic basis with perl v 5.14, getting an undefined key out of the map hash which causes perl uninitialized value warnings. To handle this, looks like need the following amendments (for the case of order by hosts.cfg content):
foreach my $element (sort { ($map{$a}{"entryid"} || 0) <=> ($map{$b}{"entryid"} || 0) } keys %map)
{
next unless defined $map${element}("entryid");
....
Another suggestion is to add timestamps to the warns and die messages (and in the d_printf subroutine if someone is running that enabled....)
At top of routine add:
$| = 1;
$SIG{__WARN__} = sub {warn sprint{"[%s] ", scalar localtime), @_};
$SIG{__DIE__} = sub {die sprint{"[%s] ", scalar localtime), @_};
From: Deiss, Mark
Sent: Wednesday, February 13, 2013 12:06 PM
To: 'xymon at xymon.com'
Subject: MAPE: tweak for display of servers
This is for MAPE 1.4 - may not be correct for 1.4+.
The MAPE web page displays the server entries in a branch in a random order. The www/MAPE/bin/parse-config.pl can be adjusted so that MAPE displays the upper branches, and the servers under a branch, follow the ordering in the Xymon hosts.cfg file. Alternatively, the file can be adjusted so the MAPE displays branches and servers under a branch in alphabetical sequence.
For the case of MAPE web page displaying per order of Xymon hosts.cfg entries. Need to save the entryid values into the map hash table for each entry (this change is sprinkled through parse-config.pl and not shown here), and sort on the entryid value in the drawMap subroutine via:
# 2/13/13 mcd - disable original loop control
#foreach my $element (keys %map)
# 2/13/13 mcd - add sort on entryid in loop control - this will follow server ordering in hosts.cfg
foreach my $element (sort { $map{$a}{"entryid"} <=> $map{$b}{"entryid"} } keys %map)
For the second case of MAPE web page displaying levels and servers in a branch in alphabetical order. Need to sort on the name value in the drawMap subroutine via:
# 2/13/13 mcd - disable original loop control
#foreach my $element (keys %map)
# 2/13/13 mcd - add sort on name in loop control - this will alphabetize order groups and servers
# override ordering in hosts.cfg
foreach my $element (sort { $map{$a}{"name"} cmp $map{$b}{"name"} } keys %map)
For this latter sort, a minor tweak is also required to populate the top leaf with a "name" value.
Popular root note
$map{0}{"title"} = $config{"company-name"}; # Read company name from config file
....
$map{0}{"entryid"} = 0;
# 2/13/13 mcd - add in something for name entry
$map{0}{"name"} = $config{"company-name"};
I can post the modified www/MAPE/bin/parse-config.pl that covers all of the changes if there is any interest, it's a 332 line file at the moment.
Some sites may want to take this sorting another step and promote red alerts (then yellow alerts) so they are grouped at the top of the MAPE web page. Right now they are scattered around in the MAPE web display. Of course the other green servers in a branch with a red/yellow server entry would also be displayed at the top of the display but the idea is to move all red/yellow tree paths and red/yellow server leafs to the top of the display.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20130218/eb267fcc/attachment.html>
More information about the Xymon
mailing list