How to check the disk usage of your VPS

The df utility displays the disk space usage on all mounted filesystem.

The -T option prints the filesystem type as well. By default, df measures the size in 1K blocks, which could be a little difficult for a desktop user to decipher. Use the -h option to get the more understandable output:

davidyin@localhost:~$ df -h -T
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  463M     0  463M   0% /dev
tmpfs          tmpfs      99M  7.0M   92M   8% /run
/dev/sda       ext4       25G   12G   12G  51% /
tmpfs          tmpfs     493M     0  493M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     493M     0  493M   0% /sys/fs/cgroup
tmpfs          tmpfs      99M     0   99M   0% /run/user/1000
davidyin@localhost:~$

The VPS system will be problemed when the disk is used 100% full.

So to make sure the disk usage in the health range is very important. Clean the files when it is growing too fast or close to 85% or 90%.

Look at the log files. For example, web site error log, web site access log, security log files.

How to take a webpage screenshot at terminal window

The scenario is to run the program inside of Ubuntu VPS.  Input a URL the program will output the jpg file.

The solution is to use wkhtmltoimage, which is a part of wkhtmtopdf.

I used to use the old version wkhtmltopdf v0.12.3. Now it is not working anymore due to some reason I don’t know.

But the wkhtmltopdf v0.12.5  is OK.

The OS is Ubuntu 18.04.

Then I install wkhtmltopdf with the following command

sudo apt-get install -y software-properties-common
sudo apt-add-repository -y "deb http://security.ubuntu.com/ubuntu xenial-security main" 
sudo apt-get -yq update
sudo apt-get install -y libxrender1 libfontconfig1 libx11-dev libjpeg62 libxtst6 fontconfig xfonts-75dpi xfonts-base libpng12-0 libjpeg-turbo8
wget "https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.xenial_amd64.deb" 
sudo dpkg -i wkhtmltox_0.12.5-1.xenial_amd64.deb 
sudo apt-get -f install

After installation, run the command to show the help of the program.

Continue reading “How to take a webpage screenshot at terminal window”

Use GoAccess to Generate Report with Multiple Nginx Log Files

I have a VPS with Nginx as a web server and also a lot of web sites on it. It is on Digital Ocean.

Here is the VPS basic information.

  • SFO2
  • 1GB Nanode
  • Ubuntu Linux 18.04.2
  • Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz, 1 cores
  • Nginx 1.15.9

All sites use one access.log file. The following code is in the http block of /etc/nginx/nginx.conf file.

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

All access logs look like below:

Now it is time to show you how to use GoAccess to Generate Report with Multiple Nginx Log files.

Install GoAccess

sudo install goaccess

 

Modify the Config file of GoAccess

GoAccess config file is located at /etc/

sudo nano /etc/goaccess.conf

Add the following code or modify the code inside of the goaccess.conf.

time-format %H:%M:%S

date-format %d/%b/%Y

log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"

Run GoAccess to generate the report

I would like to get a static report.

sudo goaccess /var/log/nginx/access.log -o /home/davidyin/mywebsite.com/report.html --log-format=COMBINED

The report looks like below:

Due to the log is not just one file. The log files are generated by date and also compressed.

Two log files are not compressed.

  • access.log
  • access.log.1

The older log files are compressed.

  • access.log.2.gz
  • access.log.3.gz
  • access.log.4.gz
  • access.log.5.gz

I want to generate all the access log files. So the command is changed to the way which can phrase multiple log files.

zcat /var/log/nginx/access.log.*.gz | goaccess /var/log/nginx/access.log /var/log/nginx/access.log.1 - -o /home/davidyin/mywebsite.com/report.html --log-format=COMBINED

The sample command above using mywebsite.com. Please replace it with your own sites.

At the last, I add this command into Cron jobs. Schedule it every hour.

How to make a slow motion video with Yi Action Camera

I have a Yi Action Camera. It is a low-end GoPro alternative.

  • Ambarella A7LS chipset, low-power digital signal processing (DSP) technology, high-definition (HD) H.264/ MJPEG video engine and a 700-MHz ARM11 applications processor. 
  • Sony IMX206, 1/2.3″, 16MP CMOS image sensor with Exmor R ability / Panasonic MN34120PA, 1/2.3″, 16MP CMOS image sensor 
  • 1080P/60FPS, 720P/120FPS, 848*480/240FPS 
  • Bluetooth (4.0BLE low power consumption) and Built-in (802.11 bgn) Single band 2.4G Wi-Fi 

 

