catcti监控linux主机,CentOS7搭建Prometheus 监控Linux主机

简介

prometheus可以拆分成多个节点进行指标收集。

23211M562-0.png

安装prometheus

wget -c https://github.com/prometheus/prometheus/releases/download/v2.23.0/prometheus-2.23.0.linux-amd64.tar.gz

tar zxvf prometheus-2.23.0.linux-amd64.tar.gz  -C /opt/

cd /opt/

ln -s prometheus-2.23.0.linux-amd64 prometheus

cat > /etc/systemd/system/prometheus.service <

[Unit]

Description=prometheus

After=network.target

[Service]

Type=simple

WorkingDirectory=/opt/prometheus

ExecStart=/opt/prometheus/prometheus --config.file="/opt/prometheus/prometheus.yml"

LimitNOFILE=65536

PrivateTmp=true

RestartSec=2

StartLimitInterval=0

Restart=always

[Install]

WantedBy=multi-user.target

EOF

systemctl daemon-reload

systemctl enable prometheus

systemctl start prometheus

23211M0T-1.png

这里配置的是监听/opt/prometheus/servers/目录下的json文件

cat > /opt/prometheus/prometheus.yml <

# my globalconfig

global:

scrape_interval:     15s # Setthe scrape intervaltoevery 15 seconds.Defaultisevery 1minute.

evaluation_interval: 15s # Evaluate rules every 15 seconds. The defaultisevery 1minute.

# scrape_timeout issettotheglobaldefault(10s).

# Alertmanager configuration

alerting:

alertmanagers:

- static_configs:

- targets:

# - alertmanager:9093

# Loadrules onceandperiodically evaluate them accordingtotheglobal'evaluation_interval'.

rule_files:

# - "first_rules.yml"

# - "second_rules.yml"

# A scrape configuration containing exactly one endpoint toscrape:

# Here it's Prometheus itself.

scrape_configs:

# The job nameisaddedasa label `job=`toanytimeseries scrapedfromthis config.

- job_name: 'prometheus'

# metrics_path defaults to'/metrics'

# scheme defaults to'http'.

static_configs:

- targets: ['localhost:9090']

- job_name: 'servers'

file_sd_configs:

- refresh_interval: 61s

files:

