Tuesday, October 12, 2010

HP-UX Directory Server components


Directory Server 8.1 is comprised of several components, which work in tandem:
• Directory Server
The Directory Server is the core LDAP server daemon. It is compliant with LDAP v3 standards. This component includes command-line server management and administration programs, and scripts for common operations like export and backing up databases.

• Directory Server Console
The Directory Server Console is the user interface that simplifies managing users, groups, and other LDAP data for your enterprise. The Console is used for all aspects of server management, including making backups; configuring security, replication, and databases; adding entries; and monitoring servers and viewing statistics.

• Administration Server
The Administration Server is the management agent that administers Directory Servers. It communicates with the Directory Server Console and performs operations on the Directory Server instances. It also provides a simple HTML interface and on-line help pages. There must be one Administration Server running on each machine that has a Directory Server
instance running on it.

• Port numbers
The Directory Server setup requires two TCP/IP port numbers: one for the Directory Server and one for the Administration Server. These port numbers must be unique. The Directory Server instance (LDAP) has a default port number of 389(non-secure, secure port is 636) . The Administration Server port number has a default number of 9830. Alternatively, you can assign any port number between 1025 and 65535 for the Directory Server and Administration Server ports; you are not required to use the defaults or the randomly-generated ports.

Thursday, September 16, 2010

Using C functions like malloc in C++.


#include iostream

using namespace std;
extern "C"
{
int puts(const char *); // Using C style functions in Cpp.
void * malloc(std::size_t);
}
int main()
{
puts("helo world ! ");
int *p;
p=(int *)malloc(sizeof(int));
return 0;
}

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