Wednesday, July 21, 2010

How google would generate new ideas

"An idea can change the world". But to have such an idea, you may need to pay your life. If you go with mathematical real analysis concept, the equation would transform to "one whole life would change the world".
So any inventor could have dream to get an idea, which could change the world. So, I could say, one idea is the most valuable stuff in the world. It may costs your life and will save lots of lives.
Google, the new generation platform for internet world. Google, started as a search engine and then become internet giant. We all will wonder when they come up with new products and idea. I always wonder, who pumps these much of ideas to them.

There might be lot many researches went on to trap the Google's idea treasure. Many assumptions or perceptions brought out by those researchers.

Today, I have started my day with a new idea. I discussed it with my friend. My friend asked me to search it on Google.
I compile the search string on Google, and before hitting the enter key I paused my self from doing so.

You know why ?

I got a spark, that why should I submit my new idea to Google corporation, though you are not intended to do so ?
Yes, if you are searching a new string, there can be mechanism to store it in Google servers to verify for a new idea to implement. I mean, if you search with new search string for finding similar items presented any where in the world. And when you found no similar idea available in internet, you got the trigger to start the research on the perception that, you are the only man knowing about it.
But is it really true ?
I believe there is another invisible, but more powerful man than you, seeing everything, obviously i didn't mean the God, behind the screen. Yes!!! Google eyes should closely watching it.

Their search engine could be the real treasure for their ideas, that change the world. Their algorithm might be like this.
1- Get the search string.
2- Check for unique or no search result.
3- Google will have a database for interested domain
4- Check for the string match with any of the data kept in Google interested domain.
5- If the new string matches with the Google's interest, take it to expert desk for further analysis.
6- Hence a new idea could be generated

The all above are my guess. I don't have any evidence for the above thoughts.

Wednesday, April 21, 2010

Memory leak management while using apache libraries



   I had faced a memory leak  issue when using apache APIs to create sockets. My application designs to monitor some set of ports continuously in a frequent time span. Application internally uses APIs from apache library to create memory pool, to create sockets, to shutdown socket etc..
First, it will create a pool of memory by using apr_pool_create function as below .
apr_pool_create(&newPool, NULL)

And then it makes a socket address with apr_sockaddr_info_get call as below.
//making socket address
apr_sockaddr_info_get(&remote_sa, dest, APR_UNSPEC,
(apr_uint16_t)portNum, 0, pool)

Then it creates a Socket as below.
apr_socket_create(&sock, remote_sa->family,
SOCK_STREAM, pool))
After creating socket, it tries binds to the port.
apr_bind(sock, remote_sa)
Then connect to the port and started listening for a connection request.
apr_connect(sock, remote_sa)

And then below functions are used for other usual socket activities.
apr_sleep(10000000);
apr_recv(sock, dataRecv, &length);

After the socket's tasks finished, we used to shutdown the socket and close for further actions.
apr_shutdown(sock, APR_SHUTDOWN_WRITE)
apr_socket_close(sock)

These all above code works in a while(1) loop. Creation of memory pool is a one time activity. Remaining tasks(from socket creation to socket closing) are continuously looped until application killed.
This application will be working as a process, which always present in active memory to listen the specified ports. I have received an issue from one of our customer saying that, he is observing a memory leak while running this process. I took this task and me too observed the same issue in my development server.
In general, reproducing a problem is the 60% of the solution. But, in memory leak problem, it will be only 40%. You may observe a leak, but you may not come to a conclusion that, this leak is happened by this reason.
I did a regular memory leak check up in the big code base. I searched from malloc, realloc, calloc etc. And I searched for any macros defined against malloc.

Nothing!!! No memory allocation calls used in the code. Then my spy glass went the the pool creation API (apr_pool_create). I observed that Memory pool is created but not freed any where. I have Apache API to delete the pool. But, if I delete the pool, application will be killed immediately. I wanted to retain my application in active memory unless, user forcefully killed him.

So I cant use apr_pool_destroy to release the memory pool. Then i visited Apache Portability Runtime library for the API reference . I found there is another call apr_pool_clear(pool) to clear the memory location. GOD GRACE. I did that !!!.
My issue is resolved. So whenever a new socket finished his tasks, he will clear the pool and return the handler to begin. And then new socket will allocate the memory from free pool. Hence no memory leak !!!


Tuesday, February 9, 2010

