summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-01-21 19:20:08 +0000
committerStef Walter <stef@memberwebs.com>2006-01-21 19:20:08 +0000
commit00e5df0f96a713060e5839f80b9b4fa6f562b0c3 (patch)
tree3ecb341887fc241f11aed374b34e6e00f26d7bdb
parent428f3570f98224e7fd2ff18e1e199068b3285a5d (diff)
Infrastructure for the C daemons.
-rw-r--r--AUTHORS1
l---------COPYING1
-rw-r--r--ChangeLog1
l---------INSTALL1
-rw-r--r--Makefile.am6
-rw-r--r--NEWS1
-rw-r--r--README1
-rw-r--r--configure.in38
-rw-r--r--src/Makefile.am7
-rw-r--r--src/rrdcollectd.c96
-rw-r--r--src/usuals.h77
11 files changed, 230 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e967018
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Nate Nielsen <nielsen@memberwebs.com>
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 <errno.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <syslog.h>
+
+/* TODO: Abstract these headers away nicely */
+#include <bsnmp/asn1.h>
+#include <bsnmp/snmp.h>
+#include <bsnmp/snmpclient.h>
+
+/* -----------------------------------------------------------------------------
+ * 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 <nielsen@memberwebs.com>
+ *
+ */
+
+#ifndef __USUALS_H__
+#define __USUALS_H__
+
+#include <sys/types.h>
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#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__ */