Zabbix combined with bat script to achieve multiple application status monitoring method

Zabbix combined with bat script to achieve multiple application status monitoring method

Scenario simulation:

Some domestic companies need to run certain window programs (ie. .exe) to support important business operations. Once these important window programs are interrupted, it will cause huge economic losses or affect work efficiency, and the consequences are so serious. Therefore, I want to monitor the status of multiple programs through Zabbix. Once these important window programs are interrupted, an alarm will be generated to notify the operation and maintenance personnel to repair them.

Prepare two bat scripts in advance, finde.bat (make the exe program to be monitored automatically discovered), check_exe_status.bat (get the status of the monitored exe program)
Step 1 – Prepare the bat script:

The contents of the findexe.bat script are as follows

@echo off

setlocal enabledelayedexpansion

set /an=0

set /a n1=0

for %%i in (%*) do (set /a n+=1)

@echo {"data":[

for %%a in (%*) do (

set /a n1+=1

@echo {"{#SERVERNAME}":"%%a"

if !n1! neq !n! (

@echo },

) else (

@echo }

)

)

echo ]}

The contents of the check_exe_status.bat script are as follows @echo off

tasklist|findstr ^%1 >/NUL 2>&1

if %errorlevel% == 0 (

echo "running"

) else (

echo "norunning"

)

Note that tasklist|findstr ^%1 >/NUL 2>&1 is used to check whether the monitoring program exe is running.

Step 2 – Create a monitoring template

insert image description here

Click Add to create a template

Then in the check_exe_status template just now, create an automatic discovery rule

insert image description here

The key value in the figure is findexe. The parameters in the key value are the multiple processes that the customer wants to monitor, enclosed in double quotes and separated by spaces.

findexe[“firefox.exe chrome.exe xxxlll.exe”]

If there are other exe programs to monitor, just separate them with spaces and fill in the blanks.

Then, under this automatic discovery rule, create a new monitoring item prototype.

insert image description here

The value of {#SERVERNAME} in the prototype is fixed and defined in the first step of findexe.bat.

Step 3 – Configure custom keys in zabbix_agent.conf

insert image description here

Customize the script path, and the custom key value must be consistent with the template name

Restart zabbix_agent

Step 4 – Verify multiple exe program status

insert image description here

Three exe program names are automatically discovered, among which xxxll.exe is a non-existent exe. To verify the effect, now close the firefox.exe program and see if its latest data will be displayed as norunning.

insert image description here

Verification successful.

This is the end of this article about how to use Zabbix combined with bat scripts to monitor the status of multiple applications. For more information about Zabbix combined with bat scripts, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Python script implements Zabbix multi-line log monitoring process analysis
  • Use Python script zabbix custom key to monitor oracle connection status
  • How to use python script to implement monitoring report in ZABBIX3.2
  • The implementation principle of Zabbix dynamic execution monitoring collection script

<<:  javascript realizes 10-second countdown for payment

>>:  Solution to nacos not being able to connect to mysql

Recommend

14 practical experiences on reducing SCSS style code by 50%

Preface Sass is an extension of the CSS3 language...

Solve the mobile terminal jump problem (CSS transition, target pseudo-class)

Preface Many friends who have just come into cont...

Pitfalls based on MySQL default sorting rules

The default varchar type in MySQL is case insensi...

How to set password for mysql version 5.6 on mac

MySQL can be set when it is installed, but it see...

Vue implements form validation function

This article mainly describes how to implement fo...

Detailed use of Echarts in vue2 vue3

Table of contents 1. Installation 2. Use Echarts ...

10 content-related principles to improve website performance

<br />English address: http://developer.yaho...

iFrame is a great way to use it as a popup layer to cover the background

I have been working on a project recently - Budou ...

Java uses Apache.POI to export HSSFWorkbook to Excel

Use HSSFWorkbook in Apache.POI to export to Excel...

Mysql accidental deletion of data solution and kill statement principle

mysql accidentally deleted data Using the delete ...

MySQL enables slow query (introduction to using EXPLAIN SQL statement)

Today, database operations are increasingly becom...

Detailed explanation of how to exit Docker container without closing it

After entering the Docker container, if you exit ...