Preparing for the incoming AppInterface changes
This commit is contained in:
parent
15ddd4916d
commit
6d18e80713
6
Makefile
6
Makefile
|
@ -1,6 +1,6 @@
|
||||||
PACKAGE = Probe
|
PACKAGE = Probe
|
||||||
VERSION = 0.0.0
|
VERSION = 0.0.0
|
||||||
SUBDIRS = src
|
SUBDIRS = data src
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
LN = ln -f
|
LN = ln -f
|
||||||
TAR = tar -czvf
|
TAR = tar -czvf
|
||||||
|
@ -21,6 +21,10 @@ dist:
|
||||||
$(RM) -r $(PACKAGE)-$(VERSION)
|
$(RM) -r $(PACKAGE)-$(VERSION)
|
||||||
$(LN) -s . $(PACKAGE)-$(VERSION)
|
$(LN) -s . $(PACKAGE)-$(VERSION)
|
||||||
@$(TAR) $(PACKAGE)-$(VERSION).tar.gz \
|
@$(TAR) $(PACKAGE)-$(VERSION).tar.gz \
|
||||||
|
$(PACKAGE)-$(VERSION)/data/Makefile \
|
||||||
|
$(PACKAGE)-$(VERSION)/data/Probe.interface \
|
||||||
|
$(PACKAGE)-$(VERSION)/data/Probe.h \
|
||||||
|
$(PACKAGE)-$(VERSION)/data/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/src/probe.c \
|
$(PACKAGE)-$(VERSION)/src/probe.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/damon.c \
|
$(PACKAGE)-$(VERSION)/src/damon.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/Makefile \
|
$(PACKAGE)-$(VERSION)/src/Makefile \
|
||||||
|
|
|
@ -2,5 +2,5 @@ package=Probe
|
||||||
version=0.0.0
|
version=0.0.0
|
||||||
config=h
|
config=h
|
||||||
|
|
||||||
subdirs=src
|
subdirs=data,src
|
||||||
dist=Makefile,COPYING,config.h
|
dist=Makefile,COPYING,config.h
|
||||||
|
|
|
@ -3,10 +3,10 @@ PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
CC = cc
|
CC = cc
|
||||||
CPPFLAGSF=
|
CPPFLAGSF= -I ../data
|
||||||
CPPFLAGS=
|
CPPFLAGS=
|
||||||
CFLAGSF = -W
|
CFLAGSF = -W
|
||||||
CFLAGS = -Wall -g -O2 -ansi
|
CFLAGS = -Wall -g -O2 -pedantic
|
||||||
LDFLAGSF= -l System
|
LDFLAGSF= -l System
|
||||||
LDFLAGS = -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib
|
LDFLAGS = -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
|
@ -31,7 +31,7 @@ DaMon_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
DaMon: $(DaMon_OBJS)
|
DaMon: $(DaMon_OBJS)
|
||||||
$(CC) -o DaMon $(DaMon_OBJS) $(DaMon_LDFLAGS)
|
$(CC) -o DaMon $(DaMon_OBJS) $(DaMon_LDFLAGS)
|
||||||
|
|
||||||
probe.o: probe.c
|
probe.o: probe.c ../data/Probe.h
|
||||||
$(CC) $(Probe_CFLAGS) -c probe.c
|
$(CC) $(Probe_CFLAGS) -c probe.c
|
||||||
|
|
||||||
damon.o: damon.c
|
damon.o: damon.c
|
||||||
|
|
121
src/damon.c
121
src/damon.c
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2008 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2009 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Network Probe */
|
/* This file is part of DeforaOS Network Probe */
|
||||||
/* Probe is not free software; you can redistribute it and/or modify it under
|
/* Probe is not free software; you can redistribute it and/or modify it under
|
||||||
* the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 3.0
|
* the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 3.0
|
||||||
|
@ -13,6 +13,8 @@
|
||||||
* You should have received a copy of the Creative Commons Attribution-
|
* You should have received a copy of the Creative Commons Attribution-
|
||||||
* NonCommercial-ShareAlike 3.0 along with Probe; if not, browse to
|
* NonCommercial-ShareAlike 3.0 along with Probe; if not, browse to
|
||||||
* http://creativecommons.org/licenses/by-nc-sa/3.0/ */
|
* http://creativecommons.org/licenses/by-nc-sa/3.0/ */
|
||||||
|
/* FIXME: catch SIGPIPE, determine if we can avoid catching it if an AppServer
|
||||||
|
* exits */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,16 +29,22 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|
||||||
#define DAMON_DEFAULT_REFRESH 10
|
#ifndef PREFIX
|
||||||
|
# define PREFIX "/usr/local"
|
||||||
|
#endif
|
||||||
#ifndef ETCDIR
|
#ifndef ETCDIR
|
||||||
# define ETCDIR PREFIX "/etc"
|
# define ETCDIR PREFIX "/etc"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DAMON_DEFAULT_REFRESH 10
|
||||||
|
|
||||||
|
|
||||||
/* types */
|
/* types */
|
||||||
|
typedef struct _DaMon DaMon;
|
||||||
|
|
||||||
typedef struct _Host
|
typedef struct _Host
|
||||||
{
|
{
|
||||||
|
DaMon * damon;
|
||||||
AppClient * appclient;
|
AppClient * appclient;
|
||||||
char * hostname;
|
char * hostname;
|
||||||
char ** ifaces;
|
char ** ifaces;
|
||||||
|
@ -46,25 +54,26 @@ typedef struct _Host
|
||||||
|
|
||||||
/* DaMon */
|
/* DaMon */
|
||||||
/* types */
|
/* types */
|
||||||
typedef struct _DaMon
|
struct _DaMon
|
||||||
{
|
{
|
||||||
|
char const * prefix;
|
||||||
unsigned int refresh;
|
unsigned int refresh;
|
||||||
Host * hosts;
|
Host * hosts;
|
||||||
unsigned int hosts_cnt;
|
unsigned int hosts_cnt;
|
||||||
Event * event;
|
Event * event;
|
||||||
} DaMon;
|
};
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
/* public */
|
/* public */
|
||||||
/* damon */
|
/* damon */
|
||||||
static int _damon_init(DaMon * damon);
|
static int _damon_init(DaMon * damon, char const * config);
|
||||||
static void _damon_destroy(DaMon * damon);
|
static void _damon_destroy(DaMon * damon);
|
||||||
|
|
||||||
static int _damon(void)
|
static int _damon(char const * config)
|
||||||
{
|
{
|
||||||
DaMon damon;
|
DaMon damon;
|
||||||
|
|
||||||
if(_damon_init(&damon) != 0)
|
if(_damon_init(&damon, config) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
if(event_loop(damon.event) != 0)
|
if(event_loop(damon.event) != 0)
|
||||||
error_print("DaMon");
|
error_print("DaMon");
|
||||||
|
@ -74,14 +83,14 @@ static int _damon(void)
|
||||||
|
|
||||||
|
|
||||||
/* _damon_init */
|
/* _damon_init */
|
||||||
static int _init_config(DaMon * damon);
|
static int _init_config(DaMon * damon, char const * filename);
|
||||||
static int _damon_refresh(DaMon * damon);
|
static int _damon_refresh(DaMon * damon);
|
||||||
|
|
||||||
static int _damon_init(DaMon * damon)
|
static int _damon_init(DaMon * damon, char const * filename)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
if(_init_config(damon) != 0)
|
if(_init_config(damon, filename) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
if((damon->event = event_new()) == NULL)
|
if((damon->event = event_new()) == NULL)
|
||||||
return error_print("DaMon");
|
return error_print("DaMon");
|
||||||
|
@ -96,19 +105,21 @@ static int _damon_init(DaMon * damon)
|
||||||
/* _init_config */
|
/* _init_config */
|
||||||
static int _config_hosts(DaMon * damon, Config * config, char const * hosts);
|
static int _config_hosts(DaMon * damon, Config * config, char const * hosts);
|
||||||
|
|
||||||
static int _init_config(DaMon * damon)
|
static int _init_config(DaMon * damon, char const * filename)
|
||||||
{
|
{
|
||||||
Config * config;
|
Config * config;
|
||||||
char * filename = ETCDIR "/damon.cfg";
|
|
||||||
char const * p;
|
char const * p;
|
||||||
char * q;
|
char * q;
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
if((config = config_new()) == NULL)
|
if((config = config_new()) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
damon->prefix = NULL;
|
||||||
damon->refresh = DAMON_DEFAULT_REFRESH;
|
damon->refresh = DAMON_DEFAULT_REFRESH;
|
||||||
damon->hosts = NULL;
|
damon->hosts = NULL;
|
||||||
damon->hosts_cnt = 0;
|
damon->hosts_cnt = 0;
|
||||||
|
if(filename == NULL)
|
||||||
|
filename = ETCDIR "/damon.cfg";
|
||||||
if(config_load(config, filename) != 0)
|
if(config_load(config, filename) != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "DaMon: %s: Could not load configuration\n",
|
fprintf(stderr, "DaMon: %s: Could not load configuration\n",
|
||||||
|
@ -116,6 +127,8 @@ static int _init_config(DaMon * damon)
|
||||||
config_delete(config);
|
config_delete(config);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if((damon->prefix = config_get(config, "", "prefix")) == NULL)
|
||||||
|
damon->prefix = ".";
|
||||||
if((p = config_get(config, "", "refresh")) != NULL)
|
if((p = config_get(config, "", "refresh")) != NULL)
|
||||||
{
|
{
|
||||||
tmp = strtol(p, &q, 10);
|
tmp = strtol(p, &q, 10);
|
||||||
|
@ -131,8 +144,8 @@ static int _init_config(DaMon * damon)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _hosts_host(Config * config, Host * host, char const * h,
|
static int _hosts_host(DaMon * damon, Config * config, Host * host,
|
||||||
unsigned int pos);
|
char const * h, unsigned int pos);
|
||||||
static int _config_hosts(DaMon * damon, Config * config, char const * hosts)
|
static int _config_hosts(DaMon * damon, Config * config, char const * hosts)
|
||||||
{
|
{
|
||||||
char const * h = hosts;
|
char const * h = hosts;
|
||||||
|
@ -156,8 +169,8 @@ static int _config_hosts(DaMon * damon, Config * config, char const * hosts)
|
||||||
return error_set_print("DaMon", 1, "%s",
|
return error_set_print("DaMon", 1, "%s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
damon->hosts = p;
|
damon->hosts = p;
|
||||||
if(_hosts_host(config, &damon->hosts[damon->hosts_cnt++], h,
|
p = &damon->hosts[damon->hosts_cnt++];
|
||||||
pos) != 0)
|
if(_hosts_host(damon, config, p, h, pos) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
h += pos;
|
h += pos;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
@ -166,11 +179,12 @@ static int _config_hosts(DaMon * damon, Config * config, char const * hosts)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char ** _host_comma(char const * line);
|
static char ** _host_comma(char const * line);
|
||||||
static int _hosts_host(Config * config, Host * host, char const * h,
|
static int _hosts_host(DaMon * damon, Config * config, Host * host,
|
||||||
unsigned int pos)
|
char const * h, unsigned int pos)
|
||||||
{
|
{
|
||||||
char const * p;
|
char const * p;
|
||||||
|
|
||||||
|
host->damon = damon;
|
||||||
host->appclient = NULL;
|
host->appclient = NULL;
|
||||||
host->ifaces = NULL;
|
host->ifaces = NULL;
|
||||||
host->vols = NULL;
|
host->vols = NULL;
|
||||||
|
@ -267,7 +281,7 @@ static int _damon_refresh(DaMon * damon)
|
||||||
Host * hosts = damon->hosts;
|
Host * hosts = damon->hosts;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "%s", "_damon_refresh()\n");
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
#endif
|
#endif
|
||||||
for(i = 0; i < damon->hosts_cnt; i++)
|
for(i = 0; i < damon->hosts_cnt; i++)
|
||||||
{
|
{
|
||||||
|
@ -276,7 +290,7 @@ static int _damon_refresh(DaMon * damon)
|
||||||
== NULL)
|
== NULL)
|
||||||
continue;
|
continue;
|
||||||
if((p = realloc(rrd, string_length(hosts[i].hostname) + 12))
|
if((p = realloc(rrd, string_length(hosts[i].hostname) + 12))
|
||||||
== NULL)
|
== NULL) /* XXX avoid this constant */
|
||||||
break;
|
break;
|
||||||
rrd = p;
|
rrd = p;
|
||||||
if(_refresh_uptime(ac, &hosts[i], rrd) != 0
|
if(_refresh_uptime(ac, &hosts[i], rrd) != 0
|
||||||
|
@ -310,7 +324,7 @@ static AppClient * _refresh_connect(Host * host, Event * event)
|
||||||
return host->appclient;
|
return host->appclient;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _rrd_update(char * file, int args_cnt, ...);
|
static int _rrd_update(DaMon * damon, char const * filename, int args_cnt, ...);
|
||||||
static int _refresh_uptime(AppClient * ac, Host * host, char * rrd)
|
static int _refresh_uptime(AppClient * ac, Host * host, char * rrd)
|
||||||
{
|
{
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
@ -318,7 +332,7 @@ static int _refresh_uptime(AppClient * ac, Host * host, char * rrd)
|
||||||
if(appclient_call(ac, &ret, "uptime") != 0)
|
if(appclient_call(ac, &ret, "uptime") != 0)
|
||||||
return error_print("DaMon");
|
return error_print("DaMon");
|
||||||
sprintf(rrd, "%s_%s", host->hostname, "uptime.rrd");
|
sprintf(rrd, "%s_%s", host->hostname, "uptime.rrd");
|
||||||
_rrd_update(rrd, 1, ret);
|
_rrd_update(host->damon, rrd, 1, ret);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +345,7 @@ static int _refresh_load(AppClient * ac, Host * host, char * rrd)
|
||||||
|| appclient_call(ac, &ret[2], "load_15") != 0)
|
|| appclient_call(ac, &ret[2], "load_15") != 0)
|
||||||
return error_print("DaMon");
|
return error_print("DaMon");
|
||||||
sprintf(rrd, "%s_%s", host->hostname, "load.rrd");
|
sprintf(rrd, "%s_%s", host->hostname, "load.rrd");
|
||||||
_rrd_update(rrd, 3, ret[0], ret[1], ret[2]);
|
_rrd_update(host->damon, rrd, 3, ret[0], ret[1], ret[2]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +356,7 @@ static int _refresh_procs(AppClient * ac, Host * host, char * rrd)
|
||||||
if(appclient_call(ac, &res, "procs") != 0)
|
if(appclient_call(ac, &res, "procs") != 0)
|
||||||
return 1;
|
return 1;
|
||||||
sprintf(rrd, "%s_%s", host->hostname, "procs.rrd");
|
sprintf(rrd, "%s_%s", host->hostname, "procs.rrd");
|
||||||
_rrd_update(rrd, 1, res);
|
_rrd_update(host->damon, rrd, 1, res);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +370,7 @@ static int _refresh_ram(AppClient * ac, Host * host, char * rrd)
|
||||||
|| appclient_call(ac, &res[3], "ram_buffer") != 0)
|
|| appclient_call(ac, &res[3], "ram_buffer") != 0)
|
||||||
return 1;
|
return 1;
|
||||||
sprintf(rrd, "%s_%s", host->hostname, "ram.rrd");
|
sprintf(rrd, "%s_%s", host->hostname, "ram.rrd");
|
||||||
_rrd_update(rrd, 4, res[0], res[1], res[2], res[3]);
|
_rrd_update(host->damon, rrd, 4, res[0], res[1], res[2], res[3]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +382,7 @@ static int _refresh_swap(AppClient * ac, Host * host, char * rrd)
|
||||||
|| appclient_call(ac, &res[1], "swap_free") != 0)
|
|| appclient_call(ac, &res[1], "swap_free") != 0)
|
||||||
return 1;
|
return 1;
|
||||||
sprintf(rrd, "%s_%s", host->hostname, "swap.rrd");
|
sprintf(rrd, "%s_%s", host->hostname, "swap.rrd");
|
||||||
_rrd_update(rrd, 2, res[0], res[1]);
|
_rrd_update(host->damon, rrd, 2, res[0], res[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,11 +393,12 @@ static int _refresh_users(AppClient * ac, Host * host, char * rrd)
|
||||||
if(appclient_call(ac, &res, "users") != 0)
|
if(appclient_call(ac, &res, "users") != 0)
|
||||||
return 1;
|
return 1;
|
||||||
sprintf(rrd, "%s_%s", host->hostname, "users.rrd");
|
sprintf(rrd, "%s_%s", host->hostname, "users.rrd");
|
||||||
_rrd_update(rrd, 1, res);
|
_rrd_update(host->damon, rrd, 1, res);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ifaces_if(AppClient * ac, Host * host, char * rrd, char * iface);
|
static int _ifaces_if(AppClient * ac, Host * host, char * rrd,
|
||||||
|
char const * iface);
|
||||||
static int _refresh_ifaces(AppClient * ac, Host * host, char * rrd)
|
static int _refresh_ifaces(AppClient * ac, Host * host, char * rrd)
|
||||||
{
|
{
|
||||||
char ** p = host->ifaces;
|
char ** p = host->ifaces;
|
||||||
|
@ -396,7 +411,8 @@ static int _refresh_ifaces(AppClient * ac, Host * host, char * rrd)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ifaces_if(AppClient * ac, Host * host, char * rrd, char * iface)
|
static int _ifaces_if(AppClient * ac, Host * host, char * rrd,
|
||||||
|
char const * iface)
|
||||||
{
|
{
|
||||||
int32_t res[2];
|
int32_t res[2];
|
||||||
|
|
||||||
|
@ -404,7 +420,7 @@ static int _ifaces_if(AppClient * ac, Host * host, char * rrd, char * iface)
|
||||||
|| appclient_call(ac, &res[1], "iftxbytes", iface) != 0)
|
|| appclient_call(ac, &res[1], "iftxbytes", iface) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
sprintf(rrd, "%s_%s%s", host->hostname, iface, ".rrd");
|
sprintf(rrd, "%s_%s%s", host->hostname, iface, ".rrd");
|
||||||
_rrd_update(rrd, 2, res[0], res[1]);
|
_rrd_update(host->damon, rrd, 2, res[0], res[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,17 +442,18 @@ static int _vols_vol(AppClient * ac, Host * host, char * rrd, char * vol)
|
||||||
int32_t res[2];
|
int32_t res[2];
|
||||||
|
|
||||||
if(appclient_call(ac, &res[0], "voltotal", vol) != 0
|
if(appclient_call(ac, &res[0], "voltotal", vol) != 0
|
||||||
|| appclient_call(ac, &res[1], "volfree", vol) != 0)
|
|| appclient_call(ac, &res[1], "volfree", vol)
|
||||||
|
!= 0)
|
||||||
return 1;
|
return 1;
|
||||||
sprintf(rrd, "%s%s%s", host->hostname, vol, ".rrd"); /* FIXME */
|
sprintf(rrd, "%s%s%s", host->hostname, vol, ".rrd"); /* FIXME */
|
||||||
_rrd_update(rrd, 2, res[0], res[1]);
|
_rrd_update(host->damon, rrd, 2, res[0], res[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _exec(char * argv[]);
|
static int _exec(char * argv[]);
|
||||||
static int _rrd_update(char * file, int args_cnt, ...)
|
static int _rrd_update(DaMon * damon, char const * filename, int args_cnt, ...)
|
||||||
{
|
{
|
||||||
char * argv[] = { "rrdtool", "update", file, NULL, NULL };
|
char * argv[] = { "rrdtool", "update", NULL, NULL, NULL };
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int pos;
|
int pos;
|
||||||
int i;
|
int i;
|
||||||
|
@ -446,6 +463,7 @@ static int _rrd_update(char * file, int args_cnt, ...)
|
||||||
if(gettimeofday(&tv, NULL) != 0)
|
if(gettimeofday(&tv, NULL) != 0)
|
||||||
return error_set_print("DaMon", 1, "%s%s", "gettimeofday: ",
|
return error_set_print("DaMon", 1, "%s%s", "gettimeofday: ",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
argv[2] = string_new_append(damon->prefix, "/", filename, NULL);
|
||||||
if((argv[3] = malloc((args_cnt + 1) * 12)) == NULL)
|
if((argv[3] = malloc((args_cnt + 1) * 12)) == NULL)
|
||||||
return error_set_print("DaMon", 1, "%s", strerror(errno));
|
return error_set_print("DaMon", 1, "%s", strerror(errno));
|
||||||
pos = sprintf(argv[3], "%ld", tv.tv_sec);
|
pos = sprintf(argv[3], "%ld", tv.tv_sec);
|
||||||
|
@ -455,6 +473,7 @@ static int _rrd_update(char * file, int args_cnt, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
ret = _exec(argv);
|
ret = _exec(argv);
|
||||||
free(argv[3]);
|
free(argv[3]);
|
||||||
|
string_delete(argv[2]);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,9 +493,12 @@ static int _exec(char * argv[])
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s() ", __func__);
|
||||||
while(*argv != NULL)
|
while(*argv != NULL)
|
||||||
fprintf(stderr, "%s ", *argv++);
|
fprintf(stderr, "%s ", *argv++);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
#endif
|
||||||
while((ret = waitpid(pid, &status, 0)) != -1)
|
while((ret = waitpid(pid, &status, 0)) != -1)
|
||||||
if(WIFEXITED(status))
|
if(WIFEXITED(status))
|
||||||
break;
|
break;
|
||||||
|
@ -487,8 +509,31 @@ static int _exec(char * argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* main */
|
/* usage */
|
||||||
int main(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
return _damon() == 0 ? 0 : 2;
|
fputs("Usage: DaMon [-f filename]\n"
|
||||||
|
" -f\tConfiguration file to load\n", stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* main */
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
int o;
|
||||||
|
char const * config = NULL;
|
||||||
|
|
||||||
|
while((o = getopt(argc, argv, "f:")) != -1)
|
||||||
|
switch(o)
|
||||||
|
{
|
||||||
|
case 'f':
|
||||||
|
config = optarg;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return _usage();
|
||||||
|
}
|
||||||
|
if(optind != argc)
|
||||||
|
return _usage();
|
||||||
|
return (_damon(config) == 0) ? 0 : 2;
|
||||||
}
|
}
|
||||||
|
|
123
src/probe.c
123
src/probe.c
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2007 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2009 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Network Probe */
|
/* This file is part of DeforaOS Network Probe */
|
||||||
/* Probe is not free software; you can redistribute it and/or modify it under
|
/* Probe is not free software; you can redistribute it and/or modify it under
|
||||||
* the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 3.0
|
* the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 3.0
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <System.h>
|
#include <System.h>
|
||||||
|
#include "Probe.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
@ -47,7 +48,8 @@
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
static int _probe_error(char const * message, int ret);
|
static int _probe_error(int ret);
|
||||||
|
static int _probe_perror(char const * message, int ret);
|
||||||
|
|
||||||
|
|
||||||
/* sysinfo */
|
/* sysinfo */
|
||||||
|
@ -319,7 +321,7 @@ static int _ifinfo_linux_append(struct ifinfo ** dev, char * buf, int nb)
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
if((p = realloc(*dev, sizeof(*p) * (nb + 1))) == NULL)
|
if((p = realloc(*dev, sizeof(*p) * (nb + 1))) == NULL)
|
||||||
return _probe_error("realloc", 1);
|
return _probe_perror("realloc", 1);
|
||||||
*dev = p;
|
*dev = p;
|
||||||
for(i = 0; i < sizeof(p->name) && buf[i] != '\0'; i++);
|
for(i = 0; i < sizeof(p->name) && buf[i] != '\0'; i++);
|
||||||
if(i != sizeof(p->name))
|
if(i != sizeof(p->name))
|
||||||
|
@ -371,9 +373,9 @@ static int _ifinfo_bsd(struct ifinfo ** dev)
|
||||||
struct ifaddrs * p;
|
struct ifaddrs * p;
|
||||||
|
|
||||||
if(fd < 0 && (fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
if(fd < 0 && (fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||||
return _probe_error("socket", -1);
|
return _probe_perror("socket", -1);
|
||||||
if(getifaddrs(&ifa) != 0)
|
if(getifaddrs(&ifa) != 0)
|
||||||
return _probe_error("getifaddrs", -1);
|
return _probe_perror("getifaddrs", -1);
|
||||||
for(p = ifa; p != NULL; p = p->ifa_next)
|
for(p = ifa; p != NULL; p = p->ifa_next)
|
||||||
{
|
{
|
||||||
if(p->ifa_addr->sa_family != AF_LINK)
|
if(p->ifa_addr->sa_family != AF_LINK)
|
||||||
|
@ -395,9 +397,9 @@ static int _ifinfo_bsd_append(struct ifinfo ** dev, char * ifname, int fd,
|
||||||
|
|
||||||
strcpy(ifdr.ifdr_name, ifname);
|
strcpy(ifdr.ifdr_name, ifname);
|
||||||
if(ioctl(fd, SIOCGIFDATA, &ifdr) == -1)
|
if(ioctl(fd, SIOCGIFDATA, &ifdr) == -1)
|
||||||
return _probe_error("SIOCGIFDATA", 1);
|
return _probe_perror("SIOCGIFDATA", 1);
|
||||||
if((p = realloc(*dev, sizeof(*p) * (nb + 1))) == NULL)
|
if((p = realloc(*dev, sizeof(*p) * (nb + 1))) == NULL)
|
||||||
return _probe_error("realloc", 1);
|
return _probe_perror("realloc", 1);
|
||||||
*dev = p;
|
*dev = p;
|
||||||
strcpy(p[nb].name, ifname);
|
strcpy(p[nb].name, ifname);
|
||||||
# if defined(DEBUG)
|
# if defined(DEBUG)
|
||||||
|
@ -448,7 +450,7 @@ static int _volinfo_linux(struct volinfo ** dev)
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if((fp = fopen("/etc/mtab", "r")) == NULL)
|
if((fp = fopen("/etc/mtab", "r")) == NULL)
|
||||||
return _probe_error("/etc/mtab", -1);
|
return _probe_perror("/etc/mtab", -1);
|
||||||
for(i = 0; fgets(buf, sizeof(buf), fp) != NULL; i++)
|
for(i = 0; fgets(buf, sizeof(buf), fp) != NULL; i++)
|
||||||
{
|
{
|
||||||
len = string_length(buf);
|
len = string_length(buf);
|
||||||
|
@ -514,14 +516,14 @@ static int _volinfo_bsd(struct volinfo ** dev)
|
||||||
int cnt2;
|
int cnt2;
|
||||||
|
|
||||||
if((cnt = getvfsstat(NULL, 0, ST_WAIT)) == -1)
|
if((cnt = getvfsstat(NULL, 0, ST_WAIT)) == -1)
|
||||||
return _probe_error("getvfsstat", -1);
|
return _probe_perror("getvfsstat", -1);
|
||||||
if((buf = malloc(sizeof(struct statvfs) * cnt)) == NULL)
|
if((buf = malloc(sizeof(struct statvfs) * cnt)) == NULL)
|
||||||
return _probe_error("malloc", -1);
|
return _probe_perror("malloc", -1);
|
||||||
if((cnt2 = getvfsstat(buf, sizeof(struct statvfs) * cnt, ST_WAIT))
|
if((cnt2 = getvfsstat(buf, sizeof(struct statvfs) * cnt, ST_WAIT))
|
||||||
== -1)
|
== -1)
|
||||||
{
|
{
|
||||||
free(buf);
|
free(buf);
|
||||||
return _probe_error("getvfsstat", -1);
|
return _probe_perror("getvfsstat", -1);
|
||||||
}
|
}
|
||||||
for(ret = 0; ret < cnt && ret < cnt2; ret++)
|
for(ret = 0; ret < cnt && ret < cnt2; ret++)
|
||||||
{
|
{
|
||||||
|
@ -540,7 +542,7 @@ static int _volinfo_bsd_append(struct volinfo ** dev, struct statvfs * buf,
|
||||||
struct volinfo * p;
|
struct volinfo * p;
|
||||||
|
|
||||||
if((p = realloc(*dev, sizeof(*p) * (nb + 1))) == NULL)
|
if((p = realloc(*dev, sizeof(*p) * (nb + 1))) == NULL)
|
||||||
return _probe_error("realloc", 1);
|
return _probe_perror("realloc", 1);
|
||||||
*dev = p;
|
*dev = p;
|
||||||
strcpy(p[nb].name, buf->f_mntonname);
|
strcpy(p[nb].name, buf->f_mntonname);
|
||||||
# if defined(DEBUG)
|
# if defined(DEBUG)
|
||||||
|
@ -565,6 +567,7 @@ static int _volinfo_generic(struct volinfo ** dev)
|
||||||
|
|
||||||
|
|
||||||
/* Probe */
|
/* Probe */
|
||||||
|
/* private */
|
||||||
/* types */
|
/* types */
|
||||||
typedef struct _Probe
|
typedef struct _Probe
|
||||||
{
|
{
|
||||||
|
@ -581,8 +584,14 @@ typedef struct _Probe
|
||||||
Probe probe;
|
Probe probe;
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* prototypes */
|
||||||
|
static int _probe_error(int ret);
|
||||||
|
static int _probe_perror(char const * message, int ret);
|
||||||
static int _probe_timeout(Probe * probe);
|
static int _probe_timeout(Probe * probe);
|
||||||
|
|
||||||
|
|
||||||
|
/* functions */
|
||||||
|
/* probe */
|
||||||
static int _probe(void)
|
static int _probe(void)
|
||||||
{
|
{
|
||||||
AppServer * appserver;
|
AppServer * appserver;
|
||||||
|
@ -600,7 +609,7 @@ static int _probe(void)
|
||||||
{
|
{
|
||||||
free(probe.ifinfo);
|
free(probe.ifinfo);
|
||||||
free(probe.volinfo);
|
free(probe.volinfo);
|
||||||
return _probe_error("Event", 1);
|
return _probe_error(1);
|
||||||
}
|
}
|
||||||
if((appserver = appserver_new_event("Probe", ASO_REMOTE, event))
|
if((appserver = appserver_new_event("Probe", ASO_REMOTE, event))
|
||||||
== NULL)
|
== NULL)
|
||||||
|
@ -608,13 +617,13 @@ static int _probe(void)
|
||||||
free(probe.ifinfo);
|
free(probe.ifinfo);
|
||||||
free(probe.volinfo);
|
free(probe.volinfo);
|
||||||
event_delete(event);
|
event_delete(event);
|
||||||
return _probe_error("AppServer", 1);
|
return _probe_error(1);
|
||||||
}
|
}
|
||||||
tv.tv_sec = PROBE_REFRESH;
|
tv.tv_sec = PROBE_REFRESH;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
if(event_register_timeout(event, &tv, (EventTimeoutFunc)_probe_timeout,
|
if(event_register_timeout(event, &tv, (EventTimeoutFunc)_probe_timeout,
|
||||||
&probe) != 0)
|
&probe) != 0)
|
||||||
_probe_error("timeout", 0);
|
_probe_error(0);
|
||||||
else
|
else
|
||||||
event_loop(event);
|
event_loop(event);
|
||||||
appserver_delete(appserver);
|
appserver_delete(appserver);
|
||||||
|
@ -624,13 +633,25 @@ static int _probe(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _probe_error(char const * message, int ret)
|
|
||||||
|
/* probe_error */
|
||||||
|
static int _probe_error(int ret)
|
||||||
|
{
|
||||||
|
error_print("Probe");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* probe_perror */
|
||||||
|
static int _probe_perror(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("Probe: ", stderr);
|
fputs("Probe: ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* probe_timeout */
|
||||||
static int _probe_timeout(Probe * probe)
|
static int _probe_timeout(Probe * probe)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -640,21 +661,24 @@ static int _probe_timeout(Probe * probe)
|
||||||
fprintf(stderr, "%s%d%s", "_probe_timeout(", count++, ")\n");
|
fprintf(stderr, "%s%d%s", "_probe_timeout(", count++, ")\n");
|
||||||
#endif
|
#endif
|
||||||
if(_sysinfo(&probe->sysinfo) != 0)
|
if(_sysinfo(&probe->sysinfo) != 0)
|
||||||
return _probe_error("sysinfo", 1);
|
return _probe_perror("sysinfo", 1);
|
||||||
if(_userinfo(&probe->users) != 0)
|
if(_userinfo(&probe->users) != 0)
|
||||||
return _probe_error("userinfo", 1);
|
return _probe_perror("userinfo", 1);
|
||||||
if((i = _ifinfo(&probe->ifinfo)) < 0)
|
if((i = _ifinfo(&probe->ifinfo)) < 0)
|
||||||
return _probe_error("ifinfo", 1);
|
return _probe_perror("ifinfo", 1);
|
||||||
probe->ifinfo_cnt = i;
|
probe->ifinfo_cnt = i;
|
||||||
if((i = _volinfo(&probe->volinfo)) < 0)
|
if((i = _volinfo(&probe->volinfo)) < 0)
|
||||||
return _probe_error("volinfo", 1);
|
return _probe_perror("volinfo", 1);
|
||||||
probe->volinfo_cnt = i;
|
probe->volinfo_cnt = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* public */
|
||||||
|
/* functions */
|
||||||
/* AppInterface */
|
/* AppInterface */
|
||||||
int uptime(void)
|
/* Probe_uptime */
|
||||||
|
uint32_t Probe_uptime(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%ld%s", "Uptime: ", probe.sysinfo.uptime, "\n");
|
printf("%s%ld%s", "Uptime: ", probe.sysinfo.uptime, "\n");
|
||||||
|
@ -663,7 +687,8 @@ int uptime(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int load_1(void)
|
/* Probe_load_1 */
|
||||||
|
uint32_t Probe_load_1(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Load 1: ", probe.sysinfo.loads[0], "\n");
|
printf("%s%lu%s", "Load 1: ", probe.sysinfo.loads[0], "\n");
|
||||||
|
@ -672,7 +697,8 @@ int load_1(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int load_5(void)
|
/* Probe_load_5 */
|
||||||
|
uint32_t Probe_load_5(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Load 5: ", probe.sysinfo.loads[1], "\n");
|
printf("%s%lu%s", "Load 5: ", probe.sysinfo.loads[1], "\n");
|
||||||
|
@ -681,7 +707,8 @@ int load_5(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int load_15(void)
|
/* Probe_load_15 */
|
||||||
|
uint32_t Probe_load_15(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Load 15: ", probe.sysinfo.loads[2], "\n");
|
printf("%s%lu%s", "Load 15: ", probe.sysinfo.loads[2], "\n");
|
||||||
|
@ -690,7 +717,8 @@ int load_15(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ram_total(void)
|
/* Probe_ram_total */
|
||||||
|
uint32_t Probe_ram_total(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Total RAM: ", probe.sysinfo.totalram, "\n");
|
printf("%s%lu%s", "Total RAM: ", probe.sysinfo.totalram, "\n");
|
||||||
|
@ -698,7 +726,9 @@ int ram_total(void)
|
||||||
return probe.sysinfo.totalram;
|
return probe.sysinfo.totalram;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ram_free(void)
|
|
||||||
|
/* Probe_ram_free */
|
||||||
|
uint32_t Probe_ram_free(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Free RAM: ", probe.sysinfo.freeram, "\n");
|
printf("%s%lu%s", "Free RAM: ", probe.sysinfo.freeram, "\n");
|
||||||
|
@ -706,7 +736,9 @@ int ram_free(void)
|
||||||
return probe.sysinfo.freeram;
|
return probe.sysinfo.freeram;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ram_shared(void)
|
|
||||||
|
/* Probe_ram_shared */
|
||||||
|
uint32_t Probe_ram_shared(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Shared RAM: ", probe.sysinfo.sharedram, "\n");
|
printf("%s%lu%s", "Shared RAM: ", probe.sysinfo.sharedram, "\n");
|
||||||
|
@ -714,7 +746,9 @@ int ram_shared(void)
|
||||||
return probe.sysinfo.sharedram;
|
return probe.sysinfo.sharedram;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ram_buffer(void)
|
|
||||||
|
/* Probe_ram_buffer */
|
||||||
|
uint32_t Probe_ram_buffer(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Buffered RAM: ", probe.sysinfo.bufferram, "\n");
|
printf("%s%lu%s", "Buffered RAM: ", probe.sysinfo.bufferram, "\n");
|
||||||
|
@ -723,7 +757,8 @@ int ram_buffer(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int swap_total(void)
|
/* Probe_swap_total */
|
||||||
|
uint32_t Probe_swap_total(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Total swap: ", probe.sysinfo.totalswap, "\n");
|
printf("%s%lu%s", "Total swap: ", probe.sysinfo.totalswap, "\n");
|
||||||
|
@ -731,7 +766,9 @@ int swap_total(void)
|
||||||
return probe.sysinfo.totalswap;
|
return probe.sysinfo.totalswap;
|
||||||
}
|
}
|
||||||
|
|
||||||
int swap_free(void)
|
|
||||||
|
/* Probe_swap_free */
|
||||||
|
uint32_t Probe_swap_free(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%lu%s", "Free swap: ", probe.sysinfo.freeswap, "\n");
|
printf("%s%lu%s", "Free swap: ", probe.sysinfo.freeswap, "\n");
|
||||||
|
@ -740,7 +777,8 @@ int swap_free(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int procs(void)
|
/* Probe_procs */
|
||||||
|
uint32_t Probe_procs(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%u%s", "Procs: ", probe.sysinfo.procs, "\n");
|
printf("%s%u%s", "Procs: ", probe.sysinfo.procs, "\n");
|
||||||
|
@ -749,7 +787,8 @@ int procs(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int users(void)
|
/* Probe_users */
|
||||||
|
uint32_t Probe_users(void)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
printf("%s%u%s", "Users: ", probe.users, "\n");
|
printf("%s%u%s", "Users: ", probe.users, "\n");
|
||||||
|
@ -758,7 +797,8 @@ int users(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ifrxbytes(char * dev)
|
/* Probe_ifrxbytes */
|
||||||
|
uint32_t Probe_ifrxbytes(String const * dev)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -773,7 +813,9 @@ int ifrxbytes(char * dev)
|
||||||
return probe.ifinfo[i].ibytes;
|
return probe.ifinfo[i].ibytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iftxbytes(char * dev)
|
|
||||||
|
/* Probe_iftxbytes */
|
||||||
|
uint32_t Probe_iftxbytes(String const * dev)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -789,12 +831,13 @@ int iftxbytes(char * dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int voltotal(char * vol)
|
/* Probe_voltotal */
|
||||||
|
uint32_t Probe_voltotal(String const * volume)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for(i = 0; i < probe.volinfo_cnt
|
for(i = 0; i < probe.volinfo_cnt
|
||||||
&& string_compare(probe.volinfo[i].name, vol) != 0;
|
&& string_compare(probe.volinfo[i].name, volume) != 0;
|
||||||
i++);
|
i++);
|
||||||
if(i == probe.volinfo_cnt)
|
if(i == probe.volinfo_cnt)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -805,12 +848,14 @@ int voltotal(char * vol)
|
||||||
return probe.volinfo[i].total * (probe.volinfo[i].block_size / 1024);
|
return probe.volinfo[i].total * (probe.volinfo[i].block_size / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
int volfree(char * vol)
|
|
||||||
|
/* Probe_volfree */
|
||||||
|
uint32_t Probe_volfree(String const * volume)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for(i = 0; i < probe.volinfo_cnt
|
for(i = 0; i < probe.volinfo_cnt
|
||||||
&& string_compare(probe.volinfo[i].name, vol) != 0;
|
&& string_compare(probe.volinfo[i].name, volume) != 0;
|
||||||
i++);
|
i++);
|
||||||
if(i == probe.volinfo_cnt)
|
if(i == probe.volinfo_cnt)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
targets=Probe,DaMon
|
targets=Probe,DaMon
|
||||||
|
cppflags_force=-I ../data
|
||||||
cflags_force=-W
|
cflags_force=-W
|
||||||
cflags=-Wall -g -O2 -ansi
|
cflags=-Wall -g -O2 -pedantic
|
||||||
ldflags_force=-l System -l dl
|
ldflags_force=-l System -l dl
|
||||||
ldflags=-L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib
|
ldflags=-L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib
|
||||||
dist=Makefile
|
dist=Makefile
|
||||||
|
@ -13,3 +14,6 @@ ldflags=-Wl,--export-dynamic
|
||||||
[DaMon]
|
[DaMon]
|
||||||
type=binary
|
type=binary
|
||||||
sources=damon.c
|
sources=damon.c
|
||||||
|
|
||||||
|
[probe.c]
|
||||||
|
depends=../data/Probe.h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user