在开始真正的监控之前我们在来看下官方文档
Your monitoring box should be viewed as a backdoor into your other systems. In many cases, the Nagios server might be allowed access through firewalls in order to monitor remote servers. In most all cases, it is allowed to query those remote servers for various information. Monitoring servers are always given a certain level of trust in order to query remote systems. This presents a potential attacker with an attractive backdoor to your systems. An attacker might have an easier time getting into your other systems if they compromise the monitoring server first. This is particularly true if you are making use of shared SSH keys in order to monitor remote systems.
Another area of concern is the ability for intruders to sniff monitoring data (status information) as it comes across the wire. If communication channels are not encrypted, attackers can gain valuable information by watching your monitoring information. Take as an example the following situation: An attacker captures monitoring data on the wire over a period of time and analyzes the typical CPU and disk load usage of your systems, along with the number of users that are typically logged into them. The attacker is then able to determine the best time to compromise a system and use its resources (CPU, etc.) without being noticed.
像这样,将nagios专门放入一台机器运行,然后通过防火墙去监控其他的机器。 2. Don't Run Nagios As Root这个对于每个服务都是如此,如果需要root权限使用sudo 3. Lock Down The Check Result Directory. 监控结果目录需要设置访问权限,如果其他用户可以进入到这个目录里,就可能发送假的监控数据,制造一些虚假的问题。 4. Lock Down The External Command File. 首先要给/usr/local/nagios/var/rw目录正确的权限,然后只能root和nagios用户写命令文件。在监控机器上尽可能较少用户数量,运行nagios命令时最好在cgi环境下,而不是用nobody的登录权限。 5. Require Authentication In The CGIs. 登录CGI也就是web界面时候一定要用户验证。这点有很多资料上面都忽略了,这是极度不安全的。 6. Implement Enhanced CGI Security Measures.主要是在登录CGI时候输入的user和password不要被第三方截取到,要加强登录和输入环境的安全。 7. Use Full Paths In Command Definitions. 指定绝对路径,在调用命令的时候。 8. Hide Sensitive Information With $USERn$ Macros.还是账户密码信息的使用,不要将账户和密码信息直接写在某个文件处,尽量可能多的使用宏命令像$USER这种变量。 9. Strip Dangerous Characters From Macros.在命令里去除一些特殊的变量或者字符,主要是防止注入式***,很有可能***者敲的一段字符就是一个执行命令,从而打开了一个系统安全后门。 10. Secure Access to Remote Agents. 不是所有的机器都能去搜集信息,所以防火墙之类的检查工具是保证安全的前提,尽可能的检查nagios使用的监控协议(NRPE,SNMP,NSclinet..)
11. Secure Communication Channels. 加密,所有的经过的网络上的数据都要进行加密,以防止万一***者截取到数据包不会轻易地获取信息。
Additional Techniques
· Stronger Authentication using Digest Authentication. If you have followed the quickstart guides, chances are that you are using Apache's Basic Authentication. Basic Authentication will send your username and password in "clear text" with every http request. Consider using a more secure method of authentication such as Digest Authentication which creates a MD5 Hash of your username and password to send with each request.
· Forcing TLS/SSL for all Web Communication. Apache provides TLS/SSL through the mod_ssl module. TLS/SSL provides a secure tunnel between the client and server that prevents eavesdropping and tampering using strong publickey/privatekey cryptography.
· Locking Down Apache Using Access Controls. Consider locking down access to the Nagios box to your IP address, IP address range, or IP subnet. If you require access outside your network you could use *** or SSH Tunnels. This is a easy and strong to limit access to HTTP/HTTPS on your system.
CGI的安全措施分为三个步骤:第一步登录的安全验证,user/password的输入不可少;第二步协议的安全,保证每个页面都运行在SSL/TLS协议下;第三步访问控制,主要是对访问的IP地址的过滤。这些在apache配置时候都讲烂了,这里不提。
Nagios的监控分几类我们在上面的图里已经看到了:Windows Server, Linux Server,Netware Server,Cisco Switch,而每类对象所用的协议的都不一样,这里我们用Linux Server来做详细实验:
首先这个逻辑图告诉我们nagios是通过check_nrpe来进行监控的,被监控的机器上需要NRPE模块,此模块提供check_disk还有check_load等功能,通道需要加密。可惜官网的描述让人蛋疼:
[Note: This document has not been completed. I would recommend you read the documentation on the NRPE addon for instructions on how to monitor a remote Linux/Unix server.]
不说了,先看下官方推荐的NRPE addon这个插件是个什么样的东东