diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-10-01 18:16:32 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-10-01 18:16:32 +0000 |
| commit | 11c8a7664e9cc65ce283aee82df3f561da6ce226 (patch) | |
| tree | c7876d449ec50ce949d20f4bc7643c484a183b02 /src | |
| parent | 2f0ff760ee34bcfe7f75e254690c0f9a68e71133 (diff) | |
| download | zabbix-11c8a7664e9cc65ce283aee82df3f561da6ce226.tar.gz zabbix-11c8a7664e9cc65ce283aee82df3f561da6ce226.tar.xz zabbix-11c8a7664e9cc65ce283aee82df3f561da6ce226.zip | |
- support for check_service[ldap] and check_service_perf[ldap]. Thanks to Andreas Brenk. (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1453 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
| -rw-r--r-- | src/zabbix_agent/Makefile.in | 6 | ||||
| -rw-r--r-- | src/zabbix_agent/sysinfo.c | 77 | ||||
| -rw-r--r-- | src/zabbix_sucker/Makefile.in | 2 |
3 files changed, 82 insertions, 3 deletions
diff --git a/src/zabbix_agent/Makefile.in b/src/zabbix_agent/Makefile.in index 825eb82e..c4df92ea 100644 --- a/src/zabbix_agent/Makefile.in +++ b/src/zabbix_agent/Makefile.in @@ -1,9 +1,11 @@ # Build rules +LIBS = @LIBS@ @LDAP_LFLAGS@ + all: - @CC@ -o ../../bin/zabbix_agent @CFLAGS@ -I../../include zabbix_agent.c sysinfo.c ../../include/log.c ../../include/cfg.c ../../include/security.c ../../include/snprintf.c ../../include/md5.c -Wall @LIBS@ - @CC@ -o ../../bin/zabbix_agentd @CFLAGS@ -I../../include zabbix_agentd.c sysinfo.c stats.c interfaces.c diskdevices.c ../../include/log.c ../../include/cfg.c ../../include/security.c ../../include/pid.c ../../include/snprintf.c ../../include/md5.c -Wall @LIBS@ + @CC@ -o ../../bin/zabbix_agent @CFLAGS@ -I../../include zabbix_agent.c sysinfo.c ../../include/log.c ../../include/cfg.c ../../include/security.c ../../include/snprintf.c ../../include/md5.c -Wall $(LIBS) + @CC@ -o ../../bin/zabbix_agentd @CFLAGS@ -I../../include zabbix_agentd.c sysinfo.c stats.c interfaces.c diskdevices.c ../../include/log.c ../../include/cfg.c ../../include/security.c ../../include/pid.c ../../include/snprintf.c ../../include/md5.c -Wall $(LIBS) clean: rm -f *.o diff --git a/src/zabbix_agent/sysinfo.c b/src/zabbix_agent/sysinfo.c index 08ffdc68..796004ac 100644 --- a/src/zabbix_agent/sysinfo.c +++ b/src/zabbix_agent/sysinfo.c @@ -116,6 +116,10 @@ #include <kstat.h> #endif +#ifdef HAVE_LDAP + #include <ldap.h> +#endif + #include "common.h" #include "sysinfo.h" @@ -2488,6 +2492,65 @@ int tcp_expect(char *hostname, short port, char *expect,char *sendtoclose, int * } } +#ifdef HAVE_LDAP +int check_ldap(char *hostname, short port,int *value) +{ + int rc; + LDAP *ldap; + LDAPMessage *res; + LDAPMessage *msg; + + char *base = ""; + int scope = LDAP_SCOPE_BASE; + char *filter="(objectClass=*)"; + int attrsonly=0; + char *attrs[2]; + + attrs[0] = "namingContexts"; + attrs[1] = NULL; + + BerElement *ber; + char *attr=NULL; + char **valRes=NULL; + + ldap = ldap_init(hostname, port); + if ( !ldap ) + { + *value=0; + return SYSINFO_RET_OK; + } + + rc = ldap_search_s(ldap, base, scope, filter, attrs, attrsonly, &res); + if( rc != 0 ) + { + *value=0; + return SYSINFO_RET_OK; + } + + msg = ldap_first_entry(ldap, res); + if( !msg ) + { + *value=0; + return SYSINFO_RET_OK; + } + + attr = ldap_first_attribute (ldap, msg, &ber); + valRes = ldap_get_values( ldap, msg, attr ); + + ldap_value_free(valRes); + ldap_memfree(attr); + if (ber != NULL) { + ber_free(ber, 0); + } + ldap_msgfree(res); + ldap_unbind(ldap); + + *value=1; + return SYSINFO_RET_OK; +} ++#endif + + /* * 0- NOT OK * 1 - OK @@ -2625,6 +2688,13 @@ int CHECK_SERVICE_PERF(const char *cmd, const char *service_and_ip_and_port,doub if(port == 0) port=22; result=check_ssh(ip,port,&value_int); } +#ifdef HAVE_LDAP + else if(strcmp(service,"ldap") == 0) + { + if(port == 0) port=389; + result=check_ldap(ip,port,&value_int); + } +#endif else if(strcmp(service,"smtp") == 0) { if(port == 0) port=25; @@ -2779,6 +2849,13 @@ int CHECK_SERVICE(const char *cmd, const char *service_and_ip_and_port,double * if(port == 0) port=22; result=check_ssh(ip,port,&value_int); } +#ifdef HAVE_LDAP + else if(strcmp(service,"ldap") == 0) + { + if(port == 0) port=389; + result=check_ldap(ip,port,&value_int); + } +#endif else if(strcmp(service,"smtp") == 0) { if(port == 0) port=25; diff --git a/src/zabbix_sucker/Makefile.in b/src/zabbix_sucker/Makefile.in index 980208ef..c06038b3 100644 --- a/src/zabbix_sucker/Makefile.in +++ b/src/zabbix_sucker/Makefile.in @@ -1,7 +1,7 @@ # Build rules INCLUDE = @MYSQL_INCLUDE@ @PGSQL_INCLUDE@ @SNMP_INCLUDE@ -LIBS = @LIBS@ @MYSQL_LFLAGS@ @PGSQL_LFLAGS@ @SNMP_LFLAGS@ +LIBS = @LIBS@ @MYSQL_LFLAGS@ @PGSQL_LFLAGS@ @SNMP_LFLAGS@ @LDAP_LFLAGS@ all: |
