GNUnet  0.10.x
Data Structures | Macros | Typedefs | Functions | Variables
gnunet-service-testbed_meminfo.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
Include dependency graph for gnunet-service-testbed_meminfo.c:

Go to the source code of this file.

Data Structures

struct  mem_table_struct
 

Macros

#define BAD_OPEN_MESSAGE
 
#define STAT_FILE   "/proc/stat"
 
#define UPTIME_FILE   "/proc/uptime"
 
#define LOADAVG_FILE   "/proc/loadavg"
 
#define MEMINFO_FILE   "/proc/meminfo"
 
#define VMINFO_FILE   "/proc/vmstat"
 
#define FILE_TO_BUF(filename, fd)
 

Typedefs

typedef struct mem_table_struct mem_table_struct
 

Functions

static int compare_mem_table_structs (const void *a, const void *b)
 
void meminfo (void)
 

Variables

static int meminfo_fd = -1
 
static char buf [2048]
 
unsigned long kb_main_shared
 
unsigned long kb_main_buffers
 
unsigned long kb_main_cached
 
unsigned long kb_main_free
 
unsigned long kb_main_total
 
unsigned long kb_swap_free
 
unsigned long kb_swap_total
 
unsigned long kb_high_free
 
unsigned long kb_high_total
 
unsigned long kb_low_free
 
unsigned long kb_low_total
 
unsigned long kb_active
 
unsigned long kb_inact_laundry
 
unsigned long kb_inact_dirty
 
unsigned long kb_inact_clean
 
unsigned long kb_inact_target
 
unsigned long kb_swap_cached
 
unsigned long kb_swap_used
 
unsigned long kb_main_used
 
unsigned long kb_writeback
 
unsigned long kb_slab
 
unsigned long nr_reversemaps
 
unsigned long kb_committed_as
 
unsigned long kb_dirty
 
unsigned long kb_inactive
 
unsigned long kb_mapped
 
unsigned long kb_pagetables
 
static unsigned long kb_vmalloc_chunk
 
static unsigned long kb_vmalloc_total
 
static unsigned long kb_vmalloc_used
 
static unsigned long kb_anon_pages
 
static unsigned long kb_bounce
 
static unsigned long kb_commit_limit
 
static unsigned long kb_nfs_unstable
 
static unsigned long kb_swap_reclaimable
 
static unsigned long kb_swap_unreclaimable
 

Macro Definition Documentation

◆ BAD_OPEN_MESSAGE

#define BAD_OPEN_MESSAGE
Value:
"Error: /proc must be mounted\n" \
" To mount /proc at boot you need an /etc/fstab line like:\n" \
" proc /proc proc defaults\n" \
" In the meantime, run \"mount proc /proc -t proc\"\n"

Definition at line 45 of file gnunet-service-testbed_meminfo.c.

◆ STAT_FILE

#define STAT_FILE   "/proc/stat"

Definition at line 51 of file gnunet-service-testbed_meminfo.c.

◆ UPTIME_FILE

#define UPTIME_FILE   "/proc/uptime"

Definition at line 53 of file gnunet-service-testbed_meminfo.c.

◆ LOADAVG_FILE

#define LOADAVG_FILE   "/proc/loadavg"

Definition at line 55 of file gnunet-service-testbed_meminfo.c.

◆ MEMINFO_FILE

#define MEMINFO_FILE   "/proc/meminfo"

Definition at line 57 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ VMINFO_FILE

#define VMINFO_FILE   "/proc/vmstat"

Definition at line 59 of file gnunet-service-testbed_meminfo.c.

◆ FILE_TO_BUF

#define FILE_TO_BUF (   filename,
  fd 
)
Value:
do { \
static int local_n; \
if (fd == -1 && (fd = open(filename, O_RDONLY)) == -1) { \
fputs(BAD_OPEN_MESSAGE, stderr); \
fflush(NULL); \
_exit(102); \
} \
lseek(fd, 0L, SEEK_SET); \
if ((local_n = read(fd, buf, sizeof buf - 1)) < 0) { \
perror(filename); \
fflush(NULL); \
_exit(103); \
} \
buf[local_n] = '\0'; \
} while (0)
#define BAD_OPEN_MESSAGE
static char buf[2048]
static char * filename

Definition at line 70 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

Typedef Documentation

◆ mem_table_struct

Function Documentation

◆ compare_mem_table_structs()

static int compare_mem_table_structs ( const void *  a,
const void *  b 
)
static

Definition at line 104 of file gnunet-service-testbed_meminfo.c.

References mem_table_struct::name.

Referenced by meminfo().