I tried to use video capture function of this camera at the followin settings:

1280×720 @120fps

I took 10 seconds video and move the video to the computer. It just has a higher frame rate, but not slow motion.

 

Then I tried to find the software, which can help me convert the video to slow motion one.

At last, I found the free tool, ffmpeg.

Download the ffmpeg windows bin file.

https://ffmpeg.zeranoe.com/builds/

I chose the latest static windows 64bit build. It is a package. I only need the ffmpeg.exe file. Find it in the package and extract it to the working directory.

Put the original video file in the same folder.

Run the following command in the command window.

ffmpeg -i ydxj1364.mp4 -filter:v "setpts=5*PTS" -r 25 test-1364.mp4

ydxj1364.mp4 is the original video file.
test-1364.mp4 is the output file name.
-filter:v “setpts=5*PTS” is to slow down the video by 5 times.
-r 25 is to force the output file to 25fps.

The command I run above has the following output.

 

ffmpeg version N-93217-ga899b3b3c5 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20190212
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 47.102 / 58. 47.102
libavformat 58. 26.101 / 58. 26.101
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 48.100 / 7. 48.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001b9fce99cc0] unsupported color_parameter_type aclc
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ydxj1364.mp4':
Metadata:
major_brand : avc1
minor_version : 0
compatible_brands: avc1isom
creation_time : 2019-02-22T12:55:06.000000Z
Duration: 00:00:11.91, start: 0.000000, bitrate: 18107 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], 18063 kb/s, 119.88 fps, 119.88 tbr, 120k tbn, 239.76 tbc (default)
Metadata:
creation_time : 2019-02-22T12:55:06.000000Z
handler_name :
: XiaoYi AVC
encoder : XiaoYi AVC encoder
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 000001b9fceb9840] using SAR=1/1
[libx264 @ 000001b9fceb9840] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001b9fceb9840] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 000001b9fceb9840] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test-1364.mp4':
Metadata:
major_brand : avc1
minor_version : 0
compatible_brands: avc1isom
encoder : Lavf58.26.101
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
creation_time : 2019-02-22T12:55:06.000000Z
handler_name :
: XiaoYi AVC
encoder : Lavc58.47.102 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 1488 fps= 45 q=-1.0 Lsize= 25879kB time=00:00:59.40 bitrate=3569.0kbits/s dup=60 drop=0 speed=1.79x
video:25860kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.071957%
[libx264 @ 000001b9fceb9840] frame I:6 Avg QP:20.70 size:167506
[libx264 @ 000001b9fceb9840] frame P:381 Avg QP:23.36 size: 54533
[libx264 @ 000001b9fceb9840] frame B:1101 Avg QP:28.55 size: 4267
[libx264 @ 000001b9fceb9840] consecutive B-frames: 0.6% 1.9% 1.0% 96.5%
[libx264 @ 000001b9fceb9840] mb I I16..4: 17.5% 24.0% 58.5%
[libx264 @ 000001b9fceb9840] mb P I16..4: 0.4% 1.3% 1.6% P16..4: 41.6% 22.2% 18.2% 0.0% 0.0% skip:14.8%
[libx264 @ 000001b9fceb9840] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 48.7% 3.8% 1.5% direct: 2.2% skip:43.9% L0:53.8% L1:43.2% BI: 3.0%
[libx264 @ 000001b9fceb9840] 8x8 transform intra:34.9% inter:28.4%
[libx264 @ 000001b9fceb9840] coded y,uvDC,uvAC intra: 95.7% 40.8% 0.3% inter: 18.4% 7.4% 0.0%
[libx264 @ 000001b9fceb9840] i16 v,h,dc,p: 6% 11% 61% 21%
[libx264 @ 000001b9fceb9840] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 21% 23% 5% 7% 5% 12% 5% 11%
[libx264 @ 000001b9fceb9840] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 20% 20% 7% 7% 6% 9% 6% 11%
[libx264 @ 000001b9fceb9840] i8c dc,h,v,p: 71% 17% 11% 1%
[libx264 @ 000001b9fceb9840] Weighted P-Frames: Y:18.1% UV:0.0%
[libx264 @ 000001b9fceb9840] ref P L0: 55.6% 11.3% 22.8% 8.3% 2.0%
[libx264 @ 000001b9fceb9840] ref B L0: 92.5% 7.1% 0.4%
[libx264 @ 000001b9fceb9840] ref B L1: 96.3% 3.7%
[libx264 @ 000001b9fceb9840] kb/s:3559.20

