<commit_before>// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
// Copyright (c) 2022 <NAME>
//
// Based on oomkill(8) from BCC by <NAME>.
// 13-Jan-2022   <NAME>   Created this.
#include <argp.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include <bpf/bpf.h>
#include <bpf/libbpf.h>
#include "oomkill.skel.h"
#include "oomkill.h"
#include "trace_helpers.h"

#define PERF_POLL_TIMEOUT_MS	100

static volatile sig_atomic_t exiting = 0;

const char *argp_program_version = "oomkill 0.1";
const char *argp_program_bug_address =
	"https://github.com/iovisor/bcc/tree/master/libbpf-tools";

static void handle_event(void *ctx, int cpu, void *data, __u32 data_sz)
{
	FILE *f;
	char buf[256];
	int n;
	struct tm *tm;
	char ts[32];
	time_t t;
	struct data_t *e = data;

	f = fopen("/proc/loadavg", "r");
	if (f) {
		memset(buf, 0 , sizeof(buf));
		n = fread(buf, 1, sizeof(buf), f);
		fclose(f);
	}
	time(&t);
	tm = localtime(&t);
	strftime(ts, sizeof(ts), "%H:%M:%S", tm);
	<commit_msg>libbpf-tools: Fix a compiler warning on oomkill<commit_after>// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
// Copyright (c) 2022 <NAME>
//
// Based on oomkill(8) from BCC by <NAME>.
// 13-Jan-2022   <NAME>   Created this.
#include <argp.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include <bpf/bpf.h>
#include <bpf/libbpf.h>
#include "oomkill.skel.h"
#include "oomkill.h"
#include "trace_helpers.h"

#define PERF_POLL_TIMEOUT_MS	100

static volatile sig_atomic_t exiting = 0;

const char *argp_program_version = "oomkill 0.1";
const char *argp_program_bug_address =
	"https://github.com/iovisor/bcc/tree/master/libbpf-tools";

static void handle_event(void *ctx, int cpu, void *data, __u32 data_sz)
{
	FILE *f;
	char buf[256];
	int n = 0;
	struct tm *tm;
	char ts[32];
	time_t t;
	struct data_t *e = data;

	f = fopen("/proc/loadavg", "r");
	if (f) {
		memset(buf, 0 , sizeof(buf));
		n = fread(buf, 1, sizeof(buf), f);
		fclose(f);
	}
	time(&t);
	tm = localtime(&t);
	strftime(ts, sizeof(ts), "%H:%M:%S", tm);
	
{'fraction_non_alphanumeric': 0.1797088262056415, 'fraction_numerical': 0.02684258416742493, 'mean_word_length': 4.235714285714286, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1035165', 'n_tokens_mistral': 991, 'n_tokens_neox': 950, 'n_words': 229}