Below you will find pages that utilize the taxonomy term “Bash”
Dump all (most?) JMX Beans via Jolokia using just the shell and a bit of json formatting
It seems jolokia doesn’t support dumping everything with just one command.
So here’s a really hacky quick and dirty way to get all information jolokia can access:
for name in $(curl --silent http://dwtest:10002/search/*:* | python -m json.tool | grep '"value":' -A9999 | tail -n +2 | head -n -2 | sed 's/ /%20/g' | cut -d'"' -f2);
do curl --silent "http://dwtest:10002/read/$name" | python -m json.tool;
done
Once you’ve gotten this far, piping the information into a file or another tool is trivial.
Executing shell commands from groovy
pre { border: 1px solid #EEE; }
Sometimes you want to run a shell command generated from groovy or just want to achieve something that’s faster/simpler in the shell in comparison to doing it with groovy. One such case would be to get the number of git commits of a repo. The command for this is fairly simple:
$ git log --oneline | wc -l
179
Running shell commands from groovy is really easy too. Make a list and call ’execute()’ on it - how awesome is that?
Using awk to remove lines from a file
A little goodie I’m writing up here to document for my own future reference.
Objective: Remove all lines matching a certrain pattern from all files in a directory structure. The pattern is in the form of “part1.
First try: grep and sed, unfortunately that leaves me with blank lines where the matching content was and I want that line removed completely. Apparently sed can’t do that.
Second try: use awk with regexes. It took me a while and I wanted to use ’next’ on matching lines but that didn’t seem to work so I ended up printing the entire line if the regex didn’t match. Here goes:
Simple python script to access jmx via jolokia
I’ve never been much of a python guy. Now there’s this production environment where we’ve got a few basic things like bash, ruby (since we’re using puppet) and python. Our Java based software has a nice JMX interface with a bunch of lifesavers in it and each JVM has the jolokia agent running (http/json access to jmx) so we can access this goodness fairly easily from scripts and/or the shell. So far what we’d be doing would be something like this:
Quality loss when saving as JPEG
So recently an article was linked on reddit about a bunch of photography myths. Number 7, called “Saving a JPEG multiple times degrades quality” which was apparently proven to be wrong disturbed me most and so I did a quick test on my own.
Further below are Three images. The Original, the one saved 30 times and an XOR of the first Two showing the differences. If you toggle between the first two you can see quite a difference in the color on the car and several other details. Running any more tests at lower than 100% quality is pretty much a waste of time once you see these results.
Tanuki Software's Java Service Wrapper and your Environment Variables
This post has been updated
Here’s an evil little gotcha I ran into when using the Tanuki Software Java Service Wrapper to run our company bamboo server. But first you need to know a little bit of context:
We had our bamboo agent running as root for a long time and about two months ago I changed that. I created a bamboo user and installed multiple agents. Each of these into its own folder along the lines of /home/bamboo/bamboo/java-agent-1
etc. Now in each of these is a wrapper script under bin/bamboo-agent.sh
. Reading up a bit on the wrapper I found out I can change the script and set the variable RUN_AS_USER=bamboo
and then simply create a symlink from /etc/init.d/java-agent-1
to /home/bamboo/bamboo/java-agent-1/bin/bamboo-agent.sh
and then start/stop the service just like any other normal unix service.
Tanuki Software's Java Service Wrapper and your Environment Variables
This post has been updated
Here’s an evil little gotcha I ran into when using the Tanuki Software Java Service Wrapper to run our company bamboo server. But first you need to know a little bit of context:
We had our bamboo agent running as root for a long time and about two months ago I changed that. I created a bamboo user and installed multiple agents. Each of these into its own folder along the lines of /home/bamboo/bamboo/java-agent-1
etc. Now in each of these is a wrapper script under bin/bamboo-agent.sh
. Reading up a bit on the wrapper I found out I can change the script and set the variable RUN_AS_USER=bamboo
and then simply create a symlink from /etc/init.d/java-agent-1
to /home/bamboo/bamboo/java-agent-1/bin/bamboo-agent.sh
and then start/stop the service just like any other normal unix service.
The simplest way to create pdf's from images
There’s probably no simpler way to create a pdf from images. Behold:
convert \*.jpg output.pdf
That’s all folks!
The simplest way to create pdf's from images
There’s probably no simpler way to create a pdf from images. Behold:
convert \*.jpg output.pdf
That’s all folks!