From 00e5df0f96a713060e5839f80b9b4fa6f562b0c3 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 21 Jan 2006 19:20:08 +0000 Subject: Infrastructure for the C daemons. --- AUTHORS | 1 + COPYING | 1 + ChangeLog | 1 + INSTALL | 1 + Makefile.am | 6 ++++ NEWS | 1 + README | 1 + configure.in | 38 ++++++++++++++++++++++ src/Makefile.am | 7 ++++ src/rrdcollectd.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/usuals.h | 77 ++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 230 insertions(+) create mode 100644 AUTHORS create mode 120000 COPYING create mode 100644 ChangeLog create mode 120000 INSTALL create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100644 configure.in create mode 100644 src/Makefile.am create mode 100644 src/rrdcollectd.c create mode 100644 src/usuals.h diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e967018 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Nate Nielsen diff --git a/COPYING b/COPYING new file mode 120000 index 0000000..7153769 --- /dev/null +++ b/COPYING @@ -0,0 +1 @@ +/usr/share/automake-1.9/COPYING \ No newline at end of file diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..06152ac --- /dev/null +++ b/ChangeLog @@ -0,0 +1 @@ +None yet diff --git a/INSTALL b/INSTALL new file mode 120000 index 0000000..81fa6ff --- /dev/null +++ b/INSTALL @@ -0,0 +1 @@ +/usr/share/automake-1.9/INSTALL \ No newline at end of file diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..fa4eb00 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,6 @@ + +EXTRA_DIST = graphics html tools +# SUBDIRS = src + +dist-hook: + rm -rf `find $(distdir)/ -name .svn` diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..c7ab92a --- /dev/null +++ b/NEWS @@ -0,0 +1 @@ +See ChangeLog \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..e845566 --- /dev/null +++ b/README @@ -0,0 +1 @@ +README diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..660d9b2 --- /dev/null +++ b/configure.in @@ -0,0 +1,38 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(rrdui, 0.1, nielsen@memberwebs.com) +AM_INIT_AUTOMAKE(rrdui, 0.1) + +LDFLAGS="$LDFLAGS -L/usr/local/lib" +CFLAGS="$CFLAGS -I/usr/local/include" + +AC_CONFIG_SRCDIR([src/rrdcollectd.c]) +AM_CONFIG_HEADER([config.h]) + +# Debug mode +AC_ARG_ENABLE(debug, + AC_HELP_STRING([--enable-debug], + [Compile binaries in debug mode])) + +if test "$enable_debug" = "yes"; then + CFLAGS="$CFLAGS -g -O0" + AC_DEFINE_UNQUOTED(_DEBUG, 1, [In debug mode]) + echo "enabling debug compile mode" +fi + +dnl Check for programs. +AC_PROG_CC +AC_PROG_INSTALL + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE + +dnl Check for header files. +AC_HEADER_STDC +dnl TODO: AC_CHECK_HEADERS +dnl TODO: Check for libbsnmpclient + +AC_MSG_RESULT() + +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..daa2319 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,7 @@ + +sbin_PROGRAMS = rrdcollectd + +rrdcollectd_SOURCES = rrdcollectd.c + +rrdcollectd_CFLAGS = -I${top_srcdir}/common/ -I${top_srcdir} +rrdcollectd_LDFLAGS = diff --git a/src/rrdcollectd.c b/src/rrdcollectd.c new file mode 100644 index 0000000..849f082 --- /dev/null +++ b/src/rrdcollectd.c @@ -0,0 +1,96 @@ +/* + * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "usuals.h" +#include +#include +#include +#include + +/* TODO: Abstract these headers away nicely */ +#include +#include +#include + +/* ----------------------------------------------------------------------------- + * TESTS + */ + +static void +test_bsnmpd() +{ + struct snmp_pdu pdu, resp; + int n; + + snmp_client_init(&snmp_client); + snmp_client.trans = SNMP_TRANS_LOC_STREAM; + snmp_client_open("northstar-link.ws.local", NULL, "wsnettle", "public"); + + snmp_pdu_create(&pdu, SNMP_PDU_SET); + + n = snmp_add_binding(&pdu, &oid_begemotAtmIfMode, SNMP_SYNTAX_INTEGER, NULL); + if (snmp_dialog(&pdu, &resp)) + errx(1, "No response from '%s': %s", snmp_client.chost, snmp_client.error); + + if (snmp_pdu_check(&pdu, &resp) <= 0) + errx(1, "Error reading from server"); +} + +/* ----------------------------------------------------------------------------- + * STARTUP + */ + +static void +usage() +{ + fprintf(stderr, "usage: rrdcollectd\n"); + fprintf(stderr, " rrdcollectd -v\n"); + exit(2); +} + +int +main(int argc, char* argv[]) +{ + int daemonize; + char ch; + + /* Parse the arguments nicely */ + while((ch = getopt(argc, argv, "v")) != -1) + { + switch(ch) + { + + /* Print version number */ + case 'v': + printf("rrdcollectd (version %s)\n", VERSION); + exit(0); + break; + + /* Usage information */ + case '?': + default: + usage(); + break; + } + } + + argc -= optind; + argv += optind; + + printf("TODO: Implementation here...\n"); + return 0; +} + diff --git a/src/usuals.h b/src/usuals.h new file mode 100644 index 0000000..f83a117 --- /dev/null +++ b/src/usuals.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2005, Nate Nielsen + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * * The names of contributors to this software may not be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * + * CONTRIBUTORS + * Nate Nielsen + * + */ + +#ifndef __USUALS_H__ +#define __USUALS_H__ + +#include + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define countof(x) (sizeof(x) / sizeof(x[0])) + +#ifdef _DEBUG + #include "assert.h" + #define ASSERT(x) assert(x) +#else + #define ASSERT(x) +#endif + +#define KL(s) ((sizeof(s) - 1) / sizeof(char)) +#define RETURN(x) { ret = (x); goto finally; } + +#endif /* __USUALS_H__ */ -- cgit v1.2.3