summaryrefslogtreecommitdiff
path: root/src/rrdcollectd.c
blob: 849f08225db03037709fc85bfafb9eec8a831810 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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;
}