|
wlmaker
|
#include "wlm_graph_shared.h"#include <libbase/libbase.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>
Classes | |
| struct | memgraph_state_t |
Macros | |
| #define | LINE_BUFFER_SIZE 256 |
| #define | MEMINFO_FIELD_COUNT 5 |
| #define | MEM_CATEGORY_COUNT 3 |
| #define | LABEL_BUFFER_SIZE 16 |
| #define | KB_PER_MB 1024UL |
| #define | KB_PER_GB (1024UL * 1024) |
| #define | KB_PER_TB (1024UL * 1024 * 1024) |
| #define | LABEL_MATCH(literal) |
Enumerations | |
| enum | { MEM_CATEGORY_CACHED = 0 , MEM_CATEGORY_BUFFERS = 1 , MEM_CATEGORY_USED = 2 } |
Functions | |
| static void | _memgraph_lut_init (uint32_t lut[256]) |
| static void | _state_free (void *app_state) |
| static void | _format_memory_size (char *buf, const size_t buf_size, const unsigned long kb) |
| static const char * | _label_fn (void *app_state) |
| static wlm_graph_read_result_t | _stats_read_fn (void *app_state, wlm_graph_values_t *values) |
| int | main (const int argc, const char **argv) |
Variables | |
| static const char | _app_name [] = "wlmmemgraph" |
| static const char | _app_help [] |
Memory usage graph dock-app for wlmaker.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
| #define KB_PER_GB (1024UL * 1024) |
Kilobytes per gigabyte.
| #define KB_PER_MB 1024UL |
Kilobytes per megabyte.
| #define KB_PER_TB (1024UL * 1024 * 1024) |
Kilobytes per terabyte.
| #define LABEL_BUFFER_SIZE 16 |
Maximum length of the label string.
| #define LABEL_MATCH | ( | literal | ) |
Matches line label against a string literal.
Compares label_len bytes of line against the literal. Used for parsing /proc/meminfo where each line has format "Label: value kB".
| literal | String literal to match against. |
| #define LINE_BUFFER_SIZE 256 |
Line buffer size for /proc/meminfo parsing.
| #define MEM_CATEGORY_COUNT 3 |
Number of memory categories tracked.
| #define MEMINFO_FIELD_COUNT 5 |
Number of fields to parse from /proc/meminfo.
| anonymous enum |
|
static |
Formats memory size with appropriate suffix (GB, MB, kB).
| buf | Output buffer. |
| buf_size | Size of output buffer. |
| kb | Memory size in kilobytes. |
|
static |
Returns the formatted memory usage label.
|
static |
Generates blue-to-green gradient LUT (256 entries).
With 3 memory categories, only indices 0, 127, and 255 are sampled (mapping count 1, 2, 3 respectively). The full 256 entries are required by the API but only 3 discrete colors matter for this use case.
| lut | Output LUT array (256 entries). |
|
static |
Frees all allocated state.
|
static |
Reads memory statistics from /proc/meminfo.
Parses MemTotal, MemFree, Buffers, Cached, and SReclaimable to compute per-category usage percentages.
| app_state | App state (memgraph_state_t pointer). |
| values | Buffer to fill (may reallocate data/num). |
| int main | ( | const int | argc, |
| const char ** | argv ) |
Main program.
|
static |
Application help.
|
static |
Application name.