Pages

Showing posts with label Solaris. Show all posts
Showing posts with label Solaris. Show all posts

Monday, March 24, 2014

Solaris P-commands

As we know , every thing in linux is a file . what ever we open or execute we deal with files. With the /proc virtual file system, even processes may be treated like files.

/proc (or procfs) is a virtual file system that allows us to examine processes like files. This means that /proc allows us to use file-like operations and intuitions when looking at processes. /proc does not occupy disk space; it is located in working memory.

Under the /proc location we see a lot of number which are nothing but the pid(process ID) for the running process. Under this pid directory, we can see some more sub directories which will give many details about the process running. We can get the same details using the Process command or P-commands in Solaris.

The available P-commands in Solaris are, 
  • pcred: Display process credentials (eg EUID/EGID, RUID/RGID, saved UIDs/GIDs)
  • pfiles: Reports fstat() and fcntl() information for all open files. This includes information on the inode number, file system, ownership and size.
  • pflags: Prints the tracing flags, pending and held signals and other /procstatus information for each LWP.
  • pgrep: Finds processes matching certain criteria.
  • pkill: Kills specified processes.
  • pldd: Lists dynamic libraries linked to the process.
  • pmap: Prints process address space map.
  • prun: Starts stopped processes.
  • prstat: Display process performance-related statistics.
  • ps: List process information.
  • psig: Lists signal actions.
  • pstack: Prints a stack trace for each LWP in the process.
  • pstop: Stops the process.
  • ptime: Times the command; does not time children.
  • ptree: Prints process genealogy.
  • pwait: Wait for specified processes to complete.
  • pwdx: Prints process working directory.

And here are some of the snippets using the above P-commands.

Display Process credentials
oracle@solaris_11X:~/Downloads/apache-tomcat-7.0.52/bin# pcred 1289
1289:   e/r/suid=0  e/r/sgid=0
        groups: 0 1 2 3 4 5 6 7 8 9 12

Display the File Opened by a process
oracle@solaris_11X:~# pfiles 1289
1289:   /usr/bin/java -Djava.util.logging.config.file=/home/oracle/Downloads/a
  Current rlimit: 65536 file descriptors
   0: S_IFCHR mode:0666 dev:551,0 ino:25690120 uid:0 gid:3 rdev:49,2
      O_RDONLY|O_LARGEFILE
      /devices/pseudo/mm@0:null
      offset:0
   1: S_IFREG mode:0644 dev:174,65544 ino:5047 uid:0 gid:0 size:2872
      O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE
      /home/oracle/Downloads/apache-tomcat-7.0.52/logs/catalina.out
      offset:2872


Display the flags
oracle@solaris_11X:~# pflags 1289
1289:   /usr/bin/java -Djava.util.logging.config.file=/home/oracle/Downloads/a
        data model = _ILP32  flags = ORPHAN|MSACCT|MSFORK
 /1:     flags = ASLEEP  lwp_wait(0x2,0x8046cb4)
 /2:     flags = ASLEEP  accept(0x32,0xce2ae320,0xce2ae380,0x1)
        sigmask = 0x00000004,0x00000000,0x00000000


Display the linked libraries by a process
oracle@solaris_11X:~# pldd 1289
1289:   /usr/bin/java -Djava.util.logging.config.file=/home/oracle/Downloads/a
/lib/libthread.so.1
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/jli/libjli.so
/lib/libdl.so.1
/usr/lib/libc/libc_hwcap3.so.1
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/client/libjvm.so
/lib/libsocket.so.1
/usr/lib/libsched.so.1
/lib/libm.so.1
/usr/lib/libCrun.so.1
/lib/libdoor.so.1
/lib/libm.so.2
/lib/libnsl.so.1
/lib/libmd.so.1
/lib/libmp.so.2
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/libverify.so
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/libjava.so
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/native_threads/libhpi.so
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/libzip.so
/usr/lib/locale/en_US.UTF-8/en_US.UTF-8.so.3
/usr/lib/locale/common/methods_unicode.so.3
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/libmanagement.so
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/libj2pkcs11.so
/usr/lib/libpkcs11.so.1
/lib/libcryptoutil.so.1
/usr/lib/security/pkcs11_softtoken.so.1
/usr/lib/libsoftcrypto.so.1
/lib/libgen.so.1
/usr/jdk/instances/jdk1.6.0/jre/lib/i386/libnet.so