MDR-ZX110 Sony Over-Ear Headphones

I bought a Sony headphone in LondonDrugs a month ago. I use it with my Xbox One console.

I like the over-ear headphone. My ears feel more comfortable. Less pressure and I can also hear the environment sound.

Look at the back.

  • 30Mm drivers provide rich, full frequency response
  • Lightweight and comfortable over-ear design
  • Swivel design enhances portability
  • 47.25-Inch Tangle-Free Y-type cord
  • White

I paid $19 because it is on sale. It is $25 on Amazon now.

 

I have an MDR-ZX100 Over-Ear Headphones for a long time. I use it on my desktop.

Fix the warning of Event 1534 on Windows 10 build 1809

It is Windows 10 build 1809. In the Event Viewer, there are a lot of warning of event 1534.

The description of warning is either:

Profile notification of event Unload for component {B31118B2-1F49-48E5-B6F5-BC21CAEC56FB} failed, error code is See Tracelogging for error details.

or:

Profile notification of event Load for component {B31118B2-1F49-48E5-B6F5-BC21CAEC56FB} failed, error code is See Tracelogging for error details.

There is no fix on it. But a workaround to remove these annoying warning.

How to remove the warning of Event ID 1534?

1, Call the registry editor Regedit (with administrator privileges) and navigate to the following two registry entries.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\
CurrentVersion\ProfileNotification

and

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\
Windows NT\CurrentVersion\ProfileNotification

2, Then select the key TDL, export it for backup, then delete it.

To delete it, you can apply the Full access to Administrtors.

If you received the error like me above, you can also use the way below.

The ownership of the key TDL may have to be changed to Andministrators.

After restarting the system, the warning message should no longer appear in the event logs.

 

Fix the Warning of Event 64, CertificateServicesClient-AutoEnrollment

My Windows 10 is 1809. Recently I saw the warning in the Event Viewer.

Event 64, CertificateServicesClient-AutoEnrollment

Certificate for local system with Thumbprint be f9 b4 cd 1xxxxxxxx f4 df 51 is about to expire or already expired.

I did the search and find the way to solve this problem.

Before to do the following, I would like to make an announcement. It is just a warning. It will not affect your Windows System.

Right Click Start > Run > type mmc > press ENTER
On the File Menu > Click Add/Remove Snap-in > Click Certificates > Click Add
Click Computer Account > click Next
Click Finish > Click OK
In the console tree, Expand Certificates > Personal > Certificates
You should see the XBL Client IPsec Issuing CA
Right Click on it > All tasks > Export
Follow the Export Wizard > Export it as a x509 (.cer) > Give it a name (example: xbl-client-ipsec.cer)
Right Click on it > Delete > Confirm Delete
Close the mmc > Say NO when asked if you want to save Console

Now, the certificate is removed. This warning should not appear in the Event Viewer.

Renew the SSL Certificate for Yinfor.com

I just renewed the SSL certificate. The cheapest DV SSL certificate I found is from GoGetSSL.com.

I paid by paypal. The price is so good. US$7.90 for two years. Comodo PositiveSSL.

After I installed the certificate on my blog. I check the certificate by clicking on the lock icon on the address bar. It is not shown as Comodo, but Sectigo.

Look at the old certificate.

Details of certificates

Continue reading “Renew the SSL Certificate for Yinfor.com”

What Is Electromagnetic Compatibility?

Electromagnetic compatibility is an important aspect of global product safety testing. Electronic devices that give off radiation play increasingly vital roles in the lives of people around the world. Electromagnetic compatibility testing ensures that such devices can withstand the emission of electromagnetic radiation given off by other electronics in the vicinity while not affecting the operation of other products with excessive electromagnetic interference.

