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 connection
  • password - The password for the SSH connection, required if private_key is not specified
  • private_key - The SSH private key for the SSH connection, required if password is not specified
  • certificate - The SSH certificate for the private key for the SSH connection
  • known_hosts - Optional SSH known hosts file to use to verify hosts
  • host_key_algorithms - Optional list of SSH host key algorithms to use
    • See constants beginning with KeyAlgo* in crypto/ssh
  • timeout - Optional timeout of the SSH connection, session and optional command.
    • The default comes from the --collector.ssh.default-timeout flag.
  • command - Optional command to run.
  • command_expect - Optional regular expression of output to expect from the command.
  • output_metric - If true the exporter will expose the command output via ssh_output{output="<output here>"} metric.
  • output_truncate - Sets the max length for a string in ssh_output metric's output label. Set to -1 to 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的更多相关文章

  1. nginx负载均衡基于ip_hash的session粘帖

    nginx负载均衡基于ip_hash的session粘帖 nginx可以根据客户端IP进行负载均衡,在upstream里设置ip_hash,就可以针对同一个C类地址段中的客户端选择同一个后端服务器,除 ...

  2. [转帖]网络协议封封封之Panabit配置文档

    原帖地址:http://myhat.blog.51cto.com/391263/322378

  3. [转帖]零投入用panabit享受万元流控设备——搭建篇

    原帖地址:http://net.it168.com/a2009/0505/274/000000274918.shtml 你想合理高效的管理内网流量吗?你想针对各个非法网络应用与服务进行合理限制吗?你是 ...

  4. 3d数学总结帖

    3d数学总结帖,以下是对3d学习过程中数学知识的简单总结 角度值和弧度制的互转 Deg2Rad 角度A1转弧度A2 => A2=A1*PI/180 Rad2Deg 弧度A2转换角度A1 => ...

  5. [转帖]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 ...

  6. [转帖]FPGA开发工具汇总

    原帖:http://blog.chinaaet.com/yocan/p/5100017074 ----------------------------------------------------- ...

  7. [Android分享] 【转帖】Android ListView的A-Z字母排序和过滤搜索功能

      感谢eoe社区的分享   最近看关于Android实现ListView的功能问题,一直都是小伙伴们关心探讨的Android开发问题之一,今天看到有关ListView实现A-Z字母排序和过滤搜索功能 ...

  8. AxureRP7.0各类交互效果汇总帖(转)

    了便于大家参考,我把这段时间发布分享的所有关于AxureRP7.0的原型做了整理. 以下资源均有对应的RP源文件可以下载. 当然 ,其中有部分是需要通过完成解密游戏[攻略]才能得到下载地址或者下载密码 ...

  9. 未能加载文件或程序集“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 ...

  10. 转帖-[教程] Win7精简教程(简易中度)2016年8月-0day

    [教程] Win7精简教程(简易中度)2016年8月 0day 发表于 2016-8-19 16:08:41  https://www.itsk.com/thread-370260-1-1.html ...

随机推荐

  1. JPA复杂查询时间查询分页排序

    JPA复杂查询时间查询分页排序 JPA复杂查询时间查询分页排序,工作上用到,因为项目是jpa,记录.代码囊括了:查询条件+时间范围+分页+排序 其实我也不太想用jpa,但是他也有优点,操作可以兼容多种 ...

  2. BFS(一)单词接龙

    对应 LeetCode 127 单词接龙 问题定义 给定一个字典序列 wordList,一个初始的单词 beginWord 和一个目标单词 endWord,现在要求每次变换满足以下条件将 beginW ...

  3. 聊聊Llama2-Chinese中文大模型

    转载请注明出处:https://www.cnblogs.com/zhiyong-ITNote 基本简述 Llama2-Chinese 大模型:由清华.交大以及浙大博士团队领衔开发:基于200B中文语料 ...

  4. CoralCache:一个提高微服务可用性的中间件

    摘要:当数据库出问题时能降级从本地缓存的数据中查询数据,CoralCache就是这样一个提高微服务可用性的中间件. 背景 有些场景下,微服务依赖数据库中一些配置项或者数量很少的数据,但当数据库本身有问 ...

  5. DTSE Tech Talk | 第11期:深入浅出畅谈华为云低时延直播技术

    摘要:详解华为云低时延直播在时延.首屏.卡顿率等体验的优化方案,及如何快速接入方法. 本文分享自华为云社区<DTSE Tech Talk | 第11期:深入浅出畅谈华为云低时延直播技术>, ...

  6. 华为云IoT设备接入服务全体验

    摘要:华为云IoT设备接入服务,海量设备,一键接入,你值得拥有! 本文分享自华为云社区<[云驻共创]Huawei Mate 40产线直击之 华为云IoT设备接入服务全体验>,原文作者:启明 ...

  7. DevCloud加持下的青软,让教育“智”上云端

    摘要:构建多体系人才云实践环境,提供企业所需人才培养平台,构建以学习为中心的全新教育生态. 本文分享自华为云社区<[云享·伙伴]第5期:华为云DevCloud加持下的青软,让教育"智& ...

  8. 云图说|Git云上仓库哪家好?一张图了解华为云代码托管服务

    阅识风云是华为云信息大咖,擅长将复杂信息多元化呈现,其出品的一张图(云图说).深入浅出的博文(云小课)或短视频(云视厅)总有一款能让您快速上手华为云.更多精彩内容请单击此处. 摘要: 云办公时代已然到 ...

  9. 带你了解敏捷和DevOps的发布策略

    摘要:随着数字化.信息化.网络化和智能化的普及和发展,企业对软件服务的质量和上线速度要求越来越高.传统研发模式难以满足要求,企业的开发运维模式逐渐向敏捷和DevOps 转型,敏捷和DevOps理念正被 ...

  10. ScreenToGif 录屏转git图片

    ScreenToGif 一款开源的屏幕录制,允许您记录屏幕的选定区域.网络摄像头的实时信息或素描板上的实时绘图.之后,您可以编辑动画并将其保存为 gif.apng.视频.psd 或 png 图像. 官 ...