To see all processes memory usage and more run the next command in your console.
ps -e -o "%z %C %U %p %t %c" |sort -n
%z ought to show the virtual size of each process in KB , and we sort the output from min usage to max.
very good tips about Managing processes on AIX Systems
This Blog is first of all memos for me!! From time to time I get exposed to new and cool stuff for developers and architects ,most of the time its a solution for a problem or tips or tricks, so, I would like to track my memos and share it with you, it can save your time and nervous, I hope you will enjoy it - by Yaniv Tzanany.
Search This Blog
Tuesday, November 25, 2008
Printing stack trace - just before crashing under linux/gcc
the next post will talk about how to write the stack trace before your application will BANG , i need it for three things:
1. to free up some resource before the crash
2. to give a hint to the developer what happen - or even in production .
3. some exception i could catch even into catch(...)
the next code sample runs under linux , and compile with g++, i couldn't find an easy way to do it under windows (via VC++) as on linux , and in my case i need it under linux.
the idea is to register for any signal you want to handle , and in your function handler you need to write your cleaner, or print out the trace.
Do NOT FORGET in case of handler function you have to call to exit method , if you don't you will get into endless loop.
if you want to get the function name in your stack trace , ADD -rdynamic flag to your link settings.
here are some resources i used:
linux backtrace , generate a stacktrace
here is my sample test:
enjoy
Yaniv
1. to free up some resource before the crash
2. to give a hint to the developer what happen - or even in production .
3. some exception i could catch even into catch(...)
the next code sample runs under linux , and compile with g++, i couldn't find an easy way to do it under windows (via VC++) as on linux , and in my case i need it under linux.
the idea is to register for any signal you want to handle , and in your function handler you need to write your cleaner, or print out the trace.
Do NOT FORGET in case of handler function you have to call to exit method , if you don't you will get into endless loop.
if you want to get the function name in your stack trace , ADD -rdynamic flag to your link settings.
here are some resources i used:
linux backtrace , generate a stacktrace
here is my sample test:
#include <iostream>
extern "C"
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
}
#include <fstream>
#include <csignal>
#include <execinfo.h>
void PrintStack()
{
//backtrace_symbols_fd(array, size, 2);
// ADD -rdynamic flag to your link , to get method name and not hex address
void * array[25];
int nSize = backtrace(array, 25);
char ** symbols = backtrace_symbols(array, nSize);
for (int i = 0; i < nSize; i++)
{
printf("%s \n", symbols[i] );
}
if(symbols)
free(symbols);
}
void intrupt(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Interactive attention signal \n",sig);
PrintStack();
exit(sig);
}
void term(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Termination request made to the program \n",sig);
exit(sig);
}
void abort(int sig)
{
//..necessary cleanup operations before terminating
// cout << "handling signal no." << sig << endl << "Abnormal termination" << endl;
printf("handling signal no. %d - Abnormal termination \n",sig);
exit(sig);
}
void floatingPoint(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Abnormal termination floatingPoint \n",sig);
PrintStack();
exit(sig);
}
void IllegalInstruction(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Abnormal termination IllegalInstruction \n",sig);
exit(sig);
}
void IllegalStorage(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Abnormal termination IllegalStorage \n",sig);
PrintStack();
// no log when there is no exit here on aix ,
//on linux its in recursion so you have to call exit
exit(sig);
}
void foo()
{
int arrInt[4] = {1,2,3,4};
for(int i = 0 ; i < 2000;i++)
{
printf(" iRet index = %d , val= %d ........... ...\n",i,arrInt[i]);
}
}
void foo3()
{
char* data = 0 ;
int iRet = strlen(data);
printf(" strlen(data) = %d ........... ...\n",iRet);
strcpy(data, "hellozadsfaddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");
printf(" dataLinux = %s ........... ...\n",data);
}
void foo2()
{
foo3();
}
class Crash
{
public:
void fooArrayOutOfIndex()
{
int arrInt[4] = {1,2,3,4};
for(int i = 0 ; i < 2000;i++)
{
printf(" iRet index = %d , val= %d ........... ...\n",i,arrInt[i]);
}
};
void foo3()
{
char* data = 0 ;
int iRet = strlen(data);
printf(" strlen(data) = %d ........... ...\n",iRet);
strcpy(data, "hellozadsfaddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");
printf(" dataLinux = %s ........... ...\n",data);
};
void fooNullPointerAccess()
{
foo3();
};
void fooLoop()
{
while(true)
{
}
};
};
int main ( int argc, char * * argv ) {
signal(SIGINT , intrupt); // register a SIGINT handler
signal(SIGTERM , term); // register a SIGTERM handler
signal(SIGABRT , abort); // register a SIGABRT handler
signal(SIGFPE , floatingPoint); // register a SIGFPE handler
signal(SIGILL , IllegalInstruction); // register a Illegal instruction handler
signal(SIGSEGV , IllegalStorage); // register a Illegal storage handler
int iRet;
bool bErr = false;
printf("Starting Server on queue %s...\n","Demo test");
try
{
printf("IN TRY........... ...\n");
iRet = 0;
iRet = iRet/0.;
printf(" iRet = %d ........... ...\n",iRet);
//foo();
// foo2();
Crash crsh;
// crsh.fooArrayOutOfIndex();
crsh.fooNullPointerAccess();
// crsh.fooLoop();
}
catch(...)
{
bErr = true;
printf("***************** ERROR ****************** .\n");
}
printf("Connected and Running ... \n");
printf("END Server \n ");
return 1;
}
enjoy
Yaniv
Friday, November 21, 2008
Monday, November 10, 2008
LDAP with java
i found very interesting articles and sample to deal with LDAP via java code .
one of the complete and best sample you can find here - This is sample program that show how to authenticate with for example a Windows Active Directory:
Active Directory LDAP and Java.
second there is a very good tutorial for JNDI & Ldap that you can find here:
Your guide to The JNDI Tutorial .
another good link with java/c#/c samples -> A Beginner's Guide to LDAP Development
a very good book you can find here LDAP-Programming-With-Java
And here is a tip to find all the ldap attributes:
To discover more LDAP attributes, go to the command prompt, type:
CSVDE -f Exportfile.csv. Then open Exportfile.csv with Excel.exe.
Alternatively, use ADSI Edit and right click the container objects.
enjoy
one of the complete and best sample you can find here - This is sample program that show how to authenticate with for example a Windows Active Directory:
Active Directory LDAP and Java.
second there is a very good tutorial for JNDI & Ldap that you can find here:
Your guide to The JNDI Tutorial .
another good link with java/c#/c samples -> A Beginner's Guide to LDAP Development
a very good book you can find here LDAP-Programming-With-Java
And here is a tip to find all the ldap attributes:
To discover more LDAP attributes, go to the command prompt, type:
CSVDE -f Exportfile.csv. Then open Exportfile.csv with Excel.exe.
Alternatively, use ADSI Edit and right click the container objects.
enjoy
Subscribe to:
Posts (Atom)