Skip to content

Commit

Permalink
feat: cache health
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Apr 22, 2024
1 parent b9ed8c5 commit 92dc5f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
22 changes: 20 additions & 2 deletions frappe/desk/doctype/system_health_report/system_health_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"top_db_tables",
"mariadb_variables_section",
"bufferpool_size",
"binary_logging"
"binary_logging",
"cache_tab",
"cache_keys",
"cache_memory_usage"
],
"fields": [
{
Expand Down Expand Up @@ -209,14 +212,29 @@
"fieldname": "binary_logging",
"fieldtype": "Data",
"label": "Binary Logging"
},
{
"fieldname": "cache_tab",
"fieldtype": "Tab Break",
"label": "Cache"
},
{
"fieldname": "cache_keys",
"fieldtype": "Int",
"label": "Number of keys"
},
{
"fieldname": "cache_memory_usage",
"fieldtype": "Data",
"label": "Memory Usage"
}
],
"hide_toolbar": 1,
"index_web_pages_for_search": 1,
"is_virtual": 1,
"issingle": 1,
"links": [],
"modified": "2024-04-18 19:39:55.039759",
"modified": "2024-04-18 19:58:14.550430",
"modified_by": "Administrator",
"module": "Desk",
"name": "System Health Report",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class SystemHealthReport(Document):
background_workers: DF.Table[SystemHealthWorkers]
binary_logging: DF.Data | None
bufferpool_size: DF.Data | None
cache_keys: DF.Int
cache_memory_usage: DF.Data | None
database: DF.Data | None
database_version: DF.Data | None
db_storage_usage: DF.Float
Expand Down Expand Up @@ -71,6 +73,7 @@ def load_from_db(self):
self.fetch_email_stats()
self.fetch_errors()
self.fetch_database_details()
self.fetch_cache_details()

def fetch_background_workers(self):
self.scheduler_status = get_scheduler_status().get("status")
Expand Down Expand Up @@ -150,6 +153,10 @@ def fetch_database_details(self):
self.bufferpool_size = frappe.db.sql("show variables like 'innodb_buffer_pool_size'")[0][1]
self.binary_logging = frappe.db.sql("show variables like 'log_bin'")[0][1]

def fetch_cache_details(self):
self.cache_keys = len(frappe.cache.get_keys(""))
self.cache_memory_usage = frappe.cache.execute_command("INFO", "MEMORY").get("used_memory_human")

def db_update(self):
raise NotImplementedError

Expand Down

0 comments on commit 92dc5f3

Please sign in to comment.