Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@Node1:/opt/noc# ./noc script --debug --pretty get_version "apcFA0D7A"
- 2018-03-24 05:26:45,613 [noc.core.dcs.base] Resolve near service postgres
- 2018-03-24 05:26:45,613 [noc.core.http.client] HTTP GET http://consul:8500/v1/health/service/postgres?passing=1&near=_agent
- 2018-03-24 05:26:45,616 [noc.core.http.client] HTTP Response 200
- 2018-03-24 05:26:45,616 [noc.core.dcs.base] Resolved near service postgres to ['10.220.21.122:5432']
- 2018-03-24 05:26:46,482 [noc.core.dcs.base] Running resolver for service mongo
- 2018-03-24 05:26:46,482 [noc.core.dcs.base] [mongo] Starting resolver
- 2018-03-24 05:26:46,483 [noc.core.http.client] HTTP GET http://consul:8500/v1/health/service/mongo?passing=1
- 2018-03-24 05:26:46,484 [noc.core.http.client] HTTP Response 200
- 2018-03-24 05:26:46,484 [noc.core.dcs.base] [mongo] Set active services to: mongo: 10.220.21.122:27017
- 2018-03-24 05:26:46,484 [noc.core.http.client] HTTP GET http://consul:8500/v1/health/service/mongo?index=460194&passing=1
- 2018-03-24 05:26:46,485 [noc.lib.nosql] Connecting to MongoDB {'username': 'noc', 'authentication_source': 'noc', 'readPreference': 'secondaryPreferred', 'replicaSet': 'noc', 'db': 'noc', 'socketKeepAlive': True, 'host': 'mongodb://noc:********@10.220.21.122:27017/noc', 'password': '********'}
- 2018-03-24 05:26:46,547 [noc.core.cache.base] Using cache backend: noc.core.cache.mongo.MongoCache
- 2018-03-24 05:26:46,611 [noc.main.models.doccategory] Registering Capability
- 2018-03-24 05:26:46,612 [noc.main.models.doccategory] Registering MetricType
- 2018-03-24 05:26:46,648 [noc.main.models.doccategory] Registering ConnectionType
- 2018-03-24 05:26:46,652 [noc.main.models.doccategory] Registering ObjectModel
- 2018-03-24 05:26:46,661 [noc.main.models.textindex] Adding FTS index for sa.managedobject
- 2018-03-24 05:26:46,676 [noc.main.models.textindex] Adding FTS index for ip.vrf
- 2018-03-24 05:26:46,679 [noc.main.models.textindex] Adding FTS index for vc.vc
- 2018-03-24 05:26:46,682 [noc.main.models.textindex] Adding FTS index for ip.prefix
- 2018-03-24 05:26:46,687 [noc.main.models.textindex] Adding FTS index for ip.address
- 2018-03-24 05:26:46,734 [noc.core.script.loader] Loading script APC.AOS.get_version
- 2018-03-24 05:26:46,743 [noc.core.profile.loader] Loading profile APC.AOS
- 2018-03-24 05:26:46,743 [script] [APC.AOS.get_version|10.20.50.50] Running. Input arguments: {}, timeout 3600
- 2018-03-24 05:26:46,744 [script] [APC.AOS.get_version|10.20.50.50] [snmp] Creating IOLoop
- 2018-03-24 05:26:46,744 [script] [APC.AOS.get_version|10.20.50.50] [snmp] Create UDP socket
- 2018-03-24 05:26:46,744 [noc.core.ioloop.snmp] [10.20.50.50] SNMP GET ['1.3.6.1.2.1.33.1.1.2.0']
- 2018-03-24 05:26:46,790 [noc.core.ioloop.snmp] [10.20.50.50] GET result: 'Smart-UPS 2200'
- 2018-03-24 05:26:46,790 [noc.core.ioloop.snmp] [10.20.50.50] SNMP GET ['.1.3.6.1.2.1.33.1.1.3.0']
- 2018-03-24 05:26:46,792 [script] [APC.AOS.get_version|10.20.50.50] [snmp] Closing UDP socket
- 2018-03-24 05:26:46,792 [script] [APC.AOS.get_version|10.20.50.50] [snmp] Closing IOLoop
- 2018-03-24 05:26:46,957 [noc.core.debug] UNHANDLED EXCEPTION (2018-03-24 05:26:46.802693)
- PROCESS: ./commands/script.py
- VERSION: 15.05.1+microservices.9200.0aefb171
- BRANCH: microservices CHANGESET: 0aefb171
- ERROR FINGERPRINT: 79739c44-b304-528f-9c32-026df85335e9
- WORKING DIRECTORY: /opt/noc
- EXCEPTION: <type 'exceptions.ValueError'> invalid literal for int() with base 10: ''
- START OF TRACEBACK
- ------------------------------------------------------------------------
- File: core/snmp/ber.py (Line: 421)
- Function: encode_oid
- 414 """
- 415 >>> BEREncoder().encode_oid("1.3.6.1.2.1.1.5.0")
- 416 '\\x06\\x08+\\x06\\x01\\x02\\x01\\x01\\x05\\x00'
- 417
- 418 :param data:
- 419 :return:
- 420 """
- 421 ==> d = [int(x) for x in data.split(".")]
- 422 r = [chr(d[0] * 40 + d[1])]
- 423 for v in d[2:]:
- 424 if v < 0x7f:
- 425 r += [chr(v)]
- 426 else:
- 427 rr = []
- Variables:
- x = ''
- self = <noc.core.snmp.ber.BEREncoder object at 0x7f62b502f790>
- data = '.1.3.6.1.2.1.33.1.1.3.0'
- ------------------------------------------------------------------------
- File: core/snmp/get.py (Line: 38)
- Function: _build_pdu
- 31 if not request_id:
- 32 request_id = random.randint(0, 0x7FFFFFFF)
- 33 # Encode variable bindings
- 34 varbinds = e.encode_sequence([
- 35 e.encode_sequence([
- 36 e.encode_oid(str(oid)),
- 37 e.encode_null()
- 38 ==> ]) for oid in oids
- 39 ])
- 40 # Encode RFC-1905 SNMP GET PDU
- 41 pdu = e.encode_choice(pdu_type, [
- 42 e.encode_int(request_id),
- 43 e.encode_int(0), # Error status
- 44 e.encode_int(0), # Error index
- Variables:
- pdu_type = 0
- oid = '.1.3.6.1.2.1.33.1.1.3.0'
- community = 'kondaro'
- oids = ['.1.3.6.1.2.1.33.1.1.3.0']
- version = 1
- request_id = 1045452829
- e = <noc.core.snmp.ber.BEREncoder object at 0x7f62b502f790>
- ------------------------------------------------------------------------
- File: core/snmp/get.py (Line: 63)
- Function: get_pdu
- 56 """
- 57 Generate SNMP v2c GET PDU
- 58 :param version:
- 59 :param community:
- 60 :param oids:
- 61 :return:
- 62 """
- 63 ==> return _build_pdu(community, PDU_GET_REQUEST, oids, request_id, version)
- 64
- 65
- 66 def getnext_pdu(community, oid, request_id=None, version=SNMP_v2c):
- 67 """
- 68 Generate SNMP v2c GETNEXT PDU
- 69 :param version:
- Variables:
- oids = ['.1.3.6.1.2.1.33.1.1.3.0']
- version = 1
- community = 'kondaro'
- request_id = None
- ------------------------------------------------------------------------
- File: core/ioloop/snmp.py (Line: 52)
- Function: snmp_get
- 45 elif isinstance(oids, dict):
- 46 oid_map = dict((oids[k], k) for k in oids)
- 47 oids = oids.values()
- 48 else:
- 49 raise ValueError("oids must be either string or dict")
- 50 logger.debug("[%s] SNMP GET %s", address, oids)
- 51 # Send GET PDU
- 52 ==> pdu = get_pdu(community=community, oids=oids, version=version)
- 53 if udp_socket:
- 54 sock = udp_socket
- 55 prev_timeout = sock.get_timeout()
- 56 else:
- 57 sock = UDPSocket(ioloop=ioloop, tos=tos)
- 58 sock.settimeout(timeout)
- Variables:
- ioloop = <tornado.platform.epoll.EPollIOLoop object at 0x7f62b502f5d0>
- tos = 0
- oid_map = {}
- community = 'kondaro'
- port = 161
- version = 1
- timeout = 10
- address = u'10.20.50.50'
- oids = ['.1.3.6.1.2.1.33.1.1.3.0']
- udp_socket = <noc.core.ioloop.udp.UDPSocket object at 0x7f62b502f6d0>
- ------------------------------------------------------------------------
- File: local/lib/python2.7/site-packages/tornado/gen.py (Line: 307)
- Function: wrapper
- 300 # Inline the first iteration of Runner.run. This lets us
- 301 # avoid the cost of creating a Runner when the coroutine
- 302 # never actually yields, which in turn allows us to
- 303 # use "optional" coroutines in critical path code without
- 304 # performance penalty for the synchronous case.
- 305 try:
- 306 orig_stack_contexts = stack_context._state.contexts
- 307 ==> yielded = next(result)
- 308 if stack_context._state.contexts is not orig_stack_contexts:
- 309 yielded = TracebackFuture()
- 310 yielded.set_exception(
- 311 stack_context.StackContextInconsistentError(
- 312 'stack_context inconsistency (probably caused '
- 313 'by yield within a "with StackContext" block)'))
- Variables:
- func = <function snmp_get at 0x7f62c09fe8c0>
- args = ()
- yielded = None
- replace_callback = True
- future = None
- result = <generator object snmp_get at 0x7f62b50289b0>
- orig_stack_contexts = ((), None)
- kwargs =
- {'address': u'10.20.50.50',
- 'community': 'kondaro',
- 'ioloop': <tornado.platform.epoll.EPollIOLoop object at 0x7f62b502f5d0>,
- 'oids': '.1.3.6.1.2.1.33.1.1.3.0',
- 'tos': 0,
- 'udp_socket': <noc.core.ioloop.udp.UDPSocket object at 0x7f62b502f6d0>,
- 'version': 1}
- ------------------------------------------------------------------------
- File: local/lib/python2.7/site-packages/tornado/concurrent.py (Line: 238)
- Function: result
- 231 before the `Future` is done, so the ``timeout`` is never used.
- 232 """
- 233 self._clear_tb_log()
- 234 if self._result is not None:
- 235 return self._result
- 236 if self._exc_info is not None:
- 237 try:
- 238 ==> raise_exc_info(self._exc_info)
- 239 finally:
- 240 self = None
- 241 self._check_done()
- 242 return self._result
- 243
- 244 def exception(self, timeout=None):
- Variables:
- self = None
- timeout = None
- ------------------------------------------------------------------------
- File: local/lib/python2.7/site-packages/tornado/gen.py (Line: 1055)
- Function: run
- 1048 return
- 1049 self.future = None
- 1050 try:
- 1051 orig_stack_contexts = stack_context._state.contexts
- 1052 exc_info = None
- 1053
- 1054 try:
- 1055 ==> value = future.result()
- 1056 except Exception:
- 1057 self.had_exception = True
- 1058 exc_info = sys.exc_info()
- 1059 future = None
- 1060
- 1061 if exc_info is not None:
- Variables:
- exc_info = None
- self = <tornado.gen.Runner object at 0x7f62b49c40d0>
- future = None
- orig_stack_contexts = ((), None)
- ------------------------------------------------------------------------
- File: core/script/snmp/base.py (Line: 105)
- Function: run
- 98 self.result = yield snmp_get(
- 99 address=self.script.credentials["address"],
- 100 oids=oids,
- 101 community=str(self.script.credentials["snmp_ro"]),
- 102 tos=self.script.tos,
- 103 ioloop=self.get_ioloop(),
- 104 udp_socket=self.get_socket(),
- 105 ==> version=version
- 106 )
- 107 self.timeouts = self.timeouts_limit
- 108 if self.beef:
- 109 # Restore from beef
- 110 self.beef.set_snmp_get(oids, self.result)
- 111 except SNMPError as e:
- Variables:
- self = <noc.core.script.snmp.base.SNMP object at 0x7f62b502f250>
- version = 1
- oids = '.1.3.6.1.2.1.33.1.1.3.0'
- ------------------------------------------------------------------------
- File: local/lib/python2.7/site-packages/tornado/gen.py (Line: 1063)
- Function: run
- 1056 except Exception:
- 1057 self.had_exception = True
- 1058 exc_info = sys.exc_info()
- 1059 future = None
- 1060
- 1061 if exc_info is not None:
- 1062 try:
- 1063 ==> yielded = self.gen.throw(*exc_info)
- 1064 finally:
- 1065 # Break up a reference to itself
- 1066 # for faster GC on CPython.
- 1067 exc_info = None
- 1068 else:
- 1069 yielded = self.gen.send(value)
- Variables:
- exc_info = None
- self = <tornado.gen.Runner object at 0x7f62b49c40d0>
- future = None
- orig_stack_contexts = ((), None)
- ------------------------------------------------------------------------
- File: local/lib/python2.7/site-packages/tornado/concurrent.py (Line: 238)
- Function: result
- 231 before the `Future` is done, so the ``timeout`` is never used.
- 232 """
- 233 self._clear_tb_log()
- 234 if self._result is not None:
- 235 return self._result
- 236 if self._exc_info is not None:
- 237 try:
- 238 ==> raise_exc_info(self._exc_info)
- 239 finally:
- 240 self = None
- 241 self._check_done()
- 242 return self._result
- 243
- 244 def exception(self, timeout=None):
- Variables:
- self = None
- timeout = None
- ------------------------------------------------------------------------
- File: local/lib/python2.7/site-packages/tornado/ioloop.py (Line: 458)
- Function: run_sync
- 451 if timeout is not None:
- 452 timeout_handle = self.add_timeout(self.time() + timeout, self.stop)
- 453 self.start()
- 454 if timeout is not None:
- 455 self.remove_timeout(timeout_handle)
- 456 if not future_cell[0].done():
- 457 raise TimeoutError('Operation timed out after %s seconds' % timeout)
- 458 ==> return future_cell[0].result()
- 459
- 460 def time(self):
- 461 """Returns the current time according to the `IOLoop`'s clock.
- 462
- 463 The return value is a floating-point number relative to an
- 464 unspecified time in the past.
- Variables:
- self = <tornado.platform.epoll.EPollIOLoop object at 0x7f62b502f5d0>
- run = <function run at 0x7f62b502a758>
- func = <function run at 0x7f62b502a488>
- timeout = None
- future_cell = [<tornado.concurrent.Future object at 0x7f62b502f810>]
- ------------------------------------------------------------------------
- File: core/script/snmp/base.py (Line: 122)
- Function: get
- 115 if not self.timeouts:
- 116 raise self.FatalTimeoutError()
- 117 raise self.TimeOutError()
- 118 else:
- 119 raise
- 120
- 121 version = self._get_snmp_version(version)
- 122 ==> self.get_ioloop().run_sync(run)
- 123 return self.result
- 124
- 125 def set(self, *args):
- 126 """
- 127 Perform SNMP GET request
- 128 :param oid: string or list of oids
- Variables:
- cached = False
- self = <noc.core.script.snmp.base.SNMP object at 0x7f62b502f250>
- version = 1
- run = <function run at 0x7f62b502a488>
- oids = '.1.3.6.1.2.1.33.1.1.3.0'
- ------------------------------------------------------------------------
- File: sa/profiles/APC/AOS/get_version.py (Line: 31)
- Function: execute_snmp
- 24 rx_platform = re.compile(r"^(?P<platform>.+?)\s+named\s+", re.MULTILINE)
- 25
- 26 rx_platform1 = re.compile(r"^Name\s+: (?P<platform>.+?)\s+Date",
- 27 re.MULTILINE)
- 28
- 29 def execute_snmp(self, **kwargs):
- 30 platform = self.snmp.get("1.3.6.1.2.1.33.1.1.2.0")
- 31 ==> firmware = self.snmp.get(".1.3.6.1.2.1.33.1.1.3.0")
- 32 return {
- 33 "vendor": "APC",
- 34 "platform": platform,
- 35 # "version": firmware
- 36 "version": firmware
- 37 }
- Variables:
- platform = 'Smart-UPS 2200'
- self = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
- kwargs = {}
- ------------------------------------------------------------------------
- File: core/script/base.py (Line: 422)
- Function: call_method
- 415 if isinstance(handler, six.string_types):
- 416 handler = getattr(self, handler, None)
- 417 if handler is None:
- 418 self.logger.debug("No '%s' handler. Passing to next method" % m)
- 419 continue
- 420 # Call handler
- 421 try:
- 422 ==> r = handler(**kwargs)
- 423 if isinstance(r, PartialResult):
- 424 if self.partial_result:
- 425 self.partial_result.update(r.result)
- 426 else:
- 427 self.partial_result = r.result
- 428 self.logger.debug("Partial result: %r. Passing to next method", self.partial_result)
- Variables:
- self = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
- m = u'S'
- fallback_handler = None
- cli_handler =
- <bound method Script.execute_cli of <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>>
- handler =
- <bound method Script.execute_snmp of <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>>
- kwargs = {}
- snmp_handler =
- <bound method Script.execute_snmp of <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>>
- access_preference = u'SC*'
- ------------------------------------------------------------------------
- File: core/script/base.py (Line: 385)
- Function: execute
- 378 # Raise error
- 379 raise self.NotSupportedError()
- 380 else:
- 381 # New SNMP/CLI API
- 382 return self.call_method(
- 383 cli_handler=self.execute_cli,
- 384 snmp_handler=self.execute_snmp,
- 385 ==> **kwargs
- 386 )
- 387
- 388 def call_method(self, cli_handler=None, snmp_handler=None,
- 389 fallback_handler=None, **kwargs):
- 390 """
- 391 Call function depending on access_preference
- Variables:
- self = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
- kwargs = {}
- ------------------------------------------------------------------------
- File: core/script/base.py (Line: 247)
- Function: run
- 240 self.logger.info("Using cached result")
- 241 cache_hit = True
- 242 except KeyError:
- 243 pass
- 244 # Execute script
- 245 if not cache_hit:
- 246 try:
- 247 ==> result = self.execute(**self.args)
- 248 if self.cache and self.parent and result:
- 249 self.logger.info("Caching result")
- 250 self.set_cache(self.name, self.args, result)
- 251 finally:
- 252 if not self.parent:
- 253 # Close SNMP socket when necessary
- Variables:
- cache_hit = False
- self = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
- ------------------------------------------------------------------------
- File: commands/script.py (Line: 118)
- Function: handle
- 111 capabilities=caps,
- 112 args=args,
- 113 version=version,
- 114 timeout=3600,
- 115 name=script,
- 116 collect_beef=bool(beef)
- 117 )
- 118 ==> result = scr.run()
- 119 if pretty:
- 120 pprint.pprint(result)
- 121 elif yaml:
- 122 import yaml
- 123 import sys
- 124 yaml.dump(result, sys.stdout)
- Variables:
- obj = <ManagedObject: apcFA0D7A>
- beef = None
- service = <__main__.ServiceStub object at 0x7f62b5017e50>
- script = u'APC.AOS.get_version'
- script_class = <class 'noc.sa.profiles.APC.AOS.get_version.Script'>
- self = <__main__.Command object at 0x7f62c19b1b10>
- args = {}
- use_snmp = True
- caps =
- {u'SNMP': True,
- u'SNMP | Bulk': True,
- u'SNMP | IF-MIB': True,
- u'SNMP | v1': True,
- u'SNMP | v2c': True,
- u'SNMP | v3': False}
- yaml = False
- object_name = ['apcFA0D7A']
- version = None
- arguments = []
- pretty = True
- credentials =
- {'access_preference': u'SC',
- 'address': u'10.20.50.50',
- 'cli_protocol': 'telnet',
- 'password': None,
- 'path': None,
- 'raise_privileges': True,
- 'snmp_ro': u'kondaro',
- 'snmp_version': 'v2c',
- 'super_password': None,
- 'user': None}
- access_preference = None
- options = {}
- scr = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
- ------------------------------------------------------------------------
- File: core/management/base.py (Line: 75)
- Function: run_from_argv
- 68 enable_profiling = cmd_options.pop("enable_profiling", False)
- 69 show_metrics = cmd_options.pop("show_metrics", False)
- 70 if enable_profiling:
- 71 # Start profiler
- 72 import yappi
- 73 yappi.start()
- 74 try:
- 75 ==> return self.handle(*args, **cmd_options) or 0
- 76 except CommandError as e:
- 77 self.print(str(e))
- 78 return 1
- 79 except KeyboardInterrupt:
- 80 self.print("Ctrl+C")
- 81 return 3
- Variables:
- parser =
- ArgumentParser(prog='script.py', usage=None, description=None, version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
- loglevel = 'debug'
- enable_profiling = False
- args = ()
- cmd_options =
- {'access_preference': None,
- 'arguments': [],
- 'beef': None,
- 'object_name': ['apcFA0D7A'],
- 'pretty': True,
- 'script': ['get_version'],
- 'use_snmp': True,
- 'yaml': False}
- argv = ['--debug', '--pretty', 'get_version', 'apcFA0D7A']
- self = <__main__.Command object at 0x7f62c19b1b10>
- show_metrics = False
- options =
- Namespace(access_preference=None, arguments=[], beef=None, object_name=['apcFA0D7A'], pretty=True, script=['get_version'], use_snmp=True, yaml=False)
- ------------------------------------------------------------------------
- END OF TRACEBACK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement