|
wlmaker
|
#include "wlm_graph_shared.h"#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <libbase/libbase.h>
Classes | |
| struct | scale_entry_t |
| struct | rate_history_t |
| struct | netgraph_state_t |
Macros | |
| #define | NET_CATEGORY_COUNT 3 |
| #define | PEAK_RATE_MIN (1024ULL * 1024ULL) |
| #define | PEAK_DECAY_DIVISOR 128 |
| #define | PEAK_DECAY_THRESHOLD 1024 |
| #define | LINE_BUFFER_SIZE 512 |
| #define | HEADER_LINE_COUNT 2 |
| #define | LABEL_BUFFER_SIZE 16 |
| #define | BYTES_PER_KB 1024ULL |
| #define | BYTES_PER_MB (1024ULL * 1024ULL) |
| #define | BYTES_PER_GB (1024ULL * 1024ULL * 1024ULL) |
| #define | SCALE_COUNT (sizeof(_scales) / sizeof(_scales[0])) |
Enumerations | |
| enum | { NET_CATEGORY_IN = 0 , NET_CATEGORY_OUT = 1 , NET_CATEGORY_IN_OUT = 2 } |
Functions | |
| static size_t | _scale_index_ceil (const unsigned long long val) |
| static const char * | _label_fn (void *app_state) |
| static void | _state_free (void *app_state) |
| static wlm_graph_read_result_t | _stats_read_fn (void *app_state, wlm_graph_values_t *values) |
| static void | _regenerate_fn (void *app_state, wlm_graph_values_t *samples, const uint32_t samples_num) |
| int | main (const int argc, const char **argv) |
Variables | |
| static const char | _app_name [] = "wlmnetgraph" |
| static const char | _app_help [] |
| static const scale_entry_t | _scales [] |
Network 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 BYTES_PER_GB (1024ULL * 1024ULL * 1024ULL) |
Bytes per gigabyte.
| #define BYTES_PER_KB 1024ULL |
Bytes per kilobyte.
| #define BYTES_PER_MB (1024ULL * 1024ULL) |
Bytes per megabyte.
| #define HEADER_LINE_COUNT 2 |
Number of header lines to skip in /proc/net/dev.
| #define LABEL_BUFFER_SIZE 16 |
Maximum length of the label string.
| #define LINE_BUFFER_SIZE 512 |
Line buffer size for /proc/net/dev parsing.
| #define NET_CATEGORY_COUNT 3 |
Number of network categories tracked.
| #define PEAK_DECAY_DIVISOR 128 |
Peak rate decay divisor (~1% decay per sample).
| #define PEAK_DECAY_THRESHOLD 1024 |
Threshold below which peak rate doesn't decay.
| #define PEAK_RATE_MIN (1024ULL * 1024ULL) |
Minimum peak rate for scaling (1 MB/s in bytes).
| anonymous enum |
|
static |
Returns the scale label.
|
static |
Regenerates historical samples at the current scale.
| app_state | App state (netgraph_state_t pointer). |
| samples | Array of sample buffers to regenerate (newest first). |
| samples_num | Number of samples to regenerate. |
|
static |
Finds index of smallest scale >= val.
| val | Value to find ceiling scale for. |
|
static |
Frees all allocated state.
|
static |
Reads network statistics from /proc/net/dev.
Parses all interfaces (excluding loopback) and sums RX/TX bytes. Computes rate since last read and scales to 0-255 based on peak rate.
| app_state | App state (netgraph_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.
|
static |
Available scale values (1/10/100 × KB/MB/GB).