Stop using rediff

I have reasons to believe that rediff’s code quality has become really pathetic day by day. Delivery managers aren’t paying attention to the feedbacks. They keep putting bad code and pile up stacks of powerful servers to hide their bad programming practices!

Its high time Rediff ! WAKE UP!

After my initial post on a full quality analysis of rediff which can be found here I thought they would improve the quality but they went worse. Neither did they improve the quality but they left out loop holes for themselves for hackers to hack in.

The below screenshots would explain:

rediff_bad_coding Click to enlarge

rediff_code_horror Click to enlarge

I did email the product manager, but he asked me to wait and I’m still waiting!!

Picture 3 Click to enlarge.

So now I’ve decided that I will stop using Rediff, and go to other news sites which are good for my browser.

Kolkata …

Lot of things happened last week while I was in Kolkata. I was on a hunt to find a good office — Aparantly I didn’t get any good one. A few of them were good but the prices have hiked up a lot. Not worth the space!

If someone is reading this blog and can help me out, I would be most delighted. I need good office to accomodate 10 people for a software house.

It also happened that I attended the Kolkata Tweetup on Sunday. There were 16 people who had come in at Park Street Macdonalds. Wide range of age groups starting from school students to working professionals ( we didn’t have any sr. citizen!). It was fun to meet the mix bag of young and a little oldies like me!

Lot of discussions took place, Overall it was a light evening.

kolkata-tweetup

I formally announced the launch of @KolkataTech (http://www.KolkataTech.com) which is inspired by @PuneTech (http://www.PuneTech.com). Its very rare that some IT event or anything related to IT happens in Kolkata. There are many reasons to it. Barcamp took place after all the cities had 4-5 Barcamps already! Some of you would like to read my earlier post about why there wont be a Barcamp in Kolkata  (http://hussulinux.blogspot.com/2008/02/barcamp-kolkata-why-kolkata-still.html)

But the point is that the bongs are catching up and they are doing it good. It just needs some motivation.

I’m planning to have a good social and technical networking in Kolkata once my office is setup. Hoping to have some techie talks session, camps etc to guide out the new generation of kids

Besides just technical things, I am planning to venture out on Finance domain + Stock and Forex markets. Lets hope the Marwadi’s in Kol (who have lotsa black money convert it to white) have their portfolios done by my company!

All this and more coming up from September 2009. Stay tuned..

apachectl : Beauty of apache controller interface

Every tired to change apache config from a program and then wondered how to restart apache. Here’s a solution. APACHECTL.

When you do restart of apache, it will kill all the current sessions. But with apachectl you have option to restart the server gracefully without killing any previous sessions. This way all further connections will take up the new settings.

I’ve been doing this for a small little experiment, I wanted to add dynamic subdomains, So I had to edit the apache host httpd.conf files and we all know we have to restart the server after any config file is changed. So here’s an alternative. Change the config files from your PHP or CGI etc, and then call this apachectl.

The command is :  apachectl graceful

For Ubuntu and debian system the command would be : apache2ctl graceful

Here are some quick references from Apache’s official page:

start
Start the Apache httpd daemon. Gives an error if it is already running. This is equivalent to apachectl -k start.
stop
Stops the Apache httpd daemon. This is equivalent to apachectl -k stop.
restart
Restarts the Apache httpd daemon. If the daemon is not running, it is started. This command automatically checks the configuration files as in configtest before initiating the restart to make sure the daemon doesn’t die. This is equivalent to apachectl -k restart.
fullstatus
Displays a full status report from mod_status. For this to work, you need to have mod_status enabled on your server and a text-based browser such as lynx available on your system. The URL used to access the status report can be set by editing the STATUSURL variable in the script.
status
Displays a brief status report. Similar to the fullstatus option, except that the list of requests currently being served is omitted.
graceful
Gracefully restarts the Apache httpd daemon. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them. This command automatically checks the configuration files as in configtest before initiating the restart to make sure Apache doesn’t die. This is equivalent to apachectl -k graceful.
configtest
Run a configuration file syntax test. It parses the configuration files and either reports Syntax Ok or detailed information about the particular syntax error. This is equivalent to apachectl -t.

The following additional option is available, but deprecated.

startssl
This is equivalent to apachectl -k start -DS

Notes from China

I really enjoyed my recent trip to China. I would like to share with you some of my experiences.

My Flight was from Calcutta, India to Kunming, China. From Kunming a local flight to GuangZhou.

I really liked GuangZhou. Nice climate, nice young people! I was there to attend 105th International Import Export fair. Its not mykinda game of business altogether but I agreed to it thinking what’s the harm to explore.

I rather describe the entire visit in pictures.

c5 Canton Fair Ground

c3 Opening ceremony

c4 Fair Grounds

c2 Costs only USD 5000

c1 Area surrounding the fair

c6 Speaking on stage — software imports

c8 felicitation

c7 Pretty Girls dance show

shopp Shopping in GuangZhou

shp Fun!

From GuangZhou I went to HK and then back to Kunming. Overall it was a nice short trip and the fair was quite interesting!

SSH proxy – Running SSH over blocked ports, SSH on mobile phones, SSH over HTTP

Imagine yourself in a scenario where you’re a behind a firewall and cannot access the SSH, or you’re controlling your servers via your mobile. Here’s a quick way to manage your servers through HTTP via command line. You can fire scripts, run shell commands etc.

Be careful, it will not ask you any username/password and runs with username Apache/SYSTEM.

The script is tested over linux and windows servers!

ssh-over-http1

ssh-over-http2

All you need is an Apache server with PHP installed. Just create a PHP file and insert the following code.

Put in a comment if this really helped you!

//— BEGIN OF CODE—-

<html>
<head>
<title>HussuLinux SSH over HTTP…</title>
</head>
<body>
<form id=”form1″ name=”form1″ method=”post” action=””>
<label>Enter Command
<input type=”text” name=”cmd” />
</label>
<input type=”submit” name=”Submit” value=”Submit” />
</form>

Output :
<textarea cols=”100″ rows=”30″>
<?php
$cmd = $_POST[‘cmd’];
if ($cmd==””)
{
//Do Nothing!
}
else
{
echo htmlspecialchars((shell_exec($cmd)));
}
?>
</textarea>
</body>
</html>

//— END OF CODE—–

Webmethods running linux commands as a java service

Recently a friend asked me how in webmethods, she could fire linux specific utility tasks. She wanted to find out if the disk space is full on linux. This can be done very easily by the “df- kh” command. But how to invoke this through webmethods?

Solution: Follow the steps below.

Step 1: Create a Java Service with the following input and output

webmethods-java-service-1

Step 2: Paste in the following code:

//—- BEGIN OF CODE
//Author: Hussain Fakhruddin
//Date: 20090203
IDataCursor cursor = pipeline.getCursor();
//Return if no command is specified…
if (!cursor.first(“command”)) return;
String output = “”;
try {
String command = (String)cursor.getValue();
String line=””;

//Creating a Process Instance and executing the command..
Process p = Runtime.getRuntime().exec(command);

// Capturing the output.
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output = output + line + “\n”;
}
input.close();
}
catch (Exception err) {
// Do something on error… may be throw a ServiceException
}
// setting the outputMsg for whatever output the command has given.
cursor.insertAfter(“outputMsg”, output);

