Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
2d4abb99
Commit
2d4abb99
authored
5 years ago
by
George Joseph
Committed by
Gerrit Code Review
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge "taskprocessor.c: Add CLI commands to reset taskprocessor stats."
parents
35395ee5
4de1e6d0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/CHANGES-staging/taskprocessor-reset-stats.txt
+7
-0
7 additions, 0 deletions
doc/CHANGES-staging/taskprocessor-reset-stats.txt
main/taskprocessor.c
+78
-0
78 additions, 0 deletions
main/taskprocessor.c
with
85 additions
and
0 deletions
doc/CHANGES-staging/taskprocessor-reset-stats.txt
0 → 100644
+
7
−
0
View file @
2d4abb99
Subject: taskprocessor.c
Added two new CLI commands to reset stats for taskprocessors. You can
reset stats for a single, specific taskprocessor ('core reset
taskprocessor <taskprocessor>'), or you can reset all taskprocessors
('core reset taskprocessors'). These commands will reset the counter for
the number of tasks processed as well as the max queue size.
This diff is collapsed.
Click to expand it.
main/taskprocessor.c
+
78
−
0
View file @
2d4abb99
...
@@ -153,11 +153,15 @@ static int tps_ping_handler(void *datap);
...
@@ -153,11 +153,15 @@ static int tps_ping_handler(void *datap);
static
char
*
cli_tps_ping
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
);
static
char
*
cli_tps_ping
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
);
static
char
*
cli_tps_report
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
);
static
char
*
cli_tps_report
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
);
static
char
*
cli_subsystem_alert_report
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
);
static
char
*
cli_subsystem_alert_report
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
);
static
char
*
cli_tps_reset_stats
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
);
static
char
*
cli_tps_reset_stats_all
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
);
static
struct
ast_cli_entry
taskprocessor_clis
[]
=
{
static
struct
ast_cli_entry
taskprocessor_clis
[]
=
{
AST_CLI_DEFINE
(
cli_tps_ping
,
"Ping a named task processor"
),
AST_CLI_DEFINE
(
cli_tps_ping
,
"Ping a named task processor"
),
AST_CLI_DEFINE
(
cli_tps_report
,
"List instantiated task processors and statistics"
),
AST_CLI_DEFINE
(
cli_tps_report
,
"List instantiated task processors and statistics"
),
AST_CLI_DEFINE
(
cli_subsystem_alert_report
,
"List task processor subsystems in alert"
),
AST_CLI_DEFINE
(
cli_subsystem_alert_report
,
"List task processor subsystems in alert"
),
AST_CLI_DEFINE
(
cli_tps_reset_stats
,
"Reset a named task processor's stats"
),
AST_CLI_DEFINE
(
cli_tps_reset_stats_all
,
"Reset all task processors' stats"
),
};
};
struct
default_taskprocessor_listener_pvt
{
struct
default_taskprocessor_listener_pvt
{
...
@@ -1254,3 +1258,77 @@ void ast_taskprocessor_build_name(char *buf, unsigned int size, const char *form
...
@@ -1254,3 +1258,77 @@ void ast_taskprocessor_build_name(char *buf, unsigned int size, const char *form
/* Append sequence number to end of user name. */
/* Append sequence number to end of user name. */
snprintf
(
buf
+
user_size
,
SEQ_STR_SIZE
,
"-%08x"
,
ast_taskprocessor_seq_num
());
snprintf
(
buf
+
user_size
,
SEQ_STR_SIZE
,
"-%08x"
,
ast_taskprocessor_seq_num
());
}
}
static
void
tps_reset_stats
(
struct
ast_taskprocessor
*
tps
)
{
ao2_lock
(
tps
);
tps
->
stats
.
_tasks_processed_count
=
0
;
tps
->
stats
.
max_qsize
=
0
;
ao2_unlock
(
tps
);
}
static
char
*
cli_tps_reset_stats
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
)
{
const
char
*
name
;
struct
ast_taskprocessor
*
tps
;
switch
(
cmd
)
{
case
CLI_INIT
:
e
->
command
=
"core reset taskprocessor"
;
e
->
usage
=
"Usage: core reset taskprocessor <taskprocessor>
\n
"
" Resets stats for the specified taskprocessor
\n
"
;
return
NULL
;
case
CLI_GENERATE
:
return
tps_taskprocessor_tab_complete
(
a
);
}
if
(
a
->
argc
!=
4
)
{
return
CLI_SHOWUSAGE
;
}
name
=
a
->
argv
[
3
];
if
(
!
(
tps
=
ast_taskprocessor_get
(
name
,
TPS_REF_IF_EXISTS
)))
{
ast_cli
(
a
->
fd
,
"
\n
Reset failed: %s not found
\n\n
"
,
name
);
return
CLI_SUCCESS
;
}
ast_cli
(
a
->
fd
,
"
\n
Resetting %s
\n\n
"
,
name
);
tps_reset_stats
(
tps
);
ast_taskprocessor_unreference
(
tps
);
return
CLI_SUCCESS
;
}
static
char
*
cli_tps_reset_stats_all
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
)
{
struct
ast_taskprocessor
*
tps
;
struct
ao2_iterator
iter
;
switch
(
cmd
)
{
case
CLI_INIT
:
e
->
command
=
"core reset taskprocessors"
;
e
->
usage
=
"Usage: core reset taskprocessors
\n
"
" Resets stats for all taskprocessors
\n
"
;
return
NULL
;
case
CLI_GENERATE
:
return
NULL
;
}
if
(
a
->
argc
!=
e
->
args
)
{
return
CLI_SHOWUSAGE
;
}
ast_cli
(
a
->
fd
,
"
\n
Resetting stats for all taskprocessors
\n\n
"
);
iter
=
ao2_iterator_init
(
tps_singletons
,
0
);
while
((
tps
=
ao2_iterator_next
(
&
iter
)))
{
tps_reset_stats
(
tps
);
ast_taskprocessor_unreference
(
tps
);
}
ao2_iterator_destroy
(
&
iter
);
return
CLI_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment