diff options
author | Stef Walter <stef@memberwebs.com> | 2006-01-21 19:20:08 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2006-01-21 19:20:08 +0000 |
commit | 00e5df0f96a713060e5839f80b9b4fa6f562b0c3 (patch) | |
tree | 3ecb341887fc241f11aed374b34e6e00f26d7bdb /src | |
parent | 428f3570f98224e7fd2ff18e1e199068b3285a5d (diff) |
Infrastructure for the C daemons.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 7 | ||||
-rw-r--r-- | src/rrdcollectd.c | 96 | ||||
-rw-r--r-- | src/usuals.h | 77 |
3 files changed, 180 insertions, 0 deletions
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__ */ |