]>
Commit | Line | Data |
---|---|---|
831a5ef6 AM |
1 | #!/usr/bin/perl |
2 | # Converter script for adding existing OpenVPN N2N connections to collectd | |
3 | # Used for core update 89 | |
4 | ||
5 | my %ovpnconfig=(); | |
6 | ||
7 | require '/var/ipfire/general-functions.pl'; | |
8 | ||
9 | open(COLLECTDVPN, ">${General::swroot}/ovpn/collectd.vpn") or die "Unable to open collectd.vpn: $!"; | |
10 | print COLLECTDVPN "Loadplugin openvpn\n"; | |
11 | print COLLECTDVPN "\n"; | |
12 | print COLLECTDVPN "<Plugin openvpn>\n"; | |
13 | print COLLECTDVPN "Statusfile \"/var/run/ovpnserver.log\"\n"; | |
14 | ||
15 | &General::readhasharray("/var/ipfire/ovpn/ovpnconfig", \%ovpnconfig); | |
16 | foreach 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 | ||
22 | print COLLECTDVPN "</Plugin>\n"; | |
23 | close(COLLECTDVPN); | |
24 | ||
25 | # Reload collectd afterwards | |
26 | system("/usr/local/bin/collectdctrl restart &>/dev/null"); |