Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • N noc
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 440
    • Issues 440
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 26
    • Merge requests 26
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • noc
  • noc
  • Issues
  • #1541
Closed
Open
Issue created Mar 15, 2021 by Николай@KND909

Не работают скрипты по snmp для профиля cisco.smb

Как воспроизвести:

  1. ./noc script --access-preference S --debug --pretty get_interfaces (or get_switchport or another else in /opt/noc/sa/profiles/Cisco/SMB/)

  2. VERSION: 20.4.3 BRANCH: HEAD CHANGESET: c86766dc ERROR FINGERPRINT: 3642528d-595e-5b48-9cab-231ae9799efc WORKING DIRECTORY: /opt/noc EXCEPTION: <class 'noc.core.script.error.NotSupportedError'> Access preference 'S' is not supported START OF TRACEBACK

What is the current bug behavior?

не проставляются ifindexes, остальное вроде бы собирается по ssh (но возможно еще что-то не очевидное) image

What is the expected correct behavior?

если к примеру поместить в "custom" скрипт от /opt/noc/sa/profiles/Cisco/IOS/get_interfaces.py snmp работает (конечно собираемые данные не всегда корректны)

Relevant logs and/or screenshots

VERSION: 20.4.3
BRANCH: HEAD CHANGESET: c86766dc
ERROR FINGERPRINT: 3642528d-595e-5b48-9cab-231ae9799efc
WORKING DIRECTORY: /opt/noc
EXCEPTION: <class 'noc.core.script.error.NotSupportedError'> Access preference 'S' is not supported
START OF TRACEBACK
------------------------------------------------------------------------
File: core/script/base.py (Line: 508)
Function: call_method
  501                     if access_preference == "S*":
  502                         self.logger.info("Last S method break by timeout.")
  503                         raise self.snmp.TimeOutError
  504                 except NotImplementedError:
  505                     self.logger.debug(
  506                         "Access method '%s' is not implemented. Passing to next method", m
  507                     )
  508 ==>         raise self.NotSupportedError(
  509                 "Access preference '%s' is not supported" % access_preference[:-1]
  510             )
  511
  512         def execute_cli(self, **kwargs):
  513             """
  514             Process script using CLI
Variables:
                self =
<noc.sa.profiles.Cisco.SMB.get_interfaces.Script object at 0x7efe4eec7bb0>
         cli_handler =
<bound method Script.execute_cli of <noc.sa.profiles.Cisco.SMB.get_interfaces.Script object at 0x7efe4eec7bb0>>
        snmp_handler =
<bound method BaseScript.execute_snmp of <noc.sa.profiles.Cisco.SMB.get_interfaces.Script object at 0x7efe4eec7bb0>>
    fallback_handler = None
              kwargs = {}
   access_preference = 'S*'
                   m = '*'
             handler = None
------------------------------------------------------------------------
File: core/script/base.py (Line: 451)
Function: execute
  444                 for f in self._execute_chain:
  445                     if f._match(self, self.version):
  446                         return f(self, **kwargs)
  447                     # Raise error
  448                 raise self.NotSupportedError()
  449             else:
  450                 # New SNMP/CLI API
  451 ==>             return self.call_method(
  452                     cli_handler=self.execute_cli, snmp_handler=self.execute_snmp, **kwargs
  453                 )
  454
  455         def call_method(self, cli_handler=None, snmp_handler=None, fallback_handler=None, **kwargs):
  456             """
  457             Call function depending on access_preference
Variables:
                self =
<noc.sa.profiles.Cisco.SMB.get_interfaces.Script object at 0x7efe4eec7bb0>
              kwargs = {}
------------------------------------------------------------------------
File: core/script/base.py (Line: 307)
Function: run
  300                         self.logger.info("Using cached result")
  301                         cache_hit = True
  302                     except KeyError:
  303                         pass
  304                 # Execute script
  305                 if not cache_hit:
  306                     try:
  307 ==>                     result = self.execute(**self.args)
  308                         if self.cache and self.parent and result:
  309                             self.logger.info("Caching result")
  310                             self.set_cache(self.name, self.args, result)
  311                     finally:
  312                         if not self.parent:
  313                             # Close SNMP socket when necessary
Variables:
                self =
<noc.sa.profiles.Cisco.SMB.get_interfaces.Script object at 0x7efe4eec7bb0>
           cache_hit = False