Display the process address space of a process
oracle@solaris_11X:~# pmap 1289
1289:   /usr/bin/java -Djava.util.logging.config.file=/home/oracle/Downloads/a
08045000      12K rwx--    [ stack ]
08050000      44K r-x--  /usr/jdk/instances/jdk1.6.0/bin/java
0806A000       4K rwx--  /usr/jdk/instances/jdk1.6.0/bin/java
0806B000    7064K rwx--    [ heap ]

top command in solaris
prstat
 PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
 719 oracle     84M   57M sleep   46    0   0:02:23  10% Xorg/3
 933 oracle     90M   20M sleep   54    0   0:00:30 6.7% gnome-terminal/2

print the signals from a process
oracle@solaris_11X:~# psig 1289
1289:   /usr/bin/java -Djava.util.logging.config.file=/home/oracle/Downloads/a
HUP     caught  UserHandler     RESTART HUP,INT,QUIT,ILL,TRAP,ABRT,EMT,FPE,BUS,SEGV,SYS,PIPE,ALRM,TERM,USR1,USR2,CLD,PWR,WINCH,URG
INT     ignored


Print the Threads of a Process
oracle@solaris_11X:~/Downloads/apache-tomcat-7.0.52/bin# pstack 1661
1661:   /usr/bin/java -Djava.util.logging.config.file=/home/oracle/Downloads/a
-----------------  lwp# 1 / thread# 1  --------------------
 ceaa21a7 lwp_wait (2, 8046ce4)
 cea9988c _thrp_join (2, 0, 8046d50, 1) + 63
 cea999db thr_join (2, 0, 8046d50) + 23


stop a process
oracle@solaris_11X:~/Downloads/apache-tomcat-7.0.52/bin# pstop 1661
oracle@solaris_11X:~/Downloads/apache-tomcat-7.0.52/bin# ps aex 1661
   PID TT       S  TIME COMMAND
1661 pts/2    T  0:05 /usr/bin/java
-Djava.util.logging.config.file=/home/oracle/Downloads/apache-tomcat-7.0.52/conf/logging.properties

Check the State “T” which says it is stopped

Start the Process
oracle@solaris_11X:~/Downloads/apache-tomcat-7.0.52/bin# prun 1661
oracle@solaris_11X:~/Downloads/apache-tomcat-7.0.52/bin# ps aex 1661
   PID TT       S  TIME COMMAND
1661 pts/2    R  0:05 /usr/bin/java
-Djava.util.logging.config.file=/home/oracle/Downloads/apache-tomcat-7.0.52/conf/logging.properties

Check the State “R” which says it is started.


More to Come , Happy Learning J
Read More

Friday, January 24, 2014

SMF (Service Management Facility) In Solaris

Managing Services is different in Solaris when compared with linux systems. The SMF - Service management facility a new system included in the Solaris which performs the task of managing services in solaris.

Linux usually stores start and stop files in /etc/rc*.d location which will do the start and stop of the services. These same location are available as files in Solaris or may be an empty locations.

In order to learn how the SMF works we need to learn some basic commands on how to handle these,

svcs
svcadm

enabling or disabling of the services in solaris is done using the svcadm command and we can use svcs command to see the status of the services

svcs –a : list all the services by their state

oracle@solaris_11X:/etc$ svcs -a | head
STATE             STIME    FMRI
legacy_run      0:16:01 lrc:/etc/rc2_d/S20sysetup
legacy_run      0:16:02 lrc:/etc/rc2_d/S47pppd
legacy_run      0:16:02 lrc:/etc/rc2_d/S72autoinstall
legacy_run      0:16:02 lrc:/etc/rc2_d/S73cachefs_daemon
legacy_run      0:16:02 lrc:/etc/rc2_d/S89PRESERVE
disabled          0:15:54 svc:/network/rpc/meta:default
disabled          0:16:00 svc:/network/rpc/rstat:default
disabled          0:16:06 svc:/application/x11/xvnc-inetd:default
disabled          0:16:07 svc:/network/nfs/rquota:default

in order to enable/disable services in Solaris we can use

svcadm enable network/http:apache2
svcadm disable network/http:apache2

If you enable or disable a service and reboot your machine the service will be restored to the state last specified.

If you see the output of the svcs –a command ,we can see FMRI which is called fault management resource identifier which identifies the service. Some of the services have an instance name on the end (the :default of svc:/network/rpc:default).There can be multiple instances of a single service executing on the system at one time.

The _nal thing to note is the STATE column. This column is telling us the current state of each service. The legacy run state is for services that are still executing from the old /etc/rc*.d scripts. Other states include disabled and online which gives us the necessary data.

There is one more state called offline lists all of the services that were unable to start, or had a service fault, and have been taken offline by SMF.

Svcs –xv will give information about the services that are offline and also a reason for that. The svcs -x output also gives pointers on where you can go for information on the current issue. These can be pointers to websites, log messages or man pages. These are typically very handy resources in diagnosing and correcting the issue at hand.

# svcs -x
svc:/network/physical:default (physical network interfaces)
State: disabled since Thu Sep 28 15:33:17 2006
Reason: Disabled by an administrator.
See: http://sun.com/msg/SMF-8000-05
See: ifconfig(1M)

# svcs -xv
svc:/network/physical:default (physical network interfaces)
State: disabled since Thu Sep 28 15:33:17 2006
Reason: Disabled by an administrator.
See: http://sun.com/msg/SMF-8000-05
See: man -M /usr/share/man -s 1M ifconfig
Impact: 5 dependent services are not running:
svc:/milestone/network:default
svc:/network/nfs/nlockmgr:default
svc:/network/nfs/client:default
svc:/network/nfs/status:default
svc:/network/ssh:default

Some more command include,

  • svcs -a: Lists all services currently installed, including their state.
  • svcs -d FMRI: Lists dependencies for FMRI.
  • svcs -D FMRI: Lists dependents for FMRI.
  • svcs -l FMRI: Provides a long listing of information about FMRI; includes dependency information
  • svcs -p FMRI: Shows relationships between services and processes.
  • svcs -t: This change is temporary (does not persist past a boot).
  • svcs -x: Explains why a service is not available.
  • svcs -xv: Verbose debugging information.

  • svcadm clear FMRI: Clear faults for FMRI.
  • svcadm disable FMRI: Disable FMRI.
  • svcadm enable FMRI: Enable FMRI.
  • svcadm refresh FMRI: Force FMRI to read config file.
  • svcadm restart FMRI: Restart FMRI. 
There are some more commands that we need to learn when dealing with Services in Solaris. They are

svccfg  - command which use to configures services
inetadm – command which will be used to administer inetd services.
inetconv – command which will be used to convert inetd services to SMF.

The inetd daemon is a special network process that runs on each system and starts server processes that do not automatically start at boot time.


Network services can be independently enabled or disabled using the inetadm command.
inetadm    ==> to list the current state of all network facilities

Consider starting and stopping the telnet service using inetadm command like,

inetadm | grep telnet        ==> to view if telnet is enabled or not

inetadm -d telnet        ==> to disable the telnet facility
inetadm | grep telnet

inetadm -e telnet        ==> to enable the telnet facility
inetadm | grep telnet

inetadm -l telnet        ==> to list the details about telnet


These services managed by inetadm can be converted to SMF services using inetconv command. There are three main types of services provided by SMF.Transient, Wait and Contract services. Transient services are often con_guration services requiring no long-running process. Wait services run for the lifetime of the child process and are restarted when the process exits. Contract services are the standard system daemons and require processes which run forever once started. The death of all processes in a contract service is considered a service error which will cause the service to restart.

More to Come , happy learning
Read More

Wednesday, January 22, 2014

Solaris Directory Structure

The Solaris directory structure is similar like linux but with a little changes






















There are couple of directories which are not available in linux

 /kernel -Contains kernel components common to all platforms within a particular instruction set that are needed for booting the system.

/platform –Contains platform definition files.
 /proc – Process Information  , Even though this is available in linux too  , the basics of this location is different in Solaris when compared with linux

/proc contains information on the current system configuration and process along with _les you can alter to update kernel variables and process information. Besides a new location called /platform which contain platform speci_c information and applications

/vol – Disk volumes mounted under this directory.

/var – variable files where the Content of the files that are expected to grow can be found under this directory like system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); temp files needed across reboots (/var/tmp).


More to Come , Happy Learning


Read More