Node_exporter一键安装部署脚本(Shell)
#!/bin/bash
#
# rhel7. 安装node_exporter 用于监控数据采集
# Usage:
# sh addNode.sh
#Logs: /var/log/messages
#History: // v3
#Create_Time: --
# USE: small_wei
#
# WEB_PATH='http://12.0.94.46:8086' #这里是我测试环境下的文件下载链接路径
# https://github.com/prometheus/node_exporter 官方下载地址 Install_PATH=/opt/node
Server_file=/usr/lib/systemd/system
RED_COLOR='\E[1;31m' #红
GREEN_COLOR='\E[1;32m' #绿
RES='\E[0m' node_user=node
node_group=node
Time_date=$(date +"%Y%m%d%H%M%S") if [ ! $(id -u) == ];then
echo -e "${GREEN_COLOR}Please run with the root user!${RES}"
exit
fi #防止重复执行
if [ $(ps -ef | grep $ |grep -v grep | wc -l) -gt ];then #理论值为 , 但这里是
echo -e "${RED_COLOR} $0 The script is executing, do not repeat!, Run id is $$${RES}"
exit
fi #create group if not exists
egrep "^${node_group}" /etc/group >/dev/null
if [ $? -ne ];then
groupadd ${node_group}
echo -e "${node_group} group Creating a successful"
fi #create user if not exists
egrep "^${node_user}" /etc/passwd >/dev/null
if [ $? -ne ];then
useradd -g ${node_group} ${node_user}
echo -e "${node_user} user Creating a successful"
fi port=`netstat -anp|grep `
if test -z "${port}"
then
mkdir -p ${Install_PATH}
chown -R ${node_user}:${node_user} ${Install_PATH}
wget -p ${Install_PATH} $WEB_PATH/downloadFile/node_exporter
chmod +x ${Install_PATH}/node_exporter
if [[ $? == ]];then
echo -e "${GREEN_COLOR}Environment readiness complete${RES}"
fi
#-----------------
if [ -f "${Server_file}/node_exporter.service" ];then
cp -f ${Server_file}/node_exporter.service ${Server_file}/node_exporter.service.bak${Time_date}
fi if [ $? == ];then
echo -e "${GREEN_COLOR}node_exporter.service.bak${Time_date} File The backup successful${RES}"
else
echo -e "${RED_COLOR}node_exporter.service.bak${Time_date} File backup failed${RES}"
exit
fi
cat >${Server_file}/node_exporter.service <<-EOF
[Unit]
Description=Prometheus node exporter
Documentation=https://prometheus.io/
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target [Service]
User=${node_user}
Group=${node_group}
Type=simple
#ExecStart=${Install_PATH}/node_exporter --web.listen-address=: --log.level=error
ExecStart=${Install_PATH}/node_exporter --web.listen-address=: --log.level=info [Install]
WantedBy=multi-user.target
EOF systemctl daemon-reload
systemctl restart node_exporter if [ $? == ];then
echo -e "${GREEN_COLOR}node_exporte Server start success!${RES}"
else
echo -e "${RED_COLOR}node_exporte Server start ERROR!${RES}"
exit
fi
#------------------
else
echo -e "${GREEN_COLOR}port:9100 is busy,failed${RES}"
fi systemctl enable node_exporter
systemctl status node_exporter #验证
curl -I -m -o /dev/null -s -w %{http_code} 127.0.0.1: \n if [ $? == ];then
echo -e "${GREEN_COLOR}register node in consul success${RES}"
else
echo -e "${RED_COLOR}Registration failed or registered, please check! ${RES}"
exit
fi
Node_exporter一键安装部署脚本(Shell)的更多相关文章
- 分布式实时日志系统(一)环境搭建之 Jstorm 集群搭建过程/Jstorm集群一键安装部署
最近公司业务数据量越来越大,以前的基于消息队列的日志系统越来越难以满足目前的业务量,表现为消息积压,日志延迟,日志存储日期过短,所以,我们开始着手要重新设计这块,业界已经有了比较成熟的流程,即基于流式 ...
- linux一键安装vncserver脚本
title: linux一键安装vncserver脚本 date: 2016-04-11 14:32:04 tags: --- linux多数情况下是作为服务器使用的,管理员一般也喜欢使用命令行来管理 ...
- Rehat一键安装mysql脚本和备份数据库脚本
Rehat一键安装mysql脚本 ##说明:适用,Rehat 5 6 7 1.运行状态,运行成功输出mysql临时密码 2.代码如下 #!/bin/bash #获取系统信息 sudo cat /etc ...
- (转)CentOS一键安装Nginx脚本
原文:https://www.xiaoz.me/archives/10301 https://blog.slogra.com/post-676.html-----centos7一键安装nginx脚本
- rsync服务端一键安装rsync脚本(非源码)
export RSYNC_PASSWORD=123 USER=rsync AUTHUSERS=bck MK=backupmk local_dir=/backup yum remove rsync &a ...
- 通过跳板机建立信任,对多个tomcat服务统一安装部署(shell编写)
unifyDeploy 自动化统一安装部署 系统版本: unifyDeploy0.1 文件编号: 0.1 发布日期: 2014-06-26 编 制: WangYong 版权所有 内部资料注意保密 ...
- 一键安装cobbler脚本
#!/bin/bash # # Install Cobbler(Kickstart) Tools / # Created by OceanHo(gzhehai@foxmail.com) AT -- # ...
- 一键安装lnmp脚本
前段时间一直在找一个快速部署lnmp环境的方法,也没找着,就自己写了一个,结合网上的大神们的.我的方法是脚本结合源码包,很多依赖裤都是yum安装的,这都在脚本里面,需要的源码包我都下载好了,打包成压缩 ...
- 最新版kubernetesV1.14.1集群一键自动部署脚本
部署命令如下:详情及注意事项请看README.md git clone https://github.com/luckman666/deploy_Kubernetes-v1.14.1.git cd d ...
随机推荐
- Rest_Framework之频率组件部分
一.RestFramework之频率组件源码部分 频率组件的源码部分和权限组件流程一模一样的,这里就不多说了,直接上源码的主要逻辑部分: def check_throttles(self, reque ...
- ios发送短信验证码计时器的swift实现
转载自:http://www.jianshu.com/p/024dd2d6e6e6# Update: Xcode 8.2.1 Swift 3 先介绍一下 属性观测器(Property Observer ...
- Python3爬虫(3)_urllib.error
注:参照https://blog.csdn.net/c406495762/article/details/59488464 Learn_ERROR: urllib.error可以接收有urllib.r ...
- Python 图形验证码库、二维码库的使用
1. 图形验证码库 captcha # 引入图形库 from captcha.image import ImageCaptcha # 获取图像对象 image = ImageCaptcha(width ...
- RESTful基本概念
文章目录 01 前言 02 RESTful的来源 03 RESTful6大原则 1. C-S架构 2. 无状态 3.统一的接口 4.一致的数据格式 4.系统分层 5.可缓存 6.按需编码.可定制代码( ...
- 学习笔记34_EF上下文管理
*上下文对象dbContext最好不要频繁的使用Using(var dbContext = new ....):那么就会产生过多的数据库交互:而且每个dbContext中村的数据,由于操作不同,数据可 ...
- linux 查看磁盘信息
一.查看磁盘和分区 ACCB947E:Home zhangsan$ df -h Filesystem Size Used Avail Capacity iused ifree %iused Mount ...
- 相关推导式-Python
列表.’字典等推导式 #利用zip()函数同时给多个变量赋值 a = [1,2,3,4,5] b = [4,5,6,7,8] c = [9,2,3,4,0] l = [[1,2],[3,4]] for ...
- svn:"Update item to this version"、"Revert to this version"及"Revert changes from this version"详细说明
背景: 今天在svn分支上做了一些课题性研究,发现当前的环境版本不稳定, 和领导研究后决定还原到前面的版本以继续进行课题. 问题: 因此遇到了问题,是应该选择“Update item to this ...
- PostgreSQL的模式、表、空间、用户间的关系
在平时的工作中,我们经常接触到数据库表和用户以及角色的使用,由于经常使用默认的数据库表空间和模式(Schema),所以我们往往忽略了数据库表空间和模式的概念以及作用. 接下来,先介绍一下模式和表空间的 ...