PHP Source code for comment box in unicode language(like malayalam, tamil and arabic)

        A comment box is a must have feature in many of the web based aplications. Users should able to save their comments on their own language. Many of the news papers are allowing their visitors to express their views about the articles/news published. Comment enabled web pages will increase user engagement, hence more income from advertisement venders can expect.
Making a comment box is nothing if you are using PHP and MySQL in most scenario.

1. Declare a Rich text box using HTML Tags.
2. On submit, collect the inserted values and save it to mySQL database, thats it.

Though, saving your text in mySQL database will be difficult if you are playing with Unicode charactors.  I know many of my friends are complaining about that. They were tried to save malayalam unicode characters and, while retrieving the saved text they got a bunch of question marks. 
Eg:
They saved " ചേന്ദമംഗല്ലൂര്‍ നല്ലൊരു നാടാണല്ലൊ ... ഹി ഹി ഹി "
They recieved " ????????????????????????????  ??? "
Its because, unicode charaters are a unique special numercial codes for different languages. MySQL may not decode it to proper language representation unless you are explicity told to him. I have a solution for this problem.
1. Use SET NAMES 'utf8' before database transaction started.
2. Convert your table collation settings to  'utf8_general_ci'

visit my old post for more details about this .
http://techcmr.blogspot.com/2009/07/store-and-retrieve-unicode-characters.html

Hope you understand the technique behind the unicode operations.  Now we can move into the coding part of the comment box. I have to PHP funcitons, which you can use for making a comment box in your web based aplication.

   1:  function commentbox($dcName,$docId,$act_page,$SecurePath="../../lib/",$security="secured")


   2:  {


   3:   


   4:      echo("<form name='"."inputfrm"."' enctype='"."multipart/form-data"."' method='"."post"."' action='".$act_page."?mod=".$security. "' onSubmit='"."return ValidateForm()"."'>");


   5:      echo("<fieldset>");


   6:      


   7:      echo("<textarea name='"."ta"."' rows='"."10"."' cols='"."50"."'></textarea>");


   8:      echo("<br>");


   9:      echo("Doc ID:"); 


  10:      echo("<input name='"."docId"."' type='"."text"."' value='".$docId."' size='"."5"."'  readonly='"."true"."'>");


  11:      echo("<br><br>");


  12:      echo("Name &nbsp;:"); 


  13:      echo("<input name='"."txtName"."' type='"."text"."' size='"."25"."'>");


  14:      echo("<font face='"."Verdana, Arial, Helvetica, sans-serif"."'>* (Mandatory)</font>");


  15:      echo("<br><br>");


  16:      echo("Email &nbsp;: ");


  17:      echo("<input name='"."txtEmail"."' type='"."text"."' size='"."50"."'>");


  18:   


  19:      if($security=="secured")


  20:      {


  21:          


  22:          echo("<table width='"."100%"."' border='"."0"."' cellspacing='"."0"."' cellpadding='"."0"."'><tr>");


  23:          echo("<td width='"."10%"."'>");


  24:          echo("<td width='"."80%"."'>");


  25:          //pass a session id to the query string of the script to prevent ie caching


  26:          echo("<br>");


  27:          echo("<img src='".$SecurePath."securimage_show.php?sid=".md5(uniqid(time()))."'><br/>");


  28:   


  29:  //        echo("<img src='".$SecurePath."securimage_show.php><br />");


  30:          echo("<font color='"."#ff0000"."'>");


  31:          echo("Enter the string displayed above<br>");


  32:          echo("</font>");


  33:          echo("<input type='"."text"."' name='"."securityCode"."' /><br />");


  34:          echo("</td>");


  35:          


  36:          echo("<td width='"."10%"."'>");


  37:          echo("</tr></table>");


  38:      }


  39:   


  40:      echo("</p>");


  41:      echo("<p align='"."right"."'><input type='"."submit"."' value='"."Save Comment"."' /></p>");


  42:      echo("</fieldset>");


  43:      echo("</form>");


  44:  }




