Skip to content

Instantly share code, notes, and snippets.

View kazeburo's full-sized avatar

Masahiro Nagano kazeburo

View GitHub Profile
#!perl
use strict;
my %stats;
{
open my $fh, '<', '/proc/net/snmp' or die "$!\n";
my @keys;
while (<$fh>) {
chomp;
diff --git a/src/ngx_http_headers_more_headers_in.c b/src/ngx_http_headers_more_headers_in.c
index c3eb8f7..527c8a5 100644
--- a/src/ngx_http_headers_more_headers_in.c
+++ b/src/ngx_http_headers_more_headers_in.c
@@ -739,6 +739,7 @@ ngx_http_set_connection_header(ngx_http_request_t *r,
if (ngx_strcasestrn(value->data, "close", 5 - 1)) {
r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE;
r->headers_in.keep_alive_n = -1;
+ r->keepalive = 0;
diff --git a/starter.go b/starter.go
index c65ce00..4d47000 100644
--- a/starter.go
+++ b/starter.go
@@ -517,7 +517,6 @@ func (s *Starter) StartWorker(sigCh chan os.Signal, ch chan processState) *os.Pr
sigs = append(sigs, sig)
}
}
-
// if received any signals, during the wait, we bail out
#!/usr/bin/perl
use strict;
use warnings;
use JSON;
sub cap_cmd {
my ($cmdref) = @_;
pipe my $logrh, my $logwh
or die "Died: failed to create pipe:$!\n";
my $pid = fork;
user nobody nobody;
daemon off;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 200000;
worker_processes 1;
pcre_jit on;
events {
use epoll;
@kazeburo
kazeburo / gist:608fc2ba0748e6ab3663
Last active June 29, 2017 23:53
perl redis client benchmark
# perl memcached.pl
Rate pp fast
pp 21167/s -- -89%
fast 197745/s 834% --
# perl -Ilib -Iblib/arch eg/benchmark.pl
single get =======
Rate redis fast hiredis jet
redis 34841/s -- -56% -68% -71%
fast 80082/s 130% -- -27% -33%
#!/usr/bin/perl
use strict;
use warnings;
use IO::Handle;
use Getopt::Long;
use File::Spec;
sub find_path {
my $pg = shift;
@kazeburo
kazeburo / nagios_web.psgi
Last active January 30, 2017 01:38
PSGI file to serving Nagios WebUI
use Plack::App::CGIBin;
use Plack::App::PHPCGIFile;
use Plack::Builder;
use Plack::Builder::Conditionals;
my $cgibin = Plack::App::CGIBin->new(
root => "/usr/local/nagios/sbin",
exec_cb => sub { my $file = shift; $file =~ m!\.cgi$! and -x $file },
)->to_app;
my $htdocs = Plack::App::PHPCGIFile->new(
#!/usr/bin/perl
use strict;
use warnings;
use JSON;
sub cap_cmd {
my ($cmdref) = @_;
pipe my $logrh, my $logwh
or die "Died: failed to create pipe:$!\n";
$ perl stats_elb.pl --region us-west-2 --elb ProdElb | mkr throw --service production