tag:blogger.com,1999:blog-46178321733108275632024-03-14T03:07:32.603-07:00Fred's BlogOpensource with life.Unknownnoreply@blogger.comBlogger853125tag:blogger.com,1999:blog-4617832173310827563.post-29167671908618778402017-05-10T05:20:00.000-07:002017-05-10T05:20:11.762-07:00 How to Resume an SCP Transfer<code>
rsync -P -e ssh local_file user@host:remote_file
</code>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-52775934437643733062015-08-03T03:25:00.001-07:002015-08-03T04:41:46.192-07:00How to upload vhd or file in Azure ChinaStep 1:<br />
<br />
<pre class="code">azure storage account connectionstring show --blob-endpoint gfw.blob.core.chinacloudapi.cn mcops</pre>
<br />
Step 2:<br />
<br />
<pre class="code">azure storage blob upload -c '<step1 string>' -f /tmp/coreos_production_azure_image.vhd --container test --blobtype page</pre>
<br />
Step 3:<br />
<br />
<pre class="code">
azure vm image create -f -u https://gfw.blob.core.chinacloudapi.cn/vm-images/coreos_production_azure_image1.vhd -f -v CoreOS-Latest --location "China North" --os Linux https://gfw.blob.core.chinacloudapi.cn/vm-images/coreos_production_azure_image.vhd
azure vm image create myimage --blob-url https://myaccount.blob.core.chinacloudapi.cn/mycontainer/ImageName.vhd --os linux</pre>
<br />
Step 4:<br />
<br />
<pre class="code">azure vm create <dnsname> <imagename> -u <vmusername> -p <vmpassword> -l <location></pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-29784070828270792202015-07-10T23:01:00.000-07:002015-07-11T07:10:57.689-07:00Starting with Strace<h2>
What is strace?</h2>
<div>
Strace is a “system call trace” program. It attaches to a process and tracks system calls and signals made to and from it (and possibly it’s children). There are limitations to strace, some of which are detailed below. However, strace can be a very valuable tool for determining the root cause of many issues. This post only covers very basic usage of strace. The example used here can be done using jailshell.</div>
<div>
<span id="more-21552" style="box-sizing: border-box;"></span></div>
<h3>
What is a process?</h3>
<div>
For the purposes of this tutorial, a process is a unique instance of program being run, identified on the system by a unique process identifier (pid). For more information see<a href="http://www.linfo.org/process.html" style="-webkit-transition: all 500ms ease; background-color: transparent; box-sizing: border-box; color: #ff6c2c; text-decoration: none; transition: all 500ms ease;" target="_blank">http://www.linfo.org/process.html</a> and <a href="http://en.wikipedia.org/wiki/Process_identifier" style="-webkit-transition: all 500ms ease; background-color: transparent; box-sizing: border-box; color: #ff6c2c; text-decoration: none; transition: all 500ms ease;" target="_blank">http://en.wikipedia.org/wiki/Process_identifier</a></div>
<h3>
What is a system call?</h3>
<div>
A system call is how a program requests that the operating system kernel perform a task for it. There are quite a few “normal” tasks that the operating system kernel does for programs regularly, including extremely common file operations like reading and writing. More information regarding system calls can be found at: <a href="http://en.wikipedia.org/wiki/System_call" style="-webkit-transition: all 500ms ease; background-color: transparent; box-sizing: border-box; color: #ff6c2c; text-decoration: none; transition: all 500ms ease;" target="_blank">http://en.wikipedia.org/wiki/System_call</a></div>
<h3>
What information can strace capture? Not capture?</h3>
<div>
Strace can tell you</div>
<ul>
<li style="box-sizing: border-box; text-align: left;">what files and network connections were opened, closed, or attempted</li>
<li style="box-sizing: border-box; text-align: left;">what was read from and written to from said files and connections</li>
</ul>
<div>
Strace cannot tell you what is happening inside the process. It is not a debugger and is not aware of the variables used inside the process.</div>
<h3>
What do I have to know before I can use strace?</h3>
<div>
Strace is a power tool in your troubleshooting bag. But it’s not the most basic tool. General troubleshooting (checking log files, researching error messages, etc) should be done before attempting to solve a problem with strace. Before using strace, you’ll need to be able to reliably reproduce the issue so that you can catch it with strace. You’ll also need to determine what process to strace (covered later).</div>
<h3>
When am I not able to use strace?</h3>
<div>
In addition to there being times when strace will not be helpful, there are a few scenarios when you can not use strace. While most normal processes can be attached to by strace, there are some exceptions.</div>
<div>
You cannot attach to a process in these scenarios:</div>
<ul>
<li style="box-sizing: border-box; text-align: left;">when a debugger or other tracing program is already attached</li>
<li style="box-sizing: border-box; text-align: left;">when you do not own the process, unless you are running the strace as root</li>
<li style="box-sizing: border-box; text-align: left;">when the system has special protections preventing strace from being used to gather information</li>
</ul>
<h3>
Resource considerations</h3>
<div>
Output files created by strace files do get very big very quickly, but more importantly are the numerous writes that strace output produces. This i/o hit is not mitigated (and is frequently made worse) by outputting to the terminal instead of a file.</div>
<h2>
Before you start to strace</h2>
<h3>
Ensuring strace is installed</h3>
<div>
You can determine if strace is installed by typing:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">strace -V</code></div>
<div>
If strace is installed, you’ll see something like: strace — version 4.5.19. If it’s not installed, you’ll see something like bash: strace: command not found. Install strace with:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">yum install strace</code></div>
<div>
This command does require root access, so if you do not have root, you will need to request that your web hosting provider install strace for you.<br />
<a name='more'></a></div>
<h3>
Finding the right process</h3>
<div>
The ps command is very useful if you need to attach strace to a long running existing process (like a backup that you think may have stalled). The important column is the PID column. It will frequently be either the first or second column, depending on which options you use.</div>
<div>
What output you can see with the ps command is greatly dependent on your permissions for the server. A user with jailshell will frequently see very little:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />cptest@cptest.test [~]# ps uxfww<br style="box-sizing: border-box;" />USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND<br style="box-sizing: border-box;" />cptest 1 0.0 0.1 108300 1780 ? S 10:01 0:00 jailshell<br style="box-sizing: border-box;" />cptest 10 0.0 0.1 110192 1036 ? R+ 10:02 0:00 ps wwwfux<br style="box-sizing: border-box;" />cptest@cptest.test [~]#</code></div>
<div>
The root user will see quite a bit more (part of the results from the command ps uxfww):<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />root 1042 0.0 0.1 249088 1992 ? Sl Aug27 0:02 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5<br style="box-sizing: border-box;" />root 1120 0.0 0.0 4080 624 ? Ss Aug27 0:00 /usr/sbin/acpid<br style="box-sizing: border-box;" />root 1192 0.0 0.1 66616 1220 ? Ss Aug27 0:00 /usr/sbin/sshd<br style="box-sizing: border-box;" />root 10424 0.0 0.3 104484 4068 ? Ss 09:59 0:00 _ sshd: root@pts/0<br style="box-sizing: border-box;" />root 10432 0.0 0.1 108296 1828 pts/0 Ss 09:59 0:00 _ -bash<br style="box-sizing: border-box;" />root 10486 0.0 0.1 110340 1132 pts/0 R+ 10:00 0:00 _ ps wwwfux<br style="box-sizing: border-box;" />root 1204 0.0 0.1 108296 1544 ? S Aug27 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/nt13188.product.cpanel.vm.pid<br style="box-sizing: border-box;" />root 1355 0.0 0.1 19608 1100 ? Ss Aug27 0:01 /usr/sbin/dovecot<br style="box-sizing: border-box;" />root 1368 0.0 0.1 13444 1280 ? S Aug27 0:00 _ dovecot/log<br style="box-sizing: border-box;" />root 1372 0.0 0.2 16428 2084 ? S Aug27 0:01 _ dovecot/config<br style="box-sizing: border-box;" />root 1449 0.0 5.0 165480 51148 ? Ss Aug27 2:09 /usr/local/cpanel/3rdparty/perl/514/bin/spamd -d --allowed-ips=127.0.0.1 --pidfile=/var/run/spamd.pid --max-children=3 --max-spare=1<br style="box-sizing: border-box;" />root 1557 0.0 4.8 165480 49116 ? S Aug27 0:00 _ spamd child<br style="box-sizing: border-box;" />root 1471 0.0 0.0 110316 948 ? Ss Aug27 0:00 /usr/sbin/abrtd<br style="box-sizing: border-box;" />root 1483 0.0 0.5 73712 5176 ? Ss Aug27 0:33 /usr/local/apache/bin/httpd -k start -DSSL</code></div>
<div>
A jailshell user will not be able to see processes that it did not start in the terminal they are running ps from. This includes php processes and cPanel login sessions. A normal/bash shell user will be able to see all their processes – and processes running as other users.</div>
<div>
If you are attaching strace as the process starts, you will not need to use ps to determine the pid. If you only have jail shell access, you will be limited to using strace on processes you can start yourself (from the jail shell).</div>
<h2>
Starting strace and basic options</h2>
<div>
There are two ways to attach a strace to a process: you can start the process with strace attached or you can attach strace to an already running process.</div>
<h3>
Strace a process start to finish</h3>
<div>
Staring a process with strace already attached means starting strace and having strace start the process. You tell strace you want it to start the process by adding the command you want to strace as the last argument of strace. This sounds complicated, but is easy. For example, if you wanted to strace the script ./chdir.sh start to finish, you would use this command:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"># strace ./chdir.sh</code></div>
<div>
will print the strace output generated when running the shell script chdir.sh to the screen. Note that the command does run normally – any actions normally performed by the script being invoked will occur normally. Strace logs them, it does not stop them from occurring.</div>
<h3>
Attaching to an already running process: -p PID</h3>
<div>
If instead, you wish to attach to a long running process (like, say, a backup) you would use the similar command:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"># strace -p 12345</code></div>
<div>
In this case, the orange text is the -p (pid) option followed by the target process’s process ID. To detach from a strace, use Ctrl-D.</div>
<h3>
Saving strace output to a file: -o filename</h3>
<div>
In most cases, you’ll want to save your strace output to a file. This is frequently faster than outputting to the terminal, and it gives you the opportunity to easily search the output using tools like grep. For example to save the output of the above command to a file called “debug.strace” in the current directory, you would use the command:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"># strace -o debug.strace -p 12345</code></div>
<div>
You can use any path that you have access to. The file does not need to already exist. If it does, strace will overwrite it. If you use a path you don’t have access to, you’ll get a Permission denied error and strace won’t attach:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />mary@mary.test [~/public_html]# strace -f -o /root/perl-quiet2.strace ./open-silent.pl<br style="box-sizing: border-box;" />strace: can't fopen '/root/perl-quiet2.strace': Permission denied<br style="box-sizing: border-box;" />mary@mary.test [~/public_html]#</code></div>
<h3>
Following forks: -f and -ff</h3>
<div>
Many processes create child processes to handle some of the work, and you will almost certainly need to tell strace to log them as well. This is recursive – if the child process creates a child, that “grandchild” will also be included in the strace. This is called “following forks”, and there are two ways to do so with strace. You can have strace merge all the output together with -f, or you can use -ff with -o and have strace write one file for each process (-ff).</div>
<h3>
Targeting in time: -t, -tt, -ttt, -T</h3>
<div>
Timestamps are extremely useful. You may need to order events in a strace file and a log file or want to know how long a system call took. The four “t” options of strace can help with this:</div>
<div>
<strong style="box-sizing: border-box;">switch</strong><strong style="box-sizing: border-box;">what it does</strong><strong style="box-sizing: border-box;">example</strong><br />
<strong style="box-sizing: border-box;"><br /></strong></div>
<table style="background-color: #f4f4f4; border-collapse: collapse; border-spacing: 0px; box-sizing: border-box; color: #555555; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 18px; line-height: 25.7142868041992px;"><thead style="box-sizing: border-box;"></thead><tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding: 0px;">-t</td><td style="box-sizing: border-box; padding: 0px;">add a timestamp to each line</td><td style="box-sizing: border-box; padding: 0px;">12:39:18 brk(0) = 0x8da000</td></tr>
<tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding: 0px;">-tt</td><td style="box-sizing: border-box; padding: 0px;">add a timestamp with microseconds</td><td style="box-sizing: border-box; padding: 0px;">12:39:34.601873 brk(0) = 0x18cc000</td></tr>
<tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding: 0px;">-ttt</td><td style="box-sizing: border-box; padding: 0px;">add a timestamp with microseconds and the number of seconds since the epoch</td><td style="box-sizing: border-box; padding: 0px;">1401557981.377712 brk(0) = 0x1509000</td></tr>
<tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding: 0px;">-T</td><td style="box-sizing: border-box; padding: 0px;">add the time spent in the system call</td><td style="box-sizing: border-box; padding: 0px;"><em style="box-sizing: border-box;">using both -ttt and -T:</em> 1401558007.457779 brk(0) = 0x1d59000 <0.000012></td></tr>
</tbody></table>
<h3>
Verbosity and string size: -v and -s</h3>
<div>
Neither of these options is used in the example, but they are worth mentioning because they can be very useful.</div>
<div>
The string size option (-s) lets you change how much of a string being read or written is shown in the strace output. The default string length is 32. There are a few things to note:</div>
<ul>
<li style="box-sizing: border-box; text-align: left;">Filenames are not considered strings and are always printed in full</li>
<li style="box-sizing: border-box; text-align: left;">strace will still tell you how long the string was, even if it doesn’t show you the whole thing</li>
<li style="box-sizing: border-box; text-align: left;">string length is not quite the same as the number of characters (because string length includes control characters like the newline and some UTF-8 characters are more than 1 unit long by strace’s counting method)</li>
</ul>
<div>
The -v (verbose) switch tells strace to print the more information about environment for many calls. This is very noticeable on the “stat” call. For instance, the first line of a strace without the verbose option looks like this:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">1489 execve("./open-silent.pl", ["./open-silent.pl"], [/* 31 vars */]) = 0</code><br />
with the verbose option, I see:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">execve("./open-silent.pl", ["./open-silent.pl"], ["HOSTNAME=nt12199.product.cpanel."..., "TERM=xterm-256color", "SHELL=/bin/bash", "HISTSIZE=1000", "SSH_CLIENT=10.1.7.152 56078 22", "PERL5LIB=/home/mary/perl5/lib/pe"..., "OLDPWD=/home/mary", "PERL_MB_OPT=--install_base "/hom"..., "SSH_TTY=/dev/pts/0", "USER=mary", "LS_COLORS=rs=0:di=01;34:ln=01;36"..., "MAIL=/var/spool/mail/mary", "PATH=/usr/local/jdk/bin:/home/ma"..., "PWD=/home/mary/public_html", "JAVA_HOME=/usr/local/jdk", "EDITOR=pico", "LANG=en_US.UTF-8", "HISTCONTROL=ignoredups", "SHLVL=1", "HOME=/home/mary", "LS_OPTIONS=--color=tty -F -a -b "..., "PERL_LOCAL_LIB_ROOT=/home/mary/p"..., "LOGNAME=mary", "VISUAL=pico", "CVS_RSH=ssh", "CLASSPATH=.:/usr/local/jdk/lib/c"..., "SSH_CONNECTION=10.1.7.152 56078 "..., "LESSOPEN=|/usr/bin/lesspipe.sh %"..., "PERL_MM_OPT=INSTALL_BASE=/home/m"..., "G_BROKEN_FILENAMES=1", "_=/usr/bin/strace"]) = 0</code></div>
<h2>
Reading strace output</h2>
<div>
Using strace to document the activity of a very simple script like this one:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />#!/bin/bash<br style="box-sizing: border-box;" />cd /home/</code><br />
produces a 6.3K file when using a invoking strace with this command:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">strace -o changedir ./chdir.sh</code></div>
<div>
The script is functionally useless, but stracing it does produce some output for us to examine. Please do try this at home; it’s the best way to learn.<br />
<br />
When you do, you’ll see that the first line in the strace is:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">execve("./chdir.sh", ["./chdir.sh"], [/* 22 vars */]) = 0</code></div>
<div>
You’ll see a line similar to this (with the execve call) when you start strace with a command. You will not see it if you attach strace to an already running process. The majority of the file contains information that we don’t care about as beginners, but there are a few items of interest.</div>
<h3>
File Handles</h3>
<div>
The second line of interest is:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">open("./chdir.sh", O_RDONLY) = 3</code></div>
<div>
This is the operating system opening the script we’re running. It’s using the open system call to open the file ./chdir.sh in readonly mode. It’s assigned it file handle #3. After it opens the file, it reads it. Strace does not give you the name of the file ever again – it only tells you what file handle it’s reading from:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">read(3, "#!/bin/bashnncd /home/nn", 80) = 24</code></div>
<div>
The above line tells you that the system read 24 bytes from file handle #3. It even helpfully tells you the content of those 24 bytes, because it’s short. Normally the entire amount read by the system will not be included in the strace – only the first small amount.</div>
<div>
To determine what that file is, you have to scroll up and see what the last file that was opened successfully with that file handle. Linux does reuse file handles, so it’s not uncommon to see something like:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />open("./chdir.sh", O_RDONLY) = 3<br style="box-sizing: border-box;" />read(3, "#!/bin/bashnncd /home/nn", 80) = 24<br style="box-sizing: border-box;" />close(3)<br style="box-sizing: border-box;" />open("./read.sh", O_RDONLY) = 3<br style="box-sizing: border-box;" />ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffbfda78c0) = -1 ENOTTY (Inappropriate ioctl for device)</code></div>
<div>
In this case, the error is not important – the kernel is simply telling the program that the file ./read.sh is not a terminal. You will see this frequently in strace output and can ignore it. The important detail to remember here is that file handles are re-used, and it’s important to read up from the line your interested in to find what file is currently being referenced by the file handle.</div>
<h3>
File handles 1 and 2</h3>
<div>
File handles 1 and 2 are special. File handle 1 is standard input and file handle 2 is standard output. Standard error is another special file handle that, if used, frequently takes up file handle 3. A tutorial on standard input, output, and error can be found at:<a href="http://www.linfo.org/stdio.html" style="-webkit-transition: all 500ms ease; background-color: transparent; box-sizing: border-box; color: #ff6c2c; text-decoration: none; transition: all 500ms ease;" target="_blank">http://www.linfo.org/stdio.html</a>.</div>
<h3>
Manual pages (getting more info)</h3>
<div>
The linux manual pages are divided into sections. Section 2 is for system calls, like the ones you will see in strace output. Each system call has it’s own manual page that includes all the things that are allowed to go as arguments (between the parentheses) and all the return values (things that can appear after the “=” sign).</div>
<div>
At this stage, the manual page is mostly useful for looking up things that appear in the strace output. For instance, an example used later will contain the following output:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">open("./chdir.sh", O_RDONLY) = 3</code></div>
<div>
If you want to know what O_RDONLY means, you can either search the web for “man open linux” and use your browsers “find on page” function to find the information regarding O_RDONLY or you can use man 2 open and (by default) the “/” key to search inside the manpage. The first instance of O_RDONLY on the page says:</div>
<blockquote style="background-color: #f4f4f4; border-left-color: rgb(238, 238, 238); border-left-style: solid; border-left-width: 5px; box-sizing: border-box; color: #555555; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 22.5px; margin: 0px 0px 25px; padding: 12.5px 25px;">
<div>
The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR. These request opening the file read-only, write-only, or read/write, respectively.</div>
</blockquote>
<div>
We now know that the file was opened read only. Lets say that instead of the above, output, we saw:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">open("./chdir.sh", O_RDONLY) = EACCES</code></div>
<div>
We then search on the manual page for EACCES and find:</div>
<blockquote style="background-color: #f4f4f4; border-left-color: rgb(238, 238, 238); border-left-style: solid; border-left-width: 5px; box-sizing: border-box; color: #555555; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 22.5px; margin: 0px 0px 25px; padding: 12.5px 25px;">
<div>
The requested access to the file is not allowed, or search permission is denied for one of the directories in the path prefix of pathname, or the file did not exist yet and write access to the parent directory is not allowed. (See also path_resolution(7).</div>
</blockquote>
<div>
This is a little verbose, but it basically says that this is an access error – like permission denied.</div>
<h2>
Example: Permission Issues</h2>
<div>
Permission issues are very common on linux servers, and can sometimes be hard to track down. Strace can be a helpful tool for many permissions issues. With cPanel, you’ll be using strace on a lot of perl scripts. It’s also likely that there will be multiple errors in one script. This example shows two permissions and a missing file issue.</div>
<ol>
<li style="box-sizing: border-box; text-align: left;">Create a file in your working directory called “open-warn.pl” and copy the contents below into it. Ensure that it is set to be executable (chmod +x open-warn.pl)</li>
<li style="box-sizing: border-box; text-align: left;">Create a file called “test-read” that contains a short string, like “This is a test file”, and ensure that it has 0 permissions.</li>
<li style="box-sizing: border-box; text-align: left;">Create a directory called “content”, and copy the test-read file into it.</li>
<li style="box-sizing: border-box; text-align: left;">Ensure that the content folder has 0 permissions, and that the test-read file inside the content folder it is set to 644.</li>
<li style="box-sizing: border-box; text-align: left;">Ensure that there is no file named “test-read-missing” in the working directory.</li>
<li style="box-sizing: border-box; text-align: left;">Run strace on open-warn.pl, following forks and outputting to the file perl-test.strace</li>
</ol>
<div>
The file for step 1:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# cat open-warn.pl<br style="box-sizing: border-box;" />#!/usr/bin/perl</code></div>
<div>
print “Testing bad file permissionsn”;<br />
$filename = “test-read”;<br />
open( FILE, “< $filename” ) or warn “Can’t open $filename : $!”;<br />
close FILE;</div>
<div>
print “Testing bad folder permissionsn”;<br />
$filename = “content/test-read”;<br />
open( FILE, “< $filename” ) or warn “Can’t open $filename : $!”;<br />
close FILE;</div>
<div>
print “Testing missing filen”;<br />
$filename = “test-read-missing”;<br />
open( FILE, “< $filename” ) or warn “Can’t open $filename : $!”;<br />
close FILE;</div>
<div>
The “n” at the end of each print statement tells perl to insert a newline. It also tells perl to flush the print buffer (print right now). Without them, all the error messages would print above all the print statements. (Go ahead and try it)</div>
<div>
The output from step 5:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# strace -f -o perl-test.strace ./open-warn.pl<br style="box-sizing: border-box;" />Testing bad file permissions<br style="box-sizing: border-box;" />Can't open test-read : Permission denied at ./open-warn.pl line 5.<br style="box-sizing: border-box;" />Testing bad folder permissions<br style="box-sizing: border-box;" />Can't open content/test-read : Permission denied at ./open-warn.pl line 10.<br style="box-sizing: border-box;" />Testing missing file<br style="box-sizing: border-box;" />Can't open test-read-missing : No such file or directory at ./open-warn.pl line 15.<br style="box-sizing: border-box;" />[~/public_html]#</code></div>
<div>
So we have two “Permission Denied” and one “No such file” error. We can grep for either EACCES or “Permission denied” in the strace and find the errors quickly and easily:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# grep EACCES ../perl-test.strace<br style="box-sizing: border-box;" />8817 open("test-read", O_RDONLY) = -1 EACCES (Permission denied)<br style="box-sizing: border-box;" />8817 open("content/test-read", O_RDONLY) = -1 EACCES (Permission denied)</code></div>
<div>
When we grep for ENOENT or “No such file”, however, we get quite a few more. Below I have two examples of pulling out some of the lines I know I don’t need. Unfortunately, determining what you can safely exclude is highly context dependent.</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# grep ENOENT ../perl-test.strace | grep -v "/usr/"<br style="box-sizing: border-box;" />8817 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 stat("/home/mary/perl5/lib/perl5/5.10.1/x86_64-linux-thread-multi", 0x7fff625b1400) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 stat("/home/mary/perl5/lib/perl5/5.10.1", 0x7fff625b1400) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 stat("/home/mary/perl5/lib/perl5/x86_64-linux-thread-multi", 0x7fff625b1400) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 stat("/home/mary/perl5/lib/perl5/5.10.0", 0x7fff625b1400) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 open("test-read-missing", O_RDONLY) = -1 ENOENT (No such file or directory)</code><br />
or<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# grep ENOENT ../perl-test.strace | grep -v "perl5"<br style="box-sizing: border-box;" />8817 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)<br style="box-sizing: border-box;" />8817 open("test-read-missing", O_RDONLY) = -1 ENOENT (No such file or directory)</code></div>
<div>
Either way, it’s the last line that gives us what we’re looking for.</div>
<div>
Now, this was a little easy – we knew what to look for because the error message told us. Most of the time, you’ll be using strace because the error messages are not so helpful. Lets modify our open-warn.pl program and call it open-silent.pl:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# cat open-silent.pl<br style="box-sizing: border-box;" />#!/usr/bin/perl</code></div>
<div>
print “Testing bad file permissions”;<br />
$filename = “test-read”;<br />
open( FILE, “< $filename” ) or warn “Can’t open an important file”;<br />
close FILE;</div>
<div>
print “Testing bad folder permissions”;<br />
$filename = “content/test-read”;<br />
open( FILE, “< $filename” ) or warn “Can’t open an important file”;<br />
close FILE;</div>
<div>
print “Testing missing file”;<br />
$filename = “test-read-missing”;<br />
open( FILE, “< $filename” ) or warn “Can’t open an important file”;<br />
close FILE;</div>
<div>
Now when we run strace we get output like this:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# strace -f -o perl-quiet.strace ./open-silent.pl<br style="box-sizing: border-box;" />Can't open an important file at ./open-silent.pl line 5.<br style="box-sizing: border-box;" />Can't open an important file at ./open-silent.pl line 10.<br style="box-sizing: border-box;" />Can't open an important file at ./open-silent.pl line 15.<br style="box-sizing: border-box;" />Testing bad file permissionsTesting bad folder permissionsTesting missing [~/public_html]#</code></div>
<div>
Now, it still gives you some hints – like the line number. But every single one of those lines reads:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">open( FILE, "< $filename" ) or warn "Can't open an important file";</code></div>
<div>
If the program was long and complicated, we’d have no way of knowing if it was the same file that was being attempted multiple times or if there were multiple files. Now the strace file tells us something useful. I would start by checking for permission errors, since they are the most common reason that a file can’t be opened:<br />
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# grep EACCES perl-quiet.strace<br style="box-sizing: border-box;" />1489 open("test-read", O_RDONLY) = -1 EACCES (Permission denied)<br style="box-sizing: border-box;" />1489 open("content/test-read", O_RDONLY) = -1 EACCES (Permission denied)</code></div>
<div>
That gives us two of our three errors. Honestly, if I were debugging for real, at this point I would just check all the permissions on public_html and it’s subfolders and files. Because permission issues usually come in large batches on a webserver.<br />
<br /></div>
<div>
Once I’ve fixed the permission issues on test-read and content, I can run strace again. Now I only have one error message. I’m going to check for permission issues again, because sometimes when you fix one permission issue (especially on a directory) it uncovers more permission issues. Unfortunately for me, there are no more permission issues:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;"><br style="box-sizing: border-box;" />[~/public_html]# grep EACCES perl-quiet2.strace<br style="box-sizing: border-box;" />[~/public_html]#</code></div>
<div>
So now I have to think of what else might cause a file not to be opened. Maybe the file just isn’t there. So I grep for ENOENT and man there’s a lot of output. I always start at the bottom – especially if the error stops the program from running to completion. In this case, the last line is:</div>
<div>
<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 16.2000007629395px; padding: 2px 4px;">1595 open("test-read-missing", O_RDONLY) = -1 ENOENT (No such file or directory)</code></div>
<div>
Now I know that a program related file is missing. Depending on what my actual application is depends on how I fix this. In this case, I’m just going to touch the file to create it. Now when I run the script (./open-silent.pl) it does not output any error messages.<br />
<br />
Source: https://blog.cpanel.com/starting-with-strace/</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4617832173310827563.post-32107615987766502842015-06-30T20:27:00.003-07:002015-06-30T20:27:30.835-07:00Trace zabbix server<pre class="code">
objdump -DSswx zabbix_server | gzip -c > zabbix_server.objbump.gz
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-7242977771611726572015-06-29T22:04:00.003-07:002015-06-29T22:06:52.542-07:00iOS code sign error - User interaction not allowedEarlier today I was trying to build an iOS application over VPN, SSH or Bamboo (Jenkins), I was connected to my iMac at work. I was running a command line script that I had written in order to automate the build process and facilitate deployment to our network server. This involved a B2B application, so not something that would go into the App Store.<br />
<br />
Anyway, I had built the application like this, it resulted in an .app file:<br />
<pre class="code">$> xcodebuild -target "$APP_NAME" -sdk iphoneos -configuration Release</pre>
<br />
Next I signed this .app and packaged it into an .ipa file:<br />
<pre class="code">$> xcrun -sdk iphoneos PackageApplication -v "$APP_NAME.app" -o "$APP_NAME.ipa" --sign "iPhone Distribution"</pre>
<br />
This resulted in an error:<br />
<pre class="code">$> build/Release-iphoneos/$APP_NAME.app: User interaction is not allowed</pre>
<br />
The key to solving this problem was unlocking the keychain access in order for the user to be able to sign applications. You can do this like this:<br />
<pre class="code">$> security unlock-keychain /Users/$USER/Library/Keychains/$KEYCHAIN.keychain</pre>
<br />
Note:<br />
<ol>
<li>replace <i>$APP_NAME</i> with the name of your application</li>
<li>replace <i>$USER</i> with the name of your local user account, I used 'fred'</li>
<li>replace <i>$KEYCHAIN</i> with the name of the target keychain, I used 'login'</li>
</ol>
Unknownnoreply@blogger.com0香港22.396428 114.1094970000000321.9265115 113.46405000000003 22.8663445 114.75494400000004tag:blogger.com,1999:blog-4617832173310827563.post-2204831427052663682014-12-31T09:21:00.002-08:002014-12-31T09:23:12.747-08:00use vmnet patch with vmware 10.0.4 and kernel 3.17<pre class="code">diff -ur vmnet-only.a/netif.c vmnet-only/netif.c
--- vmnet-only.a/netif.c 2014-10-10 03:23:08.585920012 +0300
+++ vmnet-only/netif.c 2014-10-10 03:23:09.245920008 +0300
@@ -149,7 +149,7 @@
memcpy(deviceName, devName, sizeof deviceName);
NULL_TERMINATE_STRING(deviceName);
- dev = alloc_netdev(sizeof *netIf, deviceName, VNetNetIfSetup);
+ dev = alloc_netdev(sizeof *netIf, deviceName, NET_NAME_UNKNOWN, VNetNetIfSetup);
if (!dev) {
retval = -ENOMEM;
goto out;
</pre>
<br />
<br />
<ol>
<li>tar xf /usr/lib/vmware/modules/source/vmnet.tar -C /tmp/vmware</li>
<li>patch vmnet-only.a/netif.</li>
<li>tar -cf vmnet.tar vmnet-only/
cp vmnet.tar /usr/lib/vmware/modules/source/</li>
<li># vmware-modconfig --console --install-all</li>
</ol>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4617832173310827563.post-64939804167949837202014-07-16T06:28:00.000-07:002014-07-16T06:28:11.489-07:00Stop gvfsd-metadata Using 100% CPU and Disk High I/OIf your Linux system is slowly grinding to a halt, and you manage to pull up the System Monitor and see that gvfsd-metadata is using 100% of the CPU, here’s how to correct it. In a terminal run the following 2 commands:
<pre class="code">rm -rf ~/.local/share/gvfs-metadata
pkill gvfsd-metadata
</pre>
Your system should now be back to normal.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-25199453270335220342014-05-30T00:26:00.004-07:002014-05-30T00:26:53.412-07:00The best command to create raw datafile used by Oracle databaseOracle recommends creating new datafiles on devices with zero offset. The command "<b>/usr/sbin/mklv -y LVname -T O -w n -s n -r n VGname NumPPs</b>" can be used. Please contact Oracle customer support for more details.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-78526587093550472752014-05-09T02:55:00.003-07:002014-05-09T02:58:15.820-07:00AIX make filesystemList PV (Disk)
<br />
<pre class="code">bash-3.2# lspv
hdisk0 0056b0de849951c7 rootvg active
hdisk1 0056b0dee1558f91 rootvg active
hdisk5 0056b0de8d3ad7c5 datavg2 active
hdisk6 0056b0de8d3b2189 datavg active
</pre>
use <i><b>smit vg</b></i> to make new vg
View vg information
<br />
<pre class="code">bash-3.2# lsvg datavg
VOLUME GROUP: datavg VG IDENTIFIER: 0056b0de00004c0000000145e01e8ee2
VG STATE: active PP SIZE: 1024 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1673 (1713152 megabytes)
MAX LVs: 256 FREE PPs: 1172 (1200128 megabytes)
LVs: 2 USED PPs: 501 (513024 megabytes)
OPEN LVs: 0 QUORUM: 2 (Enabled)
TOTAL PVs: 1 VG DESCRIPTORS: 2
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 1 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 2032 MAX PVs: 16
LTG size (Dynamic): 1024 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
</pre>
view vg's lv
<br />
<pre class="code">bash-3.2# lsvg -l datavg
datavg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
test1 jfs2 500 500 1 closed/syncd /test1
loglv00 jfs2log 1 1 1 closed/syncd N/A
</pre>
use <i><b>smitty mklv</b></i> make a new LV<br />
<br />
use <i><b>smitty manfs</b></i> make a filesystem, then mountUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-22051694099307842252014-04-24T06:23:00.000-07:002014-04-24T06:24:40.625-07:00Use Click Package to Write Beautiful Command Application with Python<blockquote class="tr_bq">
click is a Python package for creating beautiful command line interfaces in a composable way with as little amount of code as necessary. It’s the “Command Line Interface Creation Kit”. It’s highly configurable but comes with good defaults out of the box.</blockquote>
<br />
Install
<br />
<pre class="code">pip install click </pre>
Hello world Sample
<br />
<pre class="code">import click
@click.command()
@click.option('--count', default=1, help='number of greetings')
@click.option('--name', prompt='Your name',
help='the person to greet', required=True)
def hello(count, name):
for x in range(count):
print('Hello %s!' % name)
if __name__ == '__main__':
hello()
</pre>
You can find quickstart and full docs <a href="http://click.pocoo.org/quickstart/" target="_blank">here</a>.
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-32391164570133472192014-04-04T19:09:00.004-07:002014-04-04T19:12:31.738-07:00玩了一下DD-WRT<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrJPsB5UuxjEC3Dy2SJ0iXW5HM5Rcwf_Yyp5s0ib9z-JrblnmBazPb1AzOp43wmBI7R1AyYuxzqekMNwR7nrS6LxiItQcJ8iEcJqTb2fNDdmlX4LXVUnAFRpl66BMgGQfL9353n_-S3ZM/s1600/screenshot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="dd-wrt fc2 freewifi whr-g301n" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrJPsB5UuxjEC3Dy2SJ0iXW5HM5Rcwf_Yyp5s0ib9z-JrblnmBazPb1AzOp43wmBI7R1AyYuxzqekMNwR7nrS6LxiItQcJ8iEcJqTb2fNDdmlX4LXVUnAFRpl66BMgGQfL9353n_-S3ZM/s1600/screenshot.png" height="294" title="DD-wrt" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-65947259561022480112014-03-31T19:06:00.002-07:002014-03-31T19:06:49.369-07:00How to trace a user login in oracle databasetrace oracle user login
<pre class="code">
alter session set tracefile_identifier='login_test';
alter session set events '10046 trace name context forever ,level 12'
conn fucker/larry
alter session set events '10046 trace name context off' ;
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-26163965475342709722014-03-06T18:54:00.001-08:002014-03-06T19:02:03.495-08:00Auto Kill Bloking Session on Oracle Database with SQL<pre class="code">
DECLARE
CURSOR c1 IS select process,sid,serial#, blocking_session from v$session where blocking_session is not null;
i NUMBER:= 0;
BEGIN
FOR e_rec IN c1 LOOP
i:= i+1;
EXECUTE immediate 'ALTER SYSTEM KILL SESSION ' ||''''|| e_rec.sid ||','|| e_rec.serial# ||''' ';
END LOOP;
END;
/
</pre>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4617832173310827563.post-54662094946346156752014-02-26T19:17:00.001-08:002014-02-26T19:17:38.723-08:00Download Movabletype Old VersionYou must buy MT6. It's not a opensource soft from MT6. But you can download MT1-MT6 RC here.<br />
<br />
<a href="http://movabletype.org/downloads/archives/">http://movabletype.org/downloads/archives/</a><br />
<br />
<a href="http://movabletype.org/downloads/betas/">http://movabletype.org/downloads/betas/</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-1067743397202432162014-02-16T22:46:00.000-08:002014-02-16T22:46:48.612-08:00How to earn online<ol>
<li>Join an affiliate program.</li>
<li>Choose free offers (easier for you to get earning)</li>
<li>Create a review for that product on Blogspot.</li>
<li>Promote that page.</li>
</ol>
<br />
<b>Free traffic sources:</b><br />
<br />
<ol>
<li>Forums</li>
<li>Social Networks</li>
<li>Video Sharing Sites</li>
<li>PDF Sharing Sites</li>
<li>Article Directories</li>
<li>Offline</li>
<li>Answers Sites</li>
<li>Groups</li>
<li>Blog Comments (set Google alerts)</li>
<li>Learn SEO and rank that blog.</li>
</ol>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-36130589290431075842013-12-01T01:55:00.000-08:002013-12-01T01:55:18.768-08:00 A $45 Linux SSD Laptop from China<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1O2DhDJKJ2y9k6YCZwI03O6LUAc_RAoWu-Hd_0afp6cdY1_hnJM9YEVwkmR8BtehGzTrJRlSUJSW0p1m8aZZ4M6p5NI0hgrRQqCmXGcbDxvpa7lSqA1xdw7R_lbzubZSC9_U1dTQhMzk/s1600/df1b8b9717f6dd2ad44deebb599c122e.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1O2DhDJKJ2y9k6YCZwI03O6LUAc_RAoWu-Hd_0afp6cdY1_hnJM9YEVwkmR8BtehGzTrJRlSUJSW0p1m8aZZ4M6p5NI0hgrRQqCmXGcbDxvpa7lSqA1xdw7R_lbzubZSC9_U1dTQhMzk/s1600/df1b8b9717f6dd2ad44deebb599c122e.jpg" /></a></div>
Last week a Chinese computer company <a href="http://www.loongsonclub.cn/tg/" rel="nofollow" target="_blank">sell a laptop with $45</a>.<br /><br />There is some english information about the laptop.<div>
<br /><div>
Lemote ultra mini-laptop is powered by the latest design-by-China 64-bit Loongson-2F processor which speeds at 900MHz.The integrated DDR 2 and PCI 2 controllers and independently designed Northbridge chipsets.<br /><h4>
Product characteristics:</h4>
<ol>
<li>Strong computing:<br />It employs the latest Loongson-2F processor, 64-bit, four-issue Out-Of-Order structure and integrated memory controller.</li>
<li>Energy saving and environmental friendly:<br />Less than 20 W, which is one tenth of an ordinary PC. The materials are ROHS compliant.</li>
<li>Quiet operation:<br />Less than 60 db.</li>
<li>security: <br />Yeeloong 8089 is a safe computing device. On one hand, the hardware components including chipset and matching motherboard are designed by Lemote wholly, which lowers the risico's being intruded by various viruses. On another hand, by employing GNU Linux operating system, it is almost immune to viruses.</li>
<li>Infinite customization: <br />The unique programmable Northbridge provides space for customization; the operation and application of free operating system could adopt a free open-source software (FOSS), which is a powerful software package management mechanism that provides the most convenient methods for users' customization and development demands to exempt from getting into the trouble of software copyright.</li>
<li>low cost: <br />The entire product, including processor, system, software and so on, are all designed by Lemote. The cost for software, hardware and synthesized usage cost is only of an ordinary PC.</li>
</ol>
<h4>
Specifications</h4>
<ul>
<li>Processor: Loongson 2F CPU, 900MGHz, integrated DDR II and PCI 2 controllers;</li>
<li>Memory slots: SO-DIMM DDR2, 512MB;</li>
<li>South bridge: AMD CS5536;</li>
<li>Display: 1024 x 600, 8,9" TFT LCD;</li>
<li>Network: Rtl8139 + RTL8187B(wifi);</li>
<li>Interface: USB2.0x3, earphone+MIC, SDx1, RJ45x1, VGAx1, DC-inx1; SD reader supports SDHC.</li>
<li>Storage: 8G SSD;</li>
<li>Graphics: SMI712</li>
<li>Webcam: Webcam with 300K pixel</li>
<li>SD: Realtek RTS5158E</li>
<li>Size: 25,2 x 3 x 18,5cm</li>
<li>Weight: 1 kg </li>
<li>Operating Systems: Debian Linux; Loonux; Red Flag Linux;</li>
<li>Full power: less than 20 W;</li>
<li>USB: 2 x USBBattery: 3 Cell Lithium.</li>
</ul>
<h4>
Application field</h4>
It could be used as ordinary laptop as well as professional computing device for users who have higher demand for security and software customization such as institutions, prototype product development, government, corporate R & D, high education, financial and security organizations etc.<br /><br /> </div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4617832173310827563.post-4631222685236759732013-10-29T22:07:00.001-07:002013-10-29T22:07:16.453-07:00 How to Empty Postfix Mail Queue<code>
mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "email@address.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -
</code>
<code>
sudo postsuper -d ALL
</code>
<code>
ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'}L
</code>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-74149660960382095652013-10-28T09:16:00.002-07:002013-10-28T09:16:51.932-07:00OSX is not better than LinuxOpensource OS is better. I think so.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-7561756770773744002013-10-05T05:10:00.002-07:002013-10-05T05:10:31.000-07:00How to count mail on queue<code>sudo find /var/spool/postfix/deferred/. ! -name . ! -name '?' -print | wc -l</code>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-78149044115729322812013-07-08T20:03:00.001-07:002013-07-08T20:07:48.088-07:00Sending and Receiving Data use Java socket programming<code>//java socket client example<br />
import java.io.*;<br />
import java.net.*;<br />
<br />
public class socket_client<br />
{<br />
public static void main(String[] args) throws IOException<br />
{<br />
Socket s = new Socket();<br />
String host = "dev.easy-conn.com";<br />
PrintWriter s_out = null;<br />
BufferedReader s_in = null;<br />
<br />
try<br />
{<br />
s.connect(new InetSocketAddress(host , 6557));<br />
System.out.println("Connected");<br />
<br />
//writer for socket<br />
s_out = new PrintWriter( s.getOutputStream(), true);<br />
//reader for socket<br />
s_in = new BufferedReader(new InputStreamReader(s.getInputStream()));<br />
}<br />
<br />
//Host not found<br />
catch (UnknownHostException e)<br />
{<br />
System.err.println("Don't know about host : " + host);<br />
System.exit(1);<br />
}<br />
<br />
//Send message to server<br />
String message = "GET hosts\r\n\r\n";<br />
s_out.println( message );<br />
<br />
System.out.println("Message send");<br />
<br />
//Get response from server<br />
String response;<br />
while ((response = s_in.readLine()) != null)<br />
{<br />
System.out.println( response );<br />
}<br />
}<br />
}<br />
</code>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4617832173310827563.post-90902351715291078582013-07-04T01:57:00.002-07:002013-07-04T01:57:59.426-07:00Bind livestatus unix socket to TCP socket use Python and twisted<code>from twisted.internet import protocol, reactor<br />
import socket,os<br />
<br />
socket_path = "/var/lib/nagios3/rw/live"<br />
<br />
class Echo(protocol.Protocol):<br />
def dataReceived(self, data):<br />
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)<br />
<br />
s.connect(socket_path)<br />
<br />
s.send(data)<br />
s.shutdown(socket.SHUT_WR)<br />
answer = s.recv(100000000)<br />
self.transport.write(answer)<br />
<br />
class EchoFactory(protocol.Factory):<br />
def buildProtocol(self, addr):<br />
return Echo()<br />
<br />
reactor.listenTCP(6557, EchoFactory())<br />
reactor.run()<br />
</code>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-22327923823619462462013-07-01T20:38:00.000-07:002013-07-01T20:38:06.968-07:00 One liner to download Oracle JDK with wget<code><span style="font-family: Courier New, Courier, monospace;">wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk-7u17-download-1501626.html;" http://download.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-i586.tar.gz --no-check-certificate -O jdk-7u25-linux-i586.tar.gz</span></code>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-19274022476279580832013-06-30T23:23:00.000-07:002013-07-01T20:39:44.366-07:00Create a read only monitor user to Oracle database需要 SYSDBA 权限。
<code><pre class="sql" style="-webkit-box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: none !important; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px !important; clear: none !important; color: #505050; font-size: 12px; line-height: 1.5; overflow: visible !important; padding: 0px 4px !important; white-space: pre-wrap; width: auto !important;"><span style="font-family: Courier New, Courier, monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">USER</span> nagios <span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span> oradbmon;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">SESSION</span> <span style="color: #993333; font-weight: bold;">TO</span> nagios;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span> any dictionary <span style="color: #993333; font-weight: bold;">TO</span> nagios;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">ON</span> V_$SYSSTAT <span style="color: #993333; font-weight: bold;">TO</span> nagios;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">ON</span> V_$INSTANCE <span style="color: #993333; font-weight: bold;">TO</span> nagios;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">ON</span> V_$LOG <span style="color: #993333; font-weight: bold;">TO</span> nagios;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">ON</span> SYS<span style="color: #66cc66;">.</span>DBA_DATA_FILES <span style="color: #993333; font-weight: bold;">TO</span> nagios;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">ON</span> SYS<span style="color: #66cc66;">.</span>DBA_FREE_SPACE <span style="color: #993333; font-weight: bold;">TO</span> nagios;</span></pre></code>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4617832173310827563.post-56883737953884539422013-04-04T04:27:00.000-07:002013-06-26T00:04:04.998-07:00Puma and rails to auto start on Linux rc.local<code>su ubuntu -c 'source /etc/profile && cd /home/ubuntu/downloads/redmine-2.1/ && NEWRELIC_ENABLE=true rails s Puma -e production -p 8080 -d'</code>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4617832173310827563.post-43838841298592310922013-02-17T03:34:00.000-08:002013-06-26T00:04:04.989-07:00DBSNMP、SYSMAN密码修改重新配置EM<code>emca -config dbcontrol db</code>Unknownnoreply@blogger.com0