From: <buc...@us...> - 2011-05-13 11:38:30
|
Revision: 232 http://devmon.svn.sourceforge.net/devmon/?rev=232&view=rev Author: buchanmilne Date: 2011-05-13 11:38:24 +0000 (Fri, 13 May 2011) Log Message: ----------- Update to version that supports using Xymon::Client that returns arrays rather than requiring the caller to process the raw string Modified Paths: -------------- trunk/extras/devmongraphtitle.pl Modified: trunk/extras/devmongraphtitle.pl =================================================================== --- trunk/extras/devmongraphtitle.pl 2011-05-13 11:24:27 UTC (rev 231) +++ trunk/extras/devmongraphtitle.pl 2011-05-13 11:38:24 UTC (rev 232) @@ -21,16 +21,35 @@ } my ($testname,$intname) = split(/\./,$files[0],3); $intname =~ s/_/\//g if ($intname); +print "Looking for $intname\n" if $ENV{'DEBUG'}; -my $bb=Xymon::Client->new; +my $bb; +if ($ENV{'DEBUG'}) { + $bb=Xymon::Client->new(undef,debug=>1); +} else { + $bb=Xymon::Client->new; +} my $result = $bb->hobbitdlog("$hostname.$testname"); + +#For api returning string +if (0) { while (<$result>) { chomp; + print if $ENV{'DEBUG'}; if (m(^<tr><td>$intname ([^<]+)?<\/td><td>)) { $intdesc = $1; print "Network Traffic on $intname ($intdesc) $period\n"; exit 0; } } +} +foreach (@{$result}) { + print if $ENV{'DEBUG'}; + if (m(^<tr><td>$intname ([^<]+)?<\/td><td>)) { + $intdesc = $1; + print "Network Traffic on $intname ($intdesc) $period\n"; + exit 0; + } +} print "Network Traffic on $intname $period\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <buc...@us...> - 2016-01-08 10:19:02
|
Revision: 253 http://sourceforge.net/p/devmon/code/253 Author: buchanmilne Date: 2016-01-08 10:18:59 +0000 (Fri, 08 Jan 2016) Log Message: ----------- Enforcing a maximum title length (82 chars), and do various changes to accommodate as much of the description as possible if the title is too long Modified Paths: -------------- trunk/extras/devmongraphtitle.pl Modified: trunk/extras/devmongraphtitle.pl =================================================================== --- trunk/extras/devmongraphtitle.pl 2015-09-15 15:18:07 UTC (rev 252) +++ trunk/extras/devmongraphtitle.pl 2016-01-08 10:18:59 UTC (rev 253) @@ -12,6 +12,9 @@ my $graphinstance = shift || ""; my $period = shift||""; my @files = @ARGV; +my $maxdesclen = 82; +my $longheader = "Network traffic on"; +my $shortheader = "Traffic on"; my $intdesc; @@ -39,7 +42,7 @@ print if $ENV{'DEBUG'}; if (m(^<tr><td>$intname ([^<]+)?<\/td><td>)) { $intdesc = $1; - print "Network Traffic on $intname ($intdesc) $period\n"; + print generate_title($intname,$intdesc), "\n"; exit 0; } } @@ -48,8 +51,34 @@ print if $ENV{'DEBUG'}; if (m(^<tr><td>$intname ([^<]+)?<\/td><td>)) { $intdesc = $1; - print "Network Traffic on $intname ($intdesc) $period\n"; + print generate_title($intname,$intdesc), "\n"; exit 0; } } print "Network Traffic on $intname $period\n"; + +sub generate_title { + my ($int,$descr) = @_; + my $title; + $title = "$longheader $int ($descr) $period"; + return $title if (length($title) <= $maxdesclen); + + if (length($title) > $maxdesclen + length($longheader) - length($shortheader) ) { + $period =~ s/ Hours/h/; + $period =~ s/ Days/d/; + } + $title = "$shortheader $int ($descr) $period"; + return $title if (length($title) <= $maxdesclen); + + $title = "$int ($descr) $period"; + return $title if (length($title) <= $maxdesclen); + + $title = "$int ($descr)"; + if ( length($title) > $maxdesclen ) { + substr($descr,length($descr) - length($title) + $maxdesclen - 3,length($title) - $maxdesclen +3,".."); + #$title = "$int ($descr) $period"; + $title = "$int ($descr)"; + } + return $title; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <buc...@us...> - 2016-03-11 11:47:04
|
Revision: 255 http://sourceforge.net/p/devmon/code/255 Author: buchanmilne Date: 2016-03-11 11:47:02 +0000 (Fri, 11 Mar 2016) Log Message: ----------- Fix displaying of descriptions for sub-interfaces, and shorten by removing parenthesis Modified Paths: -------------- trunk/extras/devmongraphtitle.pl Modified: trunk/extras/devmongraphtitle.pl =================================================================== --- trunk/extras/devmongraphtitle.pl 2016-03-11 11:45:44 UTC (rev 254) +++ trunk/extras/devmongraphtitle.pl 2016-03-11 11:47:02 UTC (rev 255) @@ -22,7 +22,12 @@ print "Network Traffic $period\n"; exit 0 } -my ($testname,$intname) = split(/\./,$files[0],3); +my $rrd = $files[0]; +my ($testname,$intname); +if ($rrd =~ /^([^\.]+)\.(.*)\.rrd$/) { + ($testname,$intname) = ($1,$2); +} +#my ($testname,$intname) = split(/\./,$files[0],3); $intname =~ s/_/\//g if ($intname); print "Looking for $intname\n" if $ENV{'DEBUG'}; @@ -73,11 +78,11 @@ $title = "$int ($descr) $period"; return $title if (length($title) <= $maxdesclen); - $title = "$int ($descr)"; + $title = "$int $descr"; if ( length($title) > $maxdesclen ) { substr($descr,length($descr) - length($title) + $maxdesclen - 3,length($title) - $maxdesclen +3,".."); #$title = "$int ($descr) $period"; - $title = "$int ($descr)"; + $title = "$int $descr"; } return $title; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |