前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >在Cacti中使用ATS的stats_over_http模块进行监控部分性能

在Cacti中使用ATS的stats_over_http模块进行监控部分性能

作者头像
星哥玩云
发布2022-06-29 18:43:25
4410
发布2022-06-29 18:43:25
举报
文章被收录于专栏:开源部署

最近要监控ATS,使用stats_over_http.so模块可以使用url来查看ats的状态,在cacti里面加上了几个值来监控,包含: proxy.process.http.completed_requests

Cacti利用stats_over_http.so模块监控ats的部分数据下载:

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2014年资料/1月/2日/在Cacti中使用ATS的stats_over_http模块进行监控部分性能

下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm

所有收到请求,使用count模式统计每秒完成的请求 proxy.process.http.incoming_requests proxy.process.http.outgoing_requests 进入和出的请求,基本能够描述ats的繁忙程度 proxy.process.http.1xx_responses proxy.process.http.2xx_responses proxy.process.http.3xx_responses proxy.process.http.4xx_responses proxy.process.http.5xx_responses 给客户端返回的HTTP status code的数量,基本反映服务情况 proxy.process.http.tcp_hit_count_stat    proxy.process.http.tcp_refresh_hit_count_stat proxy.process.http.tcp_ims_hit_count_stat proxy.process.http.tcp_miss_count_stat    proxy.process.http.tcp_refresh_miss_count_stat proxy.process.http.tcp_ims_miss_count_stat 6个来计算命中率(命中/(命中+失败)),基本能够反映命中率 ps:cacti,在用php写script/command的时候,echo输出结果必须一次性输出,否则cacti无法接收到结果,比如 echo "a:"."20 ";echo "b:"."30";只能接收到a的值,必须 echo "a:"."20 "."b:"."30";才可以,但在cli里输出是一样的。这点问题折腾了1个上午。

cacti建立模板和输入就大概写个流程,就不仔细写了 1、Data Input Methods,记得选择script/command 就可以了,Input String里对照程序来写比如: <path_php_binary> -q <path_cacti>/scripts/flashapp_get_ts_stat.php completed_requests <host_ip>

记得填对应的需求就好了,下面的Output fields,大家根据输出来写吧 2、Data Templates 自己起名字了,什么的。不会看前面的文章,注意下面的Data Source Type 选择就好了 3、Graph Templates 这部分 大家根据喜好自己设置吧。 ps附件 cacti模板和php,php放到scripts目录,xml导入就好了

