阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

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

452次阅读
没有评论

共计 5884 个字符,预计需要花费 15 分钟才能阅读完成。

最近要监控 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].” “;
// }
?>

Cacti 的详细介绍:请点这里
Cacti 的下载地址:请点这里

相关阅读

RHEL6.4 环境 Cacti 中 spine 安装 http://www.linuxidc.com/Linux/2013-11/92797.htm

RHEL6.4 中使用 Cacti+Spine 监控主机实现发送邮件报警 http://www.linuxidc.com/Linux/2013-11/92795.htm

CentOS 5.5 完整安装 Cacti+Spine http://www.linuxidc.com/Linux/2011-12/49701.htm

CentOS 6 下 Cacti 搭建文档 http://www.linuxidc.com/Linux/2013-06/86595.htm

RHEL5.9 下 Cacti 监控部署详解 http://www.linuxidc.com/Linux/2013-06/85427.htm

CentOS 6.3 下 Cacti 安装详解 http://www.linuxidc.com/Linux/2013-05/84279.htm

CentOS Linux 下快速安装配置 Cacti 中文版 http://www.linuxidc.com/Linux/2013-03/81627.htm

更多 RedHat 相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计5884字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19351
评论数
4
阅读量
7976348
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
如何安装2026年最强个人助理ClawdBot、完整安装教程

如何安装2026年最强个人助理ClawdBot、完整安装教程

如何安装 2026 年最强个人助理 ClawdBot、完整安装教程 一、前言 学不完,根本学不完!近期,一款名...
从“纸堆”到“电子化”文档:用这个开源系统打造你的智能文档管理系统

从“纸堆”到“电子化”文档:用这个开源系统打造你的智能文档管理系统

从“纸堆”到“电子化”文档:用这个开源系统打造你的智能文档管理系统 大家好,我是星哥。公司的项目文档存了一堆 ...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍 前言 在 AI 自动化快速发展的当下,浏览器早已不再只是...
每天一个好玩的网站-手机博物馆-CHAZ 3D Experience

每天一个好玩的网站-手机博物馆-CHAZ 3D Experience

每天一个好玩的网站 - 手机博物馆 -CHAZ 3D Experience 一句话介绍:一个用 3D 方式重温...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
每天一个好玩的网站-手机博物馆-CHAZ 3D Experience

每天一个好玩的网站-手机博物馆-CHAZ 3D Experience

每天一个好玩的网站 - 手机博物馆 -CHAZ 3D Experience 一句话介绍:一个用 3D 方式重温...
零成本上线!用 Hugging Face免费服务器+Docker 快速部署HertzBeat 监控平台

零成本上线!用 Hugging Face免费服务器+Docker 快速部署HertzBeat 监控平台

零成本上线!用 Hugging Face 免费服务器 +Docker 快速部署 HertzBeat 监控平台 ...
还在找免费服务器?无广告免费主机,新手也能轻松上手!

还在找免费服务器?无广告免费主机,新手也能轻松上手!

还在找免费服务器?无广告免费主机,新手也能轻松上手! 前言 对于个人开发者、建站新手或是想搭建测试站点的从业者...
开源MoneyPrinterTurbo 利用AI大模型,一键生成高清短视频!

开源MoneyPrinterTurbo 利用AI大模型,一键生成高清短视频!

  开源 MoneyPrinterTurbo 利用 AI 大模型,一键生成高清短视频! 在短视频内容...
让微信公众号成为 AI 智能体:从内容沉淀到智能问答的一次升级

让微信公众号成为 AI 智能体:从内容沉淀到智能问答的一次升级

让微信公众号成为 AI 智能体:从内容沉淀到智能问答的一次升级 大家好,我是星哥,之前写了一篇文章 自己手撸一...