diff --git a/README.md b/README.md index eff5a9f1..efe52990 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config/config.example.yml b/config/config.example.yml index a9ef777a..eef2e222 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -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. ## diff --git a/src/invidious/config.cr b/src/invidious/config.cr index a5fc0aca..1bafca78 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -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 diff --git a/src/invidious/helpers/loadavg.cr b/src/invidious/helpers/loadavg.cr new file mode 100644 index 00000000..dffab823 --- /dev/null +++ b/src/invidious/helpers/loadavg.cr @@ -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 \ No newline at end of file diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index a0e5165b..bcd586b7 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -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 %> @@ -38,6 +39,9 @@ <% if uptime_enabled %> server <%= Invidious::Uptime.get_uptime %> <% end %> + <% if loadavg_enabled %> + server load <%= Invidious::Loadavg.get_loadavg %> + <% end %>