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

How to set PATH environment variable in Linux system (3 methods)

1. In Windows system, many software installations...

Linux traceroute command usage detailed explanation

Traceroute allows us to know the path that inform...

Detailed explanation of the usage of setUp and reactive functions in vue3

1. When to execute setUp We all know that vue3 ca...

About CSS floating and canceling floating

Definition of Float Sets the element out of the n...

KTL tool realizes the method of synchronizing data from MySQL to MySQL

Use ktl tool to synchronize data from mysql to my...

XHTML 2.0 New Features Preview

<br />Before browsers can handle the next ge...

Vue project realizes paging effect

The paging effect is implemented in the vue proje...

How to analyze MySQL query performance

Table of contents Slow query basics: optimizing d...

Detailed tutorial on configuring local yum source in CentOS8

The centos8 distribution is released through the ...

PHP scheduled backup MySQL and mysqldump syntax parameters detailed

First, let's introduce several common operati...