function insertComment($docName,$DocId,$uText,$Uname,$TxtEmail,$ipAdr=0)
{
include 'connect.php';
$pageURL=curPageURL();
// echo($pageURL);
// $ipAdr ='93.174.94.53';
$BlockedIps=IsBlockedIP($ipAdr);
if($BlockedIps>0)
{
$isSuspects=1;
}
else
{
$isSuspects=0;
}
$aproved=0;
$time = time(now);
$phptime=date('Y-m-d H:i:s', $time);
@mysql_query("SET NAMES 'utf8'",$id); /// Its very inportant to display or insert unicode characters in db
$unicodeText = preg_replace('#\r?\n#', '<br />', $uText);
$cQryPart="insert into document (docName, DocID, Comments, aproved, u_name, email,CDate,isSuspects,extra,extra2) values ";
$cQry=$cQryPart."('".$docName."',".$DocId.",'".$unicodeText."',".$aproved.",'".$Uname."','".$TxtEmail."','".$phptime."','".$isSuspects."','".$ipAdr."','".$pageURL."')" ;
// echo($cQry);
$cresult = @mysql_query($cQry,$id) or
die("Unable to Execute the query");

mysql_close($id);
}

Friday, October 30, 2009

System management Homepage features list



Below are the supported feature list of OpenVMS System  Management Homepage (SMH).

Here I am using traps for indicating the SNMP traps(events). One trap is kind of message sending from SNMP agents to any SNMP trap receiver tools.

·         Storage

1.      Smart Array 6400 Controller

2.      DVD/USB Controller information

3.      SCSI Controller Information

4.      Smart Array p400

5.      SAS HBA

    1. SAS Address
    2. SAS Model
    3. Physical disk Model
    4. Physical disk Status
    5. Physical disk Capacity
    6. No traps for status change
    7. Traps from disk removal or insertion

6.      Fiber channel controller (FGA)

    1. World Wide Port Name
    2. Model

7.      Smart array traps

    1. Status change
    2. Battery failure traps
    3. Spare status traps
    4. Physical drive status

8.      Disk information

·         Model

·         Status

·         Capacity

·         Space used

·         Disk threshold monitoring

·         Traps for status change and removal/add

·         Network Controller information

1.      Model

2.      Port information

3.      Status

4.      Receive Statistics & Transmit Statistics

5.      IP Address

6.       Physical Address

7.       Interface Information

·         System Environment

1.      Power Sensors

a.       Power status

b.      Traps for status change

2.      Power On Messages

3.      Cooling and Temperature

a.       Traps for temperature exceeds from system thresholds

b.      Fan status information

c.       Fan status change traps

·         System Board

1.      Number of processors

2.      Processor status

3.      Processor models

4.      Processor threshold monitoring

5.      No traps for processor

·         System Resources

1.      System resources information

2.      Memory utilization and threshold information

3.      Traps for thresholds exceeding and falling

·         System Summary

·         Cluster Monitoring

o       Cluster add and remove traps

 

If you are much eager to see the sample screens of SMH,  please scroll down


OK, Now you can ask any question regarding SMH. Its my pleasure to answer !!!

Monday, October 19, 2009

Multiple Extension problem in OpenVMS

OpenVMS, the veteran Operating system. Still rules many territories in the tech world. Most of the Stock exchanges in world is under this veteran OS. Many Railway corporations are in his influence still. Indian Railway, the world biggest railway system is with him last few decades. Lots of process control systems are served by OpenVMS server. Lots of Steel plants are saved their life with this grandpa.
Oh !!!
Again I started story telling.
Yes, I know our problem is how to handle multiple extensions in OpenVMS.
For Example,
If you have file named ,test.php.en;1
  Don't scared about the ‘;’ and ‘1’ after the file name. Its VMS style of file handling. ‘;1’ tells you that, you are using first version of the file named test.php.en. If you modify the test.php.en, then new version will be created. then its name will be test.php.en;2.
This is the way which VMS helps his users to trace back. The maximum number of VMS file version will be 32767 !!!
Oooops !!!.
You can modify your file more than 30000 and still revert back to first version.
OK, OK.
If you have a file named test.php.en and you wanted to open it.
what you will do?
you will list the files by entering
$ dir
then list of the files will be listed as below:

Directory ALET$DKA100:[SYS0.SYSCOMMON.HP.HPSMH]
SMH$SPECIFIC.SAVE;1 SMH$START.COM;1     SMH$STOP.COM;1      SMH$STOP_SNMPAGENTS.COM;1
TEST^.PHP.EN;2      TEST^.PHP.EN;1

 
This name may lead you to a confusion. one extra ‘^’ symbol added with your file name. And if you type the file name as TEST^.PHP.EN; to open the file, Obviously system will not open the file for you.
Its because VMS handles multiple extensions as a special case.
 
This problem will annoy you many places. When you wanted to check the differences between TEST^.PHP.EN;1 and TEST^.PHP.EN;2 , you will get an error message.
 
$ diff TEST^.PHP.EN;2  TEST^.PHP.EN;1

“%DCL-W-PARMDEL, invalid parameter delimiter - check use of special characters  \^\ “

 
So, our problem is defined now !!! .
We need to use the multiple extension files smoothly.
The resolution also very smooth.just declare below command at your telnet/terminal emulator window. That’s it.
 
$ set proces/parse_style=extended
Now everything works fine. you can use any multiple doted file, as usual.
Ask me, If you have any more questions
 
 

Tuesday, October 13, 2009

SMH – System Management Home Page

Availability of proper Manageability solutions is the essential requirement to sell computer servers. Though your server solutions are robust and high available or offers unique features to the customers, lack of server management software may lead you to reduced sales. Since rarely customers think of appointing an expert to manage your server. But, they could buy a moderate server with enough tools available for managing it.

Hewlett-Packard, the king of the server making business(I didn’t forget IBM and DELL), have variety of server solutions. HP-UX is the most famous server Operating system from HP. There are lot many articles available about HP-UX. I like to pick the less rubbed ball from the pot.

OpenVMS, Most aged Operating system in the server world. He is 32 year old now. Still runs 100Km per hour on the thread-mill and takes 200 kg dumbbells on each hands. When he was with Digitals hand, he was less explored muscle man. Now with hp, he used to attend international weight lift championship.

Oh!!!

I am going out of the play ground. We are talking about OpenVMS operating system. Earlier this OS was available only on VAX and Alpha architecture. Last few years its available in Intel’s Itanium processor. I would say, from my experience, its a real robust OS. If you wanted to automate your manufacturing factory, give that job to him and go to bed. You don’t need need to have a night mare about the server failure.

There are lots of free tools available for managing OpenVMS servers. System Management Home Page(predecessor of Insight management Agents) is one among from that. Its SNMP based system hardware monitoring and diagnosing software. It has Web interface, so you can see your server internals from remote Desktop.

SMH offers below features

1. Single place for seeing system components status. Right now it has four statuses as OK, Degraded, Failed and unknown.

2. Displaying information about Network interface cards.

3. Displaying information regarding different storage controllers. Say…

- Smart Array controllers
- SAS Controllers
- FGA

4. Processor information including model, speed, etc. And you can set thresholds for usage. And SNMP traps will be generated if thresholds exceeds

5. Hard disk information including space used . Its is possible to set the thresholds for space usage. And SNMP traps will be generated if thresholds exceeds

6. System board information.

7. Power related information

8. Cooling and temperature information

9. Operating system related information.

SMH designed to collect information from SNMP. So SMH installation will also install number SNMP agents in the server and one user has additional facility to read information directly from these SNMP agents. Apache is the web server using to host the web pages.

Let me conclude my briefing now. Its my pleasure to answer your queries regarding SMH or OpenVMS.

Sunday, August 9, 2009

Start and Stop CPU in OpenVMS

Yes, Its not a dream!!! .
You can start or stop a particular Processor in multiprocessor server.If you don't want to involve all of the available processors for the current tasks running in the system, just stop the unwanted CPU. Then server will remove the stopped CPU from active CPU database. This feature will help an organization to reduce much of the power conception by CPU usage.
Currently this feature available only on OpenVMS Operating system running on VAX/Alpha or I64 machines. below are the commands to manage the CPUS.

1.
$ show cpu/full

2.$ stop/cpu 2 // this command will stop a CPU of id 2. This id can be see from executing 'show cpu/full command'

3.
$ start/cpu 2 // This command will start the stopped CPU of id 2.

More details :

The STOP/CPU command removes a secondary processor from the active set in an OpenVMS multiprocessing system. If the secondary processor is not executing a process when the STOP/CPU command is issued, it enters the STOPPED state. If the secondary is executing a process at the time, it continues to execute the current process until it attempts to schedule another process. When this occurs, the secondary enters the STOPPED state.
The OpenVMS operating system subjects a processor to a set of checks when it is the object of a STOP/CPU command. As a result, you may not be permitted to stop certain processors that are vital to the functioning of the system. In these cases, there is usually a process in the system that can execute only on the processor you intend to stop. You can determine this by issuing a SHOW CPU/FULL command. In unusual circumstances, you can bypass the checking mechanism by using the /OVERRIDE_CHECKS qualifier in the command.
The STOP/CPU command has no effect if its object processor is already in the STOPPED state when it is issued.

