我的文件是:
[root@test等]# cat nrpe.cfg我想更换/dev/sdb和/dev/xvda1在 ruby 中
命令 [check_users]=/usr/local/nagios/libexec/check_users -w 30 -c 35 命令[check_load] = /usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20 命令[check_disk] = /usr/local/nagios/libexec/check_disk -w 20%-c 10%-p /dev/sda1 命令[check_hda]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sdb 命令 [check_procs]=/usr/local/nagios/libexec/check_procs -w 200 -c 250
答案1
File.write('nrpe.cfg', File.read('nrpe.cfg').gsub('/dev/sdb', '/dev/xvda1'))