a few common Linux monitoring scriptsA few common Linux monitoring scriptsThe following is a number of host monitoring scripts, we can change according to their own circumstances, and hope to give you a little help.1. Check the host network card traffic#!/bin/bash#network#Mike. XuWhile:; DoTime= ' Date +%m '-"%d" "%k":
In linux, some simple system monitoring script companies do not have a dedicated system administrator. Therefore, some server security measures have to be done by our programmers themselves. We do not know much about Linux servers and have checked some information, below are a few simple server monitoring scripts written by myself. we hope that the pipeline that
Configure the servers to be monitored
Array definition: host_ports= (Host_name=host_port=uri_path)Host_name for easy-to-identify server namesHost_port for server IP and service portUri_path the request path for the economy
Open firewall port for script running server, intranet IP and extranet IP, but be consistent with Host_port-A rh-firewall-1-input-m state--state new-m tcp-p tcp-s 121.45.111.17--dport 8090-j ACCEPT
Monitoring
After installing the COLLECTD tool on the host, you can obtain data such as cpu,memery,if-traffic of the virtual machine on the host by using the COLLECTD tool. Monitoring of these data can be achieved through Nagios monitoring scripts.The following is a simple monitoring virtual machine memory script:#!/bin/bash#desc:tocheckmemoryaboutvminstancestate_ok=0state_w
Achieve the following goals1, monitor the Oracle database monitoring and the status of the instance, if the monitoring or the instance hangs, then starts, and the Mail informs, the script attempts to start the corresponding service2, if the service started successfully, then the mail notification just hung, and now has started successfully, if the startup failed, then the MailTips, just hung, and still can
Zabbix Monitoring Windows log Scripts The script is used to monitor the logs on the Windows Server, view the log file at the end of n rows, and if n rows contain a field, output 0, otherwise output 1, and then zabbix the profile empty definition Kye, for monitoring.Text file line break is "\ n"Edit Script log.pyImportsysimportredeflast_lines (filename,lines=1): Lines=int (lines) block_size=1024block = ' nl_
/sendmail.log 2>1echo "******" >>/usr/local/zabbix/share/zabbix/alertscripts/sendmail.log 2>1Note that the arguments must be extended in quotation marks, otherwise the parameters will not be fully recognized.send_alert_mail.py Script content:Cat send_alert_mail.py#!/usr/bin/python#coding =utf-8‘‘‘@date 20160808@author LJB‘‘‘Import SysImport SmtplibFrom Email.mime.text import Mimetextmailto_list=[' [email protected]Mail_host= "Smtp.yourdomain.com" #设置服务器mail_user= "User" #用户名mail_pass= "Password"
average, divided into and out. If the script executes every 1 minutes, the calculated traffic value is the flat value of 1 minutes. The script has two parameters the first is the name of the network card, such as: Eth0, the second is in or out is in or out of the traffic, the script can calculate the machine on all the network card traffic as long as the first parameter change Eth0,eth1,lo and so on. But it's a pity that the first run will automatically create a temporary file for the *net[io].
A script for monitoring the Elasticsearch index was found in the Nagios community, and then modified to use the listening IP that is normally used for incoming elasticsearch for using a script that monitors the Elasticsearch health state in Nagios#!/bin/bash#check_elasticsearch_health.sh#memofornagiosoutputsstate_ok=0state_warning=1state _critical=2state_unknown=3#positionparameterjudgmentif[$#-lt1];then echo "Pleaseenterhostaddress" echo "Ex>$0host_a
Break fi # #注意一定要再次初始化为空testprg="" DoneEcho "End $---($pName,$myStatus,$testPrg)-------------------"if[-Z"$pName"]; Then # # #发现测被测试程序异常退出后, stop the test programKillall MytesterEcho "Stop Testprogram mytester"fiEcho "' Date '"Echo "---------------current Status------------------"PS | Grep-e"mainapp| Subapp "| Grep-v grepEcho ""This realizes that every 10s reads the status of the process, and then displays, when the discovery process exists and the s
the control of the script, designed the above scripts.Scripting practices:This script I have used in the production environment, we can be placed on our slave MySQL machine for monitoring, and sometimes also recommended manual check, once found that rsync--delete automatically deleted the/data/data inside the data, that is, from the database location, the script does not alarm.Post-application:The post-company MySQL database is prepared by a master o
/nrpe.cfg fileVim/etc/nagios/nrpe.cfg # Add a line: (on client)command[check_disk]=/usr/lib/nagios/plugins/check_disk.shSave, restart Nrpe service/etc/init.d/nrpe Restart (on client)on the server side operation:4. The way to detect if the script is working correctly is to execute the following command to the server side:check_nrpe-h ip-c check_disk (server)//This IP is the IP of the clientif normal, it will output a row of disk detection data, or may be error. 5. Add the appropriate service to t
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.