I like feedback! Let me know if you're using it please!
Updates:
2006-09-06
2006-08-28
2006-08-29
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!
checks_external.h
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");
+ }
}
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
Comment