diff options
author | Sohaib Mohamed <sohaib.amhmd@gmail.com> | 2022-05-04 09:55:43 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2023-02-19 17:56:50 +0100 |
commit | bdb63a497beeb4b317296ca123c507233a2af889 (patch) | |
tree | bffc8cc1105326e719aa21fccbe3bb3efdfe1aea /pcp | |
parent | 62f4628efef67280c7c480dcd5df65867bd4d960 (diff) |
Implement File Descriptor Meter support for PCP
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
Diffstat (limited to 'pcp')
-rw-r--r-- | pcp/PCPMetric.h | 2 | ||||
-rw-r--r-- | pcp/Platform.c | 15 | ||||
-rw-r--r-- | pcp/Platform.h | 2 |
3 files changed, 19 insertions, 0 deletions
diff --git a/pcp/PCPMetric.h b/pcp/PCPMetric.h index c0966b38..e89a0a4c 100644 --- a/pcp/PCPMetric.h +++ b/pcp/PCPMetric.h @@ -93,6 +93,8 @@ typedef enum PCPMetric_ { PCP_ZRAM_CAPACITY, /* zram.capacity */ PCP_ZRAM_ORIGINAL, /* zram.mm_stat.data_size.original */ PCP_ZRAM_COMPRESSED, /* zram.mm_stat.data_size.compressed */ + PCP_VFS_FILES_COUNT, /* vfs.files.count */ + PCP_VFS_FILES_MAX, /* vfs.files.max */ PCP_PROC_PID, /* proc.psinfo.pid */ PCP_PROC_PPID, /* proc.psinfo.ppid */ diff --git a/pcp/Platform.c b/pcp/Platform.c index d9f75ebc..a76c0288 100644 --- a/pcp/Platform.c +++ b/pcp/Platform.c @@ -25,6 +25,7 @@ in the source distribution for its full text. #include "DiskIOMeter.h" #include "DynamicColumn.h" #include "DynamicMeter.h" +#include "FileDescriptorMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Macros.h" @@ -115,6 +116,7 @@ const MeterClass* const Platform_meterTypes[] = { &DiskIOMeter_class, &NetworkIOMeter_class, &SysArchMeter_class, + &FileDescriptorMeter_class, NULL }; @@ -192,6 +194,8 @@ static const char* Platform_metricNames[] = { [PCP_ZRAM_CAPACITY] = "zram.capacity", [PCP_ZRAM_ORIGINAL] = "zram.mm_stat.data_size.original", [PCP_ZRAM_COMPRESSED] = "zram.mm_stat.data_size.compressed", + [PCP_VFS_FILES_COUNT] = "vfs.files.count", + [PCP_VFS_FILES_MAX] = "vfs.files.max", [PCP_PROC_PID] = "proc.psinfo.pid", [PCP_PROC_PPID] = "proc.psinfo.ppid", @@ -727,6 +731,17 @@ bool Platform_getNetworkIO(NetworkIOData* data) { return true; } +void Platform_getFileDescriptors(double* used, double* max) { + *used = NAN; + *max = 65536; + + pmAtomValue value; + if (PCPMetric_values(PCP_VFS_FILES_COUNT, &value, 1, PM_TYPE_32) != NULL) + *used = value.l; + if (PCPMetric_values(PCP_VFS_FILES_MAX, &value, 1, PM_TYPE_32) != NULL) + *max = value.l; +} + void Platform_getBattery(double* level, ACPresence* isOnAC) { *level = NAN; *isOnAC = AC_ERROR; diff --git a/pcp/Platform.h b/pcp/Platform.h index f06f2266..f90e2813 100644 --- a/pcp/Platform.h +++ b/pcp/Platform.h @@ -131,6 +131,8 @@ extern pmOptions opts; size_t Platform_addMetric(PCPMetric id, const char* name); +void Platform_getFileDescriptors(double* used, double* max); + void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec); void Platform_gettime_monotonic(uint64_t* msec); |