diff --git a/bird/bird.go b/bird/bird.go index 285f9e8..2c923ac 100644 --- a/bird/bird.go +++ b/bird/bird.go @@ -49,7 +49,11 @@ func fromCache(key string) (Parsed, bool) { } func toCache(key string, val Parsed) { - val["ttl"] = time.Now().Add(10 * time.Minute) + var ttl int = 5 + if ClientConf.CacheTtl > 0 { + ttl = ClientConf.CacheTtl + } + val["ttl"] = time.Now().Add(time.Duration(ttl) * time.Minute) Cache.Lock() Cache.m[key] = val Cache.Unlock() diff --git a/bird/config.go b/bird/config.go index bfcdaed..37a94c0 100644 --- a/bird/config.go +++ b/bird/config.go @@ -13,6 +13,7 @@ type BirdConfig struct { Listen string ConfigFilename string `toml:"config"` BirdCmd string `toml:"birdc"` + CacheTtl int `toml:"ttl"` } type ParserConfig struct { diff --git a/birdwatcher.go b/birdwatcher.go index d210d14..c41a9fd 100644 --- a/birdwatcher.go +++ b/birdwatcher.go @@ -89,6 +89,7 @@ func PrintServiceInfo(conf *Config, birdConf bird.BirdConfig) { log.Println("Starting Birdwatcher") log.Println(" Using:", birdConf.BirdCmd) log.Println(" Listen:", birdConf.Listen) + log.Println(" Cache TTL:", birdConf.CacheTtl) // Endpoint Info if len(conf.Server.AllowFrom) == 0 { diff --git a/etc/ecix/birdwatcher.conf b/etc/ecix/birdwatcher.conf index ad5aab7..e48aec3 100644 --- a/etc/ecix/birdwatcher.conf +++ b/etc/ecix/birdwatcher.conf @@ -45,12 +45,13 @@ requests_per_minute = 10 listen = "0.0.0.0:29188" config = "/etc/bird.conf" birdc = "/sbin/birdc" - +ttl = 5 # time to live (in minutes) for caching of cli output [bird6] listen = "0.0.0.0:29189" config = "/etc/bird6.conf" birdc = "/sbin/birdc6" +ttl = 5 # time to live (in minutes) for caching of cli output [parser] # Remove fields e.g. interface @@ -60,4 +61,3 @@ filter_fields = [] per_peer_tables = true peer_protocol_prefix = 'ID' pipe_protocol_prefix = 'P' -