Hi Tim,
Thanks for your input. I have made several changes to our documentation
from your comments, especially regarding the text referring to the Ant
build sensor (oops).
Coincidentally, we have also devised a solution to supporting bash with
our CLI sensor. Our appoach incorporates an entry into the .bash_logout
file, that uses the HISTTIMEFORMAT option to bash's history mechanism,
combined with a sed statement to create a UTC timestamp. Below is a
copy extracted from the .bash_logout file.
Thanks again for your input Tim. If you would like to read the Jira
issue documenting this addition, here is the URL:
http://hackydev.ics.hawaii.edu:8080/browse/HACK-298
Best regards,
Mike
**********************************************************
*echo 'Collecting and sending CLI Sensor data from Bash...'
# Format the history so that it prints the timestamp of the command in
UTC format.
HISTTIMEFORMAT = %s
export HISTTIMEFORMAT
# Copy the unformatted history into a file.
history > unformatted.history.hacky.cli
# Process that file so that it is formatted in the following manner
(i.e. make consistent with Cli sensor input):
# Timestamp in UTC (preceded by #+)
# Command
sed 's| *\([0-9]*\) *\([0-9]*\) *|#+\2\n|' unformatted.history.hacky.cli
> history.hacky.cli
# Add the machine name to a file.
uname -n > uname.hacky.cli
# Combine the machine name file at the end of the formatted history file
and store them
# in a data file to be sent to the Hackystat server.
cat uname.hacky.cli history.hacky.cli > data.hacky.cli
# Send the data to the Hackystat server.
java -cp
$HOME/.hackystat/cli/sensorshell.jar:$HOME/.hackystat/cli/sensor.cli.jar
org.hackystat.app.cli.sensor.CliSensor data.hacky.cli
# Clean up files and history (to prevent duplicate sending of data).
rm -f *.hacky.cli
history -c
echo 'Sending CLI Sensor data...done.'
********************************************************
Philip Johnson wrote:
Thanks, Tim, and excellent timing: Mike is working on the docbook for
this sensor today!
Mike, please incorporate.
Cheers,
Philip
--On Monday, October 10, 2005 6:19 PM -0700 Tim Shadel
<[EMAIL PROTECTED]> wrote:
I got the CLI sensor working on bash on my Mac (OSX 10.4) today. You
guys probably have already done this, but here's what I did using the
6.8.1007 CLI sensor:
1. Install darwin ports (more than one command, see URL) [1]
2. Install the bash port [2]
% sudo port install bash
3. Symlink /bin/bash to /opt/local/bin/bash
% sudo mv /bin/bash /bin/bash-orig
% sudo ln -s /opt/local/bin/bash /bin/bash
4. Check version
% /bin/bash --version
GNU bash, version 3.00.16(1)-release (powerpc-apple-darwin8.2.0)
Copyright (C) 2004 Free Software Foundation, Inc.
5. Change .logout to .bash_logout
% mv ~/.logout ~/.bash_logout
6. Change history -S to a few other commands. Force a history file
write. Add the '+' sign to all timestamps (I'm assuming that the '+'
means something like 'after the epoch', so for all practical purposes,
everything will be '+'). I found the file format from [3].
% vi ~/.bash_logout
#history -S history.hacky.cli
history -w
cat $HISTFILE | sed -e "s/^#\([1-9]\)/#+\1/" > history.hacky.cli
7. Symlink .logout so hackyInstaller still works (I'm really hoping
that it won't overwrite my changes -- just that it'll still recognize
that the CLI sensor is installed. If not, then perhaps these changes
should be incorporated into hackyInstaller.
% ln -s ~/.bash_logout ~/.logout
8. Test CLI sensor according to docs. 66 CLI data entries received
for today. Groovy. :-)
Issues
----------
A. I found a cut-and-paste error in the appendix for the CLI sensor.
In the section, "A.5.2.4. Configure and install the Unix CLI sensor"
the text refers to the Ant build sensor. No biggie.
B. Is the '+' hack really necessary? I don't know how sensitive the
hackyCLI parser is to the file format. If it could handle files with
or without the '+' then we can get rid of this hack.
C. The 'history -w' may not really be the best command to use; just
the simplest. If you, like me, often have multiple shells open, then
this may or may not work. I haven't thought through all the
scenarios, but I did run across this blog entry [4] that discusses the
history file across multiple shells.
Let me know if this works for anyone else. I'm happy to be using the
CLI with Bash. :-) Thanks for finding the time feature in bash 3.0!
--Tim
[1] http://darwinports.com/
[2] http://bash.darwinports.com/
[3]
https://www.redhat.com/archives/taroon-list/2004-September/msg00353.html
[4] http://tech.rufy.com/entry/72
On 9/9/05, Mike Paulding <[EMAIL PROTECTED]> wrote:
Hey Tim,
Thanks. Yeah, we found that the hard way as well and it will certainly
be in the docs.
Best regards,
Mike
Tim Shadel wrote:
> I was looking to get this setup on my Mac, but it appears that the
> HISTTIMEFORMAT is a bash 3.0+ feature and my Mac OS X 10.4 only has
> 2.0 by default.
>
> http://www.freelinuxcdrom.com/LDP/LDP/abs/html/histcommands.html
>
> ~ tim$ bash --version
> GNU bash, version 2.05b.0(1)-release (powerpc-apple-darwin8.0)
> Copyright (C) 2002 Free Software Foundation, Inc.
>
> I guess a port is available here, http://bash.darwinports.com/, but I
> haven't tried that yet. Anyway, something to consider for the docs.
>
> Thanks,
>
> Tim
>
> On 8/20/05, Mike Paulding <[EMAIL PROTECTED]> wrote:
>
>
>> Excellent news, Cedric. That adds a whole new user base for our
CLI sensor.
>>
>> I will work on updating the documentation.
>>
>> Thanks,
>> Mike
>>
>>
>> (Cedric) Qin ZHANG wrote:
>>
>>
>>
>>> Hi,
>>>
>>> I was just reading bash documentation, and realized that our
command
>>> line invocation sensor can be used with BASH.
>>>
>>> The problem we encountered was that bash history does not contain a
>>> time stamp field. It turns out that there is a bash shell variable
>>> that controls the time stamp setting. You can try to set
>>> HISTTIMEFORMAT='%H:%M:%S '
>>> and see what happens when you type 'history'.
>>>
>>> The format string is documented in <time.h> strftime() function. It
>>> can be changed to match csh time stamp format. So what we actually
>>> need is just some extra user documentation for our sensor to
work with
>>> bash.
>>>
>>> Cheers,
>>>
>>> Cedric
>>>
>>>
>>>
>
>
>