diff --git a/Makefile.am b/Makefile.am index 97ecf43d5..a6572abb6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -375,6 +375,7 @@ endif # -------------------------- pcp_platform_headers = \ + FileDescriptorMeter.h \ linux/PressureStallMeter.h \ linux/ZramMeter.h \ linux/ZramStats.h \ @@ -390,6 +391,7 @@ pcp_platform_headers = \ zfs/ZfsCompressedArcMeter.h pcp_platform_sources = \ + FileDescriptorMeter.c \ linux/PressureStallMeter.c \ linux/ZramMeter.c \ pcp/PCPDynamicColumn.c \ diff --git a/pcp/PCPMetric.h b/pcp/PCPMetric.h index aa0e2a7aa..cac988c9e 100644 --- a/pcp/PCPMetric.h +++ b/pcp/PCPMetric.h @@ -91,6 +91,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 b3d6ed4a3..9a4b275b1 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" @@ -114,6 +115,7 @@ const MeterClass* const Platform_meterTypes[] = { &DiskIOMeter_class, &NetworkIOMeter_class, &SysArchMeter_class, + &FileDescriptorMeter_class, NULL }; @@ -189,6 +191,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", @@ -699,6 +703,17 @@ bool Platform_getNetworkIO(NetworkIOData* data) { return true; } +void Platform_getFileDescriptors(double* used, double* max) { + *used = NAN; + *max = NAN; + + 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 dc51c736c..cc0fad62a 100644 --- a/pcp/Platform.h +++ b/pcp/Platform.h @@ -133,6 +133,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);