+CC=gcc
+RM=/bin/rm
+CFLAGS=
PLUGINDIR=plugins
INSTALL=/usr/bin/install
DSTPLUGINDIR=$(DESTDIR)/usr/lib/nagios/plugins
-all:
+all: check_ldaps_ip
+
+check_ldaps_ip: src/check_ldaps_ip.c
+ $(CC) -o $(PLUGINDIR)/check_ldaps_ip src/check_ldaps_ip.c
install:
$(INSTALL) -d $(DSTPLUGINDIR)
$(INSTALL) -m 0755 $(PLUGINDIR)/check_cert $(DSTPLUGINDIR)
$(INSTALL) -m 0755 $(PLUGINDIR)/check_md_raid $(DSTPLUGINDIR)
+ $(INSTALL) -m 0755 $(PLUGINDIR)/check_ldaps_ip $(DSTPLUGINDIR)
+
+clean:
+ $(RM) plugins/check_ldaps_ip
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#endif
+
+/* $Id$
+ *
+ * Small program to take an IP address, convert it into its rDNS (the first
+ * returned by the server) and run check_ldaps.
+ */
+int main(int argc, char *argv[])
+{
+ struct addrinfo *result;
+ struct addrinfo *res;
+ int error;
+
+ if (argc != 3) {
+ fprintf(stderr,"usage: check_ldaps_ip hostname basedn\n");
+ fprintf(stderr," Converts ip into the first rDNS returned by the server, and hands it off to check_ldaps\n");
+ return 1;
+ }
+
+ /* resolve the domain name into a list of addresses */
+ error = getaddrinfo(argv[1], NULL, NULL, &result);
+ if (error != 0){
+ fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
+ return EXIT_FAILURE;
+ }
+
+ char hostname[NI_MAXHOST] = "";
+
+ error = getnameinfo(result->ai_addr, result->ai_addrlen, hostname, NI_MAXHOST, NULL, 0, 0);
+ if (error != 0){
+ fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
+ }
+ if (*hostname != '\0'){
+// printf("%s\n", hostname);
+ execl("/usr/lib/nagios/plugins/check_ldaps", "/usr/lib/nagios/plugins/check_ldaps", "--ssl", "--ver3", "-H", hostname, "--base", argv[2], (char*) 0);
+ } else {
+ return EXIT_FAILURE;
+ }
+
+ freeaddrinfo(result);
+
+ return EXIT_SUCCESS;
+}
+