Ad Widget

Collapse

PATCH: External scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sarek
    Junior Member
    • Aug 2006
    • 24

    #1

    PATCH: External scripts

    I like feedback! Let me know if you're using it please!
    Updates:
    2006-09-06
    • Fixed .h define, was using the same one as the internal

    2006-08-28
    • Removed need for single quotes in parameter list
    • Removed double quotes from call to external script

    2006-08-29
    • Numeric values get stored correctly so graphs can be generated

    Since that other thread looked dead and I couldn't get the patch file I went ahead and did it myself.

    New type "Zabbix External"
    Key should be scriptname(script parameters)
    ie. xerox_severity_check.sh(-c publicsnmp -v 2c)
    Zabbix would then execute "xerox_severity_check.sh hostname -c publicsnmp -v 2c

    Default scripts location
    /etc/zabbix/externalscripts

    Please point out my errors here, seems to be working fine on my server but my C is a little rusty.

    I put the code in the post so that it won't get lost. Wouldn't want someone to look for it a few months from now and get 404's!


    Code:
    diff -ur zabbix-1.1.1-old/include/common.h zabbix-1.1.1/include/common.h
    --- zabbix-1.1.1-old/include/common.h	2006-07-19 02:13:52.000000000 -0400
    +++ zabbix-1.1.1/include/common.h	2006-08-23 10:02:53.000000000 -0400
    @@ -160,6 +160,7 @@
     #define ITEM_TYPE_SNMPv3	6
     #define ITEM_TYPE_ZABBIX_ACTIVE	7
     #define ITEM_TYPE_AGGREGATE	8
    +#define ITEM_TYPE_EXTERNAL	9
     
     /* Item value types */
     #define ITEM_VALUE_TYPE_FLOAT	0
    diff -ur zabbix-1.1.1-old/misc/conf/zabbix_server.conf zabbix-1.1.1/misc/conf/zabbix_server.conf
    --- zabbix-1.1.1-old/misc/conf/zabbix_server.conf	2006-05-05 08:23:20.000000000 -0400
    +++ zabbix-1.1.1/misc/conf/zabbix_server.conf	2006-08-23 09:59:58.000000000 -0400
    @@ -64,6 +64,10 @@
     # How ofter check host for availability during the unavailability period
     #UnavailableDelay=60
     
    +# Directory containing external scripts that can be used
    +# Default: /etc/zabbix/externalscripts
    +ExternalScripts=/etc/zabbix/externalscripts
    +
     # Name of PID file
     
     PidFile=/var/tmp/zabbix_server.pid
    diff -ur zabbix-1.1.1-old/src/zabbix_server/poller/Makefile.in zabbix-1.1.1/src/zabbix_server/poller/Makefile.in
    --- zabbix-1.1.1-old/src/zabbix_server/poller/Makefile.in	2006-07-19 09:31:18.000000000 -0400
    +++ zabbix-1.1.1/src/zabbix_server/poller/Makefile.in	2006-08-23 11:41:10.000000000 -0400
    @@ -63,7 +63,7 @@
     am_libzbxpoller_a_OBJECTS = checks_agent.$(OBJEXT) \
     	checks_internal.$(OBJEXT) checks_simple.$(OBJEXT) \
     	checks_snmp.$(OBJEXT) checks_aggregate.$(OBJEXT) \
    -	poller.$(OBJEXT)
    +	checks_external.$(OBJEXT) poller.$(OBJEXT)
     libzbxpoller_a_OBJECTS = $(am_libzbxpoller_a_OBJECTS)
     DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
     depcomp = $(SHELL) $(top_srcdir)/depcomp
    @@ -187,7 +187,7 @@
     SUBDIRS = 
     INCLUDES = -I@top_srcdir@/include @MYSQL_INCLUDE@ @ORACLE_INCLUDE@ @SNMP_INCLUDE@
     lib_LIBRARIES = libzbxpoller.a
    -libzbxpoller_a_SOURCES = checks_agent.c checks_internal.c checks_simple.c checks_snmp.c checks_aggregate.c poller.c
    +libzbxpoller_a_SOURCES = checks_agent.c checks_external.c checks_internal.c checks_simple.c checks_snmp.c checks_aggregate.c poller.c
     all: all-recursive
     
     .SUFFIXES:
    @@ -264,6 +264,7 @@
     @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_agent.Po@am__quote@
     @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_aggregate.Po@am__quote@
     @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_internal.Po@am__quote@
    +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_external.Po@am__quote@
     @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_simple.Po@am__quote@
     @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_snmp.Po@am__quote@
     @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poller.Po@am__quote@
    diff -ur zabbix-1.1.1-old/src/zabbix_server/poller/poller.c zabbix-1.1.1/src/zabbix_server/poller/poller.c
    --- zabbix-1.1.1-old/src/zabbix_server/poller/poller.c	2006-05-19 09:34:49.000000000 -0400
    +++ zabbix-1.1.1/src/zabbix_server/poller/poller.c	2006-08-23 10:04:27.000000000 -0400
    @@ -50,6 +50,7 @@
     #include "checks_agent.h"
     #include "checks_aggregate.h"
     #include "checks_internal.h"
    +#include "checks_external.h"
     #include "checks_simple.h"
     #include "checks_snmp.h"
     
    @@ -90,6 +91,10 @@
     	{
     		res=get_value_internal(item, result);
     	}
    +	else if(item->type == ITEM_TYPE_EXTERNAL)
    +	{
    +		res=get_value_external(item, result);
    +	}
     	else if(item->type == ITEM_TYPE_AGGREGATE)
     	{
     		res=get_value_aggregate(item, result);
    diff -ur zabbix-1.1.1-old/src/zabbix_server/server.c zabbix-1.1.1/src/zabbix_server/server.c
    --- zabbix-1.1.1-old/src/zabbix_server/server.c	2006-07-06 05:04:31.000000000 -0400
    +++ zabbix-1.1.1/src/zabbix_server/server.c	2006-08-23 09:56:03.000000000 -0400
    @@ -124,6 +124,7 @@
     char	*CONFIG_DBPASSWORD		= NULL;
     char	*CONFIG_DBSOCKET		= NULL;
     int	CONFIG_DBPORT			= 3306;
    +char	*CONFIG_EXTERNALSCRIPTS		= NULL;
     int	CONFIG_ENABLE_REMOTE_COMMANDS	= 0;
     
     /* From table config */
    @@ -355,6 +356,7 @@
     		{"DBPassword",&CONFIG_DBPASSWORD,0,TYPE_STRING,PARM_OPT,0,0},
     		{"DBSocket",&CONFIG_DBSOCKET,0,TYPE_STRING,PARM_OPT,0,0},
     		{"DBPort",&CONFIG_DBPORT,0,TYPE_INT,PARM_OPT,1024,65535},
    +		{"ExternalScripts",&CONFIG_EXTERNALSCRIPTS,0,TYPE_STRING,PARM_OPT,0,0},
     		{0}
     	};
     
    @@ -383,6 +385,10 @@
     	{
     		CONFIG_FPING_LOCATION=strdup("/usr/sbin/fping");
     	}
    +	if(CONFIG_EXTERNALSCRIPTS == NULL)
    +	{
    +		CONFIG_EXTERNALSCRIPTS=strdup("/etc/zabbix/externalscripts");
    +	}
     
     }
    checks_external.h
    Code:
    /*
    ** ZABBIX
    ** Copyright (C) 2000-2005 SIA Zabbix
    **
    ** This program is free software; you can redistribute it and/or modify
    ** it under the terms of the GNU General Public License as published by
    ** the Free Software Foundation; either version 2 of the License, or
    ** (at your option) any later version.
    **
    ** This program is distributed in the hope that it will be useful,
    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    ** GNU General Public License for more details.
    **
    ** You should have received a copy of the GNU General Public License
    ** along with this program; if not, write to the Free Software
    ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    **/
    
    #ifndef ZABBIX_CHECKS_EXTERNAL_H
    #define ZABBIX_CHECKS_EXTERNAL_H
    
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    #include "common.h"
    #include "config.h"
    #include "db.h"
    #include "log.h"
    
    extern  char*   CONFIG_EXTERNALSCRIPTS;
    
    extern  int     get_value_external(DB_ITEM *item, AGENT_RESULT *result);
    
    #endif
    Last edited by Sarek; 06-09-2006, 15:06.
  • Sarek
    Junior Member
    • Aug 2006
    • 24

    #2
    Updated external check
    Changes:
    Removed '' requirement
    Removed "" surrounding parameters passed to script

    These combined let you do
    check_xerox.sh(this sends 4 parameters)

    After calculation the script call will look like
    check_xerox.sh printer-hostname this sends 4 paramaters

    Before this it would send
    check_xerox.sh printer-hostname "this sends 4 paramaters"

    Cheers!

    checks_external.c
    Code:
    /* 
    ** ZABBIX
    ** Copyright (C) 2000-2005 SIA Zabbix
    **
    ** This program is free software; you can redistribute it and/or modify
    ** it under the terms of the GNU General Public License as published by
    ** the Free Software Foundation; either version 2 of the License, or
    ** (at your option) any later version.
    **
    ** This program is distributed in the hope that it will be useful,
    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    ** GNU General Public License for more details.
    **
    ** You should have received a copy of the GNU General Public License
    ** along with this program; if not, write to the Free Software
    ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    **/
    
    #include "common.h"
    #include "checks_external.h"
    
    /******************************************************************************
     *                                                                            *
     * Function: get_value_external                                               *
     *                                                                            *
     * Purpose: retrieve data from script executed on ZABBIX server               *
     *                                                                            *
     * Parameters: item - item we are interested in                               *
     *                                                                            *
     * Return value: SUCCEED - data succesfully retrieved and stored in result    *
     *                         and result_str (as string)                         *
     *               NOTSUPPORTED - requested item is not supported               *
     *                                                                            *
     * Author: Mike Nestor                                                        *
     *                                                                            *
     * Comments:                                                                  *
     *                                                                            *
     ******************************************************************************/
    int     get_value_external(DB_ITEM *item, AGENT_RESULT *result)
    {
            FILE*   fp;
            char    scriptname[MAX_STRING_LEN];
            char    key[MAX_STRING_LEN];
            char    params[MAX_STRING_LEN];
            char    error[MAX_STRING_LEN];
            char    cmd[MAX_STRING_LEN];
            char    msg[MAX_STRING_LEN];
            char    *p,*p2;
            int     i;
    
            int     ret = SUCCEED;
    
            zabbix_log( LOG_LEVEL_DEBUG, "In get_value_external([%s])",item->key);
    
            init_result(result);
    
            strscpy(key, item->key);
            if((p2=strstr(key,"(")) != NULL)
            {
                    *p2=0;
                    strscpy(scriptname,key);
                    *p2='(';
                    p2++;
            }
            else    ret = NOTSUPPORTED;
    
            if(ret == SUCCEED)
            {
                    if((ret == SUCCEED) && (p=strstr(p2,")")) != NULL)
                    {
                            *p=0;
                            strscpy(params,p2);
                            *p=')';
                            p++;
                    }
                    else    ret = NOTSUPPORTED;
            }
            else
            {
                    snprintf(error,MAX_STRING_LEN-1,"External check [%s] is not supported", item->key);
                    zabbix_log( LOG_LEVEL_DEBUG, error);
                    SET_STR_RESULT(result, strdup(error));
                    return NOTSUPPORTED;
            }
    
            snprintf(cmd, MAX_STRING_LEN-1, "%s%s %s %s", CONFIG_EXTERNALSCRIPTS, scriptname, item->host, params);
            zabbix_log( LOG_LEVEL_DEBUG, cmd );
            if (NULL == (fp = popen(cmd, "r"))) 
            {
                    snprintf(error,MAX_STRING_LEN-1,"External check [%s] is not supported, failed execution", item->key);
                    zabbix_log( LOG_LEVEL_DEBUG, error);
                    SET_STR_RESULT(result, strdup(error));
                    return NOTSUPPORTED;
            }
    
            /* we only care about the first line */
            fgets(msg, sizeof(msg)-1, fp);
            for (i = 0; i < MAX_STRING_LEN && msg[i] != 0; ++i) 
            {
                    if (msg[i] == '\n') 
                    {
                            msg[i] = 0;
                            break;
                    }
            }
    
            set_result_type(result,item->value_type,strdup(msg));
    
            /* cleanup */
            pclose(fp);
    
            return SUCCEED;
    }
    Last edited by Sarek; 29-08-2006, 14:21. Reason: Changes to code

    Comment

    • Sarek
      Junior Member
      • Aug 2006
      • 24

      #3
      Cont.

      diff for changes to frontendphp
      Code:
      diff -ur zabbix-1.1.1-old/frontends/php/include/defines.inc.php zabbix-1.1.1/frontends/php/include/defines.inc.php
      --- zabbix-1.1.1-old/frontends/php/include/defines.inc.php      2006-06-01 09:44:54.000000000 -0400
      +++ zabbix-1.1.1/frontends/php/include/defines.inc.php  2006-08-23 11:56:28.000000000 -0400
      @@ -119,6 +119,7 @@
              define("ITEM_TYPE_SNMPV3",6);
              define("ITEM_TYPE_ZABBIX_ACTIVE",7);
              define("ITEM_TYPE_AGGREGATE",8);
      +       define("ITEM_TYPE_EXTERNAL",9);
       
              define("ITEM_VALUE_TYPE_FLOAT",0);
              define("ITEM_VALUE_TYPE_STR",1);
      diff -ur zabbix-1.1.1-old/frontends/php/include/forms.inc.php zabbix-1.1.1/frontends/php/include/forms.inc.php
      --- zabbix-1.1.1-old/frontends/php/include/forms.inc.php        2006-07-11 09:19:59.000000000 -0400
      +++ zabbix-1.1.1/frontends/php/include/forms.inc.php    2006-08-23 11:49:12.000000000 -0400
      @@ -359,6 +359,7 @@
                      $cmbType->AddItem(ITEM_TYPE_SNMPV3,S_SNMPV3_AGENT);
                      $cmbType->AddItem(ITEM_TYPE_TRAPPER,S_ZABBIX_TRAPPER);
                      $cmbType->AddItem(ITEM_TYPE_INTERNAL,S_ZABBIX_INTERNAL);
      +               $cmbType->AddItem(ITEM_TYPE_EXTERNAL,S_ZABBIX_EXTERNAL);
                      $cmbType->AddItem(ITEM_TYPE_AGGREGATE,S_ZABBIX_AGGREGATE);
                      $frmItem->AddRow(S_TYPE, $cmbType);
       
      diff -ur zabbix-1.1.1-old/frontends/php/include/locales/cn_zh.inc.php zabbix-1.1.1/frontends/php/include/locales/cn_zh.inc.php
      --- zabbix-1.1.1-old/frontends/php/include/locales/cn_zh.inc.php        2006-02-23 14:53:26.000000000 -0500
      +++ zabbix-1.1.1/frontends/php/include/locales/cn_zh.inc.php    2006-08-23 11:47:45.000000000 -0400
      @@ -380,6 +380,7 @@
              "S_SNMPV2_AGENT"=>                      "SNMPv2 agent",
              "S_SNMPV3_AGENT"=>                      "SNMPv3 agent",
              "S_ZABBIX_INTERNAL"=>                   "ZABBIX internal",
      +       "S_ZABBIX_EXTERNAL"=>                   "ZABBIX external",
              "S_ZABBIX_UNKNOWN"=>                    "δ֪",
              "S_ACTIVE"=>                            "��Ծ",
              "S_NOT_ACTIVE"=>                        "����Ծ",
      diff -ur zabbix-1.1.1-old/frontends/php/include/locales/en_gb.inc.php zabbix-1.1.1/frontends/php/include/locales/en_gb.inc.php
      --- zabbix-1.1.1-old/frontends/php/include/locales/en_gb.inc.php        2006-07-01 01:50:22.000000000 -0400
      +++ zabbix-1.1.1/frontends/php/include/locales/en_gb.inc.php    2006-08-23 11:47:26.000000000 -0400
      @@ -490,6 +490,7 @@
              "S_SNMPV2_AGENT"=>                      "SNMPv2 agent",
              "S_SNMPV3_AGENT"=>                      "SNMPv3 agent",
              "S_ZABBIX_INTERNAL"=>                   "ZABBIX internal",
      +       "S_ZABBIX_EXTERNAL"=>                   "ZABBIX external",
              "S_ZABBIX_AGGREGATE"=>                  "ZABBIX aggregate",
              "S_ZABBIX_UNKNOWN"=>                    "Unknown",
              "S_ACTIVE"=>                            "Active",
      diff -ur zabbix-1.1.1-old/frontends/php/include/locales/ja_jp.inc.php zabbix-1.1.1/frontends/php/include/locales/ja_jp.inc.php
      --- zabbix-1.1.1-old/frontends/php/include/locales/ja_jp.inc.php        2006-02-23 14:53:26.000000000 -0500
      +++ zabbix-1.1.1/frontends/php/include/locales/ja_jp.inc.php    2006-08-23 11:48:37.000000000 -0400
      @@ -390,6 +390,7 @@
              "S_SNMPV2_AGENT"=>                      "SNMPv2 agent",
              "S_SNMPV3_AGENT"=>                      "SNMPv3 agent",
              "S_ZABBIX_INTERNAL"=>                   "ZABBIX internal",
      +       "S_ZABBIX_EXTERNAL"=>                   "ZABBIX external",
              "S_ZABBIX_UNKNOWN"=>                    "不明",
              "S_ACTIVE"=>                            "有効",
              "S_NOT_ACTIVE"=>                        "無効",
      diff -ur zabbix-1.1.1-old/frontends/php/include/locales/lv_lv.inc.php zabbix-1.1.1/frontends/php/include/locales/lv_lv.inc.php
      --- zabbix-1.1.1-old/frontends/php/include/locales/lv_lv.inc.php        2006-02-23 14:53:26.000000000 -0500
      +++ zabbix-1.1.1/frontends/php/include/locales/lv_lv.inc.php    2006-08-23 11:48:03.000000000 -0400
      @@ -326,6 +326,7 @@
              "S_SNMPV2_AGENT"=>                      "SNMPv2 agent",
              "S_SNMPV3_AGENT"=>                      "SNMPv3 agent",
              "S_ZABBIX_INTERNAL"=>                   "ZABBIX internal",
      +       "S_ZABBIX_EXTERNAL"=>                   "ZABBIX external",
              "S_ZABBIX_UNKNOWN"=>                    "Unknown",
              "S_ACTIVE"=>                            "Active",
              "S_NOT_ACTIVE"=>                        "Not active",
      diff -ur zabbix-1.1.1-old/frontends/php/include/locales/ru_ru.inc.php zabbix-1.1.1/frontends/php/include/locales/ru_ru.inc.php
      --- zabbix-1.1.1-old/frontends/php/include/locales/ru_ru.inc.php        2006-02-23 14:53:26.000000000 -0500
      +++ zabbix-1.1.1/frontends/php/include/locales/ru_ru.inc.php    2006-08-23 11:48:20.000000000 -0400
      @@ -326,6 +326,7 @@
              "S_SNMPV2_AGENT"=>                      "SNMPv2 agent",
              "S_SNMPV3_AGENT"=>                      "SNMPv3 agent",
              "S_ZABBIX_INTERNAL"=>                   "ZABBIX internal",
      +       "S_ZABBIX_EXTERNAL"=>                   "ZABBIX external",
              "S_ZABBIX_UNKNOWN"=>                    "Unknown",
              "S_ACTIVE"=>                            "Active",
              "S_NOT_ACTIVE"=>                        "Not active",
      diff -ur zabbix-1.1.1-old/frontends/php/items.php zabbix-1.1.1/frontends/php/items.php
      --- zabbix-1.1.1-old/frontends/php/items.php    2006-05-25 12:02:17.000000000 -0400
      +++ zabbix-1.1.1/frontends/php/items.php        2006-08-23 11:58:12.000000000 -0400
      @@ -54,7 +54,7 @@
                      "delay"=>       array(T_ZBX_INT, O_OPT,  NULL,  BETWEEN(0,86400),'isset({save})&&{type}!=2'),
                      "history"=>     array(T_ZBX_INT, O_OPT,  NULL,  BETWEEN(0,65535),'isset({save})'),
                      "status"=>      array(T_ZBX_INT, O_OPT,  NULL,  BETWEEN(0,65535),'isset({save})'),
      -               "type"=>        array(T_ZBX_INT, O_OPT,  NULL,  IN("0,1,2,3,4,5,6,7,8"),'isset({save})'),
      +               "type"=>        array(T_ZBX_INT, O_OPT,  NULL,  IN("0,1,2,3,4,5,6,7,8,9"),'isset({save})'),
                      "trends"=>      array(T_ZBX_INT, O_OPT,  NULL,  BETWEEN(0,65535),'isset({save})'),
                      "value_type"=>  array(T_ZBX_INT, O_OPT,  NULL,  IN("0,1,2,3,4"),'isset({save})'),
                      "valuemapid"=>  array(T_ZBX_INT, O_OPT,  NULL,  DB_ID,'isset({save})'),
       
      @@ -422,6 +433,7 @@
                              case 4: $type = S_SNMPV2_AGENT;                 break;
                              case 6: $type = S_SNMPV3_AGENT;                 break;
                              case 5: $type = S_ZABBIX_INTERNAL;              break;
      +                       case 9: $type = S_ZABBIX_EXTERNAL;              break;
                              case 8: $type = S_ZABBIX_AGGREGATE;             break;
                              default:$type = S_UNKNOWN;                      break;
                              }
      diff -ur zabbix-1.1.1-old/frontends/php/popup.php zabbix-1.1.1/frontends/php/popup.php
      --- zabbix-1.1.1-old/frontends/php/popup.php    2006-07-12 03:02:50.000000000 -0400
      +++ zabbix-1.1.1/frontends/php/popup.php        2006-08-23 11:49:42.000000000 -0400
      @@ -102,6 +102,7 @@
                      $cmbTypes->AddItem(ITEM_TYPE_ZABBIX,S_ZABBIX_AGENT);
                      $cmbTypes->AddItem(ITEM_TYPE_SIMPLE,S_SIMPLE_CHECK);
                      $cmbTypes->AddItem(ITEM_TYPE_INTERNAL,S_ZABBIX_INTERNAL);
      +               $cmbTypes->AddItem(ITEM_TYPE_EXTERNAL,S_ZABBIX_EXTERNAL);
                      $cmbTypes->AddItem(ITEM_TYPE_AGGREGATE,S_ZABBIX_AGGREGATE);
                      $frmTitle->AddItem(array(S_TYPE,SPACE,$cmbTypes));
              }

      Comment

      • Sarek
        Junior Member
        • Aug 2006
        • 24

        #4
        To be able to create a trigger for these I had to change
        include/config.inc.php
        Line 655 to:
        Code:
        if (eregi('^\{([0-9a-zA-Z\_\.-]+)\:([]\[0-9a-zA-Z\_\*\/\.\,\'\:\(\) -]+)\.([a-z]{3,11})\(([#0-9a-zA-Z\_\/\.\,[:space:]]+)\)\}$', $expression, $arr))

        Comment

        • primos
          Member
          • Jul 2005
          • 61

          #5
          I've compiled your code and compiles well but the check doesn't performs. Log says
          017686:20060825:143145 In get_value_external([cat])
          017686:20060825:143145 External check [cat] is not supported
          017686:20060825:143145 Parameter [cat] is not supported by agent on host [Sokol] Old status [0]

          could there be something wrong with the pasted code, could you email me the code ([email protected])

          please

          lp, p

          Comment

          • Sarek
            Junior Member
            • Aug 2006
            • 24

            #6
            in the external check "key" you have

            cat(something) ?

            The external check can only execute stuff in /etc/zabbix/externalscripts
            Also it only retrieves the first line of stdout that the script/executable returns.

            Comment

            • primos
              Member
              • Jul 2005
              • 61

              #7
              My key is cat, which is the name of the script. Am I doing something wrong?
              I the previous patch I had keys - script names and the same one line output.
              Last edited by primos; 25-08-2006, 16:07.

              Comment

              • Sarek
                Junior Member
                • Aug 2006
                • 24

                #8
                even if you script doesn't take it you need

                cat('0')

                just like with last(0) but it expects the '' also

                Comment

                • primos
                  Member
                  • Jul 2005
                  • 61

                  #9
                  Now it works but only for char, previous patch worked for other types too.Have you any plans to fix this in the near future.

                  Thanks

                  lp, P

                  Comment

                  • Sarek
                    Junior Member
                    • Aug 2006
                    • 24

                    #10
                    Odd, I'm able to pull an int. I'm getting the severity code from Xerox printers. 1-4 number.

                    Comment

                    • Sarek
                      Junior Member
                      • Aug 2006
                      • 24

                      #11
                      I made changes to checks_external.c

                      Let me know how that works out for you.

                      Originally posted by primos
                      Now it works but only for char, previous patch worked for other types too.Have you any plans to fix this in the near future.

                      Thanks

                      lp, P

                      Comment

                      • primos
                        Member
                        • Jul 2005
                        • 61

                        #12
                        But can you graph them. I do get int but only if I set char type in zabbix!

                        lp, p

                        Comment

                        • Sarek
                          Junior Member
                          • Aug 2006
                          • 24

                          #13
                          Mine is set to Numberic (integer 64bit) and Latest Data does provide a graph link. But the graph is empty. Not sure what to make of that.

                          Originally posted by primos
                          But can you graph them. I do get int but only if I set char type in zabbix!

                          lp, p

                          Comment

                          • RohrbaGe
                            Senior Member
                            • Aug 2005
                            • 167

                            #14
                            External check

                            Hi Sarek,

                            the patch for the external checks seems to open a way for a simple solution for my task.
                            I would like to monitor our IBM AS400, and put some values to zabbix for monitoring.
                            I already found a way to get those values collected on the AS400 and
                            also to get it to linux.
                            I think with your patch I can pickup those values and write to the zabbix database.

                            Do I understand right, that I have to run for each key value a own script?

                            I hope Alexei will pickup the externalCheck and use it as standard.
                            From my point of view it is a very usefull feature.
                            As I understood one dangerous point is, that if the external script hungs,
                            zabbix will not continue collecting data.
                            But maybe I´m wrong with that.
                            Anyway it could be fixed with a maximum runtime value.

                            Regards

                            Gerald

                            Comment

                            • Sarek
                              Junior Member
                              • Aug 2006
                              • 24

                              #15
                              Yes, it would probably hang. As I said I'm a little rusty with my C.

                              I'm not sure I understand the question. are you asking if you can call an external script and write multiple values? If so then the answer would be no. Just like with every other check you only get to set one value in the database. You just need a script or executable that you can call that returns one line. Only the first line is read and used, everything else is ignored. As a habbit I also have my scripts exit 0.


                              Originally posted by RohrbaGe
                              Hi Sarek,

                              the patch for the external checks seems to open a way for a simple solution for my task.
                              I would like to monitor our IBM AS400, and put some values to zabbix for monitoring.
                              I already found a way to get those values collected on the AS400 and
                              also to get it to linux.
                              I think with your patch I can pickup those values and write to the zabbix database.

                              Do I understand right, that I have to run for each key value a own script?

                              I hope Alexei will pickup the externalCheck and use it as standard.
                              From my point of view it is a very usefull feature.
                              As I understood one dangerous point is, that if the external script hungs,
                              zabbix will not continue collecting data.
                              But maybe I´m wrong with that.
                              Anyway it could be fixed with a maximum runtime value.

                              Regards

                              Gerald

                              Comment

                              Working...