32 #include <boost/algorithm/string.hpp>
33 #include <boost/filesystem.hpp>
51 lock_guard<mutex> lock(ms_mutex);
52 return _locate_install_dir(argv0);
57 if (!install_dir.empty())
62 Path exepath(proc_info().exe);
75 if (install_directory.empty()) {
76 install_dir = _locate_install_dir(proc_info().exe.c_str());
80 install_dir = install_directory;
81 while (boost::ends_with(install_dir,
"/"))
82 install_dir = install_dir.substr(0, install_dir.length()-1);
88 exe_name =
Path(proc_info().args[0]).
filename().generic_string();
95 memset(tmval, 0,
sizeof(
struct tm));
104 return cpu_info().total_cores;
108 int32_t drive_count = 0;
115 #if defined(__linux__)
116 String device_regex =
"sd[a-z][a-z]?|hd[a-z][a-z]?";
117 #elif defined(__APPLE__)
118 String device_regex =
"disk[0-9][0-9]?";
123 vector<struct dirent> listing;
127 drive_count = listing.size();
133 return proc_info().pid;
void initialize(const String &name)
Public initialization function - creates a singleton instance of LogWriter.
static bool ms_initialized
true if initialize was already called
std::string String
A String is simply a typedef to std::string.
Compatibility class for boost::filesystem::path.
static String tm_zone
Timezone abbreviation.
static void initialize_tm(struct tm *tmval)
Initialize struct tm.
static int32_t get_processor_count()
The processor count.
static long tm_gmtoff
Seconds east of UTC.
Compatibility class for boost::filesystem::path.
File system utility functions.
static String exe_name
The exe file name.
Logging routines and macros.
Compatibility Macros for C/C++.
Represents a cluster definition.
static int32_t get_drive_count()
Returns the number of drives.
static std::mutex ms_mutex
a Mutex to protect the static members
static void readdir(const String &dirname, const String &fname_regex, std::vector< struct dirent > &listing)
Reads all directory entries, applies a regular expression and returns those which match...
static String locate_install_dir(const char *argv0)
Returns the installation directory.
static String install_dir
The installation directory.
static void _init(const String &install_directory)
Internal initialization helper.
static std::unique_ptr< ClusterDefinition::ClusterDefinition > cluster_def
Cluster definition.
static int32_t get_pid()
The pid of the current process.
System information and statistics based on libsigar.
static String _locate_install_dir(const char *argv0)
Returns the installation directory; same as locate_install_dir but does not lock ms_mutex.