105 {
106  return strcmp(((const mem_table_struct*)a)->name, ((const mem_table_struct*)b)->name);
107 }
const char * name
Here is the caller graph for this function:

◆ meminfo()

void meminfo ( void  )

Definition at line 186 of file gnunet-service-testbed_meminfo.c.

References buf, compare_mem_table_structs(), FILE_TO_BUF, head, kb_active, kb_anon_pages, kb_bounce, kb_commit_limit, kb_committed_as, kb_dirty, kb_high_free, kb_high_total, kb_inact_clean, kb_inact_dirty, kb_inact_laundry, kb_inact_target, kb_inactive, kb_low_free, kb_low_total, kb_main_buffers, kb_main_cached, kb_main_free, kb_main_shared, kb_main_total, kb_main_used, kb_mapped, kb_nfs_unstable, kb_pagetables, kb_slab, kb_swap_cached, kb_swap_free, kb_swap_reclaimable, kb_swap_total, kb_swap_unreclaimable, kb_swap_used, kb_vmalloc_chunk, kb_vmalloc_total, kb_vmalloc_used, kb_writeback, meminfo_fd, MEMINFO_FILE, nr_reversemaps, mem_table_struct::slot, and tail.

Referenced by mem_get_usage().

187 {
188  char namebuf[16]; /* big enough to hold any row name */
189  mem_table_struct findme = { namebuf, NULL };
190  mem_table_struct *found;
191  char *head;
192  char *tail;
193  static const mem_table_struct mem_table[] = {
194  { "Active", &kb_active }, // important
195  { "AnonPages", &kb_anon_pages },
196  { "Bounce", &kb_bounce },
197  { "Buffers", &kb_main_buffers }, // important
198  { "Cached", &kb_main_cached }, // important
199  { "CommitLimit", &kb_commit_limit },
200  { "Committed_AS", &kb_committed_as },
201  { "Dirty", &kb_dirty }, // kB version of vmstat nr_dirty
202  { "HighFree", &kb_high_free },
203  { "HighTotal", &kb_high_total },
204  { "Inact_clean", &kb_inact_clean },
205  { "Inact_dirty", &kb_inact_dirty },
206  { "Inact_laundry", &kb_inact_laundry },
207  { "Inact_target", &kb_inact_target },
208  { "Inactive", &kb_inactive }, // important
209  { "LowFree", &kb_low_free },
210  { "LowTotal", &kb_low_total },
211  { "Mapped", &kb_mapped }, // kB version of vmstat nr_mapped
212  { "MemFree", &kb_main_free }, // important
213  { "MemShared", &kb_main_shared }, // important, but now gone!
214  { "MemTotal", &kb_main_total }, // important
215  { "NFS_Unstable", &kb_nfs_unstable },
216  { "PageTables", &kb_pagetables }, // kB version of vmstat nr_page_table_pages
217  { "ReverseMaps", &nr_reversemaps }, // same as vmstat nr_page_table_pages
218  { "SReclaimable", &kb_swap_reclaimable }, // "swap reclaimable" (dentry and inode structures)
219  { "SUnreclaim", &kb_swap_unreclaimable },
220  { "Slab", &kb_slab }, // kB version of vmstat nr_slab
221  { "SwapCached", &kb_swap_cached },
222  { "SwapFree", &kb_swap_free }, // important
223  { "SwapTotal", &kb_swap_total }, // important
224  { "VmallocChunk", &kb_vmalloc_chunk },
225  { "VmallocTotal", &kb_vmalloc_total },
226  { "VmallocUsed", &kb_vmalloc_used },
227  { "Writeback", &kb_writeback }, // kB version of vmstat nr_writeback
228  };
229  const int mem_table_count = sizeof(mem_table) / sizeof(mem_table_struct);
230 
232 
233  kb_inactive = ~0UL;
234 
235  head = buf;
236  for (;;)
237  {
238  tail = strchr(head, ':');
239  if (!tail)
240  break;
241  *tail = '\0';
242  if (strlen(head) >= sizeof(namebuf))
243  {
244  head = tail + 1;
245  goto nextline;
246  }
247  strcpy(namebuf, head);
248  found = bsearch(&findme, mem_table, mem_table_count,
250  );
251  head = tail + 1;
252  if (!found)
253  goto nextline;
254  *(found->slot) = (unsigned long)strtoull(head, &tail, 10);
255 nextline:
256  tail = strchr(head, '\n');
257  if (!tail)
258  break;
259  head = tail + 1;
260  }
261  if (!kb_low_total) /* low==main except with large-memory support */
262  {
265  }
266  if (kb_inactive == ~0UL)
267  {
269  }
272 }
unsigned long kb_swap_used
#define FILE_TO_BUF(filename, fd)
static unsigned long kb_vmalloc_chunk
unsigned long kb_low_total
unsigned long kb_inact_laundry
unsigned long kb_main_used
unsigned long kb_swap_cached
static unsigned long kb_anon_pages
static unsigned long kb_vmalloc_used
unsigned long kb_main_cached
unsigned long kb_main_free
unsigned long kb_mapped
unsigned long kb_main_shared
static int meminfo_fd
static int compare_mem_table_structs(const void *a, const void *b)
static unsigned long kb_swap_reclaimable
unsigned long kb_main_total
static unsigned long kb_commit_limit
static unsigned long kb_swap_unreclaimable
static char buf[2048]
unsigned long kb_high_total
static unsigned long kb_vmalloc_total
#define MEMINFO_FILE
unsigned long kb_writeback
unsigned long kb_inact_target
static unsigned long kb_bounce
unsigned long kb_inactive
unsigned long kb_low_free
unsigned long nr_reversemaps
static unsigned long kb_nfs_unstable
unsigned long kb_pagetables
static struct PendingResolutions * head
Head of list of pending resolution requests.
Definition: gnunet-ats.c:228
unsigned long kb_inact_dirty
unsigned long kb_inact_clean
unsigned long kb_slab
static struct PendingResolutions * tail
Tail of list of pending resolution requests.
Definition: gnunet-ats.c:233
unsigned long kb_main_buffers
unsigned long kb_swap_free
unsigned long kb_active
unsigned long kb_dirty
unsigned long kb_committed_as
unsigned long kb_swap_total
unsigned long kb_high_free
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ meminfo_fd

