Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch-contrib
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch-contrib
Commits
fa05d6cc
提交
fa05d6cc
authored
9月 10, 2013
作者:
Raymond Chandler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
scripts for debugging from logs instead of cli
上级
eb325df1
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
154 行增加
和
0 行删除
+154
-0
fs_log_between
intralanman/perl/log/fs_log_between
+82
-0
fs_log_reader
intralanman/perl/log/fs_log_reader
+72
-0
没有找到文件。
intralanman/perl/log/fs_log_between
0 → 100755
浏览文件 @
fa05d6cc
#!/usr/bin/perl
use
strict
;
use
warnings
;
use
Data::
Dumper
;
use
DateTime
;
use
DateTime::Format::
DateParse
;
use
Date::
Calc
qw( Delta_YMDHMS )
;
sub
usage
{
my
$msg
=
shift
;
print
"USAGE:\n\t$0 '<start timestamp>' '<end timestamp>' [log file]\n"
;
print
"$msg\n"
if
$msg
;
exit
1
;
}
my
$tmp
;
if
(
scalar
(
@ARGV
)
<
2
)
{
usage
(
'missing required args'
);
}
my
$call_start_date_str
=
shift
(
@ARGV
);
my
$call_end_date_str
=
shift
(
@ARGV
);
my
$log_file
=
shift
(
@ARGV
)
||
'/usr/local/freeswitch/log/freeswitch.log'
;
usage
(
'log file doesn\'t exist'
)
unless
-
f
$log_file
;
$call_start_date_str
=
DateTime
->
now
if
$call_start_date_str
eq
'now'
;
$call_end_date_str
=
DateTime
->
now
if
$call_end_date_str
eq
'now'
;
print
"Call Was From: $call_start_date_str - $call_end_date_str\n"
;
my
$start_dt
=
DateTime::Format::
DateParse
->
parse_datetime
(
$call_start_date_str
);
my
$end_dt
=
DateTime::Format::
DateParse
->
parse_datetime
(
$call_end_date_str
);
$tmp
=
$start_dt
->
subtract
(
minutes
=>
2
);
$tmp
=
$end_dt
->
add
(
minutes
=>
2
);
print
"find stuff between "
;
printf
(
"%s-%02s-%02s %02s:%02s:%02s"
,
$start_dt
->
year
,
$start_dt
->
month, $start_dt->day, $start_dt->hour, $start_dt->minute, $start_dt->second
);
print
" and "
;
printf
(
"%s-%02s-%02s %02s:%02s:%02s"
,
$end_dt
->
year
,
$end_dt
->
month, $end_dt->day, $end_dt->hour, $end_dt->minute, $end_dt->second
);
print
"\n"
;
my
$limit
=
10
;
my
$i
=
0
;
open
(
LOG_FILE
,
'<'
,
$log_file
);
my
%
times_seen
;
my
$start_printing
=
0
;
while
(
<
LOG_FILE
>
)
{
#print "LOG LINE: $_";
if
(
$_
=~
m/^(?:[a-z\d-]{36}\s)?(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2})/
)
{
if
(
!
$times_seen
{
$1
}
)
{
my
$datetime
=
$1
;
$times_seen
{
$1
}
=
1
;
my
$current_dt
=
DateTime::Format::
DateParse
->
parse_datetime
(
$datetime
);
my
@delta
;
if
(
!
$start_printing
)
{
@delta
=
Delta_YMDHMS
(
$start_dt
->
year
,
$start_dt
->
month, $start_dt->day, $start_dt->hour, $start_dt->minute, $start_dt->second
,
$current_dt
->
year
,
$current_dt
->
month, $current_dt->day, $current_dt->hour, $current_dt->minute, $current_dt->second
,
);
}
else
{
@delta
=
Delta_YMDHMS
(
$end_dt
->
year
,
$end_dt
->
month, $end_dt->day, $end_dt->hour, $end_dt->minute, $end_dt->second
,
$current_dt
->
year
,
$current_dt
->
month, $current_dt->day, $current_dt->hour, $current_dt->minute, $current_dt->second
,
);
}
my
$sum
=
unpack
"l"
,
pack
(
"l"
,
unpack
(
"%32d*"
,
pack
(
"d*"
,
@delta
)));
if
(
$sum
>
0
)
{
last
if
$start_printing
;
$start_printing
=
1
;
}
}
}
print
$_
if
$start_printing
;
#exit if $i == $limit;
$i
++
;
}
intralanman/perl/log/fs_log_reader
0 → 100755
浏览文件 @
fa05d6cc
#!/usr/bin/perl
use
strict
;
use
warnings
;
use
Data::
Dumper
;
use
LWP::
UserAgent
;
use
Term::
ANSIColor
;
sub
usage
{
my
$msg
=
shift
;
print
"USAGE:\n\t$0 <file> [regex]\n"
;
print
"$msg\n"
if
$msg
;
exit
;
}
my
%
colors
=
(
CRIT
=>
'red'
,
ERR
=>
'red'
,
ALERT
=>
'red'
,
WARNING
=>
'magenta'
,
NOTICE
=>
'cyan'
,
INFO
=>
'green'
,
DEBUG
=>
'yellow'
,
CONSOLE
=>
'white'
,
);
if
(
!
scalar
(
@ARGV
)
)
{
usage
(
'you must pass a file'
);
}
my
$file
=
shift
(
@ARGV
);
my
$re
=
shift
(
@ARGV
);
my
@lines
;
if
(
$file
=~
m/^http/
)
{
my
$ua
=
LWP::
UserAgent
->
new
;
my
$response
=
$ua
->
get
(
$file
);
if
(
$response
->
is_success
)
{
@lines
=
split
(
"\n"
,
$response
->
decoded_content
);
}
else
{
usage
(
$response
->
status_line
);
}
}
elsif
(
$file
eq
'-'
)
{
while
(
<
STDIN
>
)
{
chomp
;
push
(
@lines
,
$_
);
}
}
else
{
open
(
FILE
,
'<'
,
$file
)
or
usage
(
$!
);
while
(
<
FILE
>
)
{
chomp
;
push
(
@lines
,
$_
);
}
close
FILE
;
}
my
$color
;
foreach
my
$line
(
@lines
)
{
if
(
$re
)
{
next
unless
$line
=~
$re
;
}
chomp
(
$line
);
if
(
$line
=~
m/^.*\[(DEBUG|INFO|NOTICE|WARNING|ERROR)].*$/
&&
defined
$colors
{
$1
}
)
{
$color
=
$colors
{
$1
};
}
elsif
(
$line
=~
m/^([a-z\d-]{36})\s?(Dialplan|EXECUTE)/
)
{
$color
=
'yellow'
;
}
elsif
(
$line
=~
m/^(recv|send|nua|nta|soa|su|tport|nth|nea|su|url|sresolv|sdp)/
)
{
$color
=
'white'
;
}
print
colored
(
"$line\n"
,
$color
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论