Examples :


$ stop/cpu 2

//Will stop the CPU 2 and State of the CPU will be shown as STOPPED. See the out for the below command. The CPU 2 states is in STOPPED now. All the running CPUs will be in RUN state

$ show cpu/full

System: , HP rx4640 (1.30GHz/3.0MB)

SMP execlet = 3 : Enabled : Streamlined.
Config tree = Version 6
Primary CPU = 0
HWRPB CPUs = 4
Page Size = 8192
Revision Code =
Serial Number = USE44136MR
Default CPU Capabilities:
System: QUORUM RUN
Default Process Capabilities:
System: QUORUM RUN

CPU 0 State: RUN CPUDB: 89020000 Handle: 00005D70
Owner: 000004C8 Current: 000004C8 Partition 0 ()
ChgCnt: 1 State: Present, Primary, Reassignable
Process: SYSTEM PID: 2440042E
Capabilities:
System: PRIMARY QUORUM RUN RAD0
Slot Context: 92B95000
CPU - State..........: RC, PA, PP, CV, PV, PMV, PL
Type...........: Itanium Major = 31, Minor = 1
Speed..........: 1300 Mhz
LID............: 00000000
Variation......: IEEE FP, Primary Eligible
Serial Number..: e52e8e9c01b90000
Revision.......:
Halt Request...: 0
Software Comp..: 5.0
PALCODE - Revision Code..: 1.1
Compatibility..: 0
Max Shared CPUs: 0
Bindings: * None *
Fastpath:
PKD0
PKC0
PEA0
Features:
Autostart - Enabled.
Fastpath - Selection enabled as Preferred CPU.

CPU 1 State: STOPPED CPUDB: 8917AF00 Handle: 00005E80
Owner: 000004C8 Current: 000004C8 Partition 0 ()
ChgCnt: 2 State: Present, In-Console, Reassignable
Process: * None *
Capabilities:
System: QUORUM RAD0
Slot Context: 92B96000
CPU - State..........: BIP, PA, PP, CV, PV, PMV, PL
Type...........: Itanium Major = 31, Minor = 1
Speed..........: 1300 Mhz
LID............: 01000000
Variation......: IEEE FP
Serial Number..: d566f80703b90100
Revision.......:
Halt Request...: 4
Software Comp..: 5.0
PALCODE - Revision Code..: 1.1
Compatibility..: 0
Max Shared CPUs: 0
Bindings: * None *
Fastpath: * None *
Features:
Autostart - Enabled.
Fastpath - Selection enabled as Preferred CPU.

CPU 2 State: STOPPED CPUDB: 8917CD00 Handle: 00005F90
Owner: 000004C8 Current: 000004C8 Partition 0 ()
ChgCnt: 2 State: Present, In-Console, Reassignable
Process: * None *
Capabilities:
System: QUORUM RAD0
Slot Context: 92B97000
CPU - State..........: BIP, PA, PP, CV, PV, PMV, PL
Type...........: Itanium Major = 31, Minor = 1
Speed..........: 1300 Mhz
LID............: 02000000
Variation......: IEEE FP
Serial Number..: a11db90f8ddd0000
Revision.......:
Halt Request...: 4
Software Comp..: 5.0
PALCODE - Revision Code..: 1.1
Compatibility..: 0
Max Shared CPUs: 0
Bindings: * None *
Fastpath: * None *
Features:
Autostart - Enabled.
Fastpath - Selection enabled as Preferred CPU.

CPU 3 State: RUN CPUDB: 8917EC80 Handle: 000060A0
Owner: 000004C8 Current: 000004C8 Partition 0 (
)
ChgCnt: 1 State: Present, Reassignable
Process: * None *
Capabilities:
System: QUORUM RUN RAD0
Slot Context: 92B98000
CPU - State..........: RC, PA, PP, CV, PV, PMV, PL
Type...........: Itanium Major = 31, Minor = 1
Speed..........: 1300 Mhz
LID............: 03000000
Variation......: IEEE FP
Serial Number..: 87eae30f7f950300
Revision.......:
Halt Request...: 0
Software Comp..: 5.0
PALCODE - Revision Code..: 1.1
Compatibility..: 0
Max Shared CPUs: 0
Bindings: * None *
Fastpath:
EWA0
BG0
EWB0
Features:
Autostart - Enabled.
Fastpath - Selection enabled as Preferred CPU.



$ start/cpu 2

//Will start the CPU 2