ossec mysql_OSSEC日志存入Mysql

OSSEC Output and Alert options

Sending output to a Database

OSSEC supports MySQL and PostgreSQL database outputs.

1. Configuration options

These configurations options can be specified in the server or local install ossec.conf file.

database_output:

hostname

IP Address of the database server.

Allowed: any valid IP address

username

Username to access the database.

Allowed: Any Valid Username

password

Password to access the database.

Allowed: Any Password

database

Database name to store the alerts.

Allowed: database name

type

Type of database (Mysql or PostgreSQL).

Allowed: mysql/postgresql

2. Enabling Database Support

You must have the MySQL or PgSQL Client libraries installed on the OSSEC server.

# sudo apt-get install libmysqlclient-dev

# sudo apt-get install mysql-server

# sudo apt-get install mysql-client

Before you run the ”./install.sh” script execute the following to compile OSSEC with database support.

# cd ossec-hids-*

# cd src; make setdb; cd ..

# ./install.sh

3. Enable Database output in the configuration

After installation is complete database support needs to be enabled. The following command will enable the database daemon on the next restart.

# /var/ossec/bin/ossec-control enable database

4. Database Specific Setup

4.1 Database Setup

Create a database, setup the database user, and add the schema (located in the src/os_dbd directory of the distribution) with the following commands.

# mysql -u root -proot

mysql> create database ossec;

mysql> grant INSERT,SELECT,UPDATE,CREATE,DELETE,EXECUTE on ossec.* to caoqing@'192.168.27.%';

mysql> set password for caoqing@'192.168.27.%'=PASSWORD('caoqing');

mysql> flush privileges;

mysql> quit

# mysql -u root -proot ossec 

# mysql -u root -proot ossec

mysql> show tables;

+----------------------------+

| Tables_in_ossec            |

+----------------------------+

| agent                      |

| alert                      |

| category                   |

| data                       |

| location                   |

| server                     |

| signature                  |

| signature_category_mapping |

+----------------------------+

8 rows in set (0.00 sec)

4.2 OSSEC Setup

In order for ossec to output alerts and other data into the database the /var/ossec/etc/ossec.conf will need to have a  section added.

192.168.27.23

caoqing

caoqing

ossec

mysql

The values will need to be corrected for your installations hostname, mysql user, password, and database.

4.3 Complete MySQL Output

All that is left is to enable the database daemon and restart ossec for the changes to take effect.

# /var/ossec/bin/ossec-control enable database

# /var/ossec/bin/ossec-control restart

# /var/ossec/bin/ossec-control status

ossec-monitord is running...

ossec-logcollector is running...

ossec-remoted is running...

ossec-syscheckd is running...

ossec-analysisd is running...

ossec-maild not running...

ossec-execd is running...

ossec-dbd is running...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值