-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9c3167
commit 3de8816
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#ifndef _NETDATA_MOUNT_H_ | ||
#define _NETDATA_MOUNT_H_ 1 | ||
|
||
enum mount_counters { | ||
NETDATA_KEY_MOUNT_CALL, | ||
NETDATA_KEY_UMOUNT_CALL, | ||
NETDATA_KEY_MOUNT_ERROR, | ||
NETDATA_KEY_UMOUNT_ERROR, | ||
|
||
NETDATA_MOUNT_END | ||
}; | ||
|
||
#endif /* _NETDATA_MOUNT_H_ */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ NETDATA_APPS= btrfs \ | |
ext4 \ | ||
fdatasync \ | ||
fsync \ | ||
mount \ | ||
msync \ | ||
nfs \ | ||
socket \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#define KBUILD_MODNAME "mount_netdata" | ||
#include <linux/bpf.h> | ||
#include <linux/ptrace.h> | ||
|
||
#include "bpf_helpers.h" | ||
#include "netdata_ebpf.h" | ||
|
||
/************************************************************************************ | ||
* | ||
* MAPS | ||
* | ||
***********************************************************************************/ | ||
|
||
struct bpf_map_def SEC("maps") tbl_mount = { | ||
.type = BPF_MAP_TYPE_PERCPU_ARRAY, | ||
.key_size = sizeof(__u32), | ||
.value_size = sizeof(__u64), | ||
.max_entries = NETDATA_MOUNT_END | ||
}; | ||
|
||
/************************************************************************************ | ||
* | ||
* MOUNT SECTION | ||
* | ||
***********************************************************************************/ | ||
|
||
#if NETDATASEL < 2 | ||
SEC("kretprobe/" NETDATA_SYSCALL(mount)) | ||
#else | ||
SEC("kprobe/" NETDATA_SYSCALL(mount)) | ||
#endif | ||
int netdata_syscall_mount(struct pt_regs* ctx) | ||
{ | ||
libnetdata_update_global(&tbl_mount, NETDATA_KEY_MOUNT_CALL, 1); | ||
#if NETDATASEL < 2 | ||
int ret = (int)PT_REGS_RC(ctx); | ||
if (ret < 0) | ||
libnetdata_update_global(&tbl_mount, NETDATA_KEY_MOUNT_ERROR, 1); | ||
#endif | ||
|
||
return 0; | ||
} | ||
|
||
#if NETDATASEL < 2 | ||
SEC("kretprobe/" NETDATA_SYSCALL(umount)) | ||
#else | ||
SEC("kprobe/" NETDATA_SYSCALL(umount)) | ||
#endif | ||
int netdata_syscall_umount(struct pt_regs* ctx) | ||
{ | ||
libnetdata_update_global(&tbl_mount, NETDATA_KEY_UMOUNT_CALL, 1); | ||
#if NETDATASEL < 2 | ||
int ret = (int)PT_REGS_RC(ctx); | ||
if (ret < 0) | ||
libnetdata_update_global(&tbl_mount, NETDATA_KEY_UMOUNT_ERROR, 1); | ||
#endif | ||
|
||
return 0; | ||
} | ||
|
||
/************************************************************************************ | ||
* | ||
* END MOUNT SECTION | ||
* | ||
***********************************************************************************/ | ||
|
||
char _license[] SEC("license") = "GPL"; | ||
|