From 15fc1f0f4698125fb65be3a66906d80a92807a55 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Wed, 11 Jan 2017 21:32:59 +0200 Subject: add one thread when requesting next via API --- lib/oxidized/nodes.rb | 3 ++- lib/oxidized/worker.rb | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index f5a1ad0..011bfc3 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -4,7 +4,7 @@ module Oxidized class Oxidized::NotSupported < OxidizedError; end class Oxidized::NodeNotFound < OxidizedError; end class Nodes < Array - attr_accessor :source + attr_accessor :source, :jobs alias :put :unshift def load node_want=nil with_lock do @@ -73,6 +73,7 @@ module Oxidized # set last job to nil so that the node is picked for immediate update n.last = nil put n + jobs.want += 1 end end end diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 1952d01..80d65cb 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -3,8 +3,9 @@ module Oxidized require 'oxidized/jobs' class Worker def initialize nodes - @nodes = nodes - @jobs = Jobs.new(Oxidized.config.threads, Oxidized.config.interval, @nodes) + @nodes = nodes + @jobs = Jobs.new(Oxidized.config.threads, Oxidized.config.interval, @nodes) + @nodes.jobs = @jobs Thread.abort_on_exception = true end -- cgit v1.2.1 From 8c304a2f6e43f41fa58ab1f04cc2fbfc39299b15 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Thu, 12 Jan 2017 15:43:28 +0200 Subject: guard adding job via configuration option --- lib/oxidized/config.rb | 5 +++-- lib/oxidized/nodes.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb index b6b5c40..aba8b63 100644 --- a/lib/oxidized/config.rb +++ b/lib/oxidized/config.rb @@ -28,8 +28,9 @@ module Oxidized asetus.default.retries = 3 asetus.default.prompt = /^([\w.@-]+[#>]\s?)$/ asetus.default.rest = '127.0.0.1:8888' # or false to disable - asetus.default.vars = {} # could be 'enable'=>'enablePW' - asetus.default.groups = {} # group level configuration + asetus.default.next_adds_job = false # if true, /next adds job, so device is fetched immmeiately + asetus.default.vars = {} # could be 'enable'=>'enablePW' + asetus.default.groups = {} # group level configuration asetus.default.pid = File.join(Oxidized::Config::Root, 'pid') asetus.default.input.default = 'ssh, telnet' diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index 011bfc3..72a2dc4 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -73,7 +73,7 @@ module Oxidized # set last job to nil so that the node is picked for immediate update n.last = nil put n - jobs.want += 1 + jobs.want += 1 if Config.next_adds_job end end end -- cgit v1.2.1 From 64fc260a4da53af34f1f8288d4ec68c6583907ee Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Thu, 12 Jan 2017 15:45:12 +0200 Subject: fix /next guard --- lib/oxidized/nodes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index 72a2dc4..6751c7a 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -73,7 +73,7 @@ module Oxidized # set last job to nil so that the node is picked for immediate update n.last = nil put n - jobs.want += 1 if Config.next_adds_job + jobs.want += 1 if Oxidized.config.next_adds_job? end end end -- cgit v1.2.1 From 81619a27e0e63d8070d053ad7b476b85a6fb5b41 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 10 Feb 2017 16:22:13 -0500 Subject: nxos.rb: Add secret block Took config from our local setup. Adding since it does not have it --- lib/oxidized/model/nxos.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/oxidized/model/nxos.rb b/lib/oxidized/model/nxos.rb index fbe772d..e743415 100644 --- a/lib/oxidized/model/nxos.rb +++ b/lib/oxidized/model/nxos.rb @@ -3,6 +3,14 @@ class NXOS < Oxidized::Model prompt /^(\r?[\w.@_()-]+[#]\s?)$/ comment '! ' + cmd :secret do |cfg| + cfg.gsub! /^(snmp-server community).*/, '\\1 ' + cfg.gsub! /^(snmp-server user (\S+) (\S+) auth (\S+)) (\S+) (priv) (\S+)/, '\\1 ' + cfg.gsub! /^(username \S+ password \d) (\S+)/, '\\1