Slide 49
Slide 49 text
ॻ͍ͯΈͨʢൈਮʣ
php.bpf.c
#define MAX_STR_LEN 256
struct call_t {
char filename[MAX_STR_LEN];
};
struct {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__uint(max_entries, 65536);
__type(key, struct call_t);
__type(value, u64);
} php_compile_file_total SEC(".maps");
SEC("usdt//usr/lib/apache2/modules/libphp8.1.so:php:compile__file__entry")
int BPF_USDT(do_count, char *arg0, char *arg1)
{
struct call_t call = {};
bpf_probe_read_user_str(&call.filename, sizeof(call.filename), arg1);
truncate_string(call.filename, MAX_STR_LEN);
static const char fmtstr[] = "compile file entry: %s, %s\n";
bpf_trace_printk(fmtstr, sizeof(fmtstr), arg0, arg1);
increment_map(&php_compile_file_total, &call, 1);
return 0;
}
php.yaml
metrics:
counters:
- name: php_compile_file_total
help: Number of php:compile__file__entry USDT calls per filepath
labels:
- name: filename
size: 256
decoders:
- name: string