码迷,mamicode.com
首页 > Windows程序 > 详细

Windows zabbix监控远程进程实现机制

时间:2016-11-06 01:51:03      阅读:581      评论:0      收藏:0      [点我收藏+]

标签:tor   虚拟   hid   strrev   amp   trre   ade   命令   mon   

  最近负责zabbix监控部署方面的工作,需要完成本地服务端监控远程虚拟机的运行状态(CPU、打开的进程等),与大家分享下我的实现方法。

  (1) 首先,需要实现记录zabbix客户端的进程的批处理:zabbix_task.bat;

  zabbix_task.bat内容如下:

  @echo off

  chcp 65001

  tasklist /v |findstr "%username%" > c:/zabbix_temp.txt  #进程路径根据个人习惯设置

  pause

  (2) 其次,实现实时监控远程的进程的批处理,使用VBS脚本调用脚本1实现定时刷新进程,脚本命名为:zabbix_monitor.vbs

  本地电脑远程创建远程电脑的计划任务程序(当每次登陆时自动运行脚本zabbix_monitor.vbs),进行实时监控电脑进程

  zabbix_monitor.vbs内容如下:

  Set ws = CreateObject("Wscript.shell")

  do
  ws.run left(Wscritp.Scritpfullname,instrrev(wscript.Scriptfullname,"\")-1)&"\zabbix_task.bat",vbhide

  Wscript.sleep 5000 

  loop

  (3) 最后,实现过滤筛选zabbix服务端需要监控的进程脚本:zabbix_tasklist.bat

  @echo off

  setlocal enabledelayedexpansion
  chcp 65001
  echo {
  echo "data" :[
  for /f "tokens = 9*" %%i in (c:\zabbix_temp.txt)
  do(
  set "str=%%j"
  set "str=!str:\=\\!"
  if"!str!"=="!str:暂缺=!" if"!str!"=="!str:Wnd=!" if"!str!"=="!str:N/A=!" if"!str!"=="!str:MCI=!" if"!str!"=="!str:dwn=!" if"!str!"=="!str:taskeng=!"   if"!str!"=="!str:KSafeTray=!" if"!str!"=="!str:6EBF21D6BA1F=!" if"!str!"=="!str:jusched=!" if"!str!"=="!str:HwUvPUpgrade=!"                   if"!str!"=="!str:SPES=!" if"!str!"=="!str:Windows Update=!" if"!str!"=="!str:cmd.exe=!" if"!str!"=="!str:SysFader=!"
  echo {"{#TASK_NAME}":"!str!"},
  )
  echo {"{#TASK_NAME}":"NULL"}
  echo]
  echo
  }

 PS:本地电脑访问远程电脑创建计划任务程序,可以使用批处理schtask命令完成访问远程电脑 

 

  

  

Windows zabbix监控远程进程实现机制

标签:tor   虚拟   hid   strrev   amp   trre   ade   命令   mon   

原文地址:http://www.cnblogs.com/openfly/p/6034314.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!