Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The nagios page monitors what the script looks like

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "nagios page monitoring script is like", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "nagios page monitoring script is like" this article.

The purpose of writing this script is like this: although the company uses nagios to monitor all server information and sets it to send an SMS alarm after three checks, it feels that the alarm problem has occurred for half a day after three times, and the response is slow. (what? You said to change it to once every minute and call the police if there is a problem. All right! May your SMS inbox explode as soon as possible, and you can't sleep when you are bothered by the police at night. There are a lot of alarms not really because there is something wrong with the service, is it! Is there a compromise? Write such a script to help stare at the nagios page, send an email as soon as the word WARNING CRITICAL Unhandled appears on the page, and you can be notified by email reminder or some other method, so that you can check which service has gone wrong in the first place. I have no objection if I have to find someone to stare at the monitoring page during office hours. Of course, some companies have got a TV wall full of exceptions to surveillance information)

All right, needless to say, there is usually a page on the web of nagios that can see all the services. I defined hostgroup groups for all the servers, so that you can see the overview of all the servers on the summary page, as shown below:

The address of this page is: http://www.xman.com/nagios/cgi-bin/status.cgi?hostgroup=all&style=summary

(it is a pure coincidence that the original address is changed if there is any similarity)

The following is simple. Use curl to obtain web page information and filter it. The result we want is ok. The specific script is as follows:

#! / bin/bash

# Author: storysky

# This script will test the nagios page and get Warning or Critical's number

Curla=$ (curl "http://www.xman.com/nagios/cgi-bin/status.cgi?hostgroup=all&style=summary">

If [$curla-gt 0]

Then

Echo "The xman have Warning or Critical" | mail-s "The xman page have Warning or Critical" storysky@gmail.com

Fi

Curlb=$ (curl "http://www.UFO.com/nagios/cgi-bin/status.cgi?hostgroup=all&style=summary"-uUFO:UFO123-s | awk'/ WARNING | CRITICAL | Unhandled/' | wc-l)

If [$curlb-gt 0]

Then

Echo "The UFO have Warning or Critical" | mail-s "The UFO page have Warning or Critical" storysky@gmail.com

Fi

As for the worry that mail will not be able to send email, please see my previous article, "do you often fail to send email on your mail?"

Http://storysky.blog.51cto.com/628458/631267

Put him in the scheduled task and execute it every minute during office hours. (why not after work time? Because I can't see it even if it is sent to me after work time.

* / 1 10-19 * * 1-5 / scripts/auto_nagios.sh

The above is all the content of the article "how is the nagios page monitoring script?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report