andrey-shamis/logbook

LogBook

安装: 4

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 4

分支: 0

开放问题: 13

类型:项目


README

LogBook是一个允许轻松存储日志并在网页上显示它们的工具。上传可以使用curl和post日志文件。

设置

Apache配置

需要更改

sudo vi /etc/php/7.2/apache2/php.ini

可选 sudo vi /etc/php/7.2/cli/php.ini

  • post_max_size = 200M
  • upload_max_filesize = 100M
  • max_upload_file_size
  • max_execution_time = 4096
  • max_input_time = 160
  • memory_limit = 4096M
sudo a2enmod rewrite
sudo systemctl restart apache2

将此添加到您的 /etc/apache/sites-avaliable/site.name.conf

<Directory /var/www/logbook/public >
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                Allow from All
        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ index.php [QSA,L]
        </IfModule>
        </Directory>

MySQL

更大的缓冲池池需要更少的磁盘I/O来访问多次相同的表数据。在专用数据库服务器上,您可以将缓冲池大小设置为机器物理内存大小的80%。在配置缓冲池大小时,请注意以下潜在问题,并在必要时准备缩减缓冲池大小。

innodb_buffer_pool_size     = 16G

#This sets the size of the InnoDB’s redo log files which, in MySQL world, are often called simply transaction logs. 
#And right until MySQL 5.6.8 the default value of innodb_log_file_size=5M was the single biggest InnoDB 
#performance killer. Starting with MySQL 5.6.8, the default was raised to 48M which, for many intensive systems, 
#is still way too low.
#As a rule of thumb you should set this to accommodate ~1-2h worth of writes and if you’re in a hurry, 
#having this set to 1-2G will give you pretty good performance with pretty much any workload.
innodb_log_file_size = 1G

# For MyISAM tables
tmpdir                      = /var/mysqltmp

# For MyISAM tables
mkdir /var/mysqltmp
id -u mysql
id -g mysql

编辑 /etc/fstab

tmpfs           /var/mysqltmp                   tmpfs rw,gid=125,uid=117,size=16G,nr_inodes=10k,mode=0700 0 0

设置时区

sudo dpkg-reconfigure tzdata

LDAP(可选)

要求

PHP>=7.2

  • sudo apt install php7.2-ldap php7.2-zip php7.2-xml php7.2-mbstring php7.2-sqlite3

模板

版本

版本和预发布版本可以在这里找到 https://github.com/AndreyShamis/lbook/releases

代码审查

代码审查使用https://review.gerrithub.io 使用 jenkins 服务器

持续集成

Build Status

作者

Andrey Shamis lolnik@gmail.com @AndreyShamis

PSR-12

https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md

<?php

declare(strict_types=1);

namespace Vendor\Package;

use Vendor\Package\{ClassA as A, ClassB, ClassC as C};
use Vendor\Package\SomeNamespace\ClassD as D;

use function Vendor\Package\{functionA, functionB, functionC};
use const Vendor\Package\{ConstantA, ConstantB, ConstantC};

class Foo extends Bar implements FooInterface
{
    public function sampleFunction(int $a, int $b = null): array
    {
        if ($a === $b) {
            bar();
        } elseif ($a > $b) {
            $foo->bar($arg1);
        } else {
            BazClass::bar($arg2, $arg3);
        }
    }

    final public static function bar()
    {
        // method body
    }
}

内部教程

安装并启用APCu

sudo apt install php7.2-dev
pecl install apcu

编辑 /etc/php/7.2/apache2/php.ini 添加 extension=apcu.so

更改权限

sudo chown -R www-data:www-data /var/www/lbook* ; sudo chmod -R g=u /var/www/lbook*

在新机器上更改MySql密码

手册来源

$ sudo mysql_secure_installation
$ sudo service mysql stop

$ sudo mkdir -p /var/run/mysqld
$ sudo chown mysql:mysql /var/run/mysqld

$ sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &

$ mysql -u root

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> USE mysql; 
Database changed
mysql> UPDATE user SET authentication_string=PASSWORD("NEWPASS") WHERE User='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 1

mysql> UPDATE user SET plugin="mysql_native_password" WHERE User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> quit                                                                                                                                                                                    


$ sudo pkill mysqld                                                                                                                                                        

$ sudo service mysql start

上传文件

curl --noproxy "127.0.0.1" --max-time 120 --form SETUP_NAME=DELL-KUBUNTU --form 'UPTIME_START=1.73 2.68' --form 'UPTIME_END=3.73 4.68' --form NIC=TEST --form DUTIP=172.17.0.1 --form PlatformName=Platf --form k_ver= --form Kernel=4.4 --form testCaseName=sa --form testSetName=sa --form build=Build --form testCount=2  --form file=@results-03-network_WiFi_Perf.ht40/debug/autoserv.DEBUG --form setup='SUPER SETUP3' --form token=144224564212603434  http://127.0.0.1:8080/upload/new_cli