int meminfo_fd = -1
static

Definition at line 58 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ buf

char buf[2048]
static

Definition at line 64 of file gnunet-service-testbed_meminfo.c.

Referenced by adjust(), aes_128_cbc_encrypt(), allocation_cb(), attr_store_task(), auth_key_to_string(), bind_rsa_pub(), bind_rsa_sig(), check_local_data(), check_proof_of_work(), compute_policy(), conclude_autoconfig_request(), copy_from_reader(), count_and_separate_strings(), diffname(), display_bar(), display_record(), dns_result_parser(), do_accept(), do_dns_read(), do_reject(), do_resume(), do_send(), do_transmit(), download_cb(), encapsulate_for_dv(), estate2s(), extract_files(), file_generator(), find_proof(), finish_request(), forward_dv_box(), forward_dv_learn(), fwrite_le16(), fwrite_le32(), GCC_2s(), GCCH_2s(), GCP_2s(), GCPP_2s(), GCT_2s(), gen_topo_from_file(), get_class(), get_hello_address_size(), get_path_from_PATH(), get_type(), GNUNET_a2s(), GNUNET_BIO_read_meta_data(), GNUNET_BIO_read_string(), GNUNET_BIO_write_meta_data(), GNUNET_CRYPTO_crc16_n(), GNUNET_CRYPTO_crc16_step(), GNUNET_CRYPTO_crc8_n(), GNUNET_CRYPTO_kdf_mod_mpi(), GNUNET_CRYPTO_rsa_public_key_hash(), GNUNET_DISK_file_copy(), GNUNET_FRAGMENT_print_ack(), GNUNET_FRIENDS_write(), GNUNET_GNSRECORD_z2s(), GNUNET_i2s(), GNUNET_i2s2(), GNUNET_i2s_full(), GNUNET_JSON_from_data(), GNUNET_JSON_from_rsa_public_key(), GNUNET_JSON_from_rsa_signature(), GNUNET_MST_read(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_NAT_request_reversal(), GNUNET_NAT_stun_handle_packet(), GNUNET_OS_init(), GNUNET_REVOCATION_check_pow(), GNUNET_SECRETSHARING_share_write(), GNUNET_SERVER_inject(), GNUNET_sh2s(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_pp2s(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TESTBED_hosts_load_from_file(), GNUNET_uuid2s(), GSC_2s(), GSC_CLIENTS_deliver_message(), GSF_dht_lookup_(), handle_data(), handle_dns_request(), handle_encrypted(), handle_external_ip(), handle_icmp_back(), handle_icmp_remote(), handle_icmp_service(), handle_local_data(), handle_lookup_block_response(), handle_lookup_timeout(), handle_request_connection_reversal(), handle_stun(), handle_tcp_back(), handle_tcp_data(), handle_tcp_remote(), handle_udp_back(), handle_udp_remote(), helper_read(), helper_write(), load(), load_etc_hosts(), lookup_dns_servers(), make_reverse_hostname(), meminfo(), merge_addr(), message_token(), modify_record(), modify_request(), mpi_to_str(), my_conv_rsa_public_key(), my_conv_rsa_signature(), mylog(), neighbours_connect_notification(), netint_proc(), next_rnd(), no_resolve(), notify_client(), parse_rsa_public_key(), parse_rsa_signature(), play(), policy_filename_cb(), post_extract_rsa_public_key(), post_extract_rsa_signature(), post_extract_string(), post_extract_varsize_blob(), print_examples_ecdh(), process_icmp_response(), process_if(), process_payload(), process_record(), publish_fs_connect_complete_cb(), qconv_rsa_public_key(), qconv_rsa_signature(), read_dns4(), read_dns6(), read_stdio(), read_task(), reply_to_dns(), request_done(), requester_callback(), restore_valid_peers(), select_read_cb(), send_ack(), send_hello_beacon(), send_icmp_packet_via_tun(), send_response(), send_tcp_packet_via_tun(), send_udp_packet_via_tun(), set_external_ipv4(), setup_state_record(), sock_read(), start_insert(), strata_estimator_write(), stun_read_task(), tcp_from_helper(), tcp_plugin_address_to_string(), tmt_rdy_ping(), tokenized_cb(), transmit_cummulative_ack_cb(), transmit_fragment(), udp_address_to_string(), udp_ipv4_broadcast_send(), udp_ipv6_broadcast_send(), udp_select_read(), union_accept(), unix_plugin_do_read(), uri_sks_to_string(), url_decode(), url_encode(), wlan_plugin_send(), and write_all().

◆ kb_main_shared

unsigned long kb_main_shared

Definition at line 142 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_main_buffers

unsigned long kb_main_buffers

Definition at line 144 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_main_cached

unsigned long kb_main_cached

Definition at line 145 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_main_free

unsigned long kb_main_free

Definition at line 146 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_main_total

unsigned long kb_main_total

Definition at line 147 of file gnunet-service-testbed_meminfo.c.

Referenced by mem_get_usage(), and meminfo().

◆ kb_swap_free

unsigned long kb_swap_free

Definition at line 148 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_swap_total

unsigned long kb_swap_total

Definition at line 149 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_high_free

unsigned long kb_high_free

Definition at line 151 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_high_total

unsigned long kb_high_total

Definition at line 152 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_low_free

unsigned long kb_low_free

Definition at line 153 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_low_total

unsigned long kb_low_total

Definition at line 154 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_active

unsigned long kb_active

Definition at line 156 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_inact_laundry

unsigned long kb_inact_laundry

Definition at line 157 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_inact_dirty

unsigned long kb_inact_dirty

Definition at line 158 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_inact_clean

unsigned long kb_inact_clean

Definition at line 159 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_inact_target

unsigned long kb_inact_target

Definition at line 160 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_swap_cached

unsigned long kb_swap_cached

Definition at line 161 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_swap_used

unsigned long kb_swap_used

Definition at line 163 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_main_used

unsigned long kb_main_used

Definition at line 164 of file gnunet-service-testbed_meminfo.c.

Referenced by mem_get_usage(), and meminfo().

◆ kb_writeback

unsigned long kb_writeback

Definition at line 166 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_slab

unsigned long kb_slab

Definition at line 167 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ nr_reversemaps

unsigned long nr_reversemaps

Definition at line 168 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_committed_as

unsigned long kb_committed_as

Definition at line 169 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_dirty

unsigned long kb_dirty

Definition at line 170 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_inactive

unsigned long kb_inactive

Definition at line 171 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_mapped

unsigned long kb_mapped

Definition at line 172 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_pagetables

unsigned long kb_pagetables

Definition at line 173 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_vmalloc_chunk

unsigned long kb_vmalloc_chunk
static

Definition at line 175 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_vmalloc_total

unsigned long kb_vmalloc_total
static

Definition at line 176 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_vmalloc_used

unsigned long kb_vmalloc_used
static

Definition at line 177 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_anon_pages

unsigned long kb_anon_pages
static

Definition at line 179 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_bounce

unsigned long kb_bounce
static

Definition at line 180 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_commit_limit

unsigned long kb_commit_limit
static

Definition at line 181 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_nfs_unstable

unsigned long kb_nfs_unstable
static

Definition at line 182 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_swap_reclaimable

unsigned long kb_swap_reclaimable
static

Definition at line 183 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_swap_unreclaimable

unsigned long kb_swap_unreclaimable
static

Definition at line 184 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().