//—–END OF CODE————

webmethods-run-external-command-or-programs

Step 3: Run the program and pass the unix/linux command

Note: DO NOT use commands which are not exiting after giving an output. For example “tail -f” . This service is only for commands like “df -hk” or “cp file1 file2” or “pwd” or “ls -lrt“.

If you face some issues, do feel free to write back.

Webmethods to TIBCO Migration

I’ve been getting a lot of hits and requests to post something about Webmethod to Tibco migration. As discussed in many of my previous posts, Tibco is highly marketing is products and particularly asking organizations to migrate from WebMethods!  You should see the way Tibco sales guys talk! They are technically convincing!

SO lets try to discuss if its really a good decision to migrate from Webmethods to TIBCO

Reason

You must have a reason to migrate. Don’t migrate just because someone told you. Or you are getting good Tibco resource available. There are plenty of resources for Webmethods too.

You must migrate because you find something missing in WebMethods. Or something which takes a lot of time in Webmethods than Tibco.

You must migrate if supporting an application in Webmethods is more difficult than webmethods.

Problems & Strategy

So lets say you have found your big reason to actually migrate from Webmethods to TIBCO. So what are the next steps:

1. Study the architecture. There is a huge change from Hub and Spoke architecture to Bus architecture. Webmethods runs an integration server. You can run each packages / services in the single server. But Tibco is Bus Architecture. Each package/service will run as a separate BWEngine. That means you’ll end up having a lot of system level processes on the server.

2. There will be no centralised management. In webmethods, you can share a lot of common services and call them from inside. But in Tibco you need to include the utility services as part of your EAR. Please note, while running things from Tibco designer, this is not the case.

This results in usage of extra memory. Lets say you have a lot of common business services, Its absolutely impossible to include each one of them as a library in your final EAR. Hence people tend to deploy these libraries as a separate BWEngine. Again a bigger problem is to do interprocess communication. For this EMS is used. A typical example is the TIBCO CUF(Common Utility framework ). All this becomes too complex for something simple.

Tibco Administrator is again single point of management for all TIBCO BWEngines and its again a good one but not quite complex as WebMethods’ Admin panel.

What TIBCO doesn’t give you: The JMS doesn’t even have a web based EMS Queue viewer… (I plan to write it someday! Or Tibco Guys should pay me for that! !)

Tibco Admion also doesn’t give you statistics about how much CPU is consumed or how much memory is being used.

However there is a workaround for that by using Tibco HAWK. Again another product that you may have to buy.

Supporting

While supporting Tibco applications, one cannot debug it unless the code is taken from the repository or installed on your system.
You will have to manage your Tibco code through your own repository. Applying patches in Tibco is also not very matured as Webmethods.

