Merge pull request #68 from catspeed-cc/dev-server-load

Merge: dev-server-load into development
This commit is contained in:
MooCat 2024-10-22 00:09:06 -04:00 committed by GitHub
commit 7511b94ab6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 35 additions and 2 deletions

View File

@ -78,6 +78,7 @@
- add proxy patch
- sig helper reconnect patch
- uptime status patch (mooleshacat)
- loadavg status patch (mooleshacat)
- token monitor patch (mooleshacat)
**User features**
@ -169,9 +170,9 @@ This branch has the token monitor patch from myself (mooleshacat) which will che
This patch is a temporary workaround until inv_sig_helper itself can get the tokens for us. unixfox (invidious dev) raised this idea to techmetx11 (inv_sig_helper dev) and they are working on an implementation that will eventually make this patch useless. This is OK, as it is only a patch and that setup would be better performance wise than my current implementations. You can read about it here https://github.com/iv-org/inv_sig_helper/issues/10
## uptime status patch notes
## uptime & loadavg status patch notes
This branch has the uptime patch from myself (mooleshacat) which if enabled in the config, will show the uptime on the page. Please note, if everyone can see your uptime, so could a theoretical attacker. This may or may not be a good idea, you be the judge.
This branch has the uptime & loadavg patch from myself (mooleshacat) which if enabled in the config, will show the uptime and/or loadavg on the page. Please note, if everyone can see your uptime or loadavg, so could a theoretical attacker. This may or may not be a good idea, you be the judge.
## Documentation

View File

@ -246,6 +246,14 @@ http_proxy:
##
#uptime_enabled: true
##
## Enable/Disable showing the load avg on the main page.
##
## Accepted values: true, false
## Default: false
##
#loadavg_enabled: true
##
## Enable/Disable the "Popular" tab on the main page.
##

View File

@ -103,6 +103,7 @@ class Config
property use_pubsub_feeds : Bool | Int32 = false
property popular_enabled : Bool = true
property uptime_enabled : Bool = false
property loadavg_enabled : Bool = false
property captcha_enabled : Bool = true
property login_enabled : Bool = true
property registration_enabled : Bool = true

View File

@ -0,0 +1,19 @@
class Invidious::Loadavg
def self.get_loadavg
str_loadavg = "error"
if CONFIG.loadavg_enabled
str_loadavg = `/usr/bin/cat /proc/loadavg | awk -F'[ ]' '{print $1" "$2" "$3}'`
else
str_loadavg = ""
end
return str_loadavg
end
end

View File

@ -2,6 +2,7 @@
locale = env.get("preferences").as(Preferences).locale
dark_mode = env.get("preferences").as(Preferences).dark_mode
uptime_enabled = CONFIG.uptime_enabled
loadavg_enabled = CONFIG.loadavg_enabled
%>
<!DOCTYPE html>
<html lang="<%= locale %>">
@ -38,6 +39,9 @@
<% if uptime_enabled %>
<tr><td style="text-align: center; vertical-align: middle;"><font style="font-size: 10px;color:#c3c3c3;">server <%= Invidious::Uptime.get_uptime %></font></td></tr>
<% end %>
<% if loadavg_enabled %>
<tr><td style="text-align: center; vertical-align: middle;"><font style="font-size: 10px;color:#c3c3c3;">server load <%= Invidious::Loadavg.get_loadavg %></font></td></tr>
<% end %>
</table>
</div>
<div class="pure-u-1 pure-u-md-12-24 searchbar">