------------------------------------------------------------------------
File: commands/script.py (Line: 149)
Function: handle
  142                 name=script,
  143             )
  144             span_sample = 1 if update_spec or beef_output else 0
  145             result = ""
  146             if beef_output:
  147                 scr.start_tracking()
  148             with Span(sample=span_sample, suppress_trace=span_sample):
  149 ==>             result = scr.run()
  150             if pretty:
  151                 pprint.pprint(result)
  152             elif yaml_o:
  153                 import sys
  154
  155                 yaml.dump(result, sys.stdout)
Variables:
                self = <__main__.Command object at 0x7efe5e2ab460>
              script = 'Cisco.SMB.get_interfaces'
         object_name = ['swa2-arch-staropim.msk.corp-qq']
           arguments = []
              pretty = True
              yaml_o = False
            use_snmp = True
   access_preference = 'S'
     snmp_rate_limit = 0
         update_spec = None
         beef_output = None
                args = {}
             options = {}
                 obj = <ManagedObject: swa2-arch-staropim.msk.corp-qq>
         credentials =
{'access_preference': 'S',
 'address': '192.168.0.45',
 'cli_protocol': 'ssh',
 'password': '_j2RNKU5!ig@drTw',
 'path': None,
 'raise_privileges': True,
 'snmp_rate_limit': None,
 'snmp_ro': 'p5v4Xnsi8BRO',
 'snmp_version': 'v2c',
 'super_password': None,
 'user': 'prime'}
        script_class = <class 'noc.sa.profiles.Cisco.SMB.get_interfaces.Script'>
                caps =
{'DB | Interfaces': 61,
 'Network | CDP': True,
 'SNMP': True,
 'SNMP | Bulk': True,
 'SNMP | IF-MIB': True,
 'SNMP | IF-MIB | HC': True,
 'SNMP | OID | EnterpriseID': 9,
 'SNMP | v1': True,
 'SNMP | v2c': True}
             version =
{'caps': {'DB | Interfaces': 61,
          'Network | CDP': True,
          'SNMP': True,
          'SNMP | Bulk': True,
          'SNMP | IF-MIB': True,
          'SNMP | IF-MIB | HC': True,
          'SNMP | OID | EnterpriseID': 9,
          'SNMP | v1': True,
          'SNMP | v2c': True},
 'image': None,
 'platform': 'SG300-52MP 52-Port Gigabit Max-PoE Managed Switch',
 'vendor': 'Cisco Systems',
 'version': '1.4.11.2'}
             service = <__main__.ServiceStub object at 0x7efe4ef4e460>
                 scr =
<noc.sa.profiles.Cisco.SMB.get_interfaces.Script object at 0x7efe4eec7bb0>
         span_sample = 0
              result = ''
------------------------------------------------------------------------
File: core/management/base.py (Line: 78)
Function: run_from_argv
   71             self.no_progressbar = cmd_options.pop("no_progressbar", False)
   72             if enable_profiling:
   73                 # Start profiler
   74                 import yappi
   75
   76                 yappi.start()
   77             try:
   78 ==>             return self.handle(*args, **cmd_options) or 0
   79             except CommandError as e:
   80                 self.print(str(e))
   81                 return 1
   82             except KeyboardInterrupt:
   83                 self.print("Ctrl+C")
   84                 return 3
Variables:
                self = <__main__.Command object at 0x7efe5e2ab460>
                argv =
['--access-preference',
 'S',
 '--debug',
 '--pretty',
 'get_interfaces',
 'swa2-arch-staropim.msk.corp-qq']
              parser =
ArgumentParser(prog='noc script', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
             options =
Namespace(access_preference='S', arguments=[], beef_output=None, object_name=['swa2-arch-staropim.msk.corp-qq'], pretty=True, script=['get_interfaces'], snmp_rate_limit=0, update_spec=None, use_snmp=True, yaml_o=False)
         cmd_options =
{'access_preference': 'S',
 'arguments': [],
 'beef_output': None,
 'object_name': ['swa2-arch-staropim.msk.corp-qq'],
 'pretty': True,
 'script': ['get_interfaces'],
 'snmp_rate_limit': 0,
 'update_spec': None,
 'use_snmp': True,
 'yaml_o': False}
                args = ()
            loglevel = 'debug'
    enable_profiling = False
        show_metrics = False
        error_report = <function error_report at 0x7efea3d463a0>
------------------------------------------------------------------------
END OF TRACEBACK

Paste NOC version (./noc about)

NOC version is: ./noc about 20.4.3 ./noc about latest-20.3 (на обеих инсталляциях аналогично)

Edited Mar 15, 2021 by Николай
Assignee
Assign to
Time tracking