Closed kcloze closed 4 years ago
@kcloze 预计下周 https://github.com/hyperf/hyperf/issues/511
hperf速度够快,可惜应用很难再换框架了,有机会新项目考虑使用。 官方应该可以考虑swoole-exporter
swoole-exporter有地址吗?
hperf速度够快,可惜应用很难再换框架了,有机会新项目考虑使用。 官方应该可以考虑swoole-exporter
Hyperf 的组件都会考虑非 Hyperf 框架下的复用使用的,放心
+1
确实,支持!
官方有server->stats()函数 把这个加到路由里渲染成普罗米修斯格式就可以了
多谢提供思路,stats()颗粒度有点粗,不过可以做一些事情了
php-fpm的status全部内容如下:
{
pool: "www",
process manager: "dynamic",
start time: 1572592407,
start since: 104,
accepted conn: 56,
listen queue: 0,
max listen queue: 0,
listen queue len: 128,
idle processes: 1,
active processes: 1,
total processes: 2,
max active processes: 1,
max children reached: 0,
slow requests: 0,
processes: [{
pid: 7,
state: "Idle",
start time: 1572592407,
start since: 104,
requests: 28,
request duration: 2076,
request method: "GET",
request uri: "/status?json&full",
content length: 0,
user: "-",
script: "-",
last request cpu: 0,
last request memory: 2097152
},
{
pid: 8,
state: "Running",
start time: 1572592407,
start since: 104,
requests: 28,
request duration: 2651,
request method: "GET",
request uri: "/status?json&full",
content length: 0,
user: "-",
script: "-",
last request cpu: 0,
last request memory: 0
}
]
}
希望swoole能补充: worker进程
idle 进程数量在 Server::stats 中是有的。CPU和内存使用率应该使用 其他监控手段实现。进程的 CPU 这个价值不太大
系统信息可以使用 PHP 提供的 getrusage 函数获取
<?php
$dat = getrusage();
echo $dat["ru_oublock"]; // number of block output operations
echo $dat["ru_inblock"]; // number of block input operations
echo $dat["ru_msgsnd"]; // number of IPC messages sent
echo $dat["ru_msgrcv"]; // number of IPC messages received
echo $dat["ru_maxrss"]; // maximum resident set size
echo $dat["ru_ixrss"]; // integral shared memory size
echo $dat["ru_idrss"]; // integral unshared data size
echo $dat["ru_minflt"]; // number of page reclaims (soft page faults)
echo $dat["ru_majflt"]; // number of page faults (hard page faults)
echo $dat["ru_nsignals"]; // number of signals received
echo $dat["ru_nvcsw"]; // number of voluntary context switches
echo $dat["ru_nivcsw"]; // number of involuntary context switches
echo $dat["ru_nswap"]; // number of swaps
echo $dat["ru_utime.tv_usec"]; // user time used (microseconds)
echo $dat["ru_utime.tv_sec"]; // user time used (seconds)
echo $dat["ru_stime.tv_usec"]; // system time used (microseconds)
?>
下个版本中 Swoole 会增加一个 stats_file
的配置项,可以将 Server::stats() 的内容打印到文件中
prometheus目前是云原生时代的标配,适合基于k8s生态的应用监控体系。
目前php应用如果迁移到swoole下,脱离了php-fpm,整个基于php-fpm监控和apm工具只能丢弃, 希望swoole能提供prometheus的运行状态接口, 参考php-fpm的exporter:https://github.com/bakins/php-fpm-exporter
或者官方可以出基本status状态接口,类似php-fpm-status,社区完成prometheus的对接