Thursday, October 18, 2012

Dumping Environment process info before an exit at startup time (JVM)

I have this process that craps out at startup time and I'm not sure what the problem is and what the exact environment settings are at runtime startup. So I need to trap the information from the /proc/[pid]/environ file on linux. In session one I start the monitoring process that will dump the environment to a file. In session two I start the actual process..... once the process startsup the session 1 oneliner will trap the information for me.
  628  while (true) do PID=`/sbin/pidof studio-tools`;if [ -n "$PID" ]; then cat /proc/$PID/environ | tr \\0 \\n > out; /usr/sbin/lsof -p $PID >> out ; break; fi; done;

Wednesday, October 10, 2012

removing duplicate and empty elements from a perl array

Just another snippet not to remember.... removing the non-unique elements and the empty (null) elements.
sub uniq {
    return keys %{{ map { $_ => 1 } @_ }};
}

@my_array = ("one","two","three","two","three");
print join(" ", @my_array), "\n";
print join(" ", uniq(@my_array)), "\n";

Tuesday, October 9, 2012

rpcinfo to process information linux

The trickiness of NFS tracing and locking.... wonderful world...
# find the nfs mount
$ mount 
nas0964p:/prod_nas on /nas/images type nfs (rw,nosuid,soft,intr,tcp,addr=10.75.129.131)
$ rpcinfo -p 10.75.129.131
   program vers proto   port
 824395111    1   tcp  49394
 824395111    1   udp  52370
    100011    1   tcp  60884  rquotad
    100011    1   udp  62423  rquotad
 536870914    1   udp   4658
 536870914    1   tcp   4658
    100021    3   udp  58855  nlockmgr
    100021    2   udp  58855  nlockmgr
    100021    1   udp  58855  nlockmgr
    100021    4   udp  58855  nlockmgr
    100021    3   tcp  63916  nlockmgr
    100021    2   tcp  63916  nlockmgr
    100021    1   tcp  63916  nlockmgr
    100021    4   tcp  63916  nlockmgr
    100024    1   udp  54825  status
    100024    1   tcp  54825  status
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    140391    1   udp  31491
    100005    3   tcp   1234  mountd
    100005    2   tcp   1234  mountd
    100005    1   tcp   1234  mountd
    100005    3   udp   1234  mountd
    100005    2   udp   1234  mountd
    100005    1   udp   1234  mountd
 536870919    3   tcp  12345
 536870919    1   tcp  12345
 536870919    3   udp  12345
 536870919    1   udp  12345
    102660    1   udp  62703
    102660    1   tcp  61254
    100000    2   udp    111  portmapper
    100000    2   tcp    111  portmapper
# what is the program???
$ $ cat /etc/rpc
#ident "@(#)rpc 1.11 95/07/14 SMI" /* SVr4.0 1.2 */
#
# rpc
#
portmapper 100000 portmap sunrpc rpcbind
rstatd  100001 rstat rup perfmeter rstat_svc
rusersd  100002 rusers
nfs  100003 nfsprog
ypserv  100004 ypprog
mountd  100005 mount showmount
ypbind  100007
walld  100008 rwall shutdown
yppasswdd 100009 yppasswd
etherstatd 100010 etherstat
rquotad  100011 rquotaprog quota rquota
sprayd  100012 spray
3270_mapper 100013
rje_mapper 100014
selection_svc 100015 selnsvc
database_svc 100016
rexd  100017 rex
alis  100018
sched  100019
llockmgr 100020
nlockmgr 100021
x25.inr  100022
statmon  100023
status  100024
bootparam 100026
ypupdated 100028 ypupdate
keyserv  100029 keyserver
sunlink_mapper 100033
tfsd  100037
nsed  100038
nsemntd  100039
showfhd  100043 showfh
ioadmd  100055 rpc.ioadmd
NETlicense 100062
sunisamd 100065
debug_svc  100066  dbsrv
ypxfrd  100069  rpc.ypxfrd
bugtraqd 100071
kerbd  100078
event  100101 na.event # SunNet Manager
logger  100102 na.logger # SunNet Manager
sync  100104 na.sync
hostperf 100107 na.hostperf
activity 100109 na.activity # SunNet Manager
hostmem  100112 na.hostmem
sample  100113 na.sample
x25  100114 na.x25
ping  100115 na.ping
rpcnfs  100116 na.rpcnfs
hostif  100117 na.hostif
etherif  100118 na.etherif
iproutes 100120 na.iproutes
layers  100121 na.layers
snmp  100122 na.snmp snmp-cmc snmp-synoptics snmp-unisys snmp-utk
traffic  100123 na.traffic
nfs_acl  100227
sadmind  100232
nisd  100300 rpc.nisd
nispasswd 100303 rpc.nispasswdd
ufsd  100233 ufsd
pcnfsd  150001 pcnfs
amd  300019  amq
sgi_fam  391002 fam
bwnfsd  545580417
fypxfrd  600100069 freebsd-ypxfrd
$ 

Tuesday, October 2, 2012

using find and report on several lines with grep like functionality

Oneliner for finding a specific release of an artifact in a maven build file and reporting the artifact name and version even though these pieces are in different lines... And using find with the exit to print out only the successful files.
$ find . -name pom.xml -type f -exec perl -ne 'BEGIN {my $l} if (/2.0.1.RELEASE/) { printf "%s%s",$last,$_ ; $l=$last } ; $last=$_; END { exit 1 unless  $l; }' {} \; -print
   fmon-jms
   2.0.1.RELEASE
./master-service/master-service/master-proc/master-proc-core/pom.xml