2020年2月20日 星期四

Write the top to file and sed



top -b -n 30 -d 1 > top_out


# -b is batch mode
#-n is the 30 runs
# -d is 1 second to write

# out the fille
sed -n 100p top_out

or 

sed -n "100,$ p" test_out



# Ref
http://linux.vbird.org/linux_basic/0440processcontrol/0440processcontrol-fc4.php

2020年2月17日 星期一

apache log format

From http://adam-dragon.blogspot.com/2011/05/apache-log.html

Apache Custom Log Formats (如果翻譯的不對,請糾正。)

Format String Description
%% 百分比符號
%a 遠端 IP 位址
%A 本機 IP 位址
%B 回應一個 request 的大小 (bytes),含 HTTP headers
%b 以 CLF 格式回應一個 request 的大小 (bytes),含 HTTP headers
%{Foobar}C 傳送到伺服器的 Foobar cookie 的內容
%D request 傳送到伺服器的時間 (microseconds)
%{FOOBAR}e 伺服器環境變數 FOOBAR 的內容
%f 檔名
%h 遠端主機名稱
%H request 的通訊協定
%{Foobar}i The contents of Foobar: header line(s) in the request sent to the server.
Changes made by other modules (e.g. mod_headers) affect this.
%k 在一個 connection requests handled 中 keepalive 的數量
%l 遠端的 logname (This will return a dash unless mod_ident is present and Identity Check is set On).
%m The request method.
%{Foobar}n The contents of note Foobar from another module.
%{Foobar}o The contents of Foobar: header line(s) in the reply.
%p 伺服器回應一個 request 的 canonical port number
%{format}p The canonical port of the server serving the request or the server's actual port or the client's actual port.
Valid formats are canonical, local, or remote.
%P 回應 request 時的 PID
%{format}P The process ID or thread id of the child that serviced the request. Valid formats are pid, tid, and hextid. hextid requires APR 1.2.0 or higher.
%q The query string (prepended with a ? if a query string exists, otherwise an empty string).
%r First line of request.
%s 狀態. 若是由內部轉址來的 request,則將顯示原始 request 的狀態
%t 伺服器收到 request 的時間 (standard english format)
%{format}t 同上,但以自訂的格式來顯示時間
%T 伺服器回應 request 的時間 (in seconds)
%u 遠端的使用者 (from auth)
%U The URL path requested (not including any query string)
%v 伺服器回應 request 時的 canonical ServerName
%V The server name according to the UseCanonicalName setting.
%X Connection status when response is completed :
 X:connection aborted before the response completed.
 +:connection may be kept alive after the response is sent.
 -:connection will be closed after the response is sent.
This directive was %c in late versions of Apache 1.3, but this conflicted with the historical ssl %{var}c syntax.
%I Bytes received, including request and headers, cannot be zero. You need to enable mod_logio to use this.
%O Bytes sent, including headers, cannot be zero. You need to enable mod_logio to use this.

2020年2月4日 星期二

container - promethus

1. good
https://blog.techbridge.cc/2019/08/26/how-to-use-prometheus-grafana-in-flask-app/

2.  docker
https://github.com/prometheus/prometheus

3.  good example
https://k2r2bai.com/2018/06/10/cncf/prometheus/
https://ithelp.ithome.com.tw/tags/articles/prometheus
https://www.inwinstack.com/2018/11/14/prometheus-introduction-2/

4. log
https://www.robustperception.io/reloading-prometheus-configuration

document:
https://prometheus.io/docs/prometheus/latest/storage/
https://prometheus.io/docs/prometheus/latest/getting_started/

https://prometheus.io/docs/prometheus/latest/querying/basics/

https://wiki.lnd.bz/display/LFTC/Prometheus

https://yunlzheng.gitbook.io/prometheus-book/part-ii-prometheus-jin-jie/exporter/commonly-eporter-usage/use-prometheus-monitor-container

5. reload
http://codefun007.xyz/view/article_detail.htm?id=350

yaml invalidte


https://codebeautify.org/yaml-validator

https://ithelp.ithome.com.tw/articles/10193509

http://www.yamllint.com/

2020年1月14日 星期二

glibc compiler

http://www.linuxfromscratch.org/lfs/view/development/chapter05/glibc.html

https://sys.readthedocs.io/en/latest/doc/03_glibc.html

https://buildmedia.readthedocs.org/media/pdf/sys/latest/sys.pdf

https://www.itread01.com/content/1543348204.html

books
https://buildmedia.readthedocs.org/media/pdf/sys/latest/sys.pdf


https://stackoverflow.com/questions/847179/multiple-glibc-libraries-on-a-single-host

2020年1月13日 星期一

openssl & nginx install

1.  http://jianiau.blogspot.com/2015/07/openssl-config-req.html

2. https://blog.miniasp.com/post/2019/02/25/Creating-Self-signed-Certificate-using-OpenSSL


3. https://blog.cssuen.tw/create-a-self-signed-certificate-using-openssl-240c7b0579d3

4. https://blog.niclin.tw/2019/08/16/creating-self-signed-certificate-using-openssl/

2019年12月25日 星期三

php xmlrpc decode bug for large size and solution

1. When the response is large than 10MB the xmlrpc decode will return null

https://www.php.net/manual/en/function.xmlrpc-decode.php

Note that from libxml 2.7.9+ there is a limit of 10MB for the XML-RPC response.

If the response is larger, xmlrpc_decode will simply return NULL.

There is currently no way to override this limit like we can with the other xml functions (LIBXML_PARSEHUGE)


2.  solution parse using the

SimpleXML


example:
<?php
        //Enter your code here, enjoy
    $xmlString = <<<EOF
<?xml version='1.0'?>
<methodResponse>
        <params>
            <param>
                <value>
                    <array>
                        <data>
                            <value>
                                <string>Hello</string>
                            </value>
                            <value>
                                <string>Andy</string>
                            </value>
                        </data>
                    </array>
                </value>
            </param>
        </params>
</methodResponse>
EOF;

$xml = new SimpleXMLElement($xmlString);

if ($xml===null || !is_object($xml))
    die('Failed to load xml file.');
    

echo "ok";    

//print_r($xml);
echo $xml->params->param->value->array->data->value->string;
echo $xml->params->param->value->array->data->value[1]->string;