static ngx_int_t ngx_http_sysguard_update_swap(ngx_http_request_t *r, time_t exptime) { ngx_int_t rc; ngx_meminfo_t m; ngx_http_sysguard_cached_swap_exptime = ngx_time() + exptime; rc = ngx_getmeminfo(&m, r->connection->log); if (rc == NGX_ERROR) { ngx_http_sysguard_cached_swapstat = 0; return NGX_ERROR; } ngx_http_sysguard_cached_swapstat = m.totalswap == 0 ? 0 : (m.totalswap - m.freeswap) * 100 / m.totalswap; return NGX_OK; }
static ngx_int_t ngx_http_sysguard_update_mem(ngx_http_request_t *r, time_t exptime) { ngx_int_t rc; ngx_meminfo_t m; ngx_http_sysguard_cached_mem_exptime = ngx_time() + exptime; rc = ngx_getmeminfo(&m, r->connection->log); if (rc == NGX_ERROR) { ngx_http_sysguard_cached_swapstat = 0; ngx_http_sysguard_cached_free = NGX_CONF_UNSET_SIZE; return NGX_ERROR; } ngx_http_sysguard_cached_swapstat = m.totalswap == 0 ? 0 : (m.totalswap - m.freeswap) * 100 / m.totalswap; ngx_http_sysguard_cached_free = m.freeram + m.cachedram + m.bufferram; return NGX_OK; }