My Choice

I would still be reluctant to migrate to TIBCO. Not because I know Webmethods More than I know TIBCO, but because I feel webmethods is quite a good product. Tibco is more of a hype(I’m sure Tibco guys will hate me for saying this). But facts are facts. I get more stuff working and in an easy way in webmethods than TIBCO!

Reader’s Choice:

I would request the readers to post their own comments.

Webmethods:How to Kill a Running Service from the Integration Server

Many of you have wondered how to kill a WebMethods service while its running on the Integration Server.

Its become a Pet Interview Question for many but the interviewer also expects one of the following facts which is not the most recommended method to kill a running service.

Here are some facts:

1. If you are running the service on debug mode, the service will get killed if you kill your developer.
2. If you are running the service on RUN mode, the service runs on the Integration Server and will not get killed.
3. If your client has activated the service but terminated the session, the service will still run on the IS.
4. If your webmethod service is hung, You will try to Reload the entire package. But this will NOT help.
5. You will also try to unload the package but this will NOT help too.

What you need to do is on a Thread Level. The idea is quite simple: Just get the list of all the current running threads and kill the service which you need.

I will try to explain this in a step by step manner. Developers please do try it out on your dev boxes as well.

Step 1:
Create a Flow service like this:

wm1

Step 2:
Lets create a Flow service which will get ALL running threads. This should take NO input but lets output a String containing all running threads on that Integration Server.

w2

Step 3:

Insert the following Java Code in your WebMethods Flow Service that you just created. The code is commented well enough.

//—BEGIN CODE—–
// Author: Hussain Fakhruddin (hussulinux@gmail.com)
// Date: 20090128
//Get the Current Thread
Thread currentThread = Thread.currentThread();
//Get all Thread Groups.
ThreadGroup rootThreadGroup = currentThread.getThreadGroup();
//Traverse to the Top Thread Level
while (rootThreadGroup.getParent() != null) {
rootThreadGroup  = rootThreadGroup.getParent();
}
//Getting all Threads
Thread [] threads = new Thread[1000];
int threadCount = rootThreadGroup.enumerate(threads, true);
String threadList = “”;
// Now traverse through all the Threads and use the ServerThread API from webmethods to get all the thread detail.
int i=0;
for (; i<threadCount ; ++i){
if (threads[i] instanceof com.wm.app.b2b.server.ServerThread) {
//Casting a raw thread into ServerThread type
com.wm.app.b2b.server.ServerThread serverThread = (com.wm.app.b2b.server.ServerThread) threads[i];
//Getting the service Name for which the thread belongs to
if (serverThread.getState().getService() != null){
threadList = threadList + serverThread.getState().toString() ;
java.util.Stack threadStack = (java.util.Stack) serverThread.getState().getCallStack();
for (Iterator iter=threadStack.iterator(); iter.hasNext();) {
Object threadObj = iter.next();
threadList = threadList + “\n ” + threadObj.getClass().getName();
threadList = threadList + “, ” + threadObj.toString();
}
}
}
}
IDataCursor cursor = pipeline.getCursor();
cursor.insertAfter(“threads”, threadList);
cursor.destroy();

//—–END OF CODE—–

Step 4: Now lets create another flow service “killThread” with the following inputs and outputs

wm3

Step 5: Now copy paste the following code. We’re going to traverse through the entire list and call the .interrupt() method to kill the process. Note: you need to provide FULL path of the service which you want to kill. You can get the full path from the webmethods admin panel (under package management).

//—BEGIN CODE—–
// Author: Hussain Fakhruddin(hussulinux@gmail.com)
// Date: 20090128
IDataCursor cursor = pipeline.getCursor ();
if (cursor.first (“serviceName”)) {
String serviceName = (String) cursor.getValue ();
Thread current = Thread.currentThread ();
ThreadGroup root = current.getThreadGroup ();
while (root.getParent () != null) {
root = root.getParent ();
}
Thread [] threads = new Thread [1000];
int count = root.enumerate (threads, true);
String sb = “Not Found”;
StringBuffer killedList = new StringBuffer ();
for (int i=0; i<count; i++) {
if (threads[i] instanceof com.wm.app.b2b.server.ServerThread) {
com.wm.app.b2b.server.ServerThread serverThread = (com.wm.app.b2b.server.ServerThread) threads[i];
if (serverThread.getState ().getService () != null) {
java.util.Stack stack = (java.util.Stack) serverThread.getState ().getCallStack ();
for (Iterator iter=stack.iterator (); iter.hasNext ();) {
Object obj = iter.next ();
String name = obj.toString ();
if (name.trim().equals (serviceName)) {
threads[i].interrupt ();
sb = “Interrupted”;
killedList.append (stack.toString ()).append (“\n”);
}
}
}
}
}
cursor.insertAfter (“status”, sb);
cursor.insertAfter (“killedList”, killedList.toString ());
cursor.destroy ();
}
//—–END OF CODE—–

That’s it folks! Save and run it.. Come back to me if you face problems..