From: Nelis, W. <Wim...@nl...> - 2010-12-19 13:32:07
|
Hello, Below are a number of modifications to Devmon, which are in use here for almost a year. I think that some of them are usefull to other DEVMON users as well. A- In revision 118 the option is introduced to format the date/time shown in the header of each message like Xymon does. However, the date/time of the "dm" status message was forgotten. Index: dm_msg.pm =================================================================== --- dm_msg.pm (revision 3) +++ dm_msg.pm (revision 5) @@ -21,6 +21,7 @@ # Modules use strict; use Socket; + use POSIX qw/ strftime /; use dm_config; # Our global variable hash @@ -212,7 +213,8 @@ # Add the header my $host = $g{'nodename'}; $host =~ s/\./,/g; # Dont forget our FQDN stuff - $message = "status $host.dm $color ".(scalar localtime)."\n\n$message\n"; + my $now = $g{'bbdateformat'} ? strftime($g{'bbdateformat'},localtime) : scalar(localtime); + $message = "status $host.dm $color $now\n\n$message\n"; return $message; B- There is no trend-information about the run-time of devmon itself. The following patch does send the run-time as an NCV to Xymon. In Xymon additional changes are needed to capture and display these statistics. Index: dm_msg.pm =================================================================== --- dm_msg.pm (revision 5) +++ dm_msg.pm (revision 6) @@ -210,6 +210,15 @@ $message .= "&red $stalledforks forks of $g{'numforks'} are stalled\n"; } + # Replace each ":" and "=" by their equivalent HTML escape charater, in + # order not to confuse the Xymon NCV module. Write the polling time + # (in HTML comment) for storage in an RRD. + $message =~ s/:/:/g ; + $message =~ s/=/=/g ; + $message .= "<!--\n" . + "PollTime : $this_poll_time\n" . + "-->" ; + # Add the header my $host = $g{'nodename'}; $host =~ s/\./,/g; # Dont forget our FQDN stuff C- The speed of a Gigabit interface is shown as "1000 Mbps". I prefer it to be shown as "1.00 Gbps". Index: dm_tests.pm =================================================================== --- dm_tests.pm (revision 6) +++ dm_tests.pm (revision 7) @@ -1141,7 +1141,7 @@ # Get largest speed type my $speed = 1; # Start low: 1 bps - $speed *= 1000 while $bps > ($speed * 1000); + $speed *= 1000 while $bps >= ($speed * 1000); my $unit = $speeds{$speed}; # Measure to 2 decimal places @@ -1161,7 +1161,7 @@ # Get largest speed type my $speed = 1; # Start low: 1 bps - $speed *= 1000 while $bps > ($speed * 1000); + $speed *= 1000 while $bps >= ($speed * 1000); my $unit = $speeds{$speed}; # Measure to 2 decimal places D- In function read_tansforms_file the check on transform 'index' is moved. The transform checks are now in sorted order. Index: dm_templates.pm =================================================================== --- dm_templates.pm (revision 8) +++ dm_templates.pm (revision 9) @@ -534,6 +534,14 @@ last CASE; }; + $func_type eq 'index' and do { + $temp =~ s/\s*\{\s*\S+?\s*\}|\s*,\s*//g; + do_log("INDEX transform uses only a single oid at " . + "$trans_file, line $l_num", 0) + and next LINE if $temp ne ''; + last CASE; + }; + $func_type eq 'math' and do { $temp =~ s/:\s*\d+\s*$//; $temp =~ s/\{\s*\S+?\s*\}|\s|\s\.\s|x|\+|\/|-|\^|%|\||&|\d+(\.\d*)?|\(|\)\s*//g; @@ -653,14 +661,6 @@ last CASE; }; - $func_type eq 'index' and do { - $temp =~ s/\s*\{\s*\S+?\s*\}|\s*,\s*//g; - do_log("INDEX transform uses only a single oid at " . - "$trans_file, line $l_num", 0) - and next LINE if $temp ne ''; - last CASE; - }; - do_log("Unknown function '$func_type' at $trans_file, line $l_num", 0); next LINE; } @@ -1066,7 +1066,7 @@ # Erase our messages DB db_do("delete from template_messages"); - # Create our template idnex + # Create our template index for my $vendor (sort keys %{$g{'templates'}}) { for my $model (sort keys %{$g{'templates'}{$vendor}}) { Regards, Wim Nelis. ******************************************************************************************************* The NLR disclaimer (http://www.nlr.nl/emaildisclaimer) is valid for NLR e-mail messages. ******************************************************************************************************* |