Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
10b40d03
Commit
10b40d03
authored
Apr 30, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(IOC): добавил возможность выводить статистику в getInfo()
по датчику или по "заказчику"
parent
2f34b787
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
8 deletions
+81
-8
IONotifyController.h
include/IONotifyController.h
+1
-0
IONotifyController.cc
src/Processes/IONotifyController.cc
+80
-8
No files found.
include/IONotifyController.h
View file @
10b40d03
...
...
@@ -340,6 +340,7 @@ namespace uniset
void
showStatisticsForLostConsumers
(
std
::
ostringstream
&
inf
);
void
showStatisticsForConsusmers
(
std
::
ostringstream
&
inf
);
void
showStatisticsForConsumersWithLostEvent
(
std
::
ostringstream
&
inf
);
void
showStatisticsForSensor
(
std
::
ostringstream
&
inf
,
const
std
::
string
&
name
);
private
:
friend
class
NCRestorer
;
...
...
src/Processes/IONotifyController.cc
View file @
10b40d03
...
...
@@ -80,6 +80,12 @@ void IONotifyController::showStatisticsForConsumer( ostringstream& inf, const st
{
ObjectId
consumer_id
=
uniset_conf
()
->
getObjectID
(
consumer
);
if
(
consumer_id
==
DefaultObjectId
)
consumer_id
=
uniset_conf
()
->
getControllerID
(
consumer
);
if
(
consumer_id
==
DefaultObjectId
)
consumer_id
=
uniset_conf
()
->
getServiceID
(
consumer
);
if
(
consumer_id
==
DefaultObjectId
)
{
inf
<<
"not found consumer '"
<<
consumer
<<
"'"
<<
endl
;
return
;
...
...
@@ -196,6 +202,11 @@ void IONotifyController::showStatisticsForLostConsumers( ostringstream& inf )
return
;
}
inf
<<
"Statisctic for consumer with lost event:"
<<
endl
<<
"----------------------------------------"
<<
endl
;
auto
oind
=
uniset_conf
()
->
oind
;
for
(
const
auto
&
l
:
lostConsumers
)
{
...
...
@@ -275,6 +286,7 @@ void IONotifyController::showStatisticsForConsumersWithLostEvent( ostringstream&
empty
=
false
;
// выводим тех у кого lostEvent>0
inf
<<
"("
<<
setw
(
6
)
<<
a
.
first
<<
")["
<<
oind
->
getMapName
(
a
.
first
)
<<
"]"
<<
endl
;
inf
<<
"--------------------------------------------------------------------"
<<
endl
;
for
(
const
auto
&
c
:
i
.
clst
)
{
...
...
@@ -294,6 +306,54 @@ void IONotifyController::showStatisticsForConsumersWithLostEvent( ostringstream&
if
(
empty
)
inf
<<
"...not found consumers with lost event..."
<<
endl
;
else
inf
<<
"--------------------------------------------------------------------"
<<
endl
;
}
// ------------------------------------------------------------------------------------------
void
IONotifyController
::
showStatisticsForSensor
(
ostringstream
&
inf
,
const
string
&
name
)
{
auto
conf
=
uniset_conf
();
auto
oind
=
conf
->
oind
;
ObjectId
sid
=
conf
->
getSensorID
(
name
);
if
(
sid
==
DefaultObjectId
)
{
inf
<<
"..not found ID for sensor '"
<<
name
<<
"'"
<<
endl
;
return
;
}
ConsumerListInfo
*
clist
=
nullptr
;
{
uniset_rwmutex_rlock
lock
(
askIOMutex
);
auto
s
=
askIOList
.
find
(
sid
);
if
(
s
==
askIOList
.
end
()
)
{
inf
<<
"..not found consumers for sensor '"
<<
name
<<
"'"
<<
endl
;
return
;
}
clist
=
&
(
s
->
second
);
}
inf
<<
"Statisctic for sensor "
<<
"("
<<
setw
(
6
)
<<
sid
<<
")["
<<
name
<<
"]: "
<<
endl
<<
"--------------------------------------------------------------------"
<<
endl
;
uniset_rwmutex_rlock
lock2
(
clist
->
mut
);
for
(
const
auto
&
c
:
clist
->
clst
)
{
inf
<<
" ("
<<
setw
(
6
)
<<
c
.
id
<<
")"
<<
setw
(
35
)
<<
ORepHelpers
::
getShortName
(
oind
->
getMapName
(
c
.
id
))
<<
" ["
<<
" lostEvents="
<<
c
.
lostEvents
<<
" attempt="
<<
c
.
attempt
<<
" smCount="
<<
c
.
smCount
<<
"]"
<<
endl
;
}
inf
<<
"--------------------------------------------------------------------"
<<
endl
;
}
// ------------------------------------------------------------------------------------------
SimpleInfo
*
IONotifyController
::
getInfo
(
const
char
*
userparam
)
...
...
@@ -323,7 +383,7 @@ SimpleInfo* IONotifyController::getInfo( const char* userparam )
showStatisticsForConsusmers
(
inf
);
inf
<<
"-----------------------------------------------------------------------------"
<<
endl
<<
endl
;
}
else
if
(
param
==
"lost"
)
else
if
(
param
==
"lost"
)
{
inf
<<
"------------------------------- consumers list (lost event)------------------"
<<
endl
;
showStatisticsForConsumersWithLostEvent
(
inf
);
...
...
@@ -331,15 +391,27 @@ SimpleInfo* IONotifyController::getInfo( const char* userparam )
}
else
if
(
!
param
.
empty
()
)
{
showStatisticsForConsumer
(
inf
,
param
);
auto
query
=
uniset
::
explode_str
(
param
,
':'
);
if
(
query
.
empty
()
||
query
.
size
()
==
1
)
showStatisticsForConsumer
(
inf
,
param
);
else
if
(
query
.
size
()
>
1
)
{
if
(
query
[
0
]
==
"consumer"
)
showStatisticsForConsumer
(
inf
,
query
[
1
]);
else
if
(
query
[
0
]
==
"sensor"
)
showStatisticsForSensor
(
inf
,
query
[
1
]);
else
inf
<<
"Unknown command: "
<<
param
<<
endl
;
}
}
else
{
inf
<<
"IONotifyController::UserParam help: "
<<
endl
<<
" Default - Common info"
<<
endl
<<
" consumers - Consumers list "
<<
endl
<<
" lost - Consumers list with lostEvent > 0"
<<
endl
<<
" name - Statistic for consumer 'name'"
<<
" Default - Common info"
<<
endl
<<
" consumers - Consumers list "
<<
endl
<<
" lost - Consumers list with lostEvent > 0"
<<
endl
<<
" consumer:name - Statistic for consumer 'name'"
<<
endl
<<
" sensor:name - Statistic for sensor 'name'"
<<
endl
;
}
...
...
@@ -1403,14 +1475,14 @@ Poco::JSON::Object::Ptr IONotifyController::httpHelp(const Poco::URI::QueryParam
{
// 'consumers'
uniset
::
json
::
help
::
item
cmd
(
"get consumers list"
);
uniset
::
json
::
help
::
item
cmd
(
"
consumers"
,
"
get consumers list"
);
cmd
.
param
(
"sensor1,sensor2,sensor3"
,
"get consumers for sensors"
);
myhelp
.
add
(
cmd
);
}
{
// 'lost'
uniset
::
json
::
help
::
item
cmd
(
"get lost consumers list"
);
uniset
::
json
::
help
::
item
cmd
(
"
lost"
,
"
get lost consumers list"
);
myhelp
.
add
(
cmd
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment