From 907f39db4ab00de43016646660d9d1ca9c73d1f9 Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Sat, 27 Jan 2024 13:05:41 +0100 Subject: initial commit --- healthcheck.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 healthcheck.php (limited to 'healthcheck.php') diff --git a/healthcheck.php b/healthcheck.php new file mode 100644 index 0000000..ed41916 --- /dev/null +++ b/healthcheck.php @@ -0,0 +1,38 @@ +prefix . 'communievents_events'; + + $evcount = $wpdb->get_var("SELECT COUNT(id) FROM $tablename", 0, 0); + $lastsync = $wpdb->get_var("SELECT MAX(lastsync) FROM $tablename", 0, 0); + $nextsync = wp_next_scheduled('communievents_cron_hook'); + + if ($lastsync) { + $lastsync_dt = new DateTime("@$lastsync"); + $lastsync_str = $lastsync_dt->format('Y-m-d H:i:s'); + } else { + $lastsync_str = "NEVER"; + } + + if ($nextsync) { + $nextsync_dt = new DateTime("@$nextsync"); + $nextsync_str = $nextsync_dt->format('Y-m-d H:i:s'); + } else { + $nextsync_str = "NEVER"; + } + + $now_dt = new DateTime('now'); + $now_str = $now_dt->format('Y-m-d H:i:s'); + + return "" . + "
CommuniEvents Health
Event Count:$evcount" . + "
Last Sync:$lastsync_str" . + "
Next Sync:$nextsync_str" . + "
Now:$now_str" . + "
"; +} + +function communievents_setup_healthcheck() { + add_shortcode('communievents-healthcheck', 'communievents_healthcheck'); +} -- cgit v1.2.3