#include "zbxsysinfo.h"
#include "../sysinfo.h"
#include "simple.h"
#include "../common/net.h"
#include "ntp.h"
#include "zbxstr.h"
#include "zbxnum.h"
#include "zbxtime.h"
#include "zbxip.h"
#include "zbxcomms.h"
#include "log.h"
#include "cfg.h"
#ifdef HAVE_LDAP
# include <ldap.h>
#endif
#ifdef HAVE_LBER_H
# include <lber.h>
#endif
ZBX_METRIC parameters_simple[] =
{
{"net.tcp.service", CF_HAVEPARAMS, check_service, "ssh,127.0.0.1,22"},
{"net.tcp.service.perf",CF_HAVEPARAMS, check_service_perf, "ssh,127.0.0.1,22"},
{"net.udp.service", CF_HAVEPARAMS, check_service, "ntp,127.0.0.1,123"},
{"net.udp.service.perf",CF_HAVEPARAMS, check_service_perf, "ntp,127.0.0.1,123"},
{NULL}
};
#ifdef HAVE_LDAP
static int check_ldap(const char *host, unsigned short port, int timeout, int *value_int)
{
LDAP *ldap = NULL;
LDAPMessage *res = NULL;
LDAPMessage *msg = NULL;
BerElement *ber = NULL;
char *attrs[2] = {"namingContexts", NULL };
char *attr = NULL;
char **valRes = NULL;
int ldapErr = 0;
zbx_alarm_on(timeout);
*value_int = 0;
if (NULL == (ldap = ldap_init(host, port)))
{
zabbix_log(LOG_LEVEL_DEBUG, "LDAP - initialization failed [%s:%hu]", host, port);
goto lbl_ret;
}
#if defined(LDAP_OPT_SOCKET_BIND_ADDRESSES) && defined(HAVE_LDAP_SOURCEIP)
if (NULL != CONFIG_SOURCE_IP)
{
if (LDAP_SUCCESS != (ldapErr = ldap_set_option(ldap, LDAP_OPT_SOCKET_BIND_ADDRESSES, CONFIG_SOURCE_IP)))
{
zabbix_log(LOG_LEVEL_DEBUG, "LDAP - failed to set source ip address [%s]",
ldap_err2string(ldapErr));
goto lbl_ret;
}
}
#endif
if (LDAP_SUCCESS != (ldapErr = ldap_search_s(ldap, "", LDAP_SCOPE_BASE, "(objectClass=*)", attrs, 0, &res)))
{
zabbix_log(LOG_LEVEL_DEBUG, "LDAP - searching failed [%s] [%s]", host, ldap_err2string(ldapErr));
goto lbl_ret;