# mysql_audit_log **Repository Path**: yueyazhui/mysql_audit_log ## Basic Information - **Project Name**: mysql_audit_log - **Description**: MySQL审计日志可视化(插件:McAfee审计) - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2022-09-26 - **Last Updated**: 2023-10-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README MySQL审计日志可视化 审计插件:McAfee审计 思路:SSH 连接服务器,读取 json 文件,处理数据,前端展示 方案: 1. 读取到 json 文件内容,简单处理,前端直接展示 2. 定时任务,读取到 json 文件内容,处理数据,保存到 MySQL,后端写接口,前端展示 重要依赖: ```xml ch.ethz.ganymed ganymed-ssh2 262 ``` 部分代码展示: ```java public void exec(String host, String user, String password, String[] cmd) { try { Connection connection = new Connection(host); connection.connect(); boolean authenticate = connection.authenticateWithPassword(user, password); if (!authenticate) { system.out.println("服务器认证失败"); } Session session = null; for (int i = 0; i < cmd.length; i++) { session = connection.openSession(); session.execCommand(cmd[i]); InputStream stdout = new StreamGobbler(session.getStdout()); BufferedReader br = new BufferedReader(new InputStreamReader(stdout)); while (true) { String line = br.readLine(); if (line == null) { break; } System.out.println(line); } stdout.close(); session.close(); } connection.close(); } catch (IOException e) { e.printStackTrace(); } } @Test public void test() { exec("【主机】", "【用户名】", "【密码】", new String[]{"tail -n 20 /var/lib/mysql/mysql-audit.json | grep \"\""}); } ```