]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
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 1ab4dec5f1aa5053d5a8a96d798f08cf7c95e870..f33d08c61a499ff113eec47ad70e77723d6963b5 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 f344208d592b238e562f5bc42de064e16ef77a75..c35b885dad776569a3ecdc4ce6033bffa872522d 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 f5802d26ac2c7918d43e4f998e100fb5f8f1a0a9..43e6a9081e436d3ad18dc8d0dbd8c77447bedefc 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;
+}