mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add base system diagnostic
This commit is contained in:
parent
c4ba8534c5
commit
33180d0947
3 changed files with 62 additions and 2 deletions
54
data/hooks/diagnosis/00-basesystem.py
Normal file
54
data/hooks/diagnosis/00-basesystem.py
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from moulinette.utils.filesystem import read_file
|
||||||
|
from yunohost.diagnosis import Diagnoser
|
||||||
|
from yunohost.utils.packages import ynh_packages_version
|
||||||
|
|
||||||
|
|
||||||
|
class BaseSystemDiagnoser(Diagnoser):
|
||||||
|
|
||||||
|
id_ = os.path.splitext(os.path.basename(__file__))[0].split("-")[1]
|
||||||
|
cache_duration = 3600 * 24
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
# Kernel version
|
||||||
|
kernel_version = read_file('/proc/sys/kernel/osrelease').strip()
|
||||||
|
yield dict(meta={"test": "kernel"},
|
||||||
|
status="INFO",
|
||||||
|
summary=("diagnosis_basesystem_kernel", {"kernel_version": kernel_version}))
|
||||||
|
|
||||||
|
# Debian release
|
||||||
|
debian_version = read_file("/etc/debian_version").strip()
|
||||||
|
yield dict(meta={"test": "host"},
|
||||||
|
status="INFO",
|
||||||
|
summary=("diagnosis_basesystem_host", {"debian_version": debian_version}))
|
||||||
|
|
||||||
|
# Yunohost packages versions
|
||||||
|
ynh_packages = ynh_packages_version()
|
||||||
|
# We check if versions are consistent (e.g. all 3.6 and not 3 packages with 3.6 and the other with 3.5)
|
||||||
|
# This is a classical issue for upgrades that failed in the middle
|
||||||
|
# (or people upgrading half of the package because they did 'apt upgrade' instead of 'dist-upgrade')
|
||||||
|
# Here, ynh_core_version is for example "3.5.4.12", so [:3] is "3.5" and we check it's the same for all packages
|
||||||
|
ynh_core_version = ynh_packages["yunohost"]["version"]
|
||||||
|
consistent_versions = all(infos["version"][:3] == ynh_core_version[:3] for infos in ynh_packages.values())
|
||||||
|
ynh_version_details = [("diagnosis_basesystem_ynh_single_version", (package, infos["version"]))
|
||||||
|
for package, infos in ynh_packages.items()]
|
||||||
|
|
||||||
|
if consistent_versions:
|
||||||
|
yield dict(meta={"test": "ynh_versions"},
|
||||||
|
status="INFO",
|
||||||
|
summary=("diagnosis_basesystem_ynh_main_version", {"main_version": ynh_core_version[:3]}),
|
||||||
|
details=ynh_version_details)
|
||||||
|
else:
|
||||||
|
yield dict(meta={"test": "ynh_versions"},
|
||||||
|
status="ERROR",
|
||||||
|
summary=("diagnosis_basesystem_ynh_inconsistent_versions", {}),
|
||||||
|
details=ynh_version_details)
|
||||||
|
|
||||||
|
|
||||||
|
def main(args, env, loggers):
|
||||||
|
return BaseSystemDiagnoser(args, env, loggers).diagnose()
|
|
@ -150,6 +150,11 @@
|
||||||
"custom_appslist_name_required": "You must provide a name for your custom app list",
|
"custom_appslist_name_required": "You must provide a name for your custom app list",
|
||||||
"diagnosis_debian_version_error": "Could not retrieve the Debian version: {error}",
|
"diagnosis_debian_version_error": "Could not retrieve the Debian version: {error}",
|
||||||
"diagnosis_kernel_version_error": "Could not retrieve kernel version: {error}",
|
"diagnosis_kernel_version_error": "Could not retrieve kernel version: {error}",
|
||||||
|
"diagnosis_basesystem_host": "Server is running Debian {debian_version}.",
|
||||||
|
"diagnosis_basesystem_kernel": "Server is running Linux kernel {kernel_version}",
|
||||||
|
"diagnosis_basesystem_ynh_single_version": "{0} version: {1}",
|
||||||
|
"diagnosis_basesystem_ynh_main_version": "Server is running YunoHost {main_version}",
|
||||||
|
"diagnosis_basesystem_ynh_inconsistent_versions": "You are running inconsistents versions of the YunoHost packages ... most probably because of a failed or partial upgrade.",
|
||||||
"diagnosis_monitor_disk_error": "Could not monitor disks: {error}",
|
"diagnosis_monitor_disk_error": "Could not monitor disks: {error}",
|
||||||
"diagnosis_monitor_system_error": "Could not monitor system: {error}",
|
"diagnosis_monitor_system_error": "Could not monitor system: {error}",
|
||||||
"diagnosis_no_apps": "No installed application",
|
"diagnosis_no_apps": "No installed application",
|
||||||
|
@ -192,6 +197,7 @@
|
||||||
"diagnosis_security_all_good": "No critical security vulnerability was found.",
|
"diagnosis_security_all_good": "No critical security vulnerability was found.",
|
||||||
"diagnosis_security_vulnerable_to_meltdown": "You appear vulnerable to the Meltdown criticial security vulnerability",
|
"diagnosis_security_vulnerable_to_meltdown": "You appear vulnerable to the Meltdown criticial security vulnerability",
|
||||||
"diagnosis_security_vulnerable_to_meltdown_details": "To fix this, you should upgrade your system and reboot to load the new linux kernel (or contact your server provider if this doesn't work). See https://meltdownattack.com/ for more infos.",
|
"diagnosis_security_vulnerable_to_meltdown_details": "To fix this, you should upgrade your system and reboot to load the new linux kernel (or contact your server provider if this doesn't work). See https://meltdownattack.com/ for more infos.",
|
||||||
|
"diagnosis_description_basesystem": "Base system",
|
||||||
"diagnosis_description_ip": "Internet connectivity",
|
"diagnosis_description_ip": "Internet connectivity",
|
||||||
"diagnosis_description_dnsrecords": "DNS records",
|
"diagnosis_description_dnsrecords": "DNS records",
|
||||||
"diagnosis_description_services": "Services status check",
|
"diagnosis_description_services": "Services status check",
|
||||||
|
|
|
@ -74,7 +74,7 @@ def diagnosis_show(categories=[], issues=False, full=False, share=False):
|
||||||
if "data" in item:
|
if "data" in item:
|
||||||
del item["data"]
|
del item["data"]
|
||||||
if issues:
|
if issues:
|
||||||
report["items"] = [item for item in report["items"] if item["status"] != "SUCCESS"]
|
report["items"] = [item for item in report["items"] if item["status"] in ["WARNING", "ERROR"]]
|
||||||
# Ignore this category if no issue was found
|
# Ignore this category if no issue was found
|
||||||
if not report["items"]:
|
if not report["items"]:
|
||||||
continue
|
continue
|
||||||
|
@ -140,7 +140,7 @@ def diagnosis_run(categories=[], force=False):
|
||||||
else:
|
else:
|
||||||
diagnosed_categories.append(category)
|
diagnosed_categories.append(category)
|
||||||
if report != {}:
|
if report != {}:
|
||||||
issues.extend([item for item in report["items"] if item["status"] != "SUCCESS"])
|
issues.extend([item for item in report["items"] if item["status"] in ["WARNING", "ERROR"]])
|
||||||
|
|
||||||
if issues:
|
if issues:
|
||||||
if msettings.get("interface") == "api":
|
if msettings.get("interface") == "api":
|
||||||
|
|
Loading…
Add table
Reference in a new issue