Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
b80114c6
Commit
b80114c6
authored
Aug 12, 2015
by
Axel Auweter
Browse files
Fix for ticket #40: Quiet Mode for CollectAgent
parent
b85f1a1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
CollectAgent/collectagent.cpp
View file @
b80114c6
...
...
@@ -27,6 +27,7 @@
using
namespace
std
;
int
keepRunning
;
bool
statistics
;
uint64_t
msgCtr
;
uint64_t
pmsgCtr
;
SensorDataStore
*
mySensorDataStore
;
...
...
@@ -124,14 +125,15 @@ void mqttCallback(SimpleMQTTMessage *msg)
* Print usage information
*/
void
usage
()
{
printf
(
"Usage: collectagent [-D] [-l <host>] [-h <host>] [-t <ttl>]
\n
"
);
printf
(
"Usage: collectagent [-D]
[-s]
[-l <host>] [-h <host>] [-t <ttl>]
\n
"
);
printf
(
"Collectagent will accept remote connections by listening to the
\n
"
);
printf
(
"specified listen address (-l <host>) at port 1883 (default MQTT port).
\n
"
);
printf
(
"It will also connect to cassandra to the specifiec addres (-h <host>).
\n
"
);
printf
(
"The default <host> is localhost/127.0.0.1.
\n
"
);
printf
(
"If the -t option is specified, data will be inserted with the specified
\n
"
);
printf
(
"TTL in seconds.
\n
"
);
printf
(
"If the -D option is specified, CollectAgent will run as daemon.
\n\n
"
);
printf
(
"If the -D option is specified, CollectAgent will run as daemon.
\n
"
);
printf
(
"With the -s option, CollectAgent will print message statistics.
\n\n
"
);
}
int
main
(
int
argc
,
char
*
const
argv
[])
{
...
...
@@ -154,7 +156,8 @@ int main(int argc, char* const argv[]) {
listenHost
=
"localhost"
;
cassandraHost
=
"127.0.0.1"
;
ttl
=
"0"
;
while
((
ret
=
getopt
(
argc
,
argv
,
"h:l:t:D?"
))
!=-
1
)
{
statistics
=
false
;
while
((
ret
=
getopt
(
argc
,
argv
,
"h:l:t:Ds?"
))
!=-
1
)
{
switch
(
ret
)
{
case
'h'
:
cassandraHost
=
optarg
;
...
...
@@ -168,6 +171,9 @@ int main(int argc, char* const argv[]) {
case
'D'
:
dcdbdaemon
();
break
;
case
's'
:
statistics
=
true
;
break
;
case
'?'
:
default:
usage
();
...
...
@@ -235,7 +241,9 @@ int main(int argc, char* const argv[]) {
elapsed
=
(
end
.
tv_sec
-
start
.
tv_sec
)
*
1000.0
;
elapsed
+=
(
end
.
tv_usec
-
start
.
tv_usec
)
/
1000.0
;
float
publish
=
msgCtr
?
(
pmsgCtr
*
100.0
)
/
msgCtr
:
0
;
cout
<<
"Message rate: "
<<
(
msgCtr
/
elapsed
)
*
1000.0
<<
" messages/second ("
<<
publish
<<
"% PUBLISH)
\n
"
;
if
(
statistics
)
{
cout
<<
"Message rate: "
<<
(
msgCtr
/
elapsed
)
*
1000.0
<<
" messages/second ("
<<
publish
<<
"% PUBLISH)
\n
"
;
}
msgCtr
=
0
;
pmsgCtr
=
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment