Ad Widget

Collapse

Create item in Zabbix GUI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mun
    Member
    • Sep 2016
    • 67

    #1

    Create item in Zabbix GUI

    Hi,

    I have monitor gmail using python script (image 1.png) and I want to create an item for this? I do add the script under User Parameter as shown in image 2.png.
    Can someone help me?

    Thanks.

    Attached Files
  • aigars.kadikis
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2018
    • 208

    #2
    Hi, Mun!

    You have to create one item with type text and then create multiple preprocessing items with regular expression like:
    (INBOX )([0-9]+) and extract second group:
    Click image for larger version

Name:	preprocessing-extract-second-group.png
Views:	275
Size:	56.3 KB
ID:	356582


    Click image for larger version

Name:	multi-line-item.png
Views:	240
Size:	81.2 KB
ID:	356583

    and you got data captured out:
    Click image for larger version

Name:	data-captured-out.png
Views:	256
Size:	61.3 KB
ID:	356584

    Hope it helps

    Comment


    • jorginhopc
      jorginhopc commented
      Editing a comment
      Hi Aigars.

      I have a different issue but perhaps you can help me.
      picking this example, on item "multi line item" the Last Value is "UNREAD 1/1 ..." how can you use this value inside an action?
      imagine that you put a trigger on this item when length > 0 and want to send this information by email.
      inside action Î'm able to get item name, trigger name... but not the "last value" that fired the trigger

      thanks in advance
      Jorge
  • Mun
    Member
    • Sep 2016
    • 67

    #3
    Hi aigars,

    Thank you for your kind reply, but I can't get any result. Could you point any mistake on this (as attached image)?
    Thanks.
    Attached Files

    Comment

    • aigars.kadikis
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Mar 2018
      • 208

      #4
      Hi, Mun!
      Welcome back!

      Please do not create preprocessing in the main item. Leave it untouched.
      Preprocessing goes only in dependent items this time.

      Let's start from begining.

      Does zabbix user has assigned any environment in your setup?
      Code:
      grep zabbix /etc/passwd
      If it ends "/sbin/nologin" this can mean that zabbix user do not know what the command 'python' actually is. Please try out one of these methods:

      Solution 1
      Code:
      UserParameter=discovery.message,bash -c 'python /full/path/to/gmailMessageCounter.py --noauth_local_webserver'
      Solution 2
      Look where python binary is hosting on your system
      Code:
      whereis python
      Create key:
      Code:
      UserParameter=discovery.message,/path/to/python /path/to/gmailMessageCounter.py --noauth_local_webserver
      Test the key
      Code:
      zabbix_agentd -t discovery.message
      Test key from 'zabbix' users perspective:
      Code:
      sudo -H -u zabbix bash -c 'zabbix_agentd -t discovery.message'
      Regards,
      Aigars

      Comment

      • Mun
        Member
        • Sep 2016
        • 67

        #5
        Hi aigars,

        Sorry for the late reply, i have did everything as u suggested but then it showing "Timeout while executing the script" (as attached image). Any suggestion?
        Thanks.
        Attached Files

        Comment

        • tcilmo
          Senior Member
          • Nov 2016
          • 122

          #6
          Originally posted by Mun
          Hi aigars,

          Sorry for the late reply, i have did everything as u suggested but then it showing "Timeout while executing the script" (as attached image). Any suggestion?
          Thanks.
          How long does it take to run? I would adjust the value of this config item on your agent and server config files:


          ### Option: Timeout
          # Spend no more than Timeout seconds on processing.
          #
          # Mandatory: no
          # Range: 1-30
          # Default:
          # Timeout=3

          Comment


          • Mun
            Mun commented
            Editing a comment
            Hi tcilmo,

            Thank you for your reply, I have change the timeout to 30 for both agent and server config files but it keeps appear the "Timeout while executing the script" error.
            Thanks.
        • tcilmo
          Senior Member
          • Nov 2016
          • 122

          #7
          How long does it take the script to run? More than 30 seconds?

          Comment

          Working...