Script to check Oracle remotely (nagios or whatever)

For all of you that are not the lucky owner of an Enterprise Manager license or you simply want to use nagios or another monitoring engine to get status and graphs of oracle, probably you’ll be using the “check_remote_oracle” plugin.

If you’re a scripter/developer maybe you’ll understand me when you open an script and see an COMPLETELY UNREADABLE code, with no functions, no indentation… etc
And then you’ll have to change anything stupid inside the script and then f**k it does not work!

This is the story of that script, I installed it, then I have to do some changes… and then I decided to rewrite it completely…
I’m not the best scripter of the world, but I know how to use functions, indentation and that useless shit :-P

You can read the whole documentation on its wiki page.

Enjoy!

PS: updated the instructions, I forgot the information about the unprivileged user for connecting to Oracle instance.
PS2: Updated again, new control!

Openvpn in the TP-LINK WR841N[D]

Hi folks,
Here comes a post to improve that great router from TP-LINK.
Of course, I suppose you’re running openwrt on it to use the whole power of it.
The 1st I saw was that you have available a plenty set of packages… but you don’t have enough ROM to install them :-P
Inspecting a bit, I saw that under /tmp you have a “lot” of free space! (about 14MB), that will be enough to allow run openvpn without problems.
The main problem? Its a ramdisk, so each boot, everything there disappears.
What I’ve done? Install the basics with opkg and wget on boot the rest ;-)

UPDATED SCRIPT!

Continue reading “Openvpn in the TP-LINK WR841N[D]”

Parallel rsync’ing a huge directory tree

Some days ago I was on the chance to transfer a huge directory.

Huge means ~50TB with +1million files and a deep of only 6 folders under the parent one.
As I must do that kind of transfer more than 10 times with the same amount of folders… I decided to implement some kind of parallel function which launch parallel rsync’s at a given deep of my choose.

The ressult was that “pure bash” little script (the only dependency is “screen”)… You’ll notice that the main function “sync_this()” will run alone in your script only changing 2 or 3 variables ;-)
Continue reading “Parallel rsync’ing a huge directory tree”

Mysql Database creation script

Two days ago one of my client dev’s requested me to be able to create db’s on their MySQL instance.
Of course, I won’t give him the “GRANT GRANT WITH GRANT OPTION” :-P, in that case I will simply give him root password :-P
As i didn’t find anything that solves my problem over Internet, I just did mine, as allways..
Here’s he result.

Prereqs:

  • Create a Mysql user with the following grants:
    [cc lang=”bash”]
    GRANT CREATE, RELOAD, SHOW DATABASES, CREATE USER ON *.* TO ‘database_creator’@’localhost’ IDENTIFIED BY ‘YOUR_PASSWORD’ ;
    GRANT INSERT ON `mysql`.`db` TO ‘database_creator’@’localhost’ ;
    [/cc]
  • That will allow us to create databases, users, make some checks and reload privs, while we don’t create a new “root”…

You can download the script code from the wiki, also you’ll find additional information there.

Strange feature in bash script

Today, while programming (or reprogramming) some parts of one script, I’ve noticed a strange thing.
First, the two scripts.

The working one:
[cc lang=”bash”]
#!/bin/bash
let x=0
echo -e “a\nb\nc\nd” > auxfile
while read LINE
do
[[ “${LINE}” =~ ^(a|c|d)$ ]] && AUX[$x]=${BASH_REMATCH[1]} && let x++
done < auxfile echo ${AUX[@]} [/cc] And the not working (for my purpose): [cc lang="bash"] #!/bin/bash let x=0 echo -e "a\nb\nc\nd" | while read LINE do [[ "${LINE}" =~ ^(a|c|d)$ ]] && AUX[$x]=${BASH_REMATCH[1]} && let x++ done echo ${AUX[@]} [/cc] The only difference between both is just the piped while.
Someone can explain why seems to be a “reset vars” at the end of the piped while?