Skip to content
Snippets Groups Projects

Test and record for ipv6 status for different hosts in Nagios

Merged Raja Nandakumar requested to merge nraja/LHCbDIRAC:ipv6NagiosUpdate into master
3 unresolved threads

For each CE and SE, save also the ipv6 status - currently as 0:HostHasipv6address, 1:HostHasOnlyipv4Address and -1:NotAValidHost.

The xml feed from this can be used to populate a web page for the ipv6 WG to display the statuses of the different sites as seen by LHCb.

Merge request reports

Checking pipeline status.

Approval is optional

Merged by avatar (Jun 18, 2025 11:16am UTC)

Merge details

  • Changes merged into 2024-patches with 915d21fd (commits were squashed).
  • Did not delete the source branch.
  • Auto-merge enabled

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
54 54
55 55 return S_OK()
56 56
57 def isHostIPV6(host):
  • May I suggest a slightly more pythonic way ?

    In [19]: socket.getaddrinfo('storm-fe-lhcb.cr.cnaf.infn.it', None, socket.AF_INET6)
    Out[19]: 
    [(10, 1, 6, '', ('2001:760:4205:128::128:74', 0, 0, 0)),
     (10, 2, 17, '', ('2001:760:4205:128::128:74', 0, 0, 0)),
     (10, 3, 0, '', ('2001:760:4205:128::128:74', 0, 0, 0))]
    
    In [20]: socket.getaddrinfo('tbit00.nipne.ro', None, socket.AF_INET6)
    ---------------------------------------------------------------------------
    gaierror                                  Traceback (most recent call last)
    <ipython-input-20-02b8573f2095> in <module>()
    ----> 1 socket.getaddrinfo('tbit00.nipne.ro', None, socket.AF_INET6)
    
    gaierror: [Errno -2] Name or service not known
  • Thanks - will redo it with a minor change to also test for ipv4 addresses.

  • Please register or sign in to reply
  • 341 363 mappingSEFlavour = {'srm': 'SRMv2',
    342 364 'root': 'XROOTD', 'http': 'HTTPS'}
    343 365
    344 xml_append(xml_doc, xml_site, 'service',
    366 xml_se = xml_append(xml_doc, xml_site, 'service',
    345 367 endpoint=site_se_endpoint,
    346 368 flavour=mappingSEFlavour.get(site_se_flavour, 'UNDEFINED'),
    347 369 hostname=site_se_name,
    348 370 path=site_se_path)
    349 371
    372 # ipv6 status of the SE
  • added 1 commit

    • ec2dd0d8 - Bug fix and code improvement

    Compare with previous version

  • 54 55
    55 56 return S_OK()
    56 57
    58 def contains(w, t):
    59 """ A simple test to check for a string in a nested set of tuples"""
    60 return any(w in str(x) for x in t)
    61
    62 def isHostIPV6(host):
    63 """ Test if the given host is ipv6 capable. 0:ipv6 capable. 1:ipv4 only. -1:Not a valid host (no DNS record?)
    64 """
    65 adrinfo = socket.getaddrinfo(host, None)
    • this call should be in the try block

    • You will not catch the exception here if your host does not exist. You can do something like this:

      def isHostIPV6(host):
          """ Test if the given host is ipv6 capable. 0:ipv6 capable. 1:ipv4 only. -1:Not a valid host (no DNS record?)
          """
          try: # try first IPV6
            adrinfo = socket.getaddrinfo(host, None, socket.AF_INET6)
            return 0
          except socket.gaierror: No IPv6 address
            try: # then try IPv4
              adrinfo = socket.getaddrinfo(host, None, socket.AF_INET) 
              return 1
            except socket.gaierror: # The host does not exist (no IPv6 nor IPv4)
              return -1
            
      
      
      In [9]: isHostIPV6('srm-lhcb.cern.ch')
      Out[9]: 1
      
      In [10]: isHostIPV6('srm-eoslhcb.cern.ch')
      Out[10]: 0
      
      In [11]: isHostIPV6('srm-nonexist.cern.ch')
      Out[11]: -1
    • Fair enough - I was trying to do everything with a single socket call, but your version is certainly cleaner.

    • changed this line in version 3 of the diff

    • Please register or sign in to reply
  • added 1 commit

    Compare with previous version

  • Christophe Haen approved this merge request

    approved this merge request

  • Just for the record, and as discussed with @nraja: the topology agent is just supposed to dump the content of the CS in a form readable by non LHCb specific software (SAM tests, etc). It is not meant to perform tests by itself. Dumping information about whether the host is IPv6 or not is borderline. So we can let this one in

  • merged

  • Zoltan Mathe mentioned in commit 915d21fd

    mentioned in commit 915d21fd

  • Please register or sign in to reply
    Loading