首页 > 系统相关 >prometheus 监控windows

prometheus 监控windows

时间:2023-03-09 16:33:46浏览次数:44  
标签:exporter windows win etc prometheus ansible 监控 wind

通过ansible 批量操作windows机器,部署windows_exporter-0.21.0-amd64.exe

1、需要检查的点:

1)、ansible登录用户名必须与系统组记录的成员名一致,要不然会一直报错,"ntlm: the specified credentials were rejected by the server"

 

 2)、检查网络状态是否是专有网络

 

 

2、在被控windows电脑中,通过管理员方式打开powershell,执行如下

winrm quickconfig
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'

 

3、控制端在linux机器上,安装如下

pip install pywinrm>=0.2.2

4、ansible host可以如下

[wind]
my_server ansible_host=192.168.61.153 ansible_ssh_user="aaa\bbb" 
ansible_ssh_pass="xxx"

[wind:vars]
ansible_ssh_port=5985
ansible_connection="winrm"
ansible_winrm_server_cert_validation=ignore 
ansible_winrm_transport=ntlm

5、测试一下

[root@www ~]# ansible -i /etc/ansible/myhost wind -m win_ping
my_server | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

 

6、开始批量操作

---
- hosts: wind
  gather_facts: no
  tasks:
    - name: create directory
      win_file: 
        path: D:\ops_control
        state: directory
    - name: copy pkg
      win_copy:
        src: "{{item}}"
        dest: D:\ops_control\
        force: yes
      with_items:
        - /etc/ansible/pkg/windows_exporter-0.21.0-amd64.exe
        - /etc/ansible/pkg/wind_exporter.exe
        - /etc/ansible/config/config.yml
        - /etc/ansible/pkg/start_win_exporter.bat


#创建目录
ansible -i /etc/ansible/myhost wind -m win_file -a "path=D:\ops_control state=directory"

复制
ansible -i /etc/ansible/myhost wind -m win_copy -a "src=/etc/ansible/pkg/windows_exporter-0.21.0-amd64.exe dest=D:\ops_control\ force=yes"
ansible -i /etc/ansible/myhost wind -m win_copy -a "src=/etc/ansible/config/config.yml dest=D:\ops_control\ force=yes"
ansible -i /etc/ansible/myhost wind -m win_copy -a "src=/etc/ansible/pkg/start_win_exporter.bat dest=D:\ops_control\ force=yes"

执行
ansible -i /etc/ansible/myhost wind -m win_command -a "chdir=D:\ops_control  .\start_win_exporter.bat"


重启
ansible -i /etc/ansible/myhost wind -m raw -a "taskkill /F /IM windows_exporter-0.21.0-amd64.exe /T"

 

启动操作,着实不太友好,如果哪位大佬有比较好的通过ansible 执行bat在后台启动的,可以赐教一下。

7、在windows的计划任务里面部署 wind_exporter.exe,健康检查与启动。

 这个exe文件可以参考 

golang win10 app存活状态简单监控

8、ansible部分参考

https://cloud.tencent.com/developer/article/1788393

标签:exporter,windows,win,etc,prometheus,ansible,监控,wind
From: https://www.cnblogs.com/bill2014/p/17195775.html

相关文章

  • cdc-file-transfer 谷歌开源的windows 到linux 同步工具
    cdc-file-transfer是基于contentdefinedchunking以及fastcdc技术,cdc-file-transfer目前提供了两种工具cdc_rsync类似rsync的同步能力,进行文件拷贝,但是性能相比rsync......
  • Windows server2012的DHCP ping通测试
    1.首先创建俩个windowsserver2012版本的虚拟机,进行基础配置时,保证每个虚拟机处在同一lan网段 1.进入虚拟机时关闭俩台设备的防火墙    2.右击右下角的网络图标......
  • 云音乐 Android 内存监控探索篇
    小结:1、编码不规范导致的内存异常问题:内存泄露、大对象、大图等不合理的内存使用2、简单来说内存泄露就是某些不再使用的对象被其他生命周期更长的GCRoot直接或者间......
  • [转]C# 获得窗体句柄并发送消息(利用windows API可在不同进程中获取)
    编写程序模拟鼠标和键盘操作可以方便的实现你需要的功能,而不需要对方程序为你开放接口。首先,引入如下API接口:  [DllImport("user32.dll")]publicstaticexternIntP......
  • Windows快捷方式备份还原脚本
    Windows快捷方式备份还原脚本适用场景单纯备份快捷方式安装程序迁移至其他磁盘(程序文件父子层级关系不变的情况下)安装程序还是在原来的磁盘的位置,重建快捷方式(重装系统......
  • Windows 安装 Node.js 版本控制器 nvm
    参考文档:https://blog.csdn.net/MJOY791270505/article/details/126400205nvm的安装和使用(详细)_nvm安装_深沉影子灰的博客-CSDN博客1.nvm是什么?node.jsversionman......
  • How to remove "Trending searches" in Windows 10 search?
    openregistryeditor(typeregeditonthesearchboxthenhitenter)navigatetoHKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windowscreate"Explorer"......
  • Windows 下安装RabbitMQ
    下载并安装erlang原因:RabbitMQ服务端代码是使用并发式语言Erlang编写的,安装RabbitMQ的前提是安装Erlang。下载地址:http://www.erlang.org/downloads提示:安装之前务必查看E......
  • 磁盘维护命令之 dd 命令在Windows上的用法
    注意:新手不要轻易尝试,否侧容易把系统写挂掉1.网址:http://www.chrysocome.net/dd 下载dd工具,选择dd-0.5.zip下载      2.将下载后的文件解压后拷贝到E盘 ......
  • windows启动和关闭nginx
    1、进入nginx的目录D:cdEnvironment\webServer\nginx2、启动nginxstartnginx会闪出一个黑窗口然后自动关闭3、查看nginx是否启动tasklist/fi"imagenameeqngin......