PS caused by the massacre

Source: Internet
Author: User
Tags truncated cadvisor

The shell script developed has a section to determine if the process is started and the code is as follows

Start Cadvisor fail
 

Logic is fine, but always returns after the NAS executes

Start Cadvisor fail
 

After logging into the machine, the PS aux can be used to check that the process is actually started, and that executing the script on the machine is also successful.

Increase printing, and then call the NAS interface execution, found that the process name has been truncated, such as the Docker process after the parameters are all gone, but the cadvisor process, is displayed asroot 3242 2.0 0.3 78148 6308 ? Sl 20:50 0:00 /usr/local/bin/

Root2924  0.1  0.0   9420  1576? S -: -   0:xxBash v2.0/node-Root3166  2.8  0.5 259720 11948? Sl -: -   0:xx/usr/bin/Dockerroot3173  0.0  0.0      0     0? s< -: -   0:xx[Loop0]root3174  0.0  0.0      0     0? s< -: -   0:xx[Loop1]root3175  0.0  0.0      0     0? s< -: -   0:xx[Kdmflush]root3177  0.0  0.0  21248   868? S -: -   0:xxUDEVD--Daemonroot3178  0.0  0.0  21248   992? S -: -   0:xxUDEVD--Daemonroot3180  0.0  0.0      0     0? s< -: -   0:xx[Bioset]root3181  0.0  0.0      0     0? s< -: -   0:xx[Kcopyd]root3182  0.0  0.0      0     0? s< -: -   0:xx[Bioset]root3183  0.0  0.0      0     0? s< -: -   0:xx[dm-Thin]root3184  0.0  0.0      0     0? s< -: -   0:xx[Bioset]root3242  2.0  0.3  78148  6308? Sl -: -   0:xx/usr/local/bin/Root3250  0.0  0.0  15312  1128? R -: -   0:xx PSAux
 

The output of this thing is not the same as the terminal, may set the length of the display when using the NAS and directly in the terminal is not the same
Print the next
Executed directly on the machine setty -a and echo $COLUMNS the results are as follows

#setty-384000; #echo  $COLUMNS  $
 

When using the NAS call script, increase the value of printing columns, the result columns=80
The columns is set to 80 directly on the machine, resulting in the problem of truncation being reproduced.

#export columns= the#PSAuxroot3520  0.6  0.9 120996 20164? Sl -: -   1: on/usr/local/bin/Root3595  0.2  0.9  32480 20040? Sl -: -   0: A/usr/local/bin/Root7165  0.0  0.0  35728  1140? S the: the   0:xx/usr/sbin/Cronroot7166  0.0  0.0  35728  1144? S the: the   0:xx/usr/sbin/cron
 

It seems that because of the limitation of the character length, the ghost knows the environment variables of the NAS inherit from WHO.

If you need to solve the PS display process length truncated problem, the method is also more, you can modify the next PS command to output long enough, man PS a bit, found this w parameter

-w     Wide output.   for Unlimited width. --width n    Set screen width.
 

After appending ww the parameters, the script executes normally.

People who write shell scripts often encounter large pits such as environment variables, so try to choose a secure implementation or to circumvent such problems by setting their own environment variables.

PS caused by the massacre

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.