Issues Pursued by EMC Testing

The deliberate or accidental generation of electromagnetic energy is called emission. Unwanted emissions are referred to as radiofrequency interference. If a particular piece of electrical equipment has a tendency to break down or malfunction in the presence of radio frequency interference, it is referred to as the victim. The mechanism by which RFI reaches the victim is called coupling. The ability to withstand the effects of RFI is called immunity, while the tendency to break down in the presence of unwanted emissions is called susceptibility.

Ways To Make Equipment Electromagnetically Compatible

Electromagnetic compatibility can be achieved in one of three ways:

  • Hardening potential victims, i.e., increasing their immunity
  • Inhibiting the path of coupling between the RFI and the victim
  • Quieting the sources of interference

Engineering techniques such as shielding or grounding may be employed to address all three issues. Once the victim is no longer susceptible to RFI and can function in the presence of unwanted emissions, it can be said to be electromagnetically compatible.

International Electromagnetic Compatibility

Several countries have laws in place requiring that radiation-emitting products meet international standards for electromagnetic compatibility, as well as agencies to enforce those laws. In the United States, the main regulatory body for electromagnetic compatibility is the Federal Communications Commission.

Products Affected by Electromagnetic Compatibility

EMC testing is carried out on a wide range of products:

  • Medical equipment
  • Communication devices
  • Road traffic signals
  • Broadcast receivers
  • Toys
  • Tools
  • Household appliances
  • Electrical lighting equipment

Susceptibility of devices such as these to radiofrequency interference could range from a minor inconvenience to a life-threatening situation. That is why the international community places such a strong emphasis on electromagnetic compatibility.

PHP Benchmark of php 7.1, php7.2, php7.3 and even php5.6

Here I run the PHP benchmark script on my Virtualbox guest OS Ubuntu 16.04.

Every version of PHP I tested 7 times. So get rid of the highest one, and the lowest one. Get the average of the rest five scores.

php5.6.39
The average is 5.13 seconds.

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2018-12-20 17:49:49
Server : t.g2list.win@192.168.1.120
PHP version : 5.6.39-1+ubuntu16.04.1+deb.sury.org+1
Platform : Linux
--------------------------------------
test_math                 : 1.523 sec.
test_stringmanipulation   : 1.594 sec.
test_loops                : 1.147 sec.
test_ifelse               : 0.808 sec.
--------------------------------------
Total time:               : 5.072 sec.

php 7.1.25
The average is 1.859 seconds.

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2018-12-20 17:41:51
Server : t.g2list.win@192.168.1.120
PHP version : 7.1.25-1+ubuntu16.04.1+deb.sury.org+1
Platform : Linux
--------------------------------------
test_ifelse               : 0.517 sec.
test_loops                : 0.378 sec.
test_stringmanipulation   : 0.561 sec.
test_math                 : 0.389 sec.
--------------------------------------
Total time:               : 1.845 sec.

php7.2
The average is 1.286 seconds.

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2018-12-20 17:44:37
Server : t.g2list.win@192.168.1.120
PHP version : 7.2.13-1+ubuntu16.04.1+deb.sury.org+1
Platform : Linux
--------------------------------------
test_ifelse               : 0.164 sec.
test_loops                : 0.274 sec.
test_stringmanipulation   : 0.495 sec.
test_math                 : 0.336 sec.
--------------------------------------
Total time:               : 1.269 sec.

php7.3
The average is 1.31 seconds.

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2018-12-20 17:47:16
Server : t.g2list.win@192.168.1.120
PHP version : 7.3.0-1+ubuntu16.04.1+deb.sury.org+1
Platform : Linux
--------------------------------------
test_ifelse               : 0.181 sec.
test_loops                : 0.350 sec.
test_stringmanipulation   : 0.469 sec.
test_math                 : 0.323 sec.
--------------------------------------
Total time:               : 1.323 sec.

I do have to say that the tests I run is not good enough. It does’t test all the php features. Actually, it is just a very small part of it.
If you count on the database, memory usage, etc., the answer will be quite different.

  • Archives