[转帖]ssh_exporter
https://github.com/treydock/ssh_exporter
SSH exporter
The SSH exporter attempts to make an SSH connection to a remote system and optionally run a command and test output.
This exporter is intended to query multiple SSH servers from an external host.
The /ssh metrics endpoint exposes SSH metrics and requires the target parameter. The module parameter can also be used to select which configuration module to use, the default module is default.
The /metrics endpoint exposes Go and process metrics for this exporter.
Configuration
The configuration defines modules that are used to configure the SSH client for a given target.
Example:
modules:
default:
user: prometheus
private_key: /home/prometheus/.ssh/id_rsa
command: uptime
command_expect: "load average"
timeout: 5
password:
user: prometheus
password: secret
certificate:
user: prometheus
private_key: /home/prometheus/.ssh/id_ed25519
certificate: /home/prometheus/.ssh/id_ed25519-cert.pub
verify:
user: prometheus
private_key: /home/prometheus/.ssh/id_rsa
known_hosts: /etc/ssh/ssh_known_hosts
host_key_algorithms:
- ssh-rsa
command: uptime
command_expect: "load average"
timeout: 5
capture:
user: prometheus
private_key: /home/prometheus/.ssh/id_rsa
command: /some/command/with/output
output_metric: true
output_truncate: 50
Example with curl would query host1 with the password module and host2 with the default module.
curl "http://localhost:9312/ssh?target=host1.example.com:22&module=password"
curl http://localhost:9312/ssh?target=host2.example.com:22
Configuration options for each module:
user- The username for the SSH connectionpassword- The password for the SSH connection, required ifprivate_keyis not specifiedprivate_key- The SSH private key for the SSH connection, required ifpasswordis not specifiedcertificate- The SSH certificate for the private key for the SSH connectionknown_hosts- Optional SSH known hosts file to use to verify hostshost_key_algorithms- Optional list of SSH host key algorithms to use- See constants beginning with
KeyAlgo*in crypto/ssh
- See constants beginning with
timeout- Optional timeout of the SSH connection, session and optional command.- The default comes from the
--collector.ssh.default-timeoutflag.
- The default comes from the
command- Optional command to run.command_expect- Optional regular expression of output to expect from the command.output_metric- Iftruethe exporter will expose thecommandoutput viassh_output{output="<output here>"}metric.output_truncate- Sets the max length for a string inssh_outputmetric'soutputlabel. Set to-1to disable truncating.
Docker
Example of running the Docker container
docker run -d -p 9312:9312 -v "ssh_exporter.yaml:/ssh_exporter.yaml:ro" treydock/ssh_exporter
Example of running the Docker container and making SSH private key available. This requires setting private_key value to /.ssh/id_rsa.
docker run -d -p 9312:9312 \
-v "ssh_exporter.yaml:/ssh_exporter.yaml:ro" \
-v "/home/prometheus/.ssh/id_rsa:/.ssh/id_rsa:ro" \
treydock/ssh_exporter
Install
Download the latest release
Add the user that will run ssh_exporter
groupadd -r ssh_exporter
useradd -r -d /var/lib/ssh_exporter -s /sbin/nologin -M -g ssh_exporter -M ssh_exporter
Install compiled binaries after extracting tar.gz from release page.
cp /tmp/ssh_exporter /usr/local/bin/ssh_exporter
Add the necessary config, see configuration section
Add systemd unit file and start service. Modify the ExecStart with desired flags.
cp systemd/ssh_exporter.service /etc/systemd/system/ssh_exporter.service
systemctl daemon-reload
systemctl start ssh_exporter
Build from source
To produce the ssh_exporter binary:
make build
Or
go get github.com/treydock/ssh_exporter
Prometheus configs
The following example assumes this exporter is running on the Prometheus server and communicating to the remote SSH hosts.
- job_name: ssh
metrics_path: /ssh
static_configs:
- targets:
- host1.example.com:22
- host2.example.com:22
labels:
module: default
- targets:
- host3.example.com:22
- host4.example.com:22
labels:
module: verify
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9312
- source_labels: [module]
target_label: __param_module
metric_relabel_configs:
- regex: "^(module)$"
action: labeldrop
- job_name: ssh-metrics
metrics_path: /metrics
static_configs:
- targets:
- localhost:9312
[转帖]ssh_exporter的更多相关文章
- nginx负载均衡基于ip_hash的session粘帖
nginx负载均衡基于ip_hash的session粘帖 nginx可以根据客户端IP进行负载均衡,在upstream里设置ip_hash,就可以针对同一个C类地址段中的客户端选择同一个后端服务器,除 ...
- [转帖]网络协议封封封之Panabit配置文档
原帖地址:http://myhat.blog.51cto.com/391263/322378
- [转帖]零投入用panabit享受万元流控设备——搭建篇
原帖地址:http://net.it168.com/a2009/0505/274/000000274918.shtml 你想合理高效的管理内网流量吗?你想针对各个非法网络应用与服务进行合理限制吗?你是 ...
- 3d数学总结帖
3d数学总结帖,以下是对3d学习过程中数学知识的简单总结 角度值和弧度制的互转 Deg2Rad 角度A1转弧度A2 => A2=A1*PI/180 Rad2Deg 弧度A2转换角度A1 => ...
- [转帖]The Lambda Calculus for Absolute Dummies (like myself)
Monday, May 7, 2012 The Lambda Calculus for Absolute Dummies (like myself) If there is one highly ...
- [转帖]FPGA开发工具汇总
原帖:http://blog.chinaaet.com/yocan/p/5100017074 ----------------------------------------------------- ...
- [Android分享] 【转帖】Android ListView的A-Z字母排序和过滤搜索功能
感谢eoe社区的分享 最近看关于Android实现ListView的功能问题,一直都是小伙伴们关心探讨的Android开发问题之一,今天看到有关ListView实现A-Z字母排序和过滤搜索功能 ...
- AxureRP7.0各类交互效果汇总帖(转)
了便于大家参考,我把这段时间发布分享的所有关于AxureRP7.0的原型做了整理. 以下资源均有对应的RP源文件可以下载. 当然 ,其中有部分是需要通过完成解密游戏[攻略]才能得到下载地址或者下载密码 ...
- 未能加载文件或程序集“Newtonsoft.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=30a [问题点数:40分,结帖人u010259408]
未能加载文件或程序集“Newtonsoft.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=30a [问题点数:40分,结帖人u01025 ...
- 转帖-[教程] Win7精简教程(简易中度)2016年8月-0day
[教程] Win7精简教程(简易中度)2016年8月 0day 发表于 2016-8-19 16:08:41 https://www.itsk.com/thread-370260-1-1.html ...
随机推荐
- Python——第五章:Traceback模块
traceback 模块提供了在程序中处理和分析异常时的工具,帮助开发人员更好地理解程序出现问题的原因. 使用 traceback.format_exc() 函数可以获取当前异常的堆栈信息.可以把错误 ...
- MySQL优化:12种提升SQL执行效率的有效方法
在数据库管理和优化的世界里,MySQL作为一个流行的关系型数据库管理系统,其性能优化是任何数据密集型应用成功的关键.优化MySQL数据库不仅可以显著提高SQL查询的效率,还能确保数据的稳定性和可靠性. ...
- table中td超出内容隐藏,鼠标悬停全部显示(完整版,含js代码)
一.CSS语法: text-overflow:clip | ellipsis 默认值:clip 适用于:所有元素 clip: 当对象内文本溢出时不显示省略标记(...),而是将溢出的部分裁切掉. el ...
- 平衡树——AVL算法
平衡树--AVL算法 平衡树建立在二叉搜索树的基础上,加入了两侧子树大小相对平衡的特性而避免了很多情况下的算法退化.这里AVL算法实现的AVL树就是平衡树的一种. 1.二叉搜索树 在说平衡树之前我们得 ...
- 解惑“高深”的Kafka时间轮原理,原来也就这么回事!
[摘要] Kafka时间轮是Kafka实现高效的延时任务的基础,它模拟了现实生活中的钟表对时间的表示方式,同时,时间轮的方式并不仅限于Kafka,它是一种通用的时间表示方式,本文主要介绍Kafka中的 ...
- 共赴元宇宙新纪元,华为云VR开发应用大赛总决赛倒计时7天!
摘要:"第三届华为云VR开发应用暨沈阳元宇宙开发应用大赛"总决赛即将于2月13日在沈阳市和平区揭幕. 由沈阳市和平区人民政府.华为技术有限公司共同主办的"第三届华为云VR ...
- 【文末彩蛋】数据仓库服务 GaussDB(DWS)单点性能案例集锦
摘要:介绍了13种GaussDB(DWS)单点性能的案例. 一.数据倾斜 1.1 问题描述 某局点SQL执行慢,涉及大表的SQL执行不出来结果. 1.2 分析过程 数据倾斜在很多方面都会有体现: 1) ...
- 从下个月开始,App Store 要求使用 Xcode 14 构建的 iOS 16 兼容应用程序
Xcode 继向开发者发布第一个iOS 16.5 测试版后,苹果公司周二宣布了对开发者向 App Store 提交应用程序的新要求.从下个月开始,Apple 将要求每个应用程序都必须使用 Xcode ...
- cmd 7z 文件压缩
7z压缩测试 为了方便,将7z的安装目录,添加到环境变量中 # 不加环境变量的话,需要带上全路径 C:\Users\vipsoft>"C:\\Program Files\\7-Zip\ ...
- Exception in thread "main" joptsimple.UnrecognizedOptionException: zookeeper is not a recognized option
背景: 在kafka集群上使用topic相关的命令时,报错: Exception in thread "main" joptsimple.UnrecognizedOptionExc ...