Ad Widget

Collapse

Send values to Zabbix from LLD script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dragan979
    Member
    • Apr 2018
    • 49

    #1

    Send values to Zabbix from LLD script?

    LLD Script:

    Code:
    tdata=[]
    items = items[0].split()
    for emailid in items:
        resp, data = conn.uid("fetch",emailid, "(RFC822)")
        if resp == 'OK':
            email_body = data[0][1].decode('utf-8')
            mail = email.message_from_string(email_body)
            if mail["Subject"].find("PA1") > 0 or mail["Subject"].find("PA2") > 0:
              regex1 = r'(?<!^)JOB:\s*(\S+)'
              #regex2 = r'Job finished'
              #c=re.findall(regex2, email_body, re.IGNORECASE)
              a=re.findall(regex1 ,email_body) #re.IGNORECASE)
              if a:
               b=set(a)
               seen = set()
               result = []
               for item in a:
                  if item not in seen:
                   seen.add(item)
                   result.append(item)
                   output = " ".join(result)
                   tdata.append({'#job':output})
    print json.dumps({"data": tdata}, indent=4)
    Output:

    Code:
    {
        "data": [
            {
                "{#job}": "p1_risk_mandates_otc_count_breaches"
            },
            {
               "{#job}": "p1_risk_mandates_calc_levels_rerun_late"
            },        
            {
               "{#job}": "p1_run_autofix_fx_1030_nyc_mxpp01"
            },
            {
               "{#job}": "p1_run_autofix_fx_1030_nyc_mxpp01"
            },
            {
             "{#job}": "p1_risk_mandates_upcoming_limit_changes"
            }    
               ]
      }

    I created item prototype and trigger prototype and separate zabbix trapper script for sending value "failed" to all those items . All works as expected. Because value for all those items/keys is the same ("failed") i wonder is it possible to hard code that value ("failed") into LLD script and to get rid of zabbix trapper,so i can use use LLD script to send data to Zabbix without using zabbix_sender ?.
    If it's not possibe, then is it possible to use UserParameters in zabbix_agent ?
    Last edited by dragan979; 12-01-2019, 18:31. Reason: zabbix,LLD,discovery script,items,JSON
Working...