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
9c865c3e
Commit
9c865c3e
authored
Sep 10, 2012
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v0.3: Add -o option to write a log file for processor requests
parent
3f92e08c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
trackrdr.pl
prototyp/trackrdr.pl
+30
-5
No files found.
prototyp/trackrdr.pl
View file @
9c865c3e
...
...
@@ -87,11 +87,15 @@ The minimum number of seconds between status output to the log,
reporting interbal statistics (such as completed records read,
currently open records, etc.).
=item --help
=item B<-o processor_logfile>
Log file to contain the contents of all POST requests to the processor, for debugging purposes. By default no processor log file is written.
=item B<--help>
Print usage and exit
=item
--version
=item
B<--version>
Print version and exit
...
...
@@ -152,23 +156,25 @@ use Getopt::Std;
use
Pod::
Usage
;
$
Getopt::Std::
STANDARD_HELP_VERSION
=
1
;
$
main::
VERSION
=
"0.
2
"
;
$
main::
VERSION
=
"0.
3
"
;
sub
HELP_MESSAGE
{
pod2usage
(
-
exit
=>
0
,
-
verbose
=>
1
);
}
my
%
opts
;
getopts
(
"dn:v:r:u:f:l:p:s:"
,
\%
opts
);
getopts
(
"dn:v:r:u:f:l:p:s:
o:
"
,
\%
opts
);
# 0 to run forever
my
$MAX_RESTARTS
=
$opts
{
r
}
||
0
;
my
$DEBUG
=
$opts
{
d
}
||
0
;
my
$LOGFILE
=
$opts
{
l
};
my
$VLOGFILE
=
$opts
{
f
};
my
$PROCLOGFILE
=
$opts
{
o
};
my
@SHMTAGS
=
qw(ReqStart VCL_Log ReqEnd)
;
my
$VARNISH_PRE
=
$opts
{
v
}
||
'/var/opt/varnish'
;
# my $VARNISHLOG_CMD = "/usr/bin/stdbuf -o100M $VARNISH_PRE/bin/varnishlog -i ".join(',', @SHMTAGS);
my
$VARNISHLOG_CMD
=
"$VARNISH_PRE/bin/varnishlog -i "
.
join
(
','
,
@SHMTAGS
);
$VARNISHLOG_CMD
=
"$VARNISHLOG_CMD -n $opts{n}"
if
$opts
{
n
};
...
...
@@ -217,6 +223,17 @@ else {
$LOGFH
=
*
STDOUT
;
}
my
$PROCLOGFH
;
if
(
$PROCLOGFILE
)
{
$PROCLOGFH
=
new
FileHandle
">$PROCLOGFILE"
;
unless
(
defined
$PROCLOGFH
)
{
my
$err
=
$!
;
$!
=
SMF_EXIT_ERR_CONFIG
;
die
"Cannot open $PROCLOGFILE: $err\n"
;
}
$PROCLOGFH
->
autoflush
();
}
sub
logg
{
my
(
$level
,
@args
)
=
@_
;
...
...
@@ -232,6 +249,9 @@ sub logflush {
STDOUT
->
flush
();
STDERR
->
flush
();
}
if
(
$PROCLOGFH
)
{
$PROCLOGFH
->
flush
();
}
}
$SIG
{
__WARN__
}
=
sub
{
logg
(
WARN
,
@_
);
};
...
...
@@ -292,6 +312,7 @@ sub run_varnishlog {
my
$laststatus
=
time
();
while
(
<
$log
>
)
{
chomp
;
next
unless
$_
;
my
(
$tid
,
$tag
,
$cb
,
@in
)
=
split
;
logg
(
DEBUG
,
"tid=$tid tag=$tag"
);
...
...
@@ -331,6 +352,10 @@ sub run_varnishlog {
my
$data
=
join
(
'&'
,
@
{
$record
{
$tid
}{
data
}});
$records
++
;
logg
(
DEBUG
,
"$records complete records found"
);
if
(
$PROCLOGFH
)
{
print
$PROCLOGFH
'['
,
scalar
(
localtime
),
"] $data\n"
;
}
my
$resp
=
$ua
->
post
(
$PROC_URL
,
Content
=>
$data
);
if
(
$resp
->
code
!=
RC_NO_CONTENT
)
{
logg
(
WARN
,
"Processor error: "
,
...
...
@@ -382,7 +407,7 @@ sub run_varnishlog {
logg
(
NOTICE
,
"varnishlog restart"
);
}
# should never get here
SMF_EXIT_ERR_FATAL
;
exit
(
SMF_EXIT_ERR_FATAL
)
;
}
## child forwards SIGPIPE to parent
...
...
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