diff options
author | kuriyama <kuriyama@FreeBSD.org> | 2013-10-08 10:45:22 +0800 |
---|---|---|
committer | kuriyama <kuriyama@FreeBSD.org> | 2013-10-08 10:45:22 +0800 |
commit | 29e34f51f08c3167c36ace23e313ed0fa2606c16 (patch) | |
tree | f62e201cd55cc165a2853d3e86ae645e9ab61393 /net-mgmt | |
parent | 4b705d26aefeee777250bfcc004dbb3b15728d60 (diff) | |
download | freebsd-ports-gnome-29e34f51f08c3167c36ace23e313ed0fa2606c16.tar.gz freebsd-ports-gnome-29e34f51f08c3167c36ace23e313ed0fa2606c16.tar.zst freebsd-ports-gnome-29e34f51f08c3167c36ace23e313ed0fa2606c16.zip |
- Upgrade to 20131004 version.
Diffstat (limited to 'net-mgmt')
-rw-r--r-- | net-mgmt/nagios-check_memcached_paranoid/Makefile | 13 | ||||
-rw-r--r-- | net-mgmt/nagios-check_memcached_paranoid/files/check_memcached_paranoid.c | 80 |
2 files changed, 53 insertions, 40 deletions
diff --git a/net-mgmt/nagios-check_memcached_paranoid/Makefile b/net-mgmt/nagios-check_memcached_paranoid/Makefile index d46aaa9ecbe1..a7989d4ef4fd 100644 --- a/net-mgmt/nagios-check_memcached_paranoid/Makefile +++ b/net-mgmt/nagios-check_memcached_paranoid/Makefile @@ -1,8 +1,7 @@ # $FreeBSD$ PORTNAME= check_memcached_paranoid -PORTVERSION= 0.20091016 -PORTREVISION= 1 +PORTVERSION= 0.20131004 CATEGORIES= net-mgmt MASTER_SITES= # none DISTFILES= # none @@ -10,7 +9,7 @@ DISTFILES= # none MAINTAINER= kuriyama@FreeBSD.org COMMENT= Nagios plugin for checking memcached -LIB_DEPENDS= memcache:${PORTSDIR}/databases/libmemcache +LIB_DEPENDS= memcached:${PORTSDIR}/databases/libmemcached BUILD_DEPENDS= nagios-plugins>0:${PLUGINS} \ ${EXTRA_DEPENDS} \ ${NONEXISTENT}:${PLUGINS}:build @@ -26,7 +25,6 @@ EXTRA_DEPENDS= automake>0:${PORTSDIR}/devel/automake \ libtool>0:${PORTSDIR}/devel/libtool \ gmake:${PORTSDIR}/devel/gmake -NO_STAGE= yes do-extract: ${MKDIR} ${WRKSRC} ${CP} ${FILESDIR}/${FILE} ${WRKSRC} @@ -34,15 +32,16 @@ do-extract: do-build: cd ${WRKSRC}; \ NDIR=$$(${NDIR_CMD}); \ - ${CC} ${CFLAGS} -DLOCALEDIR=\"${LOCALBASE}/share/locale\" \ + ${CC} ${CFLAGS} -DLOCALEDIR=\"${LOCALBASE}/share/locale\" -D__need_getopt \ -I$${NDIR} -I$${NDIR}/plugins -I$${NDIR}/gl -I$${NDIR}/lib -I${LOCALBASE}/include \ -o ${PORTNAME} \ $${NDIR}/plugins/netutils.o $${NDIR}/plugins/utils.o \ $${NDIR}/lib/utils_base.o $${NDIR}/gl/getopt.o $${NDIR}/gl/getopt1.o \ $${NDIR}/gl/sha1.o \ - -L${LOCALBASE}/lib -lintl -lmemcache ${FILE} + -L${LOCALBASE}/lib -lintl -lmemcached ${FILE} do-install: - ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${PREFIX}/libexec/nagios + ${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nagios + ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/libexec/nagios .include <bsd.port.mk> diff --git a/net-mgmt/nagios-check_memcached_paranoid/files/check_memcached_paranoid.c b/net-mgmt/nagios-check_memcached_paranoid/files/check_memcached_paranoid.c index cf6b208fa847..763587553cdb 100644 --- a/net-mgmt/nagios-check_memcached_paranoid/files/check_memcached_paranoid.c +++ b/net-mgmt/nagios-check_memcached_paranoid/files/check_memcached_paranoid.c @@ -13,14 +13,16 @@ const char *revision = "$Revision: 0.1 $"; const char *copyright = "2009"; const char *email = "hirose31 _at_ gmail.com"; +#include <unistd.h> + #include "common.h" #include "utils.h" #include "utils_base.h" #include "netutils.h" -#include "memcache.h" +#include <libmemcached/memcached.h> -#define MEMCACHED_PORT "11211" +#define MEMCACHED_PORT 11211 #define TEST_VAL "check_memcached_paranoid" #define EXIT_OK 0 @@ -29,8 +31,8 @@ const char *email = "hirose31 _at_ gmail.com"; #define EXIT_UNKNOWN 3 -char *mc_host = NULL; -char *mc_port = MEMCACHED_PORT; +char *mc_host = NULL; +in_port_t mc_port = MEMCACHED_PORT; u_int32_t mc_expire = 0; int process_arguments(int, char **); @@ -59,11 +61,16 @@ thresholds *my_thresholds = NULL; int main(int argc, char ** argv) { - struct memcache *mc; - char key[12]; - u_int32_t keylen; - char *val; - int rv; + struct memcached_st *mc; + memcached_return_t rc; + char key[32]; + u_int32_t keylen; + char *val; + size_t value_len; + uint32_t flags; + struct timeval tv; + long microsec; + double elapsed_time; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -78,19 +85,22 @@ int main(int argc, char ** argv) TRACE("%s",">>main"); // initialize - mc = mc_new(); + gettimeofday(&tv, NULL); + mc = memcached_create(NULL); if (mc == NULL) { - puts("failed to mc_new"); + printf("MEMCACHED %s: failed to memcached_create\n", _("CRITICAL")); exit(EXIT_CRITICAL); } - TRACE("[server]%s:%s", mc_host, mc_port); - rv = mc_server_add(mc, mc_host, mc_port); - TRACE("[mc_server_add rv]%d", rv); - if (rv != 0) { - printf("failed to server_add (%d)\n", rv); + TRACE("[server]%s:%d", mc_host, (int)mc_port); + rc = memcached_server_add(mc, mc_host, (in_port_t)mc_port); + TRACE("[mc_server_add rv]%d", rc); + if (rc != MEMCACHED_SUCCESS) { + printf("MEMCACHED %s: failed to memcached_server_add (%d)\n", _("CRITICAL"), rc); exit(EXIT_CRITICAL); } + memcached_behavior_set(mc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1); + srand(time(NULL) & getpid()); sprintf(key, "%d_%s", rand(), mc_host); keylen = strlen(key); @@ -102,41 +112,45 @@ int main(int argc, char ** argv) // set TRACE("[expire]%d", mc_expire); - rv = mc_set(mc, key, keylen, val, strlen(val), mc_expire, 0); - TRACE("[set rv]%d", rv); - if (rv != 0) { - printf("failed to set (%d)\n", rv); + rc = memcached_set(mc, key, keylen, val, strlen(val), mc_expire, 0); + TRACE("[set rv]%d", rc); + if (rc != MEMCACHED_SUCCESS) { + printf("MEMCACHED %s: failed to set (%d)\n", _("CRITICAL"), rc); exit(EXIT_CRITICAL); } free(val); // get - val = (char *)mc_aget(mc, key, keylen); + val = (char *)memcached_get(mc, key, keylen, &value_len, &flags, &rc); TRACE("[val]%s", val); - if (val == NULL) { - printf("failed to get after set\n"); + if (rc != MEMCACHED_SUCCESS) { + printf("MEMCACHED %s: failed to get after set\n", _("CRITICAL")); exit(EXIT_CRITICAL); } free(val); // delete - rv = mc_delete(mc, key, keylen, 0); - TRACE("[delete rv]%d", rv); - if (rv != 0) { - printf("failed to delete (%d)\n", rv); + rc = memcached_delete(mc, key, keylen, 0); + TRACE("[delete rv]%d", rc); + if (rc != MEMCACHED_SUCCESS) { + printf("MEMCACHED %s: failed to delete (%d)\n", _("CRITICAL"), rc); exit(EXIT_CRITICAL); } // get - val = (char *)mc_aget(mc, key, keylen); + val = (char *)memcached_get(mc, key, keylen, &value_len, &flags, &rc); TRACE("[val]%s", val); - if (val != NULL) { - printf("failed to get after delete\n"); + if (rc != MEMCACHED_NOTFOUND) { + printf("MEMCACHED %s: failed to get after delete\n", _("CRITICAL")); exit(EXIT_CRITICAL); } free(val); - mc_free(mc); + memcached_free(mc); + + microsec = deltime(tv); + elapsed_time = (double)microsec / 1.0e6; + printf("MEMCACHED %s: %.3f seconds\n", _("OK"), elapsed_time); return 0; } @@ -181,7 +195,7 @@ process_arguments (int argc, char **argv) } break; case 'P': - mc_port = optarg; + mc_port = atoi(optarg); break; case 'E': mc_expire = atoi(optarg); @@ -226,7 +240,7 @@ int validate_arguments(void) void print_help(void) { char *mcport; - asprintf(&mcport, "%s", MEMCACHED_PORT); + asprintf(&mcport, "%d", MEMCACHED_PORT); print_revision (progname, revision); |