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命令。
以root登录nagios客户端: 192.168.2.80
-bash-3.00# grep nagios /etc/shadow
nagios:*LK*:::::::
-bash-3.00# su - nagios
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
为nagios用户产生ssh rsa key:
$ /usr/bin/ssh-keygen -t rsa
Generating 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
$ ls
id_rsa id_rsa.pub
$ more id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAvryQqyhFPzcXzSJiIM9JWm0jl3igF8MgJQAUMZCj6YTa
jXNMZOfrjY/OO0gjmGyz/t+I4EJDsVw4g8bvbYvsolp7acE6eJ43wCQ+5Gx/rjqxwE7LYnwGBPxDLtuS
XIjwwwroLbjNMe0cbYjmA04HHnX58yu+Ne+TOvcqttXzVN0= nagios@acs00mlcprc01
以上是rsa public key的内容。
XSCF> showssh -c pubkey
XSCF> setssh -c addpubkey -u mlc
Please input a public key:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAvryQqyhFPzcXzSJiIM9JWm0jl3igF8MgJQAUMZCj6YTa
jXNMZOfrjY/OO0gjmGyz/t+I4EJDsVw4g8bvbYvsolp7acE6eJ43wCQ+5Gx/rjqxwE7LYnwGBPxDLtuS
XIjwwwroLbjNMe0cbYjmA04HHnX58yu+Ne+TOvcqttXzVN0= nagios@acs00mlcprc01
XSCF> showssh -c pubkey
Public key:
1 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAvryQqyhFPzcXzSJiIM9JWm0jl3igF8MgJQAUMZCj6YTajXNMZOfrjY/OO0gjmGyz/t+I4EJDsVw4g8bvbYvsolp7acE6eJ43wCQ+5Gx/rjqxwE7LYnwGBPxDLtuSXIjwwwroLbjNMe0cbYjmA04HHnX58yu+Ne+TOvcqttXzVN0= nagios@acs00mlcprc01
XSCF> exit
测试用户nagios是否能够通过identity_file在XSCF上执行命令 (192.168.2.80)
$ ssh -l mlc -i /usr/local/nagios/.ssh/id_rsa 192.168.3.80 showdomainstatus -a
The 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)? yes
Warning: Permanently added ‘192.168.3.80‘ (RSA) to the list of known hosts.
DID Domain Status
00 Running
01 -
02 -
03 -
$ more /usr/local/nagios/.ssh/known_hosts
192.168.3.80 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAyRYZFTYrKzK/XYSnxUe8lvTEErvy2LV6F
0vIBjiwUwEKYh8KIFTeUdkiJbt4yn0UkjN3UDP16Ao8n53xRKRXqXlkWFmrqeY4NCY5ahG4FFayNBWVJ
0MVrL9wRak1d6il9XEv8iN3k3xayb8O22S/SID238/TbDYj9YebIkpLVpc=
第一次执行时先把xscf的地址加入到known_hosts里。
$ ssh -l mlc -i /usr/local/nagios/.ssh/id_rsa 192.168.3.80 showdomainstatus -a
DID Domain Status
00 Running
01 -
02 -
03 -
第二次执行时直接就输出命令执行结果了。
把检查脚本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 showhardconf
command[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,