Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
uplex-varnish
trackrdrd
Commits
4d00cb89
Commit
4d00cb89
authored
Oct 02, 2012
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trackrdrd: Added monitoring thread
parent
0fb97b15
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
17 deletions
+99
-17
Makefile.am
trackrdrd/src/Makefile.am
+2
-1
data.c
trackrdrd/src/data.c
+0
-12
monitor.c
trackrdrd/src/monitor.c
+73
-0
regress.sh
trackrdrd/src/test/regress.sh
+1
-1
trackrdrd.c
trackrdrd/src/trackrdrd.c
+20
-3
trackrdrd.h
trackrdrd/src/trackrdrd.h
+3
-0
No files found.
trackrdrd/src/Makefile.am
View file @
4d00cb89
...
...
@@ -10,7 +10,8 @@ trackrdrd_SOURCES = \
parse.c
\
log.c
\
config.c
\
data.c
data.c
\
monitor.c
trackrdrd_LDADD
=
\
$(VARNISHSRC)
/lib/libvarnishcompat/libvarnishcompat.la
\
...
...
trackrdrd/src/data.c
View file @
4d00cb89
...
...
@@ -123,17 +123,6 @@ data_Cleanup(void)
free
(
tbl
.
buf
);
}
static
void
data_logstats
(
void
)
{
LOG_Log
(
LOG_INFO
,
"Data table: len=%d collisions=%d insert_probes=%d find_probes=%d "
"open=%d done=%d load=%.2f occ_hi=%d seen=%d submitted=%d data_hi=%d"
,
tbl
.
len
,
tbl
.
collisions
,
tbl
.
insert_probes
,
tbl
.
find_probes
,
tbl
.
open
,
tbl
.
done
,
100
.
0
*
((
float
)
tbl
.
open
+
tbl
.
done
)
/
tbl
.
len
,
tbl
.
occ_hi
,
tbl
.
seen
,
tbl
.
submitted
,
tbl
.
data_hi
);
}
int
DATA_Init
(
void
)
{
...
...
@@ -214,5 +203,4 @@ DATA_Dump(void)
i
,
entry
.
xid
,
entry
.
tid
,
statename
[
entry
.
state
],
entry
.
end
,
entry
.
data
);
}
data_logstats
();
}
trackrdrd/src/monitor.c
0 → 100644
View file @
4d00cb89
/*-
* Copyright (c) 2012 UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 2012 Otto Gmbh & Co KG
* All rights reserved
* Use only with permission
*
* Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <syslog.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <pthread.h>
#include "trackrdrd.h"
void
*
MON_StatusThread
(
void
*
arg
)
{
struct
timespec
t
;
double
*
interval
=
(
double
*
)
arg
;
t
.
tv_sec
=
(
time_t
)
*
interval
;
t
.
tv_nsec
=
(
long
)(
t
.
tv_sec
-
*
interval
)
*
10e9
;
LOG_Log
(
LOG_INFO
,
"Monitor thread running every %.2f secs"
,
t
.
tv_sec
+
((
float
)
t
.
tv_nsec
*
10e-9
));
while
(
1
)
{
int
err
;
if
(
nanosleep
(
&
t
,
NULL
)
!=
0
)
{
if
(
errno
==
EINTR
)
{
/* XXX: Terminate on TERM, INT, etc. */
LOG_Log0
(
LOG_INFO
,
"Monitoring thread interrupted"
);
continue
;
}
else
{
LOG_Log
(
LOG_WARNING
,
"Monitoring thread: %s
\n
"
,
strerror
(
errno
));
err
=
errno
;
pthread_exit
(
&
err
);
}
}
LOG_Log
(
LOG_INFO
,
"Data table: len=%d collisions=%d insert_probes=%d find_probes=%d "
"open=%d done=%d load=%.2f occ_hi=%d seen=%d submitted=%d data_hi=%d"
,
tbl
.
len
,
tbl
.
collisions
,
tbl
.
insert_probes
,
tbl
.
find_probes
,
tbl
.
open
,
tbl
.
done
,
100
.
0
*
((
float
)
tbl
.
open
+
tbl
.
done
)
/
tbl
.
len
,
tbl
.
occ_hi
,
tbl
.
seen
,
tbl
.
submitted
,
tbl
.
data_hi
);
}
}
trackrdrd/src/test/regress.sh
View file @
4d00cb89
...
...
@@ -12,7 +12,7 @@
# stdout. The cksum must match an expected value.
CKSUM
=
$(
./trackrdrd
-f
test
/varnish.binlog
-l
-
-d
-c
test
/test.conf |
cksum
)
if
[
"
$CKSUM
"
!=
'
209068317 228977
'
]
;
then
if
[
"
$CKSUM
"
!=
'
181457956 229013
'
]
;
then
echo
"ERROR: Regression test incorrect cksum:
$CKSUM
"
exit
1
fi
...
...
trackrdrd/src/trackrdrd.c
View file @
4d00cb89
...
...
@@ -45,6 +45,7 @@
#include <unistd.h>
#include <syslog.h>
#include <sys/fcntl.h>
#include <pthread.h>
#include "compat/daemon.h"
...
...
@@ -218,6 +219,7 @@ main(int argc, char * const *argv)
*
y_arg
=
NULL
,
*
c_arg
=
NULL
;
struct
vpf_fh
*
pfh
=
NULL
;
struct
VSM_data
*
vd
;
pthread_t
monitor
;
vd
=
VSM_New
();
VSL_Setup
(
vd
);
...
...
@@ -310,7 +312,8 @@ main(int argc, char * const *argv)
*/
if
(
!
EMPTY
(
config
.
pid_file
)
&&
(
pfh
=
VPF_Open
(
config
.
pid_file
,
0644
,
NULL
))
==
NULL
)
{
perror
(
config
.
pid_file
);
LOG_Log
(
LOG_ERR
,
"Cannot write pid file %s: %s
\n
"
,
config
.
pid_file
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
}
if
(
pfh
!=
NULL
)
...
...
@@ -333,7 +336,8 @@ main(int argc, char * const *argv)
/* XXX: Install this signal handler in the child */
if
(
signal
(
SIGUSR1
,
sigusr1
)
==
SIG_ERR
)
{
perror
(
"Signal handler USR1:"
);
LOG_Log
(
LOG_ERR
,
"Cannot install signal handler for USR1: %s
\n
"
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
}
...
...
@@ -342,7 +346,20 @@ main(int argc, char * const *argv)
/* Only read the VSL tags relevant to tracking */
assert
(
VSL_Arg
(
vd
,
'i'
,
TRACK_TAGS
)
>
0
);
/* Start the monitor thread */
if
(
config
.
monitor_interval
>
0
.
0
)
{
if
(
pthread_create
(
&
monitor
,
NULL
,
MON_StatusThread
,
(
void
*
)
&
config
.
monitor_interval
)
!=
0
)
{
LOG_Log
(
LOG_ERR
,
"Cannot start monitoring thread: %s
\n
"
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
}
}
else
LOG_Log0
(
LOG_INFO
,
"Monitoring thread not running"
);
/* Main loop */
while
(
VSL_Dispatch
(
vd
,
OSL_Track
,
NULL
)
>=
0
)
;
...
...
trackrdrd/src/trackrdrd.h
View file @
4d00cb89
...
...
@@ -116,6 +116,9 @@ int LOG_Open(const char *progname);
#define LOG_SetLevel(level) logconf.setlevel(level)
#define LOG_Close() logconf.close()
/* monitor.c */
void
*
MON_StatusThread
(
void
*
arg
);
/* parse.c */
int
Parse_XID
(
const
char
*
str
,
int
len
,
unsigned
*
xid
);
int
Parse_ReqStart
(
const
char
*
ptr
,
int
len
,
unsigned
*
xid
);
...
...
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