diff --git a/ksysguardd/Linux/Memory.h b/ksysguardd/Linux/Memory.h --- a/ksysguardd/Linux/Memory.h +++ b/ksysguardd/Linux/Memory.h @@ -27,16 +27,22 @@ int updateMemory( void ); +void printTotal( const char* ); +void printTotalInfo( const char* ); void printMFree( const char* ); void printMFreeInfo( const char* ); +void printAvailable( const char* ); +void printAvailableInfo( const char* ); void printUsed( const char* ); void printUsedInfo( const char* ); void printAppl( const char* ); void printApplInfo( const char* ); void printBuffers( const char* ); void printBuffersInfo( const char* ); void printCached( const char* ); void printCachedInfo( const char* ); +void printAllocated( const char* ); +void printAllocatedInfo( const char* ); void printSwapUsed( const char* ); void printSwapUsedInfo( const char* ); void printSwapFree( const char* ); diff --git a/ksysguardd/Linux/Memory.c b/ksysguardd/Linux/Memory.c --- a/ksysguardd/Linux/Memory.c +++ b/ksysguardd/Linux/Memory.c @@ -38,10 +38,12 @@ static unsigned long long Total = 0; static unsigned long long MFree = 0; +static unsigned long long Available = 0; static unsigned long long Appl = 0; static unsigned long long Used = 0; static unsigned long long Buffers = 0; static unsigned long long Cached = 0; +static unsigned long long Allocated = 0; static unsigned long long STotal = 0; static unsigned long long SFree = 0; static unsigned long long SUsed = 0; @@ -60,6 +62,7 @@ unsigned long long Slab = 0; scan_one( MemInfoBuf, "MemTotal", &Total ); scan_one( MemInfoBuf, "MemFree", &MFree ); + scan_one( MemInfoBuf, "MemAvailable", &Available ); scan_one( MemInfoBuf, "Buffers", &Buffers ); scan_one( MemInfoBuf, "Cached", &Cached ); scan_one( MemInfoBuf, "Slab", &Slab ); @@ -71,6 +74,8 @@ Used = Total - MFree; Appl = ( Used - ( Buffers + Cached ) ); + Allocated = Total - Available; + if ( STotal == 0 ) /* no swap activated */ SUsed = 0; else @@ -92,11 +97,14 @@ if ( updateMemory() < 0 ) return; + registerMonitor( "mem/physical/total", "integer", printTotal, printTotalInfo, sm ); registerMonitor( "mem/physical/free", "integer", printMFree, printMFreeInfo, sm ); + registerMonitor( "mem/physical/available", "integer", printAvailable, printAvailableInfo, sm ); registerMonitor( "mem/physical/used", "integer", printUsed, printUsedInfo, sm ); registerMonitor( "mem/physical/application", "integer", printAppl, printApplInfo, sm ); registerMonitor( "mem/physical/buf", "integer", printBuffers, printBuffersInfo, sm ); registerMonitor( "mem/physical/cached", "integer", printCached, printCachedInfo, sm ); + registerMonitor( "mem/physical/allocated", "integer", printAllocated, printAllocatedInfo, sm ); registerMonitor( "mem/swap/used", "integer", printSwapUsed, printSwapUsedInfo, sm ); registerMonitor( "mem/swap/free", "integer", printSwapFree, printSwapFreeInfo, sm ); registerMonitor( "mem/cache/dirty", "integer", printCDirty, printCDirtyInfo, sm); @@ -161,6 +169,26 @@ return 0; } +void printTotal( const char* cmd ) +{ + (void)cmd; + + if ( Dirty ) + processMemInfo(); + + output( "%llu\n", Total ); +} + +void printTotalInfo( const char* cmd ) +{ + (void)cmd; + + if ( Dirty ) + processMemInfo(); + + output( "Total Memory\t0\t%llu\tKB\n", Total ); +} + void printMFree( const char* cmd ) { (void)cmd; @@ -181,6 +209,26 @@ output( "Free Memory\t0\t%llu\tKB\n", Total ); } +void printAvailable( const char* cmd ) +{ + (void)cmd; + + if ( Dirty ) + processMemInfo(); + + output( "%llu\n", Available ); +} + +void printAvailableInfo( const char* cmd ) +{ + (void)cmd; + + if ( Dirty ) + processMemInfo(); + + output( "Available Memory\t0\t%llu\tKB\n", Total ); +} + void printUsed( const char* cmd ) { (void)cmd; @@ -261,6 +309,26 @@ output( "Cached Memory\t0\t%llu\tKB\n", Total ); } +void printAllocated( const char* cmd ) +{ + (void)cmd; + + if ( Dirty ) + processMemInfo(); + + output( "%llu\n", Allocated ); +} + +void printAllocatedInfo( const char* cmd ) +{ + (void)cmd; + + if ( Dirty ) + processMemInfo(); + + output( "Allocated Memory\t0\t%llu\tKB\n", Total ); +} + void printSwapUsed( const char* cmd ) { (void)cmd;