禁用文件上传

# in .env
DISABLE_TEST_UPLOAD=true

在mysql中存储session

CREATE TABLE `lbk_customer_session` (
    `guid` VARBINARY(128) NOT NULL PRIMARY KEY,
    `sess_data` BLOB NOT NULL,
    `sess_lifetime` INTEGER UNSIGNED NOT NULL,
    `sess_time` INTEGER UNSIGNED NOT NULL,
    INDEX `sessions_sess_lifetime_idx` (`sess_lifetime`)
) COLLATE utf8mb4_bin, ENGINE = InnoDB;

crontab

运行 crontab -e 添加以下行

*/10 * * * *    wget --no-proxy -O- http://logbook.com/bot/delete_cycles >> /tmp/bot_cycle_delete.log
*/2  * * * *    wget --no-proxy -O- http://logbook.com/bot/find_cycles_for_delete >> /tmp/bot_find_cycles_for_delete.>
*/3  * * * *    wget --no-proxy -O- http://logbook.com/bot/cycle_event_delete >> /tmp/bot_cycle_event_delete.log
*/40 * * * *    wget --no-proxy -O- http://logbook.com/bot/setups/clean > /dev/null
*/3 * * * *     wget --no-proxy -O- http://logbook.com/bot/setups/count_cycles > /dev/null
*/13 * * * *    wget --no-proxy -O- http://logbook.com/reports/auto/create > /dev/null
*/1 * * * *     wget --no-proxy -O- http://logbook.com/api/send_emails > /dev/null
* */6 * * *     wget --no-proxy -O- http://logbook.com//failure/maintain > /dev/null
*/3 * * * *     sleep 15; wget --no-proxy -O- http://logbook.com/api/cycle/auto/cycle_close   > /dev/null 2>&1
*/2  * * * *    sleep 15; wget --no-proxy -O- http://logbook.com/bot/cycle_event_delete >> /tmp/bot_cycle_event_delet>
* */12 * * *    sleep 15; wget --no-proxy -O- http://logbook.com/build/clean_not_used   > /dev/null 2>&1
* */6 * * *     sleep 15; wget --no-proxy -O- http://logbook.com/bot/setups/clean  >> /tmp/logbook.setup.clean_not_us>
3 */12 * * *    sleep 15; wget --no-proxy -O- http://logbook.com/suites/calculate/3  > /dev/null 2>&1
2 */6 * * *     sleep 15; wget --no-proxy -O- http://logbook.com/suites/calculate/2  > /dev/null 2>&1
1 */2 * * *     sleep 15; wget --no-proxy -O- http://logbook.com/suites/calculate/1  > /dev/null 2>&1
* */20 * * *    sleep 15; wget --no-proxy -O- http://logbook.com/suites/close_unclosed/5  > /dev/null 2>&1
4 */3 * * *     sleep 15; wget --no-proxy -O- http://logbook.com/suites/close_unclosed/3  > /dev/null 2>&1

API

使用API搜索循环

curl --header "Content-Type: application/json" --request POST --data '{"cycle_name":"pass", "fromDate": "03/12/2013"}'  http://logbook.com/cycle/searchjson
curl --header "Content-Type: application/json" --request POST --data '{"cycle_name":"pass", "fromDate": "03/12/2013", "limit": "2000", "setups": [1958, 1957] }'  http://logbook.com/cycle/searchjson

可用参数

cycle_name fromDate toDate limit setups

多导出

http://logbook.com/cycle/multiexport?cycles=624144;625572;625541

导出单个测试元数据

http://logbook.com/test/export/105443579

搜索设置

curl --header "Content-Type: application/json" --request POST --data '{"setup_name":"app"}' http://logbook.com/setup/searchjson

调整您的交换设置

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

cat /proc/sys/vm/swappiness

swappiness参数配置了系统将数据从RAM交换到交换空间的频率。这是一个介于0和100之间的值,表示百分比。

接近零的值表示内核只有在绝对必要时才会将数据交换到磁盘。记住,与交换文件交互“昂贵”,因为它们比与RAM的交互慢得多,并且可能导致性能显著下降。告诉系统不要过多依赖交换通常会使系统更快。

接近100的值会尝试将更多数据放入交换,以保持更多RAM空间空闲。根据您的应用程序的内存配置或您使用服务器的方式,在某些情况下这可能是更好的选择。