首页 > 代码库 > 如何配置nagios监控SUN(富士通)MX000系列服务器的XSCF

如何配置nagios监控SUN(富士通)MX000系列服务器的XSCF

  • 配置环境说明

192.168.3.80-XSCF地址192.168.2.80-solaris操作系统IP地址 (nagios客户端)192.168.2.120-nagios服务器端check_xscf.pl-检查xscf的执行脚本,放在nagios客户端上。check_xscf.cfg-检查xscf的配置文件,主要用于设置温度和电压的阈值,放在nagios客户端上。脚本下载地址:http://exchange.nagios.org/directory/Plugins/Uncategorized/Plugin-to-check-Sun%27s-XSCF-%28local-service%29/details脚本执行方式:nagios服务器端通过check_nrpe调用nagios客户端上的check_xscf.pl脚本来执行xscf命令。

  • 在nagios客户端上为用户nagios生成rsa key

以root登录nagios客户端: 192.168.2.80-bash-3.00# grep nagios /etc/shadownagios:*LK*:::::::-bash-3.00# su - nagiosSun Microsystems Inc.   SunOS 5.10      Generic January 2005为nagios用户产生ssh rsa key:$ /usr/bin/ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/usr/local/nagios/.ssh/id_rsa):Created directory ‘/usr/local/nagios/.ssh‘.Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /usr/local/nagios/.ssh/id_rsa.Your public key has been saved in /usr/local/nagios/.ssh/id_rsa.pub.The key fingerprint is:69:d5:16:3a:e7:0d:0d:df:fe:26:96:08:f3:a4:55:f3 nagios@acs00mlcprc01$ cd /usr/local/nagios/.ssh$ lsid_rsa      id_rsa.pub$ more id_rsa.pubssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAvryQqyhFPzcXzSJiIM9JWm0jl3igF8MgJQAUMZCj6YTajXNMZOfrjY/OO0gjmGyz/t+I4EJDsVw4g8bvbYvsolp7acE6eJ43wCQ+5Gx/rjqxwE7LYnwGBPxDLtuSXIjwwwroLbjNMe0cbYjmA04HHnX58yu+Ne+TOvcqttXzVN0= nagios@acs00mlcprc01以上是rsa public key的内容。
  • 登录XSCF,增加ssh用户public key

XSCF> showssh -c pubkeyXSCF> setssh -c addpubkey -u mlcPlease input a public key:ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAvryQqyhFPzcXzSJiIM9JWm0jl3igF8MgJQAUMZCj6YTajXNMZOfrjY/OO0gjmGyz/t+I4EJDsVw4g8bvbYvsolp7acE6eJ43wCQ+5Gx/rjqxwE7LYnwGBPxDLtuSXIjwwwroLbjNMe0cbYjmA04HHnX58yu+Ne+TOvcqttXzVN0= nagios@acs00mlcprc01XSCF> showssh -c pubkeyPublic key:     1  ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAvryQqyhFPzcXzSJiIM9JWm0jl3igF8MgJQAUMZCj6YTajXNMZOfrjY/OO0gjmGyz/t+I4EJDsVw4g8bvbYvsolp7acE6eJ43wCQ+5Gx/rjqxwE7LYnwGBPxDLtuSXIjwwwroLbjNMe0cbYjmA04HHnX58yu+Ne+TOvcqttXzVN0= nagios@acs00mlcprc01XSCF> exit

  • 测试用户SSH public key方式进行身份验证

测试用户nagios是否能够通过identity_file在XSCF上执行命令 (192.168.2.80)$ ssh -l mlc -i /usr/local/nagios/.ssh/id_rsa 192.168.3.80 showdomainstatus -aThe authenticity of host ‘192.168.3.80 (192.168.3.80)‘ can‘t be established.RSA key fingerprint is d1:83:1b:b7:eb:f3:70:f2:b8:f5:e2:43:5c:af:a1:e9.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added ‘192.168.3.80‘ (RSA) to the list of known hosts.DID         Domain Status00          Running01          -02          -03          -$ more /usr/local/nagios/.ssh/known_hosts192.168.3.80 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAyRYZFTYrKzK/XYSnxUe8lvTEErvy2LV6F0vIBjiwUwEKYh8KIFTeUdkiJbt4yn0UkjN3UDP16Ao8n53xRKRXqXlkWFmrqeY4NCY5ahG4FFayNBWVJ0MVrL9wRak1d6il9XEv8iN3k3xayb8O22S/SID238/TbDYj9YebIkpLVpc=第一次执行时先把xscf的地址加入到known_hosts里。$ ssh -l mlc -i /usr/local/nagios/.ssh/id_rsa 192.168.3.80 showdomainstatus -aDID         Domain Status00          Running01          -02          -03          -第二次执行时直接就输出命令执行结果了。
  • 配置nagios客户端

把检查脚本check_xscf.pl和配置文件check_xscf.cfg拷贝到nagios客户端192.168.2.80的/usr/local/nagios/libexec目录下,并为check_xscf.pl文件增加执行权限-bash-3.00# chmod a+x /usr/local/nagios/libexec/check_xscf.pl在nagios客户端的/usr/local/nagios/etc/nrpe.cfg中增加:command[check_xscf_hw]=/usr/local/nagios/libexec/check_xscf.pl -n 192.168.3.80 -u mlc -i /usr/local/nagios/.ssh/id_rsa -c showhardconfcommand[check_xscf_ev]=/usr/local/nagios/libexec/check_xscf.pl -n 192.168.3.80 -u mlc -i /usr/local/nagios/.ssh/id_rsa -c showenvironment /usr/local/nagios/libexec/check_xscf.cfg使用nagios试运行新加的两个检查使用nagios用户试运行新加的两个检查项: -bash-3.00# su - nagios Sun Microsystems Inc.   SunOS 5.10      Generic January 2005 $ /usr/local/nagios/libexec/check_xscf.pl -n 192.168.3.80 -u mlc -i /usr/local/nagios/.ssh/id_rsa -c showhardconf Hardware OK ! | $ /usr/local/nagios/libexec/check_xscf.pl -n 192.168.3.80 -u mlc -i /usr/local/nagios/.ssh/id_rsa -c showenvironment /usr/local/nagios/libexec/check_xscf.cfg Environment OK ! |100C, 70C, 1.1*U, 0.9*U,
  • 在nagios服务器端增加相应check_nrpe的配置即可。