#!/bin/sh
DATABASE="dpi_audit_db"
SQL_TABLE="`pwd`/dpi_audit.sqlite"
create_db()
{
sqlite3 $DATABASE <<EOF
.read $SQL_TABLE
.head on
select * from access_log;
select * from audit_log;
.quit
EOF
}
insert_db()
{
sqlite3 $DATABASE <<EOF
insert into access_log(t_start,t_stop,src_ip,src_port,dst_ip,dst_port,proto,up_pkts,up_bytes,down_pkts,down_bytes,app_name,detail,id) values(1502003304,1502003352,'10.8.4.9',58101,'10.8.4.3',22,6,138,13916,0,0,'SSH','',NULL);
insert into access_log(t_start,t_stop,src_ip,src_port,dst_ip,dst_port,proto,up_pkts,up_bytes,down_pkts,down_bytes,app_name,detail,id) values(1502003304,1502003352,'10.8.4.9',58101,'10.8.4.3',80,17,138,13916,0,0,'http','',NULL);
insert into audit_log(t_start,t_stop,src_ip,src_port,dst_ip,dst_port,proto,app_name,detail,id) values(1502003304,1502003352,'10.8.4.9',58101,'10.8.4.3',22,6,'SSH','',NULL);
.head on
select * from access_log;
select * from audit_log;
.quit
EOF
}
show_db()
{
sqlite3 $DATABASE <<EOF
.head on
select * from access_log;
select * from audit_log;
.quit
EOF
}
delete_db()
{
rm -rvf $DATABASE
}
if [ $# == 0 ] ; then
echo "-------------------------------------------------------------"
echo "usage: $0 create|show|insert|delete"
exit 0;
fi
if [ $# == 1 ] ; then
case "$1" in
'create')
create_db
;;
'show')
show_db
;;
'insert')
insert_db
;;
'delete')
delete_db
;;
*)
echo "usage: $0 create|show|insert|delete"
exit 0;
esac
fi
shell脚本模板
最新推荐文章于 2024-05-17 15:28:51 发布