Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch-contrib
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch-contrib
Commits
4dd63bab
提交
4dd63bab
authored
11月 10, 2010
作者:
Michael S Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add simple Nagios plugin that checks channels and calls counts
上级
bbfc4f90
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
112 行增加
和
0 行删除
+112
-0
check_fs_channels.pl
mcollins/check_fs_channels.pl
+112
-0
没有找到文件。
mcollins/check_fs_channels.pl
0 → 100755
浏览文件 @
4dd63bab
#!/usr/bin/perl
#
# nagios-plugin-template.pl
#
# Simple template for using ESL to create Nagios plugins
#
# Requires the nagios-plugins package from http://nagiosplugins.org/
# Be sure to run ./configure --enable-perl-modules or you won't get too far!
#
use
strict
;
use
warnings
;
use
lib
'/usr/local/nagios/libexec/'
;
use
utils
qw($TIMEOUT %ERRORS &print_revision &support)
;
use
lib
'/usr/src/freeswitch.git/libs/esl/perl'
;
use
ESL
;
use
Getopt::
Long
;
$|
++
;
# No buffering, please
## Setup command line argument vars
## FreeSWITCH connection
my
$host
;
# FreeSWITCH IP address (default="localhost")
my
$port
;
# FreeSWITCH port (default="8021")
my
$pass
;
# Password to log in to event socket (default="ClueCon")
## Nagios specific options
my
$version
;
# version of the Nagios plugin
my
$help
;
# help flag
my
$timeout
;
# timeout in milliseconds
my
$warning_threshold
;
# warning threshold, integer
my
$critical_threshold
;
# critical threshold, integer
my
$verbose
;
# verbosity level (default=non-verbose)
my
$opts_ok
=
GetOptions
(
'h'
=>
\
$help
,
'help'
=>
\
$help
,
"H=s"
=>
\
$host
,
"host=s"
=>
\
$host
,
"p=i"
=>
\
$port
,
"port=i"
=>
\
$port
,
"P=s"
=>
\
$pass
,
"password=s"
=>
\
$pass
,
"t=i"
=>
\
$timeout
,
"timeout=i"
=>
\
$timeout
,
'v'
=>
\
$verbose
,
'verbose'
=>
\
$verbose
,
);
## Check command line args and set defaults
if
(
!
$opts_ok
)
{
&
usage
;
}
if
(
$help
)
{
&
usage
;
}
if
(
!
$host
)
{
$host
=
'localhost'
;
}
if
(
!
$port
)
{
$port
=
'8021'
;
}
if
(
!
$pass
)
{
$pass
=
'ClueCon'
;
}
if
(
!
$timeout
)
{
$timeout
=
$TIMEOUT
;
}
## Attempt to connect
my
$con
=
new
ESL::
ESLconnection
(
$host
,
$port
,
$pass
);
if
(
!
$con
)
{
print
"Unable to connect to FreeSWITCH on $host:$port\n"
;
exit
$ERRORS
{
'WARNING'
};
}
else
{
# print "Successfully connected to FreeSWITCH on $host:$port\n";
}
## Do a show channels
my
$chans
;
my
$calls
;
my
$e
=
$con
->
api
(
'show'
,
'channels count'
);
if
(
$e
->
getBody
()
=~
m/(\d+)/
)
{
$chans
=
$1
;
}
else
{
$chans
=
0
;
}
## Do a show calls
$e
=
$con
->
api
(
'show'
,
'calls count'
);
if
(
$e
->
getBody
()
=~
m/(\d+)/
)
{
$calls
=
$1
;
}
else
{
$calls
=
0
;
}
print
"$chans / $calls (chans / calls) \n"
;
## Proper exit
exit
$ERRORS
{
'OK'
};
sub
usage
{
print
$0
;
print
<<'EOF';
[-H|--host host] -P password [-p|--port port]
[-t timeout] [-v] [-h] [--help]
Options:
-h,--help
Print detailed help screen
-V
Print version information
-H,--host
FreeSWITCH server host name or address (default $host)
-P
FreeSWITCH password (default $pass)
-p
FreeSWITCH event socket port (default $port)
-t
Number of seconds to wait while trying to connect to FreeSWITCH server
(default $timeout)
-v
Verbose
EOF
exit
(
0
);
}
# sub usage
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论