Ad Widget

Collapse

Not having fun with custom LLD and zabbix sender

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Datacenter1.com
    Junior Member
    • May 2006
    • 10

    #1

    Not having fun with custom LLD and zabbix sender

    Hi

    I'm trying to create a custom LLD to discover installed PHP versions, handlers in a cPanel server

    I created the following User parameter:
    Code:
    UserParameter=php.discovery,/etc/zabbix/scripts/test.pl
    test.pl is very simple:
    Code:
    #!/usr/bin/perl
    
    $first = 1;
    
    print "[\n";
    
    for (`whmapi1 php_get_installed_versions|grep php|tr -d " "|sed 's/-//'|grep -v command:`)
    {
    ($php) = /(\S+)/;
    
    print "\t,\n" if not $first;
    $first = 0;
    
    print "\t{\n";
    print "\t\t\"{#PHPVERSION}\":\"$php\",\n";
    print "\t}\n";
    }
    
    print "]\n";
    The script output is like:
    Code:
    [
    {
    "{#PHPVERSION}":"alt-php70",
    }
    ,
    {
    "{#PHPVERSION}":"alt-php71",
    }
    ,
    {
    "{#PHPVERSION}":"alt-php72",
    }
    ,
    {
    "{#PHPVERSION}":"alt-php73",
    }
    ,
    {
    "{#PHPVERSION}":"alt-php74",
    }
    ]
    My discovery rule is like:
    Name: php.version
    Type: zabbix Agent (active)
    Key: php.discovery

    The item prototype is like:
    Name: {$PHPVERSION}: Handler
    Type: Zabbix Trapper
    Key: php.handler[{#PHPVERSION}]
    Type of information: Character

    There is also another script using zabbix sender to send the data pairs:
    zsend php.handler[alt-php74] cgi

    But i'm getting:
    php.handler[alt-php74] cgi
    Response from "XXXX:10051": "processed: 0; failed: 1; total: 1; seconds spent: 0.000062"


    zabbix server logs shows:
    752039:20210201:112735.380 trapper got '{"request":"sender data","data":[{"host":"xxxxxx","key":"php.handler[alt-php74]","value":"cgi"}]}'
    752039:20210201:112735.380 cannot retrieve key "php.handler[alt-php74]" on host "xxxxxx" from configuration cache


    752416:20210201:113203.107 trapper got '{"request":"agent data","data":[{"id":176,"itemid":35282,"value":"[\n\t{\n\t\t"{#PHPVERSION}":"alt-php44",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php51",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php52",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php53",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php54",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php55",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php56",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php70",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php71",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php72",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php73",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"a lt-php74",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php51",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php52",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php53",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php54",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php55",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php56",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php70",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php71",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php72",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php73",\n\t}\n\t,\n\t{\n\t\t"{#PHPVERSION}":"e a-php74",\n\t}\n]","clock":1612197122,"ns":456921}],"session":"62e361f4071f0b5ddb34443ffb4a4623"," hos t":"xxxxxxxx","version":"5.2"}'


    So i'm guessing the item prototype is wrong or something else

    Any idea or pointers in the right direction will be very much appreciated






  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    Have you completed the LLD process? Created items php.handler[blabla]?
    Show a screenshot with the settings of the created element (key).
    Which zabbix_sender call string do you use ( without abbreviations)?
    After creating items, the information about them should get into the cache - this takes some time.

    Comment

    • Datacenter1.com
      Junior Member
      • May 2006
      • 10

      #3
      Its working now, I tweak a little bit the json output and works!
      Code:
      zabbix_get -sxxxxxxx -p 10050 -k php.discovery
      {
      "data":[
      {"{#PHPVERSION}":"alt-php44"}
      ,{"{#PHPVERSION}":"alt-php51"}
      ,{"{#PHPVERSION}":"alt-php52"}
      ,{"{#PHPVERSION}":"alt-php53"}
      ,{"{#PHPVERSION}":"alt-php54"}
      ,{"{#PHPVERSION}":"alt-php55"}
      ,{"{#PHPVERSION}":"alt-php56"}
      ,{"{#PHPVERSION}":"alt-php70"}
      ,{"{#PHPVERSION}":"alt-php71"}
      ,{"{#PHPVERSION}":"alt-php72"}
      ,{"{#PHPVERSION}":"alt-php73"}
      ,{"{#PHPVERSION}":"alt-php74"}
      ,{"{#PHPVERSION}":"ea-php51"}
      ,{"{#PHPVERSION}":"ea-php52"}
      ,{"{#PHPVERSION}":"ea-php53"}
      ,{"{#PHPVERSION}":"ea-php54"}
      ,{"{#PHPVERSION}":"ea-php55"}
      ,{"{#PHPVERSION}":"ea-php56"}
      ,{"{#PHPVERSION}":"ea-php70"}
      ,{"{#PHPVERSION}":"ea-php71"}
      ,{"{#PHPVERSION}":"ea-php72"}
      ,{"{#PHPVERSION}":"ea-php73"}
      ,{"{#PHPVERSION}":"ea-php74"}
      ]
      }

      Comment

      Working...