{"latency-avg100", &latencyAvg100}, {"latency-avg1000", &latencyAvg1000},
{"latency-avg10000", &latencyAvg10000}, {"latency-avg1000000", &latencyAvg1000000},
{"uptime", uptimeOfProcess},
- {"real-memory-usage", getRealMemoryUsage}
+ {"real-memory-usage", getRealMemoryUsage},
+ {"fd-usage", getOpenFileDescriptors}
};
};
#include <errno.h>
#include <cstring>
#include <iostream>
+#include <sys/types.h>
+#include <dirent.h>
#include <algorithm>
#include <boost/optional.hpp>
#include <poll.h>
throw PDNSException("getTSIGAlgoName does not understand given algorithm, please fix!");
}
+uint64_t getOpenFileDescriptors(const std::string&)
+{
+#ifdef __linux__
+ DIR* dirhdl=opendir(("/proc/"+std::to_string(getpid())+"/fd/").c_str());
+ if(!dirhdl)
+ return 0;
+
+ struct dirent *entry;
+ int ret=0;
+ while((entry = readdir(dirhdl))) {
+ uint32_t num = atoi(entry->d_name);
+ if(std::to_string(num) == entry->d_name)
+ ret++;
+ }
+ closedir(dirhdl);
+ return ret;
+
+#else
+ return 0;
+#endif
+}
+
uint64_t getRealMemoryUsage(const std::string&)
{
#ifdef __linux__
uint64_t udpErrorStats(const std::string& str);
uint64_t getRealMemoryUsage(const std::string&);
+uint64_t getOpenFileDescriptors(const std::string&);
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)