diff --git a/src/modules/keydb_modstatsd/modmain.cpp b/src/modules/keydb_modstatsd/modmain.cpp index 5feafc284..4330d7e92 100644 --- a/src/modules/keydb_modstatsd/modmain.cpp +++ b/src/modules/keydb_modstatsd/modmain.cpp @@ -253,6 +253,7 @@ std::unordered_map g_mapInfoFields = { { "cluster_size", { StatsD_Type::STATSD_GAUGE_LONGLONG }}, { "storage_flash_available_bytes", { StatsD_Type::STATSD_GAUGE_BYTES }}, { "storage_flash_total_bytes", { StatsD_Type::STATSD_GAUGE_BYTES }}, + { "last_overload_cpu_reading", { StatsD_Type::STATSD_GAUGE_FLOAT }}, }; /* Globals */ diff --git a/src/server.cpp b/src/server.cpp index 7a716389b..062c5bd2c 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2610,6 +2610,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { perc /= cserver.cthreads; perc *= 100.0; serverLog(LL_WARNING, "CPU Used: %.2f", perc); + g_pserver->last_overload_cpu_reading = static_cast(perc); if (perc > g_pserver->overload_protect_threshold) { serverLog(LL_WARNING, "\tWARNING: CPU overload detected."); g_pserver->is_overloaded = true; @@ -6271,13 +6272,15 @@ sds genRedisInfoString(const char *section) { "used_cpu_sys_children:%ld.%06ld\r\n" "used_cpu_user_children:%ld.%06ld\r\n" "server_threads:%d\r\n" - "long_lock_waits:%" PRIu64 "\r\n", + "long_lock_waits:%" PRIu64 "\r\n" + "last_overload_cpu_reading:%.2f\r\n", (long)self_ru.ru_stime.tv_sec, (long)self_ru.ru_stime.tv_usec, (long)self_ru.ru_utime.tv_sec, (long)self_ru.ru_utime.tv_usec, (long)c_ru.ru_stime.tv_sec, (long)c_ru.ru_stime.tv_usec, (long)c_ru.ru_utime.tv_sec, (long)c_ru.ru_utime.tv_usec, cserver.cthreads, - fastlock_getlongwaitcount()); + fastlock_getlongwaitcount(), + g_pserver->last_overload_cpu_reading); #ifdef RUSAGE_THREAD struct rusage m_ru; getrusage(RUSAGE_THREAD, &m_ru); diff --git a/src/server.h b/src/server.h index c06ff74ee..3f53de6e6 100644 --- a/src/server.h +++ b/src/server.h @@ -2758,6 +2758,7 @@ struct redisServer { sds sdsAvailabilityZone; int overload_protect_threshold = 0; + float last_overload_cpu_reading = 0.0f; int is_overloaded = 0; int overload_closed_clients = 0;