Ad Widget

Collapse

API creates the items and zabbix sender fails

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • angelhc
    Senior Member
    Zabbix Certified Specialist
    • Nov 2009
    • 226

    #1

    API creates the items and zabbix sender fails

    Hello all!
    Finally we finish the API configuration to create a lot of items into a defined host, it's so usefull for us cause we generate a lot of data for our apps.
    The api creates the items, another script sends the values to the Items but it recives data randomly, for example, we create 112 items and only 70 of them can storage the data, the another ones appears like bad configuration.

    Here it's all the sctripts:

    API:

    from zabbix_api import ZabbixAPI
    import logging
    import zabbix_api

    username='api'
    password='apipass'
    zapi = zabbix_api.ZabbixAPI('172.xx.xx.xxx','/zabbix/','http')
    zapi.login(username,password)
    hostapi = zapi.host
    #We know the hostid about a query to database
    hostid = '10141'

    f = open("estadisticas.dat", "r")
    while True:
    linea = f.readline()
    if not linea: break
    a = linea
    b = "MTM"
    description = b + '.' + a[:-1]
    key = linea[:-1]
    oid = "interfaces.ifTable.ifEntry.ifInOctets.1"
    print hostid
    print key
    print description
    zapi.item.create({ 'hostid' : (hostid),'description' : (description),'key_' : key, 'snmp_oid' : oid , 'type' : "2", 'value_type' : "3", 'formula' : "1", 'snmp_community' : "public" })

    The API creates all the lines from the estadisticas.dat file to items into zabbix, an example lines:

    Estadisticas.dat

    SCA_WAS6INT_MSGS_RESPONDIDOS
    SCA_WAS6INT_TIEMPO_MIN_RESPUESTA
    SCA_WAS6INT_TIEMPO_MAX_RESPUESTA
    SCA_WAS6INT_TIEMPO_MED_RESPUESTA
    SCA_WAS6INT_NUM_CLI_AHORA
    SCA_WAS6INT_NUM_MAX_CLI_START

    After this, we runs a script which send data to those items (112):

    Send_data.sh

    /home/zabbix/bin/zabbix_sender -c /home/zabbix/conf/zabbix_agentd.conf -k SCA_WAS6INT_MSGS_RESPONDIDOS -o 14736
    /home/zabbix/bin/zabbix_sender -c /home/zabbix/conf/zabbix_agentd.conf -k SCA_WAS6INT_TIEMPO_MIN_RESPUESTA -o 0.000
    /home/zabbix/bin/zabbix_sender -c /home/zabbix/conf/zabbix_agentd.conf -k SCA_WAS6INT_TIEMPO_MAX_RESPUESTA -o 2.696
    /home/zabbix/bin/zabbix_sender -c /home/zabbix/conf/zabbix_agentd.conf -k SCA_WAS6INT_TIEMPO_MED_RESPUESTA -o 0.013
    /home/zabbix/bin/zabbix_sender -c /home/zabbix/conf/zabbix_agentd.conf -k SCA_WAS6INT_NUM_CLI_AHORA -o 3
    /home/zabbix/bin/zabbix_sender -c /home/zabbix/conf/zabbix_agentd.conf -k SCA_WAS6INT_NUM_MAX_CLI_START -o 127214547

    The .conf file have the same Hostname than zabbix host configured, and I think is more ellegant to put -c than all the configuration values (and more easy).

    The output of the Send_data.sh:
    ./zabbix_sender -vv -c /home/monaf/zabbix/conf/zabbix_agentd.conf -s bos -k SCA_WAS6INT_NUM_MAX_CLI_START -o 1
    zabbix_sender [1778104]: DEBUG: Answer [{
    "response":"success",
    "info":"Processed 0 Failed 1 Total 1 Seconds spent 0.000019"}]
    Info from server: "Processed 0 Failed 1 Total 1 Seconds spent 0.000019"
    sent: 1; skipped: 0; total: 1

    Of course the firewalls are open to the 10051 and 10050 ports.

    Any idea?
    Thanks all!
    Number of hosts 1600,Number of items +90k,Number of triggers +22k, Number of users +100, New values per second +1270

    http://zabbixes.wordpress.com/
  • MrKen
    Senior Member
    • Oct 2008
    • 652

    #2
    Could it be that the path to zabbix_agentd.conf is incorrect?

    /home/zabbix/conf/zabbix_agentd.conf

    or

    /home/monaf/zabbix/conf/zabbix_agentd.conf


    Also check that the Type of information is correct. Numeric (unsigned) or Numeric (float).

    Configuration errors will normally be shown in the zabbix_server.log

    Also, check the format of Send_data.sh
    I had a problem once where the data file had the odd carriage return in the wrong place.

    MrKen
    Disclaimer: All of the above is pure speculation.

    Comment

    • richlv
      Senior Member
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Oct 2005
      • 3112

      #3
      by default zabbix server updates configuration cache every 60 seconds. if you send to a trapper item soon after creating it, server might not be aware of it.
      what happens if you wait for a couple of minutes before sending the initial data ?
      Zabbix 3.0 Network Monitoring book

      Comment

      • angelhc
        Senior Member
        Zabbix Certified Specialist
        • Nov 2009
        • 226

        #4
        MrKen, yes it was a try to hide my production configuration... the path have correct configuration.


        richlv, that was our first idea, the server configuration cache updates, but how many time spend the zabbix server to create / update 112 items? cause if we send data to those items each minute maybe the cache update is running and never have all the data...

        This is the .conf part where the update is called:

        CacheSize=256M
        CacheUpdateFrequency=60


        It means that each 60 seconds we've an update process and no data can be sending to the items?

        Thanks!
        Number of hosts 1600,Number of items +90k,Number of triggers +22k, Number of users +100, New values per second +1270

        http://zabbixes.wordpress.com/

        Comment

        • angelhc
          Senior Member
          Zabbix Certified Specialist
          • Nov 2009
          • 226

          #5
          Perfect!
          Finally it was the problem, we send data so soon to the items.

          Thanks all!
          Number of hosts 1600,Number of items +90k,Number of triggers +22k, Number of users +100, New values per second +1270

          http://zabbixes.wordpress.com/

          Comment

          Working...