ossec批量部署中遇到了不少問題,說下其中的兩個。
linux
一、key_gen.py該腳本一次最多生成1000個keys,超過1000臺agent,需多生成幾回,只要ip對應正確的key便可。agent的名字最大支持32個字符,超過32個字符就會報錯。ide
該腳本能夠添加、移除、提取、導入agentspa
/root/ossec-hids-2.8.3/contrib/ossec-batch-manager.pl日誌
Usage: /root/ossec-hids-2.8.3/contrib/ossec-batch-manager.pl [OPERATION] [OPTIONS]server
[operations]ip
-a or --add = Add a new agentci
-r or --remove [id] = Remove agentrem
-e or --extract [id|name|ip] = Extract key部署
-m or --import [keydata] = Import keyit
-l or --list = List available agents
[options]
-k or --key [keydata] = Key data
-n or --name [name] = Agent name (32 character max)
-i or --id [id] = Agent identification (integer)
-p or --ip [ip] = IP address
二、每一臺ossec-server默認支持256個agent,最大支持2048個agent。要想支持2048個agent,須要在安裝以前設置一下。
[root@ossec-server ~]# cd ossec-hids-2.8.3/src/
[root@ossec-server src]# make setmaxagents
Specify maximum number of agents: 2048
Maximum number of agents set to 2048.
[root@ossec-server src]# cd ..
[root@ossec-server ossec-hids-2.8.3]# ./install.sh
...
...
linux系統默認最大打開文件數爲1024,須要修改內核參數爲2048
[root@ossec-server ossec-hids-2.8.3]# ulimit -n 2048
[root@ossec-server ossec-hids-2.8.3]# sysctl -w kern.maxfiles=2048
[root@ossec-server ossec-hids-2.8.3]# sysctl -w net.core.rmem_default=5123840
[root@ossec-server ossec-hids-2.8.3]# sysctl -w net.core.rmem_max = 5123840
設置開機自啓動,在該文件最後添加
[root@ossec-server ossec-hids-2.8.3]# vi /etc/profile
ulimit -n 2048
[root@ossec-server ossec-hids-2.8.3]# vi /etc/security/limits.conf
ossec soft nofile 2048
ossec hard nofile 2048
ossecr soft nofile 2048
ossecr hard nofile 2048
設置完成以後,執行命令生效
[root@ossec-server ossec-hids-2.8.3]# source /etc/profile
[root@ossec-server ossec-hids-2.8.3]# sysctl -p
查看是否成功設置open files爲2048
[root@ossec-server ossec-hids-2.8.3]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 62838
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 2048
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 62838
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
啓動ossec服務,在ossec日誌裏面也能夠查看是否設置成功
[root@ossec-server ossec-hids-2.8.3]# grep '2048' /var/ossec/logs/ossec.log
2016/03/29 14:11:37 ossec-remoted(4111): INFO: Maximum number of agents allowed: '2048'.
2016/03/29 14:12:09 ossec-remoted(4111): INFO: Maximum number of agents allowed: '2048'.