WebAdmin: Removed the duplicate memory usage querying
This commit is contained in:
parent
e51221eaf9
commit
20e7221c7c
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Lua binding: AllToLua
|
** Lua binding: AllToLua
|
||||||
** Generated automatically by tolua++-1.0.92 on 07/29/13 09:54:50.
|
** Generated automatically by tolua++-1.0.92 on 07/29/13 10:58:05.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
@ -18883,19 +18883,15 @@ static int tolua_AllToLua_cWebAdmin_GetMemoryUsage00(lua_State* tolua_S)
|
|||||||
#ifndef TOLUA_RELEASE
|
#ifndef TOLUA_RELEASE
|
||||||
tolua_Error tolua_err;
|
tolua_Error tolua_err;
|
||||||
if (
|
if (
|
||||||
!tolua_isusertype(tolua_S,1,"const cWebAdmin",0,&tolua_err) ||
|
!tolua_isusertable(tolua_S,1,"cWebAdmin",0,&tolua_err) ||
|
||||||
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||||
)
|
)
|
||||||
goto tolua_lerror;
|
goto tolua_lerror;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
const cWebAdmin* self = (const cWebAdmin*) tolua_tousertype(tolua_S,1,0);
|
|
||||||
#ifndef TOLUA_RELEASE
|
|
||||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetMemoryUsage'", NULL);
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
AString tolua_ret = (AString) self->GetMemoryUsage();
|
AString tolua_ret = (AString) cWebAdmin::GetMemoryUsage();
|
||||||
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
|
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Lua binding: AllToLua
|
** Lua binding: AllToLua
|
||||||
** Generated automatically by tolua++-1.0.92 on 07/29/13 09:54:50.
|
** Generated automatically by tolua++-1.0.92 on 07/29/13 10:58:06.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Exported function */
|
/* Exported function */
|
||||||
|
@ -243,36 +243,13 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
|
|||||||
Content += "\n<p><a href='" + BaseURL + "'>Go back</a></p>";
|
Content += "\n<p><a href='" + BaseURL + "'>Go back</a></p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// mem usage
|
AString MemUsage = GetMemoryUsage();
|
||||||
#ifndef _WIN32
|
ReplaceString(Template, "{MEM}", MemUsage);
|
||||||
rusage resource_usage;
|
ReplaceString(Template, "{USERNAME}", r->username_);
|
||||||
if (getrusage(RUSAGE_SELF, &resource_usage) != 0)
|
ReplaceString(Template, "{MENU}", Menu);
|
||||||
{
|
ReplaceString(Template, "{PLUGIN_NAME}", FoundPlugin);
|
||||||
ReplaceString( Template, AString("{MEM}"), "Error :(" );
|
ReplaceString(Template, "{CONTENT}", Content);
|
||||||
}
|
ReplaceString(Template, "{TITLE}", "MCServer");
|
||||||
else
|
|
||||||
{
|
|
||||||
AString MemUsage;
|
|
||||||
Printf(MemUsage, "%0.2f", ((double)resource_usage.ru_maxrss / 1024 / 1024) );
|
|
||||||
ReplaceString(Template, AString("{MEM}"), MemUsage);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
HANDLE hProcess = GetCurrentProcess();
|
|
||||||
PROCESS_MEMORY_COUNTERS pmc;
|
|
||||||
if( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc) ) )
|
|
||||||
{
|
|
||||||
AString MemUsage;
|
|
||||||
Printf(MemUsage, "%0.2f", (pmc.WorkingSetSize / 1024.f / 1024.f) );
|
|
||||||
ReplaceString( Template, "{MEM}", MemUsage );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// end mem usage
|
|
||||||
|
|
||||||
ReplaceString( Template, "{USERNAME}", r->username_ );
|
|
||||||
ReplaceString( Template, "{MENU}", Menu );
|
|
||||||
ReplaceString( Template, "{PLUGIN_NAME}", FoundPlugin );
|
|
||||||
ReplaceString( Template, "{CONTENT}", Content );
|
|
||||||
ReplaceString( Template, "{TITLE}", "MCServer" );
|
|
||||||
|
|
||||||
AString NumChunks;
|
AString NumChunks;
|
||||||
Printf(NumChunks, "%d", cRoot::Get()->GetTotalChunkCount());
|
Printf(NumChunks, "%d", cRoot::Get()->GetTotalChunkCount());
|
||||||
@ -436,7 +413,7 @@ AString cWebAdmin::GetBaseURL( const AStringVector& a_URLSplit )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
AString cWebAdmin::GetMemoryUsage() const
|
AString cWebAdmin::GetMemoryUsage(void)
|
||||||
{
|
{
|
||||||
AString MemUsage;
|
AString MemUsage;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -63,13 +63,13 @@ public: // tolua_export
|
|||||||
|
|
||||||
static void Request_Handler(webserver::http_request* r);
|
static void Request_Handler(webserver::http_request* r);
|
||||||
|
|
||||||
int GetPort() { return m_Port; } // tolua_export
|
int GetPort() { return m_Port; } // tolua_export
|
||||||
|
|
||||||
sWebAdminPage GetPage(const HTTPRequest& a_Request); // tolua_export
|
sWebAdminPage GetPage(const HTTPRequest& a_Request); // tolua_export
|
||||||
AString GetBaseURL(const AString& a_URL); // tolua_export
|
AString GetBaseURL(const AString& a_URL); // tolua_export
|
||||||
AString GetBaseURL(const AStringVector& a_URLSplit);
|
AString GetBaseURL(const AStringVector& a_URLSplit);
|
||||||
|
|
||||||
AString GetMemoryUsage() const; // tolua_export
|
static AString GetMemoryUsage(void); // tolua_export
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
Loading…
Reference in New Issue
Block a user