← Back to team overview

nagios-charmers team mailing list archive

[Bug 1947208] Re: amphorae check fails because of empty string

 

*** This bug is a duplicate of bug 1915671 ***
    https://bugs.launchpad.net/bugs/1915671

** This bug has been marked a duplicate of bug 1915671
   [Ussuri - Octavia] check_amphorae reports empty list - NRPE: Unable to read output

-- 
You received this bug notification because you are a member of Nagios
Charm developers, which is subscribed to Nagios Charm.
https://bugs.launchpad.net/bugs/1947208

Title:
  amphorae check fails because of empty string

Status in Nagios Charm:
  New

Bug description:
  I added a few prints in the code to show what is happening. Retrieving
  items["status"] fails because items is empty. That should be caught by
  the code instead of returning a traceback.

  
  sudo vi /usr/local/lib/nagios/plugins/check_octavia.py
  def check_amphorae(connection):

      """Check amphorae status."""

      lb_mgr = connection.load_balancer
      resp = lb_mgr.get("/v2/octavia/amphorae")

      print(resp)
      # python api is not available yet, use url
      if resp.status_code != 200:
          return [(NAGIOS_STATUS_WARNING, "amphorae api not working")]
   
      data = json.loads(resp.content)
      print(data)

      # ouput is like {"amphorae": [{...}, {...}, ...]}
      items = data.get("amphorae", [])
      print(items)

      # raise CRITICAL for ERROR status
      bad_status_list = ["ERROR"]
      bad_amp = [

          (
              NAGIOS_STATUS_CRITICAL,
              "amphora {} status is {}".format(item["id"], item["status"]),
          )
          for item in items
          if item["status"] in bad_status_list
      ]



  ubuntu@juju-fa5261-0-lxd-7:/etc/nagios/nrpe.d$ sudo /usr/local/lib/nagios/plugins/check_octavia.py --check amphorae
  <Response [200]>
  {'amphorae': [{}, {}], 'amphorae_links': []}
  [{}, {}]
  Traceback (most recent call last):

    File "/usr/local/lib/nagios/plugins/check_octavia.py", line 350, in
  <module>

      main()

    File "/usr/local/lib/nagios/plugins/check_octavia.py", line 344, in
  main

      status, message = process_checks(args)

    File "/usr/local/lib/nagios/plugins/check_octavia.py", line 285, in
  process_checks

      return nagios_exit(args, checks[args.check](connection))

    File "/usr/local/lib/nagios/plugins/check_octavia.py", line 208, in
  check_amphorae

      bad_amp = [

    File "/usr/local/lib/nagios/plugins/check_octavia.py", line 214, in
  <listcomp>

      if item["status"] in bad_status_list

  KeyError: 'status'

To manage notifications about this bug go to:
https://bugs.launchpad.net/charm-nagios/+bug/1947208/+subscriptions



References