Get the App
SLTechnology News&Howtos  ›  Servers  › 

Batch monitor whether the server service is normal

Shulou Source: shulou.com Published: 2022-06-03 00:45:04 10月02日 Update

The abnormal stop of service will be encountered in the work. In view of these problems, a monitoring of service status is done.

For example, time synchronization service NTP, abnormal stop, no alarm system is a very dangerous situation.

This paper adopts:

Shell script + Custom Monitoring zabbix to realize SMS alarm

The script is as follows:

#! / bin/bash# Confirm OS Versionunset OS_VERSIONuname-r | grep el5 > / dev/null & & OS_VERSION=el5uname-r | grep el6 > / dev/null & & OS_VERSION=el6uname-r | grep el7 > / dev/null & & OS_VERSION=el7# Begin check if ["$OS_VERSION" = "el5"-o "$OS_VERSION" = "el6"]; then pidof ntpd & > / dev/null if [$?-ne 0] Then ntpd_service_status=false # # can define a variable as a parameter and customize it to echo "ntpd_service_status $ntpd_service_status" echo "DOWN" echo "Check [ntp service status] in the monitoring item. FAILED "else ntpd_service_status=true # echo" UP "fielif [" $OS_VERSION "=" el7 "]; then pidof chronyd & > / dev/null if [$?-ne 0]; then ntpd_service_status=false echo" DOWN "echo" Check [chrony service status]. FAILED "else ntpd_service_status=true echo" UP "fifi

Zabbix script parameter transfer storage path

* * installed by yum * *

/ usr/lib/zabbix/alertscripts/

Writing a simple script for passing parameters

#! / bin/bashaddressee=$1theme=$2content=$3 echo "$addressee" > > / tmp/test.txt to verify whether zabbix is calling a script, write an echo living experiment environment that is not available from Ali Dayu of the company.

Zabbix alarm medium setting

Configuration action

Configure user-alarm medium

Configure to the host and trigger the alarm manually.

Tags: Scripts services monitoring configuration media status alarms hazards hosts companies actions parameters variables big fish ideas manual time status environment users Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn MariaDB Linux Apple