GNUnet  0.19.4
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.

◆ 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)
static char * filename
#define BAD_OPEN_MESSAGE
static char buf[2048]

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

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 106 of file gnunet-service-testbed_meminfo.c.

107 {
108  return strcmp (((const mem_table_struct *) a)->name, ((const
109  mem_table_struct *) b)
110  ->
111  name);
112 }
const char * name

References name.

Referenced by meminfo().

Here is the caller graph for this function:

◆ meminfo()

void meminfo ( void  )

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

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

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().

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 add_from_hello(), add_search_string(), add_valid_peer_address(), address_generator(), adjust(), allocation_cb(), attr_store_task(), auth_key_to_string(), bind_rsa_pub(), bind_rsa_sig(), block_reader(), buffer_append(), buffer_deinit(), buffer_init(), calc_crc_osdep(), calculate_hmac(), check_crc_buf_osdep(), check_dht_p2p_put(), check_local_data(), compute_policy(), conclude_autoconfig_request(), continue_store_activity(), copy_from_reader(), count_and_separate_strings(), create_source(), cred_add_cb(), curl_upload_cb(), d2j(), deserialize_search_file(), display_bar(), display_record(), dns_result_parser(), do_accept(), do_dns_read(), do_resume(), do_send(), do_transmit(), download_cb(), dump_buffer(), estate2s(), extract_files(), fh_reader(), file_generator(), find_proof(), finish_request(), forward_dv_box(), forward_dv_learn(), fwrite_le16(), fwrite_le32(), GCC_2s(), GCCH_2s(), GCCH_handle_local_data(), GCP_2s(), GCPP_2s(), GCT_2s(), gen_topo_from_file(), get_class(), get_hello_address_size(), get_message(), get_path_from_PATH(), get_type(), gn_crc32(), GNUNET_a2s(), GNUNET_asprintf(), GNUNET_b2s(), GNUNET_BIO_read_string(), GNUNET_buffer_clear(), GNUNET_buffer_ensure_remaining(), GNUNET_buffer_prealloc(), GNUNET_buffer_reap(), GNUNET_buffer_reap_str(), GNUNET_buffer_write(), GNUNET_buffer_write_data_encoded(), GNUNET_buffer_write_fstr(), GNUNET_buffer_write_path(), GNUNET_buffer_write_str(), GNUNET_buffer_write_vfstr(), GNUNET_CONFIGURATION_serialize_diagnostics(), GNUNET_CRYPTO_crc16_n(), GNUNET_CRYPTO_crc16_step(), GNUNET_CRYPTO_crc32_n(), GNUNET_CRYPTO_crc8_n(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hkdf(), GNUNET_CRYPTO_kdf_mod_mpi(), GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_CRYPTO_pow_hash(), GNUNET_CRYPTO_rsa_private_key_decode(), GNUNET_CRYPTO_rsa_public_key_decode(), GNUNET_CRYPTO_rsa_public_key_encode(), GNUNET_CRYPTO_rsa_public_key_hash(), GNUNET_CRYPTO_rsa_signature_decode(), GNUNET_CRYPTO_rsa_signature_encode(), GNUNET_DHT_pp2s(), GNUNET_DNSPARSER_pack(), GNUNET_FRAGMENT_print_ack(), GNUNET_FRIENDS_write(), GNUNET_FS_data_reader_copy_(), GNUNET_FS_data_reader_file_(), GNUNET_FS_read_meta_data(), GNUNET_GNS_lookup_limited(), GNUNET_GNSRECORD_z2s(), GNUNET_HELLO_builder_to_dht_hello_msg(), GNUNET_i2s(), GNUNET_i2s2(), GNUNET_i2s_full(), GNUNET_JSON_from_data(), GNUNET_JSON_from_data64(), GNUNET_JSON_from_rsa_public_key(), GNUNET_JSON_from_rsa_signature(), GNUNET_MY_result_spec_absolute_time(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_NAT_request_reversal(), GNUNET_NAT_stun_handle_packet(), GNUNET_PQ_query_param_rsa_public_key(), GNUNET_PQ_query_param_rsa_signature(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_credential_delete(), GNUNET_RECLAIM_credential_store(), GNUNET_RECLAIM_ticket_consume(), GNUNET_RECLAIM_ticket_issue(), GNUNET_RECLAIM_ticket_revoke(), GNUNET_SECRETSHARING_share_write(), GNUNET_SERVER_mst_receive(), GNUNET_sh2s(), GNUNET_snprintf(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_check_filename(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_STRINGS_urlencode(), GNUNET_TESTBED_hosts_load_from_file(), GNUNET_TIME_absolute2s(), GNUNET_TIME_timestamp2s(), GNUNET_uuid2s(), GNUNET_xmemdup_(), GSC_2s(), GSC_CLIENTS_deliver_message(), GSF_dht_lookup_(), handle_attribute_delete_message(), handle_attribute_result(), handle_attribute_store_message(), handle_client_accept(), handle_consume_ticket_message(), handle_credential_delete_message(), handle_credential_result(), handle_credential_store_message(), handle_data(), handle_dns_request(), handle_encrypted(), handle_external_ip(), handle_icmp_back(), handle_icmp_remote(), handle_icmp_service(), handle_issue_ticket_message(), handle_local_data(), handle_lookup_block_response(), handle_lookup_timeout(), handle_record_store(), handle_request_connection_reversal(), handle_revoke_ticket_message(), handle_stun(), handle_tcp_back(), handle_tcp_data(), handle_tcp_remote(), handle_ticket_result(), handle_udp_back(), handle_udp_remote(), helper_read(), helper_write(), ibf_read_slice(), ibf_write_slice(), initiate_put_from_pipe_trigger(), ip_send(), linux_read(), load(), load_etc_hosts(), login_redirect(), lookup_dns_servers(), main(), maint_child_death(), make_reverse_hostname(), make_up_icmp_service_payload(), meminfo(), merge_addr(), message_token(), mhd_content_cb(), modify_record(), modify_request(), mpi_to_str(), mst_receive(), my_conv_rsa_public_key(), my_conv_rsa_signature(), mylog(), neighbours_connect_notification(), netint_proc(), no_resolve(), notify_client(), notify_send_probe(), pack_counter(), parse(), play(), policy_filename_cb(), post_extract_rsa_public_key(), post_extract_rsa_signature(), post_extract_varsize_blob(), print_bytes(), print_bytes_(), print_examples_ecdh(), print_hex(), process_command_stdin(), process_icmp_response(), process_if(), process_incoming(), process_record(), publish_fs_connect_complete_cb(), read_cb(), read_dns4(), read_dns6(), read_from_file(), read_from_the_socket(), read_stdio(), read_task(), receiver(), relative_multiply_double(), 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_ticket_result(), send_udp_packet_via_tun(), server_send_callback(), set_external_ipv4(), setup_state_record(), sock_read(), start_insert(), strata_estimator_read(), strata_estimator_write(), stun_read_task(), tcp_from_helper(), tcp_plugin_address_to_string(), tcp_plugin_string_to_address(), tmt_rdy_ping(), tmt_rdy_pong(), to_file_raw(), to_file_raw_unaligned(), tokenized_cb(), transmit_address_to_client(), transmit_cummulative_ack_cb(), transmit_fragment(), transmit_ready(), transmit_ready_callback_wrapper(), try_handle_plaintext(), udp_address_to_string(), udp_broadcast_receive(), udp_ipv4_broadcast_send(), udp_ipv6_broadcast_send(), udp_select_read(), udp_string_to_address(), unindex_reader(), union_accept(), unix_plugin_do_read(), unpack_counter(), uri_sks_to_string(), wlan_plugin_send(), wlan_plugin_string_to_address(), write_all(), and write_test().

◆ kb_main_shared

unsigned long kb_main_shared

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

Referenced by meminfo().

◆ kb_main_buffers

unsigned long kb_main_buffers

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

Referenced by meminfo().

◆ kb_main_cached

unsigned long kb_main_cached

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

Referenced by meminfo().

◆ kb_main_free

unsigned long kb_main_free

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

Referenced by meminfo().

◆ kb_main_total

unsigned long kb_main_total

Definition at line 153 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 154 of file gnunet-service-testbed_meminfo.c.

Referenced by meminfo().

◆ kb_swap_total

unsigned long kb_swap_total

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

Referenced by meminfo().

◆ kb_high_free

unsigned long kb_high_free

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

Referenced by meminfo().

◆ kb_high_total

unsigned long kb_high_total

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

Referenced by meminfo().

◆ kb_low_free

unsigned long kb_low_free

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

Referenced by meminfo().

◆ kb_low_total

unsigned long kb_low_total

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

Referenced by meminfo().

◆ kb_active

unsigned long kb_active

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

Referenced by meminfo().

◆ kb_inact_laundry

unsigned long kb_inact_laundry

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

Referenced by meminfo().

◆ kb_inact_dirty

unsigned long kb_inact_dirty

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

Referenced by meminfo().

◆ kb_inact_clean

unsigned long kb_inact_clean

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

Referenced by meminfo().

◆ kb_inact_target

unsigned long kb_inact_target

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

Referenced by meminfo().

◆ kb_swap_cached

unsigned long kb_swap_cached

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

Referenced by meminfo().

◆ kb_swap_used

unsigned long kb_swap_used

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

Referenced by meminfo().

◆ kb_main_used

unsigned long kb_main_used

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

Referenced by mem_get_usage(), and meminfo().

◆ kb_writeback

unsigned long kb_writeback

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

Referenced by meminfo().

◆ kb_slab

unsigned long kb_slab

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

Referenced by meminfo().

◆ nr_reversemaps

unsigned long nr_reversemaps

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

Referenced by meminfo().

◆ kb_committed_as

unsigned long kb_committed_as

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

Referenced by meminfo().

◆ kb_dirty

unsigned long kb_dirty

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

Referenced by meminfo().

◆ kb_inactive

unsigned long kb_inactive

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

Referenced by meminfo().

◆ kb_mapped

unsigned long kb_mapped

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

Referenced by meminfo().

◆ kb_pagetables

unsigned long kb_pagetables

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

Referenced by meminfo().

◆ kb_vmalloc_chunk

unsigned long kb_vmalloc_chunk
static

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

Referenced by meminfo().

◆ kb_vmalloc_total

unsigned long kb_vmalloc_total
static

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

Referenced by meminfo().

◆ kb_vmalloc_used

unsigned long kb_vmalloc_used
static

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

Referenced by meminfo().

◆ kb_anon_pages

unsigned long kb_anon_pages
static

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

Referenced by meminfo().

◆ kb_bounce

unsigned long kb_bounce
static

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

Referenced by meminfo().

◆ kb_commit_limit

unsigned long kb_commit_limit
static

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

Referenced by meminfo().

◆ kb_nfs_unstable

unsigned long kb_nfs_unstable
static

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

Referenced by meminfo().

◆ kb_swap_reclaimable

unsigned long kb_swap_reclaimable
static

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

Referenced by meminfo().

◆ kb_swap_unreclaimable

unsigned long kb_swap_unreclaimable
static

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

Referenced by meminfo().