Ad Widget

Collapse

BUG/Request for improvement: api problem.get missing property "status"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zabbix-peter
    Junior Member
    • Nov 2024
    • 12

    #1

    BUG/Request for improvement: api problem.get missing property "status"

    BUG/Request for improvement: api problem.get missing property "status"


    We use the zabbix API with python zabbix_utils to get problems.
    This works great and gives us all problems in a dictonary, but ...
    What we do not get is the status of the problem; "enabled" or "disabled", thus we cannot select the relevant ones.

    Background:
    We use LLD to generate items and triggers from Prometheus and some triggers we disable because they are not relevant and only give false positives.
    In a script we need to select the alerts and have custom action.

    Solution:
    Add a property; status to the output of problem.get.


    Code example with solution in place:
    Code:
    import configs
    from zabbix_utils import ZabbixAPI
    
    config = configs.configuration()
    
    api = ZabbixAPI(config.API_HOST)
    api.login(token=config.API_TOKEN)
    
    problems = api.problem.get()
    
    for problem in problems:
        if problem['status'] == 'enabled' and problem['severity'] == '4':
            sound_the_alarm()  # this function is not implemented!
    
    api.logout()


  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Problem is not "enabled" or "disabled"... Triggers which produce events, those can be enabled or disabled...

    Did you mean that problem status field in GUI? "problem" or "closed"... then you can look on r_eventid field... if it is empty, then problem is still "open" (I think it was that way... )

    Comment

    • zabbix-peter
      Junior Member
      • Nov 2024
      • 12

      #3
      You are right, the trigger is disabled or enabled.
      The problem that is generated by the trigger is in the problem list, eventhough the trigger is disabled.

      I just need to now if the problem that is in problem.get data, is generated by an enabled or disabled trigger.
      Weird as it is, a trigger that is disabled shouldn't be (generating) a problem.

      A workaround could be an alert.get method which shows all active alerts, but i could not find something like that.

      Comment

      • zabbix-peter
        Junior Member
        • Nov 2024
        • 12

        #4
        Basically i need the same view as:
        Monitoring -> Problems
        Which are active problems and filter them in a python script for further processing.

        Comment

        • cyber
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2006
          • 4807

          #5
          Originally posted by zabbix-peter
          I just need to now if the problem that is in problem.get data, is generated by an enabled or disabled trigger.
          Weird as it is, a trigger that is disabled shouldn't be (generating) a problem.
          I guess that trigger was active at the moment when problem was generated.. When you disable trigger, that problem does not disappear, it just stays hidden... If you enable that trigger again, that old problem pops out again.

          So I guess, what you need to to is look up "objectid" (ID of the related object) from problem, where source is 0 (event created by a trigger) and object is 0 (trigger) and then look up trigger status, where triggerid=objectid...

          Comment

          • zabbix-peter
            Junior Member
            • Nov 2024
            • 12

            #6
            At the moment the LLD process "finds" the relevant items it also generates the triggers.
            Not generating the triggers by LLD causes problems in other places, meaning more work.
            I do not know if triggers in LLD, disabled by default, will be generated or that they just not apear.

            I have to find out what the best way is to deal with this.

            Thanks so much for your input on the subject cyber

            Comment

            • cyber
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Dec 2006
              • 4807

              #7
              LLD can generate all triggers in "disabled state".
              Click image for larger version

Name:	image.png
Views:	101
Size:	2.8 KB
ID:	495489

              Or go even deeper and have overrides based on LLD values..
              Click image for larger version

Name:	image.png
Views:	89
Size:	42.2 KB
ID:	495490

              Comment

              Working...