⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bd_pgsql_purge.sh

📁 linux下流量查看软件,可以查看到每台机子的具体流量
💻 SH
字号:
echo "SET sort_mem TO 45000;"echo -e "bd_rx_log \n bd_tx_log \n bd_rx_total_log \n bd_tx_total_log" | while read TABLE; docat << EOFBEGIN;insert into $TABLE (sensor_id, ip, timestamp, sample_duration, total, icmp, udp, tcp, ftp, http, p2p) select sensor_id, ip, date_trunc('day', timestamp) + (case when extract(hour from timestamp) >= 12 then interval '12 hours' else interval '0 hours' end) + interval '12 hours',60*60*12, sum(total), sum(icmp), sum(udp), sum(tcp), sum(ftp), sum(http), sum(p2p)from $TABLEwhere sample_duration < 60*60*12and timestamp < now() - interval '35 days'group by sensor_id, ip, date_trunc('day', timestamp) + (case when extract(hour from timestamp) >= 12 then interval '12 hours'else interval '0 hours' end);                                                                                                                             delete from $TABLE where sample_duration < 60*60*12 and timestamp < now() - interval '35 days';COMMIT;BEGIN;insert into $TABLE (sensor_id, ip, timestamp, sample_duration, total, icmp, udp, tcp, ftp, http, p2p) select sensor_id, ip, date_trunc('hour', timestamp)+interval '1 hour', 60*60, sum(total), sum(icmp), sum(udp), sum(tcp), sum(ftp), sum(http), sum(p2p)from $TABLEwhere sample_duration < 60*60and timestamp < now() - interval '7 days'group by sensor_id, ip, date_trunc('hour', timestamp);delete from $TABLE where sample_duration < 60*60 and timestamp < now() - interval '7 days';COMMIT;BEGIN;insert into $TABLE (sensor_id, ip, timestamp, sample_duration, total, icmp, udp, tcp, ftp, http, p2p)select sensor_id, ip, date_trunc('hour', timestamp) + (interval '1 minute' * trunc(EXTRACT(MINUTE FROM timestamp)::numeric,-1)) + interval '10 minutes',10*60, sum(total), sum(icmp), sum(udp), sum(tcp), sum(ftp), sum(http), sum(p2p)                                                                                                                             from $TABLEwhere sample_duration < 10*60and timestamp < now() - interval '2 days'group by sensor_id, ip, date_trunc('hour', timestamp) + (interval '1 minute' * trunc(EXTRACT(MINUTE FROM timestamp)::numeric,-1));delete from $TABLE where sample_duration < 10*60 and timestamp < now() - interval '2 days';COMMIT;EOFdoneecho "VACUUM ANALYZE"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -