[rancid] juniper dynamic-vpn license filtering

Erik Muller erikm at buh.org
Mon Dec 12 00:42:22 UTC 2016


I've recently started monitoring a few branch SRXes that are serving as
backup out-of-band access to production sites, and the license usage change
every time somebody (dis)connects gets to be a bit much.  The attached
patch tweaks the existing license filtering to ignore changes in usage on
small pools.  The 100 threshold is kind of arbitrary; 500 might be a more
reasonable number for where the percentage summary starts to be useful and
4000 looks to be where the large-scale subscriber licenses start - but this
at least reduces the noise at the low end.  Or should this maybe just
follow the filter_osc model?

tested on 3.3.0(ubuntu), but the patch seems clean against 3.6 still.

-e
-------------- next part --------------
--- junos.pm.orig	2016-12-11 15:38:54.564455375 -0500
+++ junos.pm	2016-12-11 15:39:42.404544746 -0500
@@ -456,20 +456,26 @@
 	next if (/^\{(master|backup)(:\d+)?\}/);
 
 	# licenses used changes constantly.  distill it to a percentage.
-	if (/^(\s+scale-subscriber)(\s+)(\d+)(\s+\d+)(.*$)/) {
+	if (/^(\s+(?:dynamic-vpn|scale-subscriber))(\s+)(\d+)(\s+\d+)(.*$)/) {
 	    my($a, $sp, $used, $avail, $rem) = ($1, $2, $3, $4, $5);
 	    my($spl, $usedl) = (length($sp), length($used));
 	    my($pcnt);
+	    my($usage);
 	    if ($avail < 1) {
 		$pcnt = ">100";
+	    } elsif ($avail < 100) {
+		# if license count is small, percentage doesn't do much to
+		# stabilize the output - just skip it.
+		$usage = "--";
 	    } else {
 		$pcnt = int(($used + 0.0) / ($avail + 0.0) * 100);
 	    }
-	    my($pcntl) = length($pcnt) + 1;
+	    if (defined $pcnt) { $usage = sprintf("%s%%",$pcnt) };
+	    my($pcntl) = length($usage) ;
 	    $spl = $spl + $usedl - $pcntl;
 
-	    my($fmt) = "%s%-" . $spl . "s%s%%%s%s\n";
-	    $_ = sprintf($fmt, $a, "", $pcnt, $avail, $rem);
+	    my($fmt) = "%s%-" . $spl . "s%s%s%s\n";
+	    $_ = sprintf($fmt, $a, "", $usage, $avail, $rem);
 	}
 
 	/Unrecognized command/ && return(1);


More information about the Rancid-discuss mailing list