]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
web: Create a function to show the service status
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Mar 2024 17:42:13 +0000 (18:42 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 6 Aug 2024 15:08:40 +0000 (17:08 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
15 files changed:
config/cfgroot/general-functions.pl
config/cfgroot/header.pl
doc/language_issues.de
doc/language_issues.en
doc/language_issues.es
doc/language_issues.fr
doc/language_issues.it
doc/language_issues.nl
doc/language_issues.pl
doc/language_issues.ru
doc/language_issues.tr
doc/language_missings
html/cgi-bin/ovpnmain.cgi
html/html/themes/ipfire/include/css/style.css
langs/en/cgi-bin/en.pl

index a87e5c070ae8ed41ea4a0a89dd94b8ef1cd8b6fe..8ba6e3f79f0a9660ba8f8630ad0c7f1a3f6c988d 100644 (file)
@@ -97,6 +97,82 @@ sub system($) {
        return $rc;
 }
 
+sub read_pids($) {
+       my $pidfile = shift;
+
+       # Open the PID file
+       open(PIDFILE, "<${pidfile}");
+
+       # Store all PIDs here
+       my @pids = ();
+
+       # Read all PIDs
+       while (<PIDFILE>) {
+               chomp $_;
+
+               if (-d "/proc/$_") {
+                       push(@pids, $_);
+               }
+       }
+
+       # Close the PID file
+       close(PIDFILE);
+
+       return @pids;
+}
+
+sub find_pids($) {
+       my $process = shift;
+
+       # Store all PIDs here
+       my @pids = ();
+
+       foreach my $status (</proc/*/status>) {
+               # Open the status file
+               open(STATUS, "<${status}");
+
+               # Read the status file
+               while (<STATUS>) {
+                       # If the name does not match, we break the loop immediately
+                       if ($_ =~ m/^Name:\s+(.*)$/) {
+                               last if ($process ne $1);
+
+                       # Push the PID onto the list
+                       } elsif ($_ =~ m/^Pid:\s+(\d+)$/) {
+                               push(@pids, $1);
+
+                               # Once we got here, we are done
+                               last;
+                       }
+               }
+
+               # Close the status file
+               close(STATUS);
+       }
+
+       return @pids;
+}
+
+sub get_memory_consumption() {
+       my $memory = 0;
+
+       foreach my $pid (@_) {
+               # Open the status file or skip on error
+               open(STATUS, "/proc/${pid}/status") or next;
+
+               while (<STATUS>) {
+                       if ($_ =~ m/^VmRSS:\s+(\d+) kB/) {
+                               $memory += $1 * 1024;
+                               last;
+                       }
+               }
+
+               close(STATUS);
+       }
+
+       return $memory;
+}
+
 # Function to remove duplicates from an array
 sub uniq { my %seen; grep !$seen{$_}++, @_ }
 
index a4b79a6a178380f2c35ab476c5fde8cafe230a24..327c446bb03951ad0f5158b3564d1f13dba56c71 100644 (file)
@@ -896,4 +896,92 @@ sub _read_manualpage_hash() {
        close($file);
 }
 
+sub ServiceStatus() {
+       my $services = shift;
+       my %services = %{ $services };
+
+       # Write the table header
+       print <<EOF;
+               <table class="tbl">
+                       <!-- <thead>
+                               <tr>
+                                       <th>
+                                               $Lang::tr{'service'}
+                                       </th>
+
+                                       <th>
+                                               $Lang::tr{'status'}
+                                       </th>
+
+                                       <th>
+                                               $Lang::tr{'memory'}
+                                       </th>
+                               </tr>
+                       </thead> -->
+
+                       <tbody>
+EOF
+
+       foreach my $service (sort keys %services) {
+               my %config = %{ $services{$service} };
+
+               my $pidfile = $config{"pidfile"};
+               my $process = $config{"process"};
+
+               # Collect all pids
+               my @pids = ();
+
+               # Read the PID file or go search...
+               if (defined $pidfile) {
+                       @pids = &General::read_pids("${pidfile}");
+               } else {
+                       @pids = &General::find_pids("${process}");
+               }
+
+               # Get memory consumption
+               my $mem = &General::get_memory_consumption(@pids);
+
+               print <<EOF;
+                               <tr>
+                                       <th scope="row">
+                                               $service
+                                       </th>
+EOF
+
+               # Running?
+               if (scalar @pids) {
+                       # Format memory
+                       $mem = &General::formatBytes($mem);
+
+                       print <<EOF;
+                                       <td class="status is-running">
+                                               $Lang::tr{'running'}
+                                       </td>
+
+                                       <td class="text-right">
+                                               ${mem}
+                                       </td>
+EOF
+
+               # Not Running
+               } else {
+                       print <<EOF;
+                                       <td class="status is-stopped" colspan="2">
+                                               $Lang::tr{'stopped'}
+                                       </td>
+EOF
+               }
+
+               print <<EOF;
+                               </tr>
+EOF
+
+       }
+
+       print <<EOF;
+               </tbody>
+               </table>
+EOF
+}
+
 1; # End of package "Header"
index 9fee272ffef92c63e62f94c46a6ca9de0a8f4bdb..e2ca260def34709eae37a6e730291cd7b2176922 100644 (file)
@@ -415,7 +415,6 @@ WARNING: translation string unused: installed updates
 WARNING: translation string unused: interfaces
 WARNING: translation string unused: intrusion detection system log viewer
 WARNING: translation string unused: intrusion detection system2
-WARNING: translation string unused: intrusion prevention system
 WARNING: translation string unused: invalid cache size
 WARNING: translation string unused: invalid date entered
 WARNING: translation string unused: invalid downlink speed
@@ -960,6 +959,7 @@ WARNING: untranslated string: log drop hostile out = Log dropped packets TO host
 WARNING: untranslated string: netbios nameserver daemon = NetBIOS Nameserver Daemon
 WARNING: untranslated string: no entries = No entries at the moment.
 WARNING: untranslated string: optional = Optional
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: pakfire invalid tree = Invalid repository selected
 WARNING: untranslated string: reg_file_data_sampling = Register File Data Sampling (RFDS)
 WARNING: untranslated string: regenerate host certificate = Renew Host Certificate
index 5b94d2fc8f1b89ecdadd5c7b8b1e88f3c26a60f3..443c2a9512b39afa1fbb43992f00e143d6c5df85 100644 (file)
@@ -1103,6 +1103,7 @@ WARNING: untranslated string: internet = INTERNET
 WARNING: untranslated string: intrusion detection = Intrusion Prevention
 WARNING: untranslated string: intrusion detection system = Intrusion Prevention System
 WARNING: untranslated string: intrusion detection system rules = Ruleset
+WARNING: untranslated string: intrusion prevention system = Intrusion Prevention System
 WARNING: untranslated string: invalid broadcast ip = Invalid broadcast IP
 WARNING: untranslated string: invalid characters found in pre-shared key = Invalid characters found in pre-shared key.
 WARNING: untranslated string: invalid default lease time = Invalid default lease time.
@@ -1455,6 +1456,7 @@ WARNING: untranslated string: ovpn on blue = OpenVPN on BLUE:
 WARNING: untranslated string: ovpn on orange = OpenVPN on ORANGE:
 WARNING: untranslated string: ovpn on red = OpenVPN on RED:
 WARNING: untranslated string: ovpn port in root range = A port number of 1024 or higher is required.
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: ovpn routes push = Routes (one per line) e.g. 192.168.10.0/255.255.255.0 192.168.20.0/24
 WARNING: untranslated string: ovpn routes push options = Route push options
 WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
index 27f9962eafa8a5898daf91bc8368178f21ccb4d6..f949d8a033a95456cabeb5bdeef51f6009d2f1cc 100644 (file)
@@ -460,7 +460,6 @@ WARNING: translation string unused: installed updates
 WARNING: translation string unused: interfaces
 WARNING: translation string unused: intrusion detection system log viewer
 WARNING: translation string unused: intrusion detection system2
-WARNING: translation string unused: intrusion prevention system
 WARNING: translation string unused: invalid cache size
 WARNING: translation string unused: invalid date entered
 WARNING: translation string unused: invalid downlink speed
@@ -1022,6 +1021,7 @@ WARNING: untranslated string: log drop hostile out = Log dropped packets TO host
 WARNING: untranslated string: no data = unknown string
 WARNING: untranslated string: openvpn cert expires soon = Expires Soon
 WARNING: untranslated string: openvpn cert has expired = Expired
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: pakfire ago = ago.
 WARNING: untranslated string: processors = Processors
 WARNING: untranslated string: reg_file_data_sampling = Register File Data Sampling (RFDS)
index a0d01d7fbe56b35dd3ab2f9de9998aca4b6ecc0b..ef480a19e531bf707676bdb74af5eb84f2d62c56 100644 (file)
@@ -443,7 +443,6 @@ WARNING: translation string unused: installed updates
 WARNING: translation string unused: interfaces
 WARNING: translation string unused: intrusion detection system log viewer
 WARNING: translation string unused: intrusion detection system2
-WARNING: translation string unused: intrusion prevention system
 WARNING: translation string unused: invalid cache size
 WARNING: translation string unused: invalid date entered
 WARNING: translation string unused: invalid downlink speed
@@ -966,6 +965,7 @@ WARNING: untranslated string: guardian service = unknown string
 WARNING: untranslated string: hostile networks total = Total Hostile Networks
 WARNING: untranslated string: ids provider eol = (EOL)
 WARNING: untranslated string: load average = Load Average
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: pakfire ago = ago.
 WARNING: untranslated string: processors = Processors
 WARNING: untranslated string: reg_file_data_sampling = Register File Data Sampling (RFDS)
index 81707b52a236039c610d982112a82c59ba1639f2..44387439cee5054fdc7e534237f64a10f5df8c89 100644 (file)
@@ -1131,6 +1131,7 @@ WARNING: untranslated string: incoming overhead in bytes per second = Incoming O
 WARNING: untranslated string: info messages = unknown string
 WARNING: untranslated string: inodes = Index-Nodes
 WARNING: untranslated string: interface mode = Interface
+WARNING: untranslated string: intrusion prevention system = Intrusion Prevention System
 WARNING: untranslated string: invalid input for inactivity timeout = Invalid input for Inactivity Timeout
 WARNING: untranslated string: invalid input for interface address = Invalid input for interface address
 WARNING: untranslated string: invalid input for interface mode = Invalid input for interface mode
@@ -1216,6 +1217,7 @@ WARNING: untranslated string: outgoing overhead in bytes per second = Outgoing O
 WARNING: untranslated string: ovpn add conf = Additional configuration
 WARNING: untranslated string: ovpn connection name = Connection Name
 WARNING: untranslated string: ovpn error md5 = You host certificate uses MD5 for the signature which is not accepted anymore. <br>Please update to the latest IPFire version and generate a new root and host certificate.</br><br>All OpenVPN clients needs then to be renewed!</br>
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
 WARNING: untranslated string: ovpn tls auth = TLS Channel Protection:
 WARNING: untranslated string: ovpn warning rfc3280 = Your host certificate is not RFC3280 compliant. <br>Please update to the latest IPFire version and generate as soon as possible a new root and host certificate.</br><br>All OpenVPN clients needs then to be renewed!</br>
index 08eb2754e2dfd3abad3979fa30eb5151777e3a9a..57edc0f5b7f1f940263949cb969173e7d585fdff 100644 (file)
@@ -1139,6 +1139,7 @@ WARNING: untranslated string: incoming overhead in bytes per second = Incoming O
 WARNING: untranslated string: info messages = unknown string
 WARNING: untranslated string: inodes = Index-Nodes
 WARNING: untranslated string: interface mode = Interface
+WARNING: untranslated string: intrusion prevention system = Intrusion Prevention System
 WARNING: untranslated string: invalid input for inactivity timeout = Invalid input for Inactivity Timeout
 WARNING: untranslated string: invalid input for interface address = Invalid input for interface address
 WARNING: untranslated string: invalid input for interface mode = Invalid input for interface mode
@@ -1242,6 +1243,7 @@ WARNING: untranslated string: ovpn connection name = Connection Name
 WARNING: untranslated string: ovpn crypt options = Cryptographic options
 WARNING: untranslated string: ovpn error md5 = You host certificate uses MD5 for the signature which is not accepted anymore. <br>Please update to the latest IPFire version and generate a new root and host certificate.</br><br>All OpenVPN clients needs then to be renewed!</br>
 WARNING: untranslated string: ovpn ha = Hash algorithm
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
 WARNING: untranslated string: ovpn tls auth = TLS Channel Protection:
 WARNING: untranslated string: ovpn warning rfc3280 = Your host certificate is not RFC3280 compliant. <br>Please update to the latest IPFire version and generate as soon as possible a new root and host certificate.</br><br>All OpenVPN clients needs then to be renewed!</br>
index 40041e45b3ef168598b10c1d9c3e6ba76f29b44d..0b3ce39a5b44c2d533c07e3acd5c7f965605b670 100644 (file)
@@ -1280,6 +1280,7 @@ WARNING: untranslated string: info messages = unknown string
 WARNING: untranslated string: inodes = Index-Nodes
 WARNING: untranslated string: integrity = Integrity:
 WARNING: untranslated string: interface mode = Interface
+WARNING: untranslated string: intrusion prevention system = Intrusion Prevention System
 WARNING: untranslated string: invalid input for dpd delay = Invalid input for DPD delay
 WARNING: untranslated string: invalid input for dpd timeout = Invalid input for DPD timeout
 WARNING: untranslated string: invalid input for inactivity timeout = Invalid input for Inactivity Timeout
@@ -1411,6 +1412,7 @@ WARNING: untranslated string: ovpn ha = Hash algorithm
 WARNING: untranslated string: ovpn mgmt in root range = A port number of 1024 or higher is required.
 WARNING: untranslated string: ovpn no connections = No active OpenVPN connections
 WARNING: untranslated string: ovpn port in root range = A port number of 1024 or higher is required.
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: ovpn routes push = Routes (one per line) e.g. 192.168.10.0/255.255.255.0 192.168.20.0/24
 WARNING: untranslated string: ovpn routes push options = Route push options
 WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
index e1b651ffd7ca334c84943e18eea847bf120e76a0..73823a7a819840f0e1d5eb4c8f443e8c5b092a3a 100644 (file)
@@ -1276,6 +1276,7 @@ WARNING: untranslated string: info messages = unknown string
 WARNING: untranslated string: inodes = Index-Nodes
 WARNING: untranslated string: integrity = Integrity:
 WARNING: untranslated string: interface mode = Interface
+WARNING: untranslated string: intrusion prevention system = Intrusion Prevention System
 WARNING: untranslated string: invalid input for dpd delay = Invalid input for DPD delay
 WARNING: untranslated string: invalid input for dpd timeout = Invalid input for DPD timeout
 WARNING: untranslated string: invalid input for inactivity timeout = Invalid input for Inactivity Timeout
@@ -1406,6 +1407,7 @@ WARNING: untranslated string: ovpn ha = Hash algorithm
 WARNING: untranslated string: ovpn mgmt in root range = A port number of 1024 or higher is required.
 WARNING: untranslated string: ovpn no connections = No active OpenVPN connections
 WARNING: untranslated string: ovpn port in root range = A port number of 1024 or higher is required.
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
 WARNING: untranslated string: ovpn tls auth = TLS Channel Protection:
 WARNING: untranslated string: ovpn warning rfc3280 = Your host certificate is not RFC3280 compliant. <br>Please update to the latest IPFire version and generate as soon as possible a new root and host certificate.</br><br>All OpenVPN clients needs then to be renewed!</br>
index 398226ca880690b8d8764e711357a32505ee59c8..9cc962515be90d99276d5aad3e3f1ff536f57c08 100644 (file)
@@ -1071,6 +1071,7 @@ WARNING: untranslated string: ids working = Changes are being applied. Please wa
 WARNING: untranslated string: info messages = unknown string
 WARNING: untranslated string: inodes = Index-Nodes
 WARNING: untranslated string: interface mode = Interface
+WARNING: untranslated string: intrusion prevention system = Intrusion Prevention System
 WARNING: untranslated string: invalid input for interface address = Invalid input for interface address
 WARNING: untranslated string: invalid input for interface mode = Invalid input for interface mode
 WARNING: untranslated string: invalid input for interface mtu = Invalid input to interface MTU
@@ -1130,6 +1131,7 @@ WARNING: untranslated string: optional = Optional
 WARNING: untranslated string: otp qrcode = OTP QRCode
 WARNING: untranslated string: ovpn connection name = Connection Name
 WARNING: untranslated string: ovpn error md5 = You host certificate uses MD5 for the signature which is not accepted anymore. <br>Please update to the latest IPFire version and generate a new root and host certificate.</br><br>All OpenVPN clients needs then to be renewed!</br>
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
 WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
 WARNING: untranslated string: ovpn tls auth = TLS Channel Protection:
 WARNING: untranslated string: ovpn warning rfc3280 = Your host certificate is not RFC3280 compliant. <br>Please update to the latest IPFire version and generate as soon as possible a new root and host certificate.</br><br>All OpenVPN clients needs then to be renewed!</br>
index fbde82a9103ddb4ad9a2514efe7f23379cd41b68..05fff37d1006dd78ab45fa38dbf7e5723e4feb4b 100644 (file)
@@ -78,6 +78,7 @@
 < notes
 < okay
 < optional
+< ovpn roadwarrior server
 < quick control
 < random number generator daemon
 < regenerate host certificate
 < log drop hostile out
 < openvpn cert expires soon
 < openvpn cert has expired
+< ovpn roadwarrior server
 < processors
 < regenerate host certificate
 < reg_file_data_sampling
 < ids provider eol
 < ids unsupported provider
 < load average
+< ovpn roadwarrior server
 < processors
 < reg_file_data_sampling
 < system time
 < ovpn add conf
 < ovpn connection name
 < ovpn error md5
+< ovpn roadwarrior server
 < ovpn rw connection log
 < ovpn tls auth
 < ovpn warning rfc3280
 < ovpn generating the root and host certificates
 < ovpn ha
 < ovpn reneg sec
+< ovpn roadwarrior server
 < ovpn rw connection log
 < ovpn tls auth
 < ovpn warning rfc3280
 < ovpn no connections
 < ovpn port in root range
 < ovpn reneg sec
+< ovpn roadwarrior server
 < ovpn routes push
 < ovpn routes push options
 < ovpn rw connection log
 < ovpn no connections
 < ovpn port in root range
 < ovpn reneg sec
+< ovpn roadwarrior server
 < ovpn rw connection log
 < ovpn tls auth
 < ovpn warning rfc3280
 < otp qrcode
 < ovpn connection name
 < ovpn error md5
+< ovpn roadwarrior server
 < ovpn rw connection log
 < ovpn tls auth
 < ovpn warning rfc3280
index f0172978f0ae315651d319a0625ef1e36b1353fa..5cf2f5eab0117205904ed2bc6fd841ce32c472e6 100755 (executable)
@@ -5247,6 +5247,15 @@ END
        $activeonrun = "disabled='disabled'";
     }
     &Header::openbox('100%', 'LEFT', $Lang::tr{'global settings'});
+
+       # Show the service status
+       &Header::ServiceStatus({
+               $Lang::tr{'ovpn roadwarrior server'} => {
+                       "process" => "openvpn",
+                       "pidfile" => "/var/run/openvpn.pid",
+               }
+       });
+
        print <<END;
     <table width='100%' border='0'>
     <form method='post'>
index 8fb34326396ad68b65724c4e40da1794d4858c95..9c45e9c5623733eac383272c2f97327ceefcf8b8 100644 (file)
@@ -133,6 +133,22 @@ iframe {
        float: right !important;
 }
 
+/*
+       Text Alignment
+*/
+
+.text-left {
+       text-align: left;
+}
+
+.text-center {
+       text-align: center;
+}
+
+.text-right {
+       text-align: right;
+}
+
 /* Header */
 
 #header {
@@ -296,6 +312,10 @@ table {
        border-spacing: 0;
 }
 
+.tbl {
+       width: 100%;
+}
+
 .tbl th {
        color: #ffffff;
        border-top: 1px solid #363636;
index ce822e2a37b12e26eda8383c6bb0f122159a16e7..4b5d0779af379b4293130ebdd272397c5beef727 100644 (file)
 'ovpn on red' => 'OpenVPN on RED:',
 'ovpn port in root range' => 'A port number of 1024 or higher is required.',
 'ovpn reneg sec' => 'Session key lifetime:',
+'ovpn roadwarrior server' => 'OpenVPN Roadwarrior Server',
 'ovpn routes push' => 'Routes (one per line) e.g. 192.168.10.0/255.255.255.0 192.168.20.0/24',
 'ovpn routes push options' => 'Route push options',
 'ovpn rw connection log' => 'OpenVPN Roadwarrior Connections Log',