{"id":256882,"date":"2015-05-09T03:32:02","date_gmt":"2015-05-08T23:32:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=256882"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=256882","title":{"rendered":"ExpvarMon \u2014 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0430 Go"},"content":{"rendered":"<p>     \t\u0414\u043b\u044f Go-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u0435\u0439\u0448\u0438\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0430\u043a\u0430\u0434\u0436 <a href=\"http:\/\/golang.org\/pkg\/expvar\/\">expvar<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0434\u0435\u0431\u0430\u0433 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 JSON-\u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0418 \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 Expvarmon, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0430\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043c\u0435\u0442\u0440\u0438\u043a \u0438 \u0434\u0435\u0431\u0430\u0433-\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 Go-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<ul>\n<li>single- \u0438 multi-services \u0440\u0435\u0436\u0438\u043c\u044b<\/li>\n<li>\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c<\/li>\n<li>\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432, bool \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b\/\u0441\u0442\u0440\u043e\u043a<\/li>\n<li>sparkline-\u0433\u0440\u0430\u0444\u0438\u043a\u0438<\/li>\n<li>\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/li>\n<li>\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0443\u043f\u0430\u0432\u0448\u0438\u0445\/\u0440\u0435\u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0432\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/li>\n<li>\u0430\u0432\u0442\u043e-\u0440\u0435\u0441\u0430\u0439\u0437 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0448\u0440\u0438\u0444\u0442\u0430 \u0438\u043b\u0438 \u043e\u043a\u043d\u0430<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/31b\/b20\/fdd\/31bb20fddf734c2b9bf6e1959339b0b8.png\"\/><br \/>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Go \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043f\u0430\u043a\u0430\u0434\u0436 <a href=\"http:\/\/golang.org\/pkg\/expvar\/\">expvar<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0434\u0435\u0431\u0430\u0433 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 json-\u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \/debug\/vars. \u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 (GC), \u0438 \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u044e\u0431\u044b\u0435 \u0441\u0432\u043e\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438\/\u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438\/\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043b\u0430\u0434\u0435\u0442 \u0432 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c time-series \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0437\u0430\u0442\u0435\u043c \u044d\u0442\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u044b.<\/p>\n<p>  \u041d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e, \u0434\u0430\u0436\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043b\u0438 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u043c, \u043d\u0435\u0442 \u0443\u0442\u0435\u0447\u0435\u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u043b\u0438 \u0433\u043e\u0440\u0443\u0442\u0438\u043d \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0446\u0435\u043b\u0443\u044e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u2014 \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u043e \u0438 \u043d\u0435\u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u043e, \u0430 \u0441\u044b\u0440\u043e\u0439 json \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0431\u0435\u043b\u0435\u043d.<\/p>\n<p>  \u0418\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0438 \u0431\u044b\u043b\u0430 \u0437\u0430 \u043f\u0430\u0440\u0443 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 expvar \u043f\u0440\u044f\u043c\u043e \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u043d\u0443\u043b\u0435\u0432\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0430\u0437 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u0435\u0439\u0448\u0438\u0439 \u043f\u0430\u043a\u0430\u0434\u0436 <a href=\"https:\/\/github.com\/gizak\/termui\">TermUI <\/a> \u043e\u0442 \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u044f \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u043e\u0432 <a href=\"http:\/\/gizak.github.io\">gizak<\/a> (\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0435\u0433\u043e <a href=\"http:\/\/gizak.github.io\">\u0434\u043e\u043c\u0430\u0448\u043d\u044e\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443<\/a>!).<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 Go \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430:  <\/p>\n<pre><code class=\"go\">go get github.com\/divan\/termui<\/code><\/pre>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, $GOPATH\/bin \u0443 \u0432\u0430\u0441 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d \u0432 $PATH.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  <\/p>\n<h5>expvar<\/h5>\n<p>  <\/p>\n<h6>\u041a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/h6>\n<p>  <\/p>\n<pre><code class=\"go\">import _ &quot;expvar&quot;<\/code><\/pre>\n<p>  <\/p>\n<h6>\u0414\u043b\u0438\u043d\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/h6>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u043f\u0430\u043a\u0435\u0442\u043e\u043c <a href=\"http:\/\/golang.org\/pkg\/expvar\/\">expvar<\/a>, \u0442\u043e \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f.<br \/>  \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/golang.org\/src\/expvar\/expvar.go?s=6520:6531#L332\">init()<\/a> \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<pre><code class=\"go\">func init() { \thttp.HandleFunc(&quot;\/debug\/vars&quot;, expvarHandler) \tPublish(&quot;cmdline&quot;, Func(cmdline)) \tPublish(&quot;memstats&quot;, Func(memstats)) }<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0445\u0435\u043d\u0434\u043b\u0435\u0440 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 URL &quot;\/debug\/vars&quot; \u0434\u043b\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e http.DefaultServeMux \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 net\/http. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d net\/http, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0442\u0430\u0440\u0442\u0430\u043d\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 http-\u0441\u0435\u0440\u0432\u0435\u0440 (\u0441\u043a\u0430\u0436\u0435\u043c, <i>http.ListenAndServe(&quot;:1234&quot;, nil)<\/i>), \u0442\u043e \u0443 \u043d\u0435\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a GET-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \/debug\/vars. \u0418 \u043e\u0442\u0432\u0435\u0442 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 JSON:  <\/p>\n<pre><code class=\"bash\">$ curl -s http:\/\/localhost:1234\/debug\/vars | json_pp | head {    &quot;cmdline&quot; : [       &quot;.\/expvar.demo&quot;,       &quot;-bind=:1234&quot;,    ],    &quot;memstats&quot; : {       &quot;NumGC&quot; : 5,       &quot;Alloc&quot; : 114016,       &quot;DebugGC&quot; : false,       &quot;HeapObjects&quot; : 519,       &quot;HeapSys&quot; : 868352,       &quot;StackInuse&quot; : 180224, <\/code><\/pre>\n<p>  \u042d\u0442\u043e JSON-\u0440\u0435\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u0432\u0443\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430\u043c\u0438 \u2014 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <a href=\"http:\/\/golang.org\/pkg\/runtime\/#MemStats\">runtime.Memstats<\/a>. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0430\u0441\u0441\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430, \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443 \u0443\u0436 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430\u044f. \u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Alloc, Sys, HeapAlloc \u2014 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c, \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u0430\u044f \u0443 OS, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0432 \u043a\u0443\u0447\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 init() \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0435 \u043f\u0430\u043a\u0430\u0434\u0436\u0430, \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443:  <\/p>\n<pre><code class=\"go\">import _ &quot;expvar&quot;<\/code><\/pre>\n<p>  <\/p>\n<h5>expvarmon<\/h5>\n<p>  \u0414\u0430\u043d\u043d\u0430\u044f \u0436\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u2014 \u043e\u043d\u0430 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0432\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 JSON \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0432\u0438\u0434\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 sparkline-\u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0434\u043b\u044f \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0412\u0441\u0435 \u0447\u0442\u043e \u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u044d\u0442\u043e \u043f\u043e\u0440\u0442 \u0438\u043b\u0438 \u00ab\u0445\u043e\u0441\u0442: \u043f\u043e\u0440\u0442\u00bb \u0441\u0435\u0440\u0432\u0438\u0441\u0430(-\u043e\u0432) \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443:  <\/p>\n<pre><code class=\"bash\">expvarmon -ports=&quot;80&quot; expvarmon -ports=&quot;23000-23010,80&quot; expvarmon -ports=&quot;80,remoteapp.corp.local:80-82&quot; <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043e\u0434\u043d\u0443, \u0442\u0430\u043a \u0438 30+ \u043f\u043e\u0440\u0442\u043e\u0432\/\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u2014 \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u0432\u0430\u0441 \u0445\u0432\u0430\u0442\u0438\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430.<br \/>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0441\u0430\u043c\u0443 \u0441\u0435\u0431\u044f:  <\/p>\n<pre><code class=\"bash\">expvarmon -self<\/code><\/pre>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u2014 5 \u0441\u0435\u043a\u0443\u043d\u0434, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435. \u0418\u043c\u0435\u0439\u0442\u0435 \u0432\u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 memstats \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0443\u0437\u044b. \u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u0430\u043f\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0431\u0435\u0436\u0438\u0442 \u043f\u043e\u0434 \u0445\u043e\u0440\u043e\u0448\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439, \u0441\u0438\u043b\u044c\u043d\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b (100ms) \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c.  <\/p>\n<pre><code class=\"bash\">expvarmon -self -i 5m expvarmon -self -i 30s<\/code><\/pre>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:  <\/p>\n<ul>\n<li>mem:memstats.Alloc<\/li>\n<li>mem:memstats.Sys<\/li>\n<li>mem:memstats.HeapAlloc<\/li>\n<li>mem:memstats.HeapInuse<\/li>\n<li>memstats.EnableGC<\/li>\n<li>memstats.NumGC<\/li>\n<li>duration:memstats.PauseTotalNs<\/li>\n<\/ul>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u0430\u043a\u043e\u043c \u043e\u043d\u0438 \u0435\u0441\u0442\u044c \u0432 JSON, \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0447\u0435\u0440\u0435\u0437 \u0442\u043e\u0447\u043a\u0443. \u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u00abmem:\u00bb, \u00abduration:\u00bb, \u00abstr:\u00bb \u2014 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b, \u0438 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\/\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0431\u0435\u0437 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430, \u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0435\u0441\u0442\u044c. \u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u00abmem:\u00bb \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u00abKB, MB, etc\u00bb \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u00abduration:\u00bb \u2014 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c int64 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 time.Duration(\u00abns, ms, s, m, etc\u00bb). \u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u00abstr:\u00bb \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0435, \u0438 sparkline-\u0433\u0440\u0430\u0444\u0438\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>  \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443:  <\/p>\n<pre><code class=\"bash\">expvarmon -ports=&quot;80&quot; -vars=&quot;mem:memstats.Alloc,duration:Response.Mean,Goroutines,str:Uptime&quot;<\/code><\/pre>\n<p>  \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u043e\u0434\u043d\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0442\u0430\u043a \u0438 \u043f\u0430\u0440\u0443 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u0432\u0430\u0441 \u0445\u0432\u0430\u0442\u0438\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430.<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 \u2014 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u044b\u0445 \u0434\u0432\u0443\u0445, \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u044b. \u0414\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b\u0438\u0441\u044c \u0437\u0430 \u0441\u0435\u0441\u0441\u0438\u044e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<\/p>\n<h4>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e<\/h4>\n<p>  Expvarmon \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u043a\u043e\u043d\u043a\u0430\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u0434\u0430\u043b\u0438 \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0435\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043e\u043f\u0440\u043e\u0441\u0430 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043f\u0430\u0434\u0435\u043d\u0438\u044f\/\u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0442\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u0441\u043b\u043e\u0432\u0438\u0442.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f. \u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u0445 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2014 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430. \u041d\u0438 \u0437\u0443\u043c\u0430, \u043d\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0438, \u043d\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0442\u0443\u0442 \u043d\u0435\u0442. \u042d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u2014 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c TermUI, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u0435\u043d\u044f\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0448\u0440\u0438\u0444\u0442\u0430 \u0438\u043b\u0438 \u043e\u043a\u043d\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430.<\/p>\n<h4>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/h4>\n<p>  \u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u043f\u0435\u0440\u0435\u0447\u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 expvar \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0434\u0432\u0443\u0445 \u0432\u0435\u0449\u0435\u0439 \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0433\u043e\u0440\u0443\u0442\u0438\u043d \u0438 \u0430\u043f\u0442\u0430\u0439\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0412\u043e\u0442 \u0434\u0435\u043c\u043e-\u0432\u0440\u0430\u043f\u043f\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0442 \u0442\u0440\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 \u0441\u0432\u043e\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043e\u0434\u043d\u0438\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c.  <\/p>\n<pre><code class=\"go\">package myexpvars  import ( \t&quot;expvar&quot; \t&quot;math\/rand&quot; \t&quot;runtime&quot; \t&quot;time&quot; )  var ( \tstartTime = time.Now().UTC() )  \/\/ goroutines is an expvar.Func compliant wrapper for runtime.NumGoroutine function. func goroutines() interface{} { \treturn runtime.NumGoroutine() }  \/\/ uptime is an expvar.Func compliant wrapper for uptime info. func uptime() interface{} { \tuptime := time.Since(startTime) \treturn int64(uptime) }  \/\/ responseTime fake var. func responseTime() interface{} { \tresp := time.Duration(rand.Intn(1000)) * time.Millisecond \treturn int64(resp) }  func init() { \texpvar.Publish(&quot;Goroutines&quot;, expvar.Func(goroutines)) \texpvar.Publish(&quot;Uptime&quot;, expvar.Func(uptime)) \texpvar.Publish(&quot;MeanResponse&quot;, expvar.Func(responseTime)) } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0439 http-\u0440\u043e\u0443\u0442\u0435\u0440, \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e<\/h4>\n<p>  \u041c\u043d\u043e\u0433\u0438\u0435 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043d\u0430 Go \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u0431-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 http-\u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432. expvar \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0414\u043b\u044f \u043d\u0435\u0433\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0430\u043d\u0443\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 http.ListenAndServer() \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u043e\u0440\u0442\u0443. \u0410 \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0440\u0443\u0436\u0443 \/debug\/vars \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 net\/http, \u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b expvar \u0431\u044b\u043b \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u043e\u0440\u0442\u0443, \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a. \u00ab\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439\u00bb ServeMux \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"go\">mux := http.NewServerMux() server := &http.Server{Addr: \u201c:80\u201d, Handler: mux} server.ListenAndServe()<\/code><\/pre>\n<p>  \u0430 \/debug\/vars \u043f\u043e\u0432\u0435\u0441\u0438\u0442\u044c \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439  <\/p>\n<pre><code class=\"go\">http.ListenAndServe(&quot;:1234&quot;, nil)<\/code><\/pre>\n<h4>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b<\/h4>\n<p>  <a href=\"\/\/habrastorage.org\/files\/050\/acc\/a2c\/050acca2ca19472eabd30283683a5276.png\"><img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/050\/acc\/a2c\/050acca2ca19472eabd30283683a5276.png\" width=\"300\"\/><\/a> <a href=\"\/\/habrastorage.org\/files\/232\/a2c\/d13\/232a2cd13fed4f9c82ee6572765933a5.png\"><img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/232\/a2c\/d13\/232a2cd13fed4f9c82ee6572765933a5.png\" width=\"300\"\/><\/a><\/p>\n<p>  <a href=\"\/\/habrastorage.org\/files\/fcb\/1c2\/623\/fcb1c262373846ceb562259b6c0822bb.png\"><img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/fcb\/1c2\/623\/fcb1c262373846ceb562259b6c0822bb.png\" width=\"300\"\/><\/a> <a href=\"\/\/habrastorage.org\/files\/c4f\/12a\/443\/c4f12a4437754ed89512b92e23c3bc29.png\"><img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/c4f\/12a\/443\/c4f12a4437754ed89512b92e23c3bc29.png\" width=\"300\"\/><\/a> <\/p>\n<h4>\u0421\u0441\u044b\u043b\u043a\u0438<\/h4>\n<p>  Github: <a href=\"https:\/\/github.com\/divan\/expvarmon\">github.com\/divan\/expvarmon<\/a><br \/>  Expvar docs: <a href=\"http:\/\/golang.org\/pkg\/expvar\/\">golang.org\/pkg\/expvar<\/a><br \/>  runtime.Memstats: <a href=\"http:\/\/golang.org\/pkg\/runtime\/#MemStats\">golang.org\/pkg\/runtime\/#MemStats<\/a>     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/257593\/\"> http:\/\/habrahabr.ru\/post\/257593\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u0414\u043b\u044f Go-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u0435\u0439\u0448\u0438\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0430\u043a\u0430\u0434\u0436 <a href=\"http:\/\/golang.org\/pkg\/expvar\/\">expvar<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0434\u0435\u0431\u0430\u0433 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 JSON-\u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0418 \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 Expvarmon, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0430\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043c\u0435\u0442\u0440\u0438\u043a \u0438 \u0434\u0435\u0431\u0430\u0433-\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 Go-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<ul>\n<li>single- \u0438 multi-services \u0440\u0435\u0436\u0438\u043c\u044b<\/li>\n<li>\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c<\/li>\n<li>\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432, bool \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b\/\u0441\u0442\u0440\u043e\u043a<\/li>\n<li>sparkline-\u0433\u0440\u0430\u0444\u0438\u043a\u0438<\/li>\n<li>\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/li>\n<li>\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0443\u043f\u0430\u0432\u0448\u0438\u0445\/\u0440\u0435\u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0432\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/li>\n<li>\u0430\u0432\u0442\u043e-\u0440\u0435\u0441\u0430\u0439\u0437 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0448\u0440\u0438\u0444\u0442\u0430 \u0438\u043b\u0438 \u043e\u043a\u043d\u0430<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/31b\/b20\/fdd\/31bb20fddf734c2b9bf6e1959339b0b8.png\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-256882","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256882","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=256882"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256882\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}