淘先锋技术网

首页 1 2 3 4 5 6 7

官网地址:JumpServer - 开源堡垒机 - 官网

在线电话:400-052-0755

技术支持:JumpServer 技术咨询


1. 概述

本篇文章主要介绍如何通过 SQL 语句查询页面查询不到的 JumpServer 的相关信息

2. SQL语句

2.1 查询七天内没有登陆 JumpServer 的僵尸用户;

select username,name from users_user where TO_DAYS(NOW()) - TO_DAYS(users_user.last_login) >= 7 or last_login is NULL and is_service_account=0;

2.2 查询30天内没有登陆 JumpServer 的僵尸用户;

select username,name from users_user where TO_DAYS(NOW()) - TO_DAYS(users_user.last_login) >= 30 or last_login is NULL and is_service_account=0;

2.3 查询没有登录过资产的僵尸用户;

SELECT username,email from users_user where users_user.id not in(SELECT DISTINCT REPLACE(terminal_session.user_id,'-','') FROM terminal_session) and is_service_account=0;

2.4 查询日志统计时间内没有登陆过的资产;

select id,hostname from assets_asset where id not in(SELECT distinct replace(terminal_session.asset_id,'-','') FROM terminal_session);

2.5 查询近30天内的登录的用户与用户登录的次数;

select username,count( * ) AS 'numbertime' from audits_userloginlog where TO_DAYS( now( ) ) - TO_DAYS( datetime ) <= 30 GROUP BY username ORDER BY 'numbertime' DESC;

2.6 查询30天内的资产登录与资产登录的次数;

select asset,count(*) as number from terminal_session where TO_DAYS( now() ) - TO_DAYS(date_end) <=30 GROUP BY asset order by count(*) DESC;

2.7 统计每个组织中的资产数量;

SELECT t.NAME, COUNT(*) FROM assets_asset a, orgs_organization t WHERE LEFT ( a.org_id, 8 ) = LEFT ( t.id, 8 ) GROUP BY t.NAME ORDER BY COUNT(*) DESC;