Zabbix Monitoring (ix): Automatic monitoring of Windows services

Source: Internet
Author: User
Tags eol

First, monitoring the status of the service key:


Service_state[service]

State of service. 0-running, 1-paused, 2-start Pending, 3-pause pending,

4-continue Pending, 5-stop Pending, 6-stopped, 7-unknown, 255-no such service

Returns 0 for run, 6 for shutdown, 7 for unknown, and 255 for No.


Second, manually monitor the client Agent service

1. View the Client service name


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/53/A9/wKiom1RtTwHDuf3LAAJOq622RTE909.jpg "style=" float: none; "title=" Image 23.png "alt=" Wkiom1rttwhduf3laajoq622rte909.jpg "/>

2. Add items to the monitoring host

Monitoring the Client Agent service status, here deliberately lost a few 2

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/53/A7/wKioL1RtT3rBtNRKAACKnPIqLwM572.jpg "style=" float: none; "title=" Image 24.png "alt=" Wkiol1rtt3rbtnrkaacknpiqlwm572.jpg "/>

3. Create a Trigger

Set not to 0 o'clock alarm because return 0 indicates run

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/53/A9/wKiom1RtTwKSycQhAADJlvr3kXU118.jpg "style=" float: none; "title=" Image 25.png "alt=" Wkiom1rttwksycqhaadjlvr3kxu118.jpg "/>

4. View the monitor image (found in last data)

You can see that because there is no Zabbix Agent2 this service, return 255, 2 is removed and then observed to see that the return value is 0

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/53/A7/wKioL1RtT3qhbubBAAEyszkTBm0319.jpg "style=" float: none; "title=" Image 26.png "alt=" Wkiol1rtt3qhbubbaaeyszktbm0319.jpg "/>


III. Automatic monitoring of Windows service status

1. Create a script

Create a new Discoverservice.bat file on the client and place it in the C:\zabbix\ directory with the following contents:

@echo Offecho {echo "data": [for/f "Skip=1 eol= tokens=*"%%i in (' net start ') do echo {"{#SERVIC E_name} ":"%%i "},echo {" {#SERVICE_NAME} ":" Zabbix Agent "}echo]echo}

Script Description:

NET start command outputs all started services, but the first line has "started the following Windows services:" And the last line "command completed successfully. ", need to be removed, so skip=1 eol= life tokens=* to understand, skip the first line and the beginning of the line, and then insert a {" {#SERVICE_NAME} ":" Zabbix Agent "} to ensure that there is no comma at the end, to meet the JSON format.


2. Modify Client Configuration

Add the following in zabbix_agentd.conf

Unsafeuserparameters=1userparameter=servicestate,c:\zabbix\discoverservice.bat

Restart Zabbix AGENTD Service


Tip: The script and configuration of the client can be done in advance at the time of installation, referencing my installation documentation:

http://ywzhou.blog.51cto.com/2785388/1579165


3. Client Testing

Run the CMD,CD to C:\zabbix directory as Administrator, enter the script file name, carriage return:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/53/A9/wKiom1RtUIrCYNOqAAMrrX_vtC8264.jpg "style=" float: none; "title=" Image 27.png "alt=" Wkiom1rtuircynoqaamrrx_vtc8264.jpg "/>


4. Service-Side testing

[Email protected] ~]#/usr/local/zabbix/bin/zabbix_get-s 10.188.1.46-k servicestate

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/53/A7/wKioL1RtUQPArH_TAAQndBLJxs4920.jpg "style=" float: none; "title=" Image 28.png "alt=" Wkiol1rtuqparh_taaqndbljxs4920.jpg "/>

Note: After visual Studio Team Foundation in the figure, the Chinese will be garbled and will be explained later.


5. Create automatic monitoring rules in Windows templates

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/53/A7/wKioL1RtUQOgUfjrAAEeQuwJDM0933.jpg "style=" float: none; "title=" Image 29.png "alt=" Wkiol1rtuqogufjraaeequwjdm0933.jpg "/>


6. Create an items prototype

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/53/A9/wKiom1RtUIvyFK4MAAFdQZMAwKs490.jpg "style=" float: none; "title=" Image 30.png "alt=" Wkiom1rtuivyfk4maafdqzmawks490.jpg "/>


7. Create a trigger prototype

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/53/A7/wKioL1RtUQOjMsr8AAFjaKIrlew835.jpg "style=" float: none; "title=" Image 31.png "alt=" Wkiol1rtuqojmsr8aafjakirlew835.jpg "/>


8. View automatic discovery rules for monitoring hosts

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/53/A9/wKiom1RtUIuxbV0QAALUCsbpbfk374.jpg "style=" float: none; "title=" Image 32.png "alt=" Wkiom1rtuiuxbv0qaalucsbpbfk374.jpg "/>

Description: The agent service repeats once, without a tube, Zabbix does not add duplicate item.


9, check the results of automatic monitoring services

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/53/A7/wKioL1RtUQOxkc6NAAcTGyHcORg540.jpg "style=" float: none; "title=" Image 33.png "alt=" Wkiol1rtuqoxkc6naactgyhcorg540.jpg "/>


10. View recently returned values

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/53/A9/wKiom1RtUIyD2QUhAAUKo1jDuDE700.jpg "style=" float: none; "title=" Image 34.png "alt=" Wkiom1rtuiyd2quhaauko1jdude700.jpg "/>


Conclusion: Autodiscover ports and services Add a large number of items, so it is not recommended to add graph to the template, and it is a good idea to create a new port group and service group when creating a template, to make it easier to view, to disable triggers for some unimportant services, or to be bothered to receive mail alerts.

In addition, Chinese garbled problem reference:



This article is from the "Moon Ching Xing Fei" blog, please be sure to keep this source http://ywzhou.blog.51cto.com/2785388/1579973

Zabbix Monitoring (ix): Automatic monitoring of Windows services

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.