Remote modification of Nrpe scripts

Source: Internet
Author: User

Remote modification of the Nrpe script preface: As an O & M personnel, frequent modification of monitoring is inevitable. It is better to change a small number of machines, if the amount is too large, it will not be easy. As the boss said, it would be silly to modify the check_disk parameter of all machines. I met today. I wrote a script to modify the check_swap of all business systems for your reference. Two files: www.2cto.com 1. hostlist: host file for modifying monitoring parameters; 2. editnrpe. sh: This is my script. When executing the script, you need to call file 1; 3. scannrpe. sh: after the modification, I will scan the Nrpe script file. The following script implements the following functions. The previous Nrpe parameter is: command [check_swap] =/usr/local/nagios/libexec/check_swap-w 80%-c 70%: command [check_swap] =/usr/local/nagios/libexec/check_swap-w 75%-c 65% Script: [only.liu@l-rtools1.ops.cn1 ~] $ Cat editnrpe. sh #! /Bin/bash # This script is auto edit Nrpe # By Only. liu swapfile = "/usr/local/nagios/etc/nrpe. cfg "for host in 'cat hostlist' do ping-c 1 $ host >>/ dev/null 2> & 1 if [" $? "= 0]; then echo" $ host is alived! "Ssh $ host" sudo sed-I-e '/check_swap/{s/\-w 80 \ %/\-w 75 \ % /; s/-c 70 \ %/-c 65 \ %/} ''$ swapfile '" if ["$? "= 0]; then echo" Swap is edited success! "Ssh $ host" grep "check_swap" $ swapfile "fi ssh $ host" ps aux | grep nrpe | grep-v grep | awk '{print \ $2}' | xargs sudo kill-HUP "ssh $ host" exit "echo" Nrpe restart OK! "Fidone after modification, don't worry, then scan: script is as follows: www.2cto.com [only.liu@l-rtools1.ops.cn1 ~] $ Cat scannrpe. sh #! /Bin/bash # This script is auto edit Nrpe # By Only. liu # hostlist = 'cat hostlist' swapfile = "/usr/local/nagios/etc/nrpe. cfg "for host in 'cat hostlist' do ping-c 1 $ host >>/ dev/null 2> & 1 if [" $? "= 0]; then echo" $ host is alived! "Ssh $ host" sudo sed-n'/check_swap/P' $ swapfile '"fidone

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.