- /opt/prometheus/servers/*.json

EOF

systemctl restart prometheus

json格式

23211H133-2.png

每个json文件需要是一个数组对象,如果不需要自定义标签,可以直接写到targets里面去也可以,可以有多个文件

[

{

"targets": [

"192.168.1.164:9100"

],

"labels": {

"instance":"192.168.1.164",

"job":"node_exporter"

}

},

{

"targets": [

"192.168.1.167:9100"

],

"labels": {

"instance":"192.168.1.167",

"job":"node_exporter"

}

}

]

安装node_exporter

安装到/opt/node_exporter路径下,保持默认的端口

https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz

tar zxvf node_exporter-1.0.1.linux-amd64.tar.gz -C /opt/

cd /opt/

ln -s  node_exporter-1.0.1.linux-amd64 node_exporter

cat > /etc/systemd/system/node_exporter.service <

[Unit]

Description=node_exporter

After=network.target

[Service]

Type=simple

WorkingDirectory=/opt/node_exporter

ExecStart=/opt/node_exporter/node_exporter

LimitNOFILE=65536

PrivateTmp=true

RestartSec=2

StartLimitInterval=0

Restart=always

[Install]

WantedBy=multi-user.target

EOF

systemctl daemon-reload

systemctl enable node_exporter

systemctl start node_exporter

图形展示

直接安装grafana进行展示

yum -y install   https://dl.grafana.com/oss/release/grafana-7.3.6-1.x86_64.rpm

systemctl enable grafana-server

systemctl start grafana-server

启动之后,grafana默认监听的是3000端口,直接使用浏览器进行访问就可以了,默认用户名密码是admin/admin,第一次登陆之后会提示修改。

23211Kb0-3.png

配置数据源:鼠标左边的菜单 Configuration -> Data Source -> Add data source -> 选择prometheus -> url那栏填入prometheus的地址就可以了 -> 最后 Save & test 就可以了。

grafana.com/grafana/dashboards 官网已经有人做好的模板,我们直接import进来就可以了。

导入面板:鼠标左边的菜单 Dashboards -> Import -> 填入id -> Load -> 选择数据源就可以了。

我经常用的是:1860 、8919 这两个来查看node_exporter监控

23211I400-4.png

总结

安装这些服务都是使用systemd进行管理的,操作起来比较方便的。

这里没有设置告警,可以根据自己的需要设置对应的告警规则,使用alertmanager进行告警。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/537811.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

自己动手实现一个html2canvas

前言 昨天写了新手引导动画的4种实现方式, 里面用到了 html2canvas 于是就顺便了解了一下实现思路. 大概就是 利用 svg 的 foreignObject 标签, 嵌入 dom, 最后再利用 canvas 绘制 svg. 从而实现最终目的. 先让大家看看效果 MDN示例 var canvas document.getElementById(canva…

Git fetch pull 详解

1、简单概括 先用一张图来理一下git fetch和git pull的概念&#xff1a; 可以简单的概括为&#xff1a; git fetch是将远程主机的最新内容拉到本地&#xff0c;用户在检查了以后决定是否合并到工作本机分支中。 而git pull 则是将远程主机的最新内容拉下来后直接合并&#x…

linux 安装redis2.8.3,Linux及Windows安装Redis(详细)

标签&#xff1a;Linux及Windows安装Redis1.Windows安装教程1.1下载https://github.com/MSOpenTech/redis/releases进入github里下载redis Windows版压缩包将我们下载好的文件放进新建的一个Redis文件夹(我在C盘创建了一个redis的文件夹)1.2启动服务打开我们Windows版的dos命令…

Git 少用 Pull 多用 Fetch 和 Merge

转自&#xff1a;http://www.oschina.net/translate/git-fetch-and-merge --------------------------------------------------------------------------------- 本文有点长而且有点乱&#xff0c;但就像Mark Twain Blaise Pascal的笑话里说的那样&#xff1a;我没有时间让…

IDEA生成可运行jar包

方式1: maven打包 maven 包中添加如下配置 <build><plugins><plugin><artifactId>maven-assembly-plugin</artifactId><configuration><appendAssemblyId>false</appendAssemblyId><descriptorRefs><descriptorRef&…

linux packet socket,linux Packet socket (1)简单介绍

本文主要来自于linux自带的man packet手冊&#xff1a;http://man7.org/linux/man-pages/man7/packet.7.html平时常常使用的INET套接字提供的是7层的抓包能力&#xff0c;抓上来的data直接就是tcp或者udp的payload&#xff0c;无需关心L3和L4的头部信息。Packet套接字提供的是L…

TortoiseGit 修改密码

当TortoiseGi默认设置了凭证助手为“管理器-所有windows用户”&#xff0c;每次向远程git推送时&#xff0c;都会去windows的凭证管理器里读取值&#xff0c;然后推送。 如果密码修改了&#xff0c;或者密码不小心输入错了&#xff0c;每次提交都会报错&#xff1a;HTTP Basic:…

linux系统常见操作,Linux系统基本操作

我们可以认为Linux是一套自由使用的类Unix操作系统&#xff0c;与Windows相比较而言&#xff0c;Linux具有安全、开源、稳定等特点。下面我来介绍Linux中一些的登录登出基本操作。1. 启动系统通常LILO是安装在MBR上的&#xff0c;计算机启动后&#xff0c;MBR上的程序被执行&am…

字符串常见处理

mystr hello world itcast and itcastcpps mystr.find(hello)print(s)ind mystr.index(world)print(ind)cou mystr.count(c)print(cou)rep mystr.replace(c,)print(rep)spl mystr.split( )print(spl)转载于:https://www.cnblogs.com/zxt-cn/p/9714841.html

git 无法访问

git分2种访问方式&#xff1a;ssh&#xff0c;https ssh模式&#xff0c;需要在github或gitlab上配置公钥&#xff0c;本地要生成秘钥。 举例&#xff1a; 公司使用gitlab 张工需要访问公司李工的代码库。 步骤&#xff1a; 1、李工要在gitlab他的项目里&#xff0c;给张…

c语言编程统计单词的个数,使用c语言如何统计单词个数

使用c语言如何统计单词个数发布时间&#xff1a;2020-04-21 13:58:58来源&#xff1a;亿速云阅读&#xff1a;207作者&#xff1a;小新使用c语言如何统计单词个数&#xff1f;相信有很多人都不太了解&#xff0c;今天小编为了让大家更加了解Golang&#xff0c;所以给大家总结了…

10 种保护 Spring Boot 应用的绝佳方法

Spring Boot大大简化了Spring应用程序的开发。它的自动配置和启动依赖大大减少了开始一个应用所需的代码和配置量&#xff0c;如果你已经习惯了Spring和大量XML配置&#xff0c;Spring Boot无疑是一股清新的空气。 Spring Boot于2014年首次发布&#xff0c;自那以后发生了很多变…

zkServer.cmd 闪退

调用 zkEnv.cmd 查看下 zkEnv.cmd 在\conf下复制zoo_sample.cfg 重命名为 zoo.cfg 再运行&#xff0c;成功

c语言单字符输入和输出函数分别为,第03章单元总练习-实训-知识拓展.doc

第03章单元总练习-实训-知识拓展《C语言程序设计》单元总结单元练习实训指导知识拓展第三章 最简单的C程序设计——顺序结构设计班级:姓名:学号:单元总结提升本单元中&#xff0c;核心内容有C语言中基本的数据类型、常量和变量、运算符和表达式以及算法的概念。通过本单元的学习…

那些你不知道的 getClientRects()

1.getClientRects()。是可以获取内联元素的内容有多少行 最近一个交互&#xff0c;在限定文字展现是5行&#xff0c;超过5行&#xff0c;则在后面添加。。。展开。如果没有展开二字&#xff0c;我们一般用css就能完成了。但是为了交互更人性化 text-overflow: -o-ellipsis-last…

idea统计代码行数

使用统计代码插件&#xff0c;可以统计代码行数。安装插件 Statistic。&#xff08;这个最好用&#xff09; File----settiing---plugins---browse repositories 重启idea后&#xff0c;底部会多一个 Statistic 点击刷新&#xff0c;行数就出来了。看最后的 Total

数据结构计算c语言数据步骤,数据结构C语言版视频教程-介绍各种最常用的数据结构 分析各种数据结构运算算法的实现过程-电脑网络视频-星火视频教程 21edu8.com...

这部数据结构C语言版视频教程结构清晰&#xff0c;实例丰富&#xff0c;具有很强的操作性和实用性。 它主要为大家介绍各种最常用的数据结构&#xff0c;以及从编程角度出发&#xff0c;分析各种数据结构运算算法的实现过程。数据结构是计算机存储、组织数据的方式。数据结构是…

极光推送小结 - iOS

此次即友盟分享小结(友盟分享小结 - iOS)之后对推送也进行了一版优化.此次分享内容依然基于已经成功集成 SDK 后 code 层级部分. 注:此次分享基于 SDK 3.1.0,若版本相差较大,仅供参考. 极光推送官方文档: https://docs.jiguang.cn/jpush/guideline/intro/ 首先,为分享单独创建了…

word去除所有的空行

申请软著时&#xff0c;需要复制源代码到word里。每行代码不能有换行&#xff0c;要紧凑的80页代码。每页要50~55行代码。 字体可设置为&#xff1a;宋体&#xff0c;5号&#xff0c;行间距固定值12。 演示实例 去除下面word代码里的空行 第一步&#xff1a; word显示隐藏的…

c语言Wndproc未定义,为什么我的老是未定义

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼这是源代码#includeLRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow){static TCHAR szAppName[] TEXT("HelloWin&qu…