graphviz nginx
ターゲット確立nginxの運転フローチャート
参照https://www.ibm.com/developerworks/cn/linux/l-graphvis/
『ingxを深く分析する』を参照してください。
参照http://stackoverflow.com/questions/6344318/pure-javascript-graphviz-equivalent/14866384
参照http://graphviz.org/content/cluster
my_debug.h
./configure後にojbs/Makefileファイルを修正する
nginxを起動して、生成します。
//usr/local/inx_sendfile/sbin/trace.txt
ファイル類似
コードの変更
smbors.hの中の
pvtrace nginx
手に入れる
graphh.dot
dot-Tjpg graphh.dot-o graphh.jpg
jpgを生成し、
これ.dotも使えます。
http://www.tuidaoba.com/html/graphviz/
svgを生成する図
dotのフォーマットに基づいてsvg図を生成するjsは
添付ファイル
graphh.dot.jpgをダウンロードしてgraphh.dotをテキストで開けばdotファイルの内容が見られます。
nginx.com nfの前に追加してください。
マスターprocess off
参照https://www.ibm.com/developerworks/cn/linux/l-graphvis/
『ingxを深く分析する』を参照してください。
参照http://stackoverflow.com/questions/6344318/pure-javascript-graphviz-equivalent/14866384
参照http://graphviz.org/content/cluster
my_debug.h
#ifndef MY_DEBUG_LENKY_H
#define MY_DEBUG_LENKY_H
#include <stdio.h>
void enable_my_debug( void ) __attribute__((no_instrument_function));
void disable_my_debug( void ) __attribute__((no_instrument_function));
int get_my_debug_flag( void ) __attribute__((no_instrument_function));
void set_my_debug_flag( int ) __attribute__((no_instrument_function));
void main_constructor( void ) __attribute__((no_instrument_function,constructor));
void main_destructor( void ) __attribute__((no_instrument_function,destructor));
void __cyg_profile_func_enter( void *,void * ) __attribute__((no_instrument_function));
void __cyg_profile_func_exit( void *,void * ) __attribute__((no_instrument_function));
#ifndef MY_DEBUG_MAIN
extern FILE *my_debug_fd;
#else
FILE *my_debug_fd;
#endif
#endif
my_debug.
#include <stdio.h>
#include <stdlib.h>
/* Function prototypes with attributes */
void main_constructor( void )
__attribute__ ((no_instrument_function, constructor));
void main_destructor( void )
__attribute__ ((no_instrument_function, destructor));
void __cyg_profile_func_enter( void *, void * )
__attribute__ ((no_instrument_function));
void __cyg_profile_func_exit( void *, void * )
__attribute__ ((no_instrument_function));
static FILE *fp;
void main_constructor( void )
{
fp = fopen( "/usr/local/nginx_sendfile/sbin/trace.txt", "w" );
if (fp == NULL) exit(-1);
}
void main_deconstructor( void )
{
fclose( fp );
}
void __cyg_profile_func_enter( void *this, void *callsite )
{
fprintf(fp, "E%p
", (int *)this);
}
void __cyg_profile_func_exit( void *this, void *callsite )
{
fprintf(fp, "X%p
", (int *)this);
}
myをひもとくdebug.cとmy_debug.hはnginxのsrc/core/ディレクトリの下に置く。./configure後にojbs/Makefileファイルを修正する
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -finstrument-functions
...
18 CORE_DEPS = src/core/nginx.h \
19 src/core/my_debug.h \
.....
84 HTTP_DEPS = src/http/ngx_http.h \
85 src/core/my_debug.h \
....
105 objs/nginx: objs/src/core/nginx.o \
106 objs/src/core/my_debug.o \
......
216 $(LINK) -o objs/nginx \
217 objs/src/core/nginx.o \
218 objs/src/core/my_debug.o \
......
331 objs/src/core/my_debug.o: $(CORE_DEPS) src/core/my_debug.c
332 $(CC) -c $(CFLAGS) $(CORE_INCS) \
333 -o objs/src/core/my_debug.o \
334 src/core/my_debug.c
make&make install後nginxを起動して、生成します。
//usr/local/inx_sendfile/sbin/trace.txt
ファイル類似
[root@haoning sbin]# head trace.txt
E0x403f88
E0x41f5ac
X0x41f5ac
E0x403f88
X0x403f88
E0x410425
E0x40ff83
E0x40fa71
X0x40fa71
E0x40ad4b
使用https://www.ibm.com/developerworks/cn/linux/l-graphvis/のpvtraceコードの変更
smbors.hの中の
13 #define MAX_FUNCTIONS 20000
14 #define MAX_FUNCTION_NAME 5000
いいえ、関数が多すぎるとエラーが発生します。pvtrace nginx
手に入れる
graphh.dot
dot-Tjpg graphh.dot-o graphh.jpg
jpgを生成し、
これ.dotも使えます。
http://www.tuidaoba.com/html/graphviz/
svgを生成する図
dotのフォーマットに基づいてsvg図を生成するjsは
<html>
<head>
<meta charset="utf-8">
<title>Viz.js</title>
</head>
<body>
<script type="text/vnd.graphviz" id="cluster">
digraph G {
subgraph cluster_0 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
a0 -> a1 -> a2 -> a3;
label = "process #1";
}
subgraph cluster_1 {
node [style=filled];
b0 -> b1 -> b2 -> b3;
label = "process #2";
color=blue
}
start -> a0;
start -> b0;
a1 -> b3;
b2 -> a3;
a3 -> a0;
a3 -> end;
b3 -> end;
start [shape=Mdiamond];
end [shape=Msquare];
}
</script>
<script src="viz.js"></script>
<script>
function inspect(s) {
return "<pre>" + s.replace(/</g, "<").replace(/>/g, ">").replace(/\"/g, """) + "</pre>"
}
function src(id) {
return document.getElementById(id).innerHTML;
}
function example(id, format, engine) {
var result;
try {
result = Viz(src(id), format, engine);
if (format === "svg")
return result;
else
return inspect(result);
} catch(e) {
return inspect(e.toString());
}
}
document.body.innerHTML += "<h1>Cluster (svg output)</h1>";
document.body.innerHTML += example("cluster", "svg");
</script>
</body>
</html>
結果は図のとおりです添付ファイル
graphh.dot.jpgをダウンロードしてgraphh.dotをテキストで開けばdotファイルの内容が見られます。
nginx.com nfの前に追加してください。
マスターprocess off