From: Michael Tremer Date: Sat, 23 Mar 2024 17:42:13 +0000 (+0100) Subject: web: Create a function to show the service status X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b16963484967977709bf21bcf2deb4adaaf4ee9;p=people%2Fmfischer%2Fipfire-2.x.git web: Create a function to show the service status Signed-off-by: Michael Tremer --- diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-functions.pl index a87e5c070..8ba6e3f79 100644 --- a/config/cfgroot/general-functions.pl +++ b/config/cfgroot/general-functions.pl @@ -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 () { + 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 () { + # Open the status file + open(STATUS, "<${status}"); + + # Read the status file + while () { + # 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 () { + 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{$_}++, @_ } diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index a4b79a6a1..327c446bb 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -896,4 +896,92 @@ sub _read_manualpage_hash() { close($file); } +sub ServiceStatus() { + my $services = shift; + my %services = %{ $services }; + + # Write the table header + print < + + + +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 < + + $service + +EOF + + # Running? + if (scalar @pids) { + # Format memory + $mem = &General::formatBytes($mem); + + print < + $Lang::tr{'running'} + + + + ${mem} + +EOF + + # Not Running + } else { + print < + $Lang::tr{'stopped'} + +EOF + } + + print < +EOF + + } + + print < + +EOF +} + 1; # End of package "Header" diff --git a/doc/language_issues.de b/doc/language_issues.de index 9fee272ff..e2ca260de 100644 --- a/doc/language_issues.de +++ b/doc/language_issues.de @@ -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 diff --git a/doc/language_issues.en b/doc/language_issues.en index 5b94d2fc8..443c2a951 100644 --- a/doc/language_issues.en +++ b/doc/language_issues.en @@ -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 diff --git a/doc/language_issues.es b/doc/language_issues.es index 27f9962ea..f949d8a03 100644 --- a/doc/language_issues.es +++ b/doc/language_issues.es @@ -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) diff --git a/doc/language_issues.fr b/doc/language_issues.fr index a0d01d7fb..ef480a19e 100644 --- a/doc/language_issues.fr +++ b/doc/language_issues.fr @@ -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) diff --git a/doc/language_issues.it b/doc/language_issues.it index 81707b52a..44387439c 100644 --- a/doc/language_issues.it +++ b/doc/language_issues.it @@ -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.
Please update to the latest IPFire version and generate a new root and host certificate.

All OpenVPN clients needs then to be renewed!
+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.
Please update to the latest IPFire version and generate as soon as possible a new root and host certificate.

All OpenVPN clients needs then to be renewed!
diff --git a/doc/language_issues.nl b/doc/language_issues.nl index 08eb2754e..57edc0f5b 100644 --- a/doc/language_issues.nl +++ b/doc/language_issues.nl @@ -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.
Please update to the latest IPFire version and generate a new root and host certificate.

All OpenVPN clients needs then to be renewed!
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.
Please update to the latest IPFire version and generate as soon as possible a new root and host certificate.

All OpenVPN clients needs then to be renewed!
diff --git a/doc/language_issues.pl b/doc/language_issues.pl index 40041e45b..0b3ce39a5 100644 --- a/doc/language_issues.pl +++ b/doc/language_issues.pl @@ -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 diff --git a/doc/language_issues.ru b/doc/language_issues.ru index e1b651ffd..73823a7a8 100644 --- a/doc/language_issues.ru +++ b/doc/language_issues.ru @@ -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.
Please update to the latest IPFire version and generate as soon as possible a new root and host certificate.

All OpenVPN clients needs then to be renewed!
diff --git a/doc/language_issues.tr b/doc/language_issues.tr index 398226ca8..9cc962515 100644 --- a/doc/language_issues.tr +++ b/doc/language_issues.tr @@ -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.
Please update to the latest IPFire version and generate a new root and host certificate.

All OpenVPN clients needs then to be renewed!
+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.
Please update to the latest IPFire version and generate as soon as possible a new root and host certificate.

All OpenVPN clients needs then to be renewed!
diff --git a/doc/language_missings b/doc/language_missings index fbde82a91..05fff37d1 100644 --- a/doc/language_missings +++ b/doc/language_missings @@ -78,6 +78,7 @@ < notes < okay < optional +< ovpn roadwarrior server < quick control < random number generator daemon < regenerate host certificate @@ -135,6 +136,7 @@ < log drop hostile out < openvpn cert expires soon < openvpn cert has expired +< ovpn roadwarrior server < processors < regenerate host certificate < reg_file_data_sampling @@ -161,6 +163,7 @@ < ids provider eol < ids unsupported provider < load average +< ovpn roadwarrior server < processors < reg_file_data_sampling < system time @@ -531,6 +534,7 @@ < ovpn add conf < ovpn connection name < ovpn error md5 +< ovpn roadwarrior server < ovpn rw connection log < ovpn tls auth < ovpn warning rfc3280 @@ -1086,6 +1090,7 @@ < 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 @@ -1968,6 +1973,7 @@ < 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 @@ -2974,6 +2980,7 @@ < ovpn no connections < ovpn port in root range < ovpn reneg sec +< ovpn roadwarrior server < ovpn rw connection log < ovpn tls auth < ovpn warning rfc3280 @@ -3469,6 +3476,7 @@ < otp qrcode < ovpn connection name < ovpn error md5 +< ovpn roadwarrior server < ovpn rw connection log < ovpn tls auth < ovpn warning rfc3280 diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index f0172978f..5cf2f5eab 100755 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -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 <
diff --git a/html/html/themes/ipfire/include/css/style.css b/html/html/themes/ipfire/include/css/style.css index 8fb343263..9c45e9c56 100644 --- a/html/html/themes/ipfire/include/css/style.css +++ b/html/html/themes/ipfire/include/css/style.css @@ -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; diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index ce822e2a3..4b5d0779a 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -2044,6 +2044,7 @@ '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',