pakfire: use correct tree on x86_64.
[ipfire-2.x.git] / src / scripts / ovpn-collectd-convert
CommitLineData
831a5ef6
AM
1#!/usr/bin/perl
2# Converter script for adding existing OpenVPN N2N connections to collectd
3# Used for core update 89
4
5my %ovpnconfig=();
6
7require '/var/ipfire/general-functions.pl';
8
9open(COLLECTDVPN, ">${General::swroot}/ovpn/collectd.vpn") or die "Unable to open collectd.vpn: $!";
10print COLLECTDVPN "Loadplugin openvpn\n";
11print COLLECTDVPN "\n";
12print COLLECTDVPN "<Plugin openvpn>\n";
13print COLLECTDVPN "Statusfile \"/var/run/ovpnserver.log\"\n";
14
15&General::readhasharray("/var/ipfire/ovpn/ovpnconfig", \%ovpnconfig);
16foreach my $key (keys %ovpnconfig) {
17 if ($ovpnconfig{$key}[0] eq 'on' && $ovpnconfig{$key}[3] eq 'net') {
18 print COLLECTDVPN "Statusfile \"/var/run/openvpn/$ovpnconfig{$key}[1]-n2n\"\n";
19 }
20}
21
22print COLLECTDVPN "</Plugin>\n";
23close(COLLECTDVPN);
24
25# Reload collectd afterwards
26system("/usr/local/bin/collectdctrl restart &>/dev/null");