Tag: Unix

bash debug – log all executed commands

Screenshot of a Bash 3.1 session demonstrating...
Screenshot of a Bash 3.1 session demonstrating its particularities. Shows exporting a variable, alias, type, Bash’s kill, environment variables PS1, BASH_VERSION and SHELLOPTS, redirecting standard output and standard error and history expansion. A POSIX session is launched from a normal session. Finally, the POSIX session kills itself (since just “exit” would be too boring). (Photo credit: Wikipedia)

Whenever I am writing a script in perl or bash, I always wish that there
was some way to have all the commands logged or output to screen. I know
there is “set -x” option to have debugging enabled, but sometimes that
seems to be too much information and I dont really need all that. So, here
is something I found recently for bash to log all the executed commands.


This will echo/print all the commands on the stdout.


Enhanced by Zemanta

Monitor your system with sysusage.

First some information on sysusage:

Description :
SysUsage continuously monitor your systems informations and generate
periodical graph reports using rrdtool or javascript jqplot library.
All reports are shown throught a web interface.

SysUsage grabs all system activities using Sar and system commands allowing
you to keep tracks of your computer or server activity during his life.
It is a great help for performance analysis and resources management. The
threshold notification can alarm you when the system capabilities are
reached by sending SMTP messages or throught Nagios reports.

By default it will monitor all you need to know on your server activity, it
is written in Perl and should works on all Unix like plateforms. It doesn’t
require a Database system like MySQL or PostgreSQL but lie on rrdtool. In
addition you can embeded your own plugins written in any programing language.

Since release 5.0 SysUsage can be run from a centralized place where
collected statistics will be stored and where graphics will be rendered.
Unless other monitoring tools with lot of administration work, SysUsage is
design to have the lesspossible things to configure and a high level of admin
system knowledge. Each server can also be self monitored and you just have to
connect your browser to the web interface to know his health level.

SysUsage is design with simplicity in mind. I want all relevant statistics
from my servers within an intuitive web interface and without spending too
much time to configure it, if you know Nagios, you know what I mean. You will
especially like SysUsage for that.

And now for the installation:

sudo yum install sysusage sysusage-httpd

Once you have installed, you would need to enable the crontab to collect the data. And the sysusage-httpd is for the apache server configure to enable you to access http://localhost/sysusage

And you are done. It pretty good to see the overall system usage wrt to CPU, Disk and network.

Enhanced by Zemanta

bash – using the vi mode more effectively.

Vi blogging bundle
Vi blogging bundle (Photo credit: pedro mg)

You can first set the bash mode to vi. This will enable some vim like features to bash. So, add this to .bashrc :

set -o vi

Once, you have done that then its time to get more out of the vi mode. First, check some things and set some interesting stuff.

#Display all the bindings :
bind -P

#Copy the current bindings and use it in inputrc:
bind -p |grep -v self-insert>~/.inputrc

In the inputrc, so generated, all the functions and macros not bound are commented with “#” and you can set them to your choice as in other examples.

And here is a link that can get you started.



Enhanced by Zemanta