php代码: <?php /* * flashapp_ts_get_web_status.php * ------------------------------------------------- * enable cacti to read ATS status from stats_over_http.so plugin. * Originally by tongyuan at flashapp dot cn - 2014/1/2 * This is simple monitor for ATS,so ...... * * usage: * flashapp_ts_get_web_status.php [completed_requests | hit_ratio | inout_requests | status_code ] [Host_ip] * * * # get from proxy.process.http.completed_requests * CMD:    flashapp_ts_get_web_status.php completed_requests [Host_ip] * OUTPUT: completed_requests:xxxx * CACAI data type:COUNT * * # get from proxy.process.http.incoming_requests and proxy.process.http.outgoing_requests * CMD:    flashapp_ts_get_web_status.php inout_requests [Host_ip] * OUTPUT: incoming_requests:xxxx outgoing_requests:xxxx * CACTI data type:COUNT * * # get from proxy.process.http.incoming_requests and proxy.process.http.outgoing_requests * CMD:    flashapp_ts_get_web_status.php status_code [Host_ip] * OUTPUT: code_axx_responses:xxx code_bxx_responses:xxx code_cxx_responses:xxx code_dxx_responses:xxx code_exx_responses:xxx * CACTI data type:COUNT * * # get simple hit * CMD:      flashapp_ts_get_web_status.php hit_ratio [Host_ip] * OUTPUT:hit_ratio:0.XXXX * CACTI data type:ABSOLUTE * EXPRESSION:  (proxy.process.http.tcp_hit_count_stat        + *              proxy.process.http.tcp_refresh_hit_count_stat + *              proxy.process.http.tcp_ims_hit_count_stat)    / * *              (proxy.process.http.tcp_hit_count_stat        + *              proxy.process.http.tcp_refresh_hit_count_stat + *              proxy.process.http.tcp_ims_hit_count_stat    + *              *              proxy.process.http.tcp_miss_count_stat        + *              proxy.process.http.tcp_refresh_miss_count_stat+ *              proxy.process.http.tcp_ims_miss_count_stat) * * examle: * grant select,show databases on *.* \ *  to monitor@'192.168.1.0/255.255.255.0' identified by 'monitor'; * */ // read paramater default port 8080, path /_stats $server_port=8080; $what_get=$_SERVER["argv"][1]; $server_ip=$_SERVER["argv"][2]; $server_path="_stats"; $url = "http://".$server_ip.$server_port."/".$server_path; if ($_SERVER["argc"] != 3 ) {     echo "Usage : flasahpp_ts_get_web_stats.php  [completed_requests | hit_ratio | inout_requests | status_code ] <Host_ip>\n";     exit(1); } # deactivate http headers $no_http_headers = true; # include some cacti files for ease of use include(dirname(__FILE__) . "/../include/global.php"); include(dirname(__FILE__) . "/../lib/snmp.php"); // # get stats from server $r_str = @file_get_contents($url); if (empty($r_str)) {exit(1);} // # convert the resault $r_str = (array)json_decode($r_str); $r_str = (array)$r_str["global"]; // count hit ratio $hit_hit_count=$r_str["proxy.process.http.tcp_hit_count_stat"]+                 $r_str["proxy.process.http.tcp_refresh_hit_count_stat"]+                 $r_str["proxy.process.http.tcp_ims_hit_count_stat"]; $hit_miss_count=$r_str["proxy.process.http.tcp_miss_count_stat"]+                 $r_str["proxy.process.http.tcp_refresh_miss_count_stat"]+                 $r_str["proxy.process.http.tcp_ims_miss_count_stat"]; $hit_ratio = $hit_hit_count / ($hit_hit_count+$hit_miss_count); // get out what u wont. if ( $what_get == "completed_requests" ) {     echo "completed_requests:".$r_str["proxy.process.http.completed_requests"];     exit(0); } if ( $what_get == "hit_ratio") {     echo "hit_ratio:".$hit_ratio;     exit(0); } if ( $what_get == "inout_requests" ) {     $output = "incoming_requests:" . $r_str["proxy.process.http.incoming_requests"]." "             . "outgoing_requests:" . $r_str["proxy.process.http.outgoing_requests"]."\n";     echo $output;     exit(0); } if ( $what_get == "status_code" ) {     $output = "code_axx_responses:" . $r_str["proxy.process.http.1xx_responses"]." "             . "code_bxx_responses:" . $r_str["proxy.process.http.2xx_responses"]." "             . "code_cxx_responses:" . $r_str["proxy.process.http.3xx_responses"]." "             . "code_dxx_responses:" . $r_str["proxy.process.http.4xx_responses"]." "             . "code_exx_responses:" . $r_str["proxy.process.http.5xx_responses"]."\n";     echo $output;     exit(0); } echo "Usage : flasahpp_ts_get_web_stats.php completed_requests|hit_ratio|inout_requests|status_code <Host_ip> \n"; // foreach ($my_fi as $s){ //        echo  $s.":".$r_str[$s]." "; // } ?>

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
命令行工具
腾讯云命令行工具 TCCLI 是管理腾讯云资源的统一工具。使用腾讯云命令行工具,您可以快速调用腾讯云 API 来管理您的腾讯云资源。此外,您还可以基于腾讯云的命令行工具来做自动化和脚本处理,以更多样的方式进行组合和重用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档