vpn-statistic: create collectd wrapper to restart collectd when first vpn was created
authorAlexander Marx <alexander.marx@ipfire.org>
Tue, 7 Apr 2015 13:35:31 +0000 (15:35 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Apr 2015 12:59:26 +0000 (14:59 +0200)
This wrapper is only used, when the first openvpn RW is created. Then
the collectd has to be restarted to get the vpn Data and create rrd Data

config/rootfiles/common/misc-progs
config/rootfiles/core/89/filelists/files
src/misc-progs/Makefile
src/misc-progs/collectdctrl.c [new file with mode: 0644]

index 1ab4dec..f33d08c 100644 (file)
@@ -2,6 +2,7 @@ usr/local/bin/addonctrl
 #usr/local/bin/applejuicectrl
 usr/local/bin/backupctrl
 #usr/local/bin/clamavctrl
+usr/local/bin/collectdctrl
 usr/local/bin/dhcpctrl
 usr/local/bin/dnsmasqctrl
 usr/local/bin/extrahdctrl
index f344208..c35b885 100644 (file)
@@ -11,6 +11,7 @@ srv/web/ipfire/cgi-bin/netovpnrw.cgi
 srv/web/ipfire/cgi-bin/netovpnsrv.cgi
 srv/web/ipfire/cgi-bin/ovpnmain.cgi
 srv/web/ipfire/cgi-bin/vpnmain.cgi
+usr/local/bin/collectdctrl
 usr/local/bin/openvpnctrl
 var/ipfire/backup/bin/backup.pl
 var/ipfire/graphs.pl
index f5802d2..43e6a90 100644 (file)
@@ -25,7 +25,7 @@ LIBS    = -lsmooth -lnewt
 PROGS = iowrap
 SUID_PROGS = squidctrl sshctrl ipfirereboot \
        ipsecctrl timectrl dhcpctrl snortctrl \
-       applejuicectrl rebuildhosts backupctrl \
+       applejuicectrl rebuildhosts backupctrl collectdctrl \
        logwatch openvpnctrl firewallctrl \
        wirelessctrl getipstat qosctrl launch-ether-wake \
        redctrl syslogdctrl extrahdctrl sambactrl upnpctrl tripwirectrl \
diff --git a/src/misc-progs/collectdctrl.c b/src/misc-progs/collectdctrl.c
new file mode 100644 (file)
index 0000000..86e4b2a
--- /dev/null
@@ -0,0 +1,39 @@
+/* This file is part of the IPFire Firewall.
+ *
+ * This program is distributed under the terms of the GNU General Public
+ * Licence.  See the file COPYING for details.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include "setuid.h"
+
+int main(int argc, char *argv[]) {
+       if (!(initsetuid()))
+               exit(1);
+
+       if (argc < 2) {
+               fprintf(stderr, "\nNo argument given.\n\ncollectdctrl (start|stop|restart)\n\n");
+               exit(1);
+       }
+
+       if (strcmp(argv[1], "restart") == 0) {
+               safe_system("/etc/rc.d/init.d/collectd restart");
+
+       } else if (strcmp(argv[1], "stop") == 0) {
+               safe_system("/etc/rc.d/init.d/collectd stop");
+
+       } else if (strcmp(argv[1], "start") == 0) {
+               safe_system("/etc/rc.d/init.d/collectd start");
+
+       } else {
+               fprintf(stderr, "\nBad argument given.\n\ncollectdctrl (start|stop|restart)\n\n");
+               exit(1);
+       }
+
+       return 0;
+}