38 static void init_options() {
40 (
"my-ip",
"Display the primary IP Address of the host")
41 (
"install-dir",
"Display install directory")
42 (
"property,p",
strs(),
"Display the value of the specified property")
47 typedef Meta::list<MyPolicy, DefaultPolicy>
Policies;
51 cout << System::cpu_info() << endl;
52 cout << System::cpu_stat() << endl;
53 cout << System::mem_stat() << endl;
54 cout << System::disk_stat() << endl;
55 cout << System::os_info() << endl;
56 cout << System::swap_stat() << endl;
57 cout << System::net_info() << endl;
58 cout << System::net_stat() << endl;
59 cout << System::proc_info() << endl;
60 cout << System::proc_stat() << endl;
61 cout << System::fs_stat() << endl;
62 cout << System::term_info() << endl;
63 cout <<
"{System: install_dir='" << System::install_dir
64 <<
"' exe_name='" << System::exe_name <<
"'}" << endl;
69 int main(
int ac,
char *av[]) {
70 init_with_policies<Policies>(ac, av);
71 bool has_option =
false;
74 cout << System::net_info().primary_addr << endl;
77 if (
has(
"install-dir")) {
78 cout << System::install_dir << endl;
81 if (
has(
"property")) {
85 cout << Properties::to_str((*
properties)[s]) << endl;
Interface and base of config policy.
PropertiesPtr properties
This singleton map stores all options.
std::vector< String > Strings
Desc & cmdline_desc(const char *usage)
A macro which definds global functions like get_bool(), get_str(), get_i16() etc. ...
bool has(const String &name)
Check existence of a configuration value.
Compatibility Macros for C/C++.
Initialization helper for applications.
int main(int ac, char *av[])
Po::typed_value< Strings > * strs(Strings *v=0)
const char * system_info_lib_version()
Returns a descriptive string of the libsigar version.
Meta::list< MyPolicy, DefaultPolicy > Policies
System information and statistics based on libsigar.