UnixPedia : HPUX / LINUX / SOLARIS: 2016

Wednesday, December 28, 2016

Resolving Port conflict on Unix

Application port number 50304 been used by Unix dm_TL_adapter, this happen if port are not reserved on the system. Port is taken by dm_TL_adapter and application not be able to start it. To resolve it.

1 - Find what is using the port with lsof command

[root@horses:/sbin/init.d]#
#-> lsof -i :50304
COMMAND    PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
dm_TL_ada 6774 root    3u  IPv4 0xe000000223094ac0      0t0  TCP *:50304 (LISTEN)

2 - try to stop or kill the process or consult expert if not sure about your action.
[root@horses:/sbin/init.d]#
#-> /sbin/init.d/diagnostic stop

[root@horses:/sbin/init.d]#
#-> ps -ef |grep -i 6774
    root  6774     1  0  Dec 17  ?         0:06 /usr/sbin/stm/uut/bin/tools/monitor/dm_TL_adapter
    root 29184 18309  1 04:51:29 pts/4     0:00 grep -i 6774

[root@horses:/sbin/init.d]#
#-> grep -i dm_TL_adapter *

[root@horses:/sbin/init.d]#
#-> kill -9 6774

3 - Re-validate the process and port usage.
[root@horses:/sbin/init.d]#
#-> ps -ef |grep -i 6774
    root  4473 18309  0 04:51:55 pts/4     0:00 grep -i 6774

[root@horses:/sbin/init.d]#
#-> lsof -i :50304

4 - Ask application team to start the application as port is freed.

[root@horses:/sbin/init.d]#
#-> lsof -i :50304

5 - after application start port is taken by application service.
[root@horses:/sbin/init.d]#
#-> lsof -i :50304
COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
jlaunch 12666 tqaadm99u  IPv4 0xe00000023c54a040      0t0  TCP *:50304 (LISTEN)

[root@horses:/sbin/init.d]#

Wednesday, December 21, 2016

Stop Cron Daemon from Sending Email for Each Job

Stop Cron Daemon from Sending Email for Each Job

Question sent in by Howard from Pasadena:

Q: I have some cron jobs that run overnight on my Linux systems.  Each of these jobs output information to a text file if I ever need to review.  Some are written to send emails via the mail command.  But since I put these scripts on a new system and added them to crontab, I am getting an email for each job that runs.  There are too maybe emails being sent to root. Is there a way to stop this behavior?

A: Crond typically sends an email when a cron job is run. It uses the MAILTO variable in /etc/crontab to determine who receives the email, by default this is root. There are several ways to stop this behavior.

1. Change the MAILTO variable to blank.

You can edit the /etc/crontab file and change the MAILTO variable to the following: 
MAILTO=""
This will effectively disable all emails from the cron daemon.  You can then decide from within the script to send mail using the mailx command or the command of your choice.

This is not my preferred method as I like to receive an email when there is an error with the cronjob.

2. Redirect STDOUT and STDERR to null to suppress output.  

By suppressing output of the script, there will be nothing for crond to send.

Add the following to the crontab entry to send all output (STDERR and STDOUT) to the /dev/null. 
>/dev/null 2>&1
For example:
0 5 * * * /example/script >/dev/null 2>&1This also has it's drawbacks as you will be suppressing any errors that may be helpful to debug problems with the script.

3. Configure crond to send the script output to the system log, and disable sending mail of output. 

You can configure crond by editing the /etc/sysconfig/crond file and changing the CRONDARGS line.  Adding the "-s" argument will send the output to the system log, and adding the "-m off" argument will disable crond from sending emails of the job output.

For example:
[root@centos7 ~]# cat /etc/sysconfig/crond
# Settings for the CRON daemon.
# CRONDARGS= :  any extra command-line startup arguments for crond
CRONDARGS=-s -m off

You will have to restart the crond service to read the new arguments:
#-> /etc/init.d/crond restartStopping crond:                                            [  OK  ]Starting crond:                                            [  OK  ]


Any of the above methods will work for completely suppressing emails from cron daemon when jobs run.  This is not ideal in my mind as I would like to be notified if errors occur in my cron jobs.  I prefer to either write my scripts to produce no output (no standard output-but still output errors), or redirect STDOUT only to /dev/null.  This will cause crond to ONLY send an email if an error has occurred.

Example of only redirecting STDOUT only:
0 5 * * * /example/script > /dev/null

Friday, November 4, 2016

HP APA Commands using lanadmin and nwmgr

HP APA Commands using lanadmin and nwmgr

TaskLegacy Commandnwmgr Command
Display command helplanadmin -X -H 900nwmgr –help -S apa
View link aggregate statuslanadmin -x -v 900nwmgr -c lan900
Create a MANUAL mode link aggregatelanadmin -X -a 1 2 900nwmgr -a -A links=1,2 -A mode=MANUAL -I 900 -S apa
Create a failover grouplanapplyconfnwmgr -a -A links=1,2 -A mode=LAN_MONITOR -I 900 -S apa
Remove all ports from a link aggregatelanadmin -X -c 900nwmgr -d -A links=all -I 900 -S apa
Remove all ports from a failover grouplandeleteconf -g lan900nwmgr -d -A links=all -c lan900
Remove specific ports from a link aggregatelanadmin -X -d 1 2 900nwmgr -d -A links=1,2 -I 900 -S apa
Update the load balancing algorithm and group
capability for a link aggregate
lanadmin -X -l LB_MAC 900
lanadmin -X -g 900 900 900
nwmgr -s -A lb=LB_MAC, gc=900 -I 900 -S apa
Update the group capability and configuration
mode for a port
lanadmin -X -p 3 900 900
lanadmin -X -p 3 FEC_AUTO 900
nwmgr -s -A gc=900, mode=FEC_AUTO -I 3 -S apa
Update the group capability for a link aggregatelanadmin -X -g 900 900 900nwmgr -s -A gc=900 -I 900 -S apa
Update the administrative key and load
balancing for a link aggregate
lanadmin -X -k 900 900 900
lanadmin -X -l LB_IP 900
nwmgr -s -A key=900 -A lb=LB_IP -I 900 -S apa
Update the administrative key and
configuration mode for a port
lanadmin -X -k 4 900 900
lanadmin -X -p 4 LACP_AUTO 900
nwmgr -s -A key=900 -A mode=LACP_AUTO -I 4 -S apa
Update the administrative key for a portlanadmin -X -k 4 900 900nwmgr -s -A key=900 -I 4 -S apa
Update the load balancinglanadmin -X -l LB_IP 900nwmgr -s -A lb=LB_IP -I 900 -S apa
Set the configuration mode on a portlanadmin -X -p 5 MANUAL 900nwmgr -s -A mode=MANUAL -I 5 -S apa
Set the system priority on a portlanadmin -X -s 5 10 900nwmgr -s -A sys_pri=10 -I 5 -S apa
Display the MAC addresslanadmin -a 900nwmgr -A mac -c lan900
Display the speedlanadmin -s 900nwmgr -A speed -c lan900
Display the MTU, MAC address, and speedlanadmin -m -a -s 900nwmgr -A mtu,mac,speed -c lan900
nwmgr -A all -c lan900
Display group capabilitylanadmin -x -g 5 900nwmgr -A gc -I 5 -S apa
Display aggregate port statuslanadmin -x -i 900nwmgr -A all -c lan900
Display administrative keylanadmin -x -k 5 900nwmgr -A key -I 5 -S apa
Display load balancing algorithmlanadmin -x -l 900nwmgr -A lb -c lan900 -S apa
Display port statuslanadmin -x -p 5 900nwmgr -A mode -I 5 -S apa
Display system prioritylanadmin -x -s 5 900nwmgr -A sys_pri -I 5 -S apa
Display current port prioritylanadmin -x -t 5 900nwmgr -A port_pri -I 5 -S apa
Display aggregate statuslanadmin -x -v 900nwmgr -v -c lan900
Check network connectivitylinkloop -i 900 0xaabbccddeeffnwmgr –diag -A dest=0xaabbccddeeff -c lan900
Get statisticslanadmin -g 900nwmgr –st -c lan900
Monitoring statisticsapa-monitor -p 5nwmgr –st monitor -S apa -I 900
Reset an APA interfacelanadmin -r 900nwmgr -r -c lan900
Reset statisticslanadmin -c 900nwmgr -r –st -c lan900
View basic helplanadmin -x -h 900nwmgr -h -S apa
View verbose helplanadmin -X -H 900nwmgr -h -v -S apa
Clear data flows on a link aggregatelanadmin -X -o 900nwmgr -r -q data_flow -c lan900
List all interfaces on the systemlanscannwmgr
List all APA interfaceslanscan -qnwmgr -S apa

Tuesday, June 14, 2016

How to check what are process running on the Filesystem

#your system should hold the binary of lsof, or you can install from HP tooling site.

#
fuser and lsof will let you know the process which are accessing the Filesystem, and help you to figure out the problem of space lock and busy status of FS.

tcsci012:root:/.root
# fuser -cu /ees/shr/oradata10
/ees/shr/oradata10:    21388o(eesdba)    1480o(eesdba)   13338o(eesdba)   24762o(eesdba)   13277o(eesdba)   18125o(eesdba)   13363o(eesdba)   13312o(eesdba)   13479o(eesdba)   13404o(eesdba)   18160o(eesdba)   21397o(eesdba)   18189o(eesdba)   21464o(eesdba)   18077o(eesdba)   18046o(eesdba)   21437o(eesdba)   26481o(eesdba)    2828o(eesdba)    8771o(eesdba)    9939o(eesdba)    4319o(eesdba)    6360o(eesdba)    8059o(eesdba)    6312o(eesdba)    2020o(eesdba)   16953o(eesdba)    7430o(eesdba)    2847o(eesdba)    6212o(eesdba)    3182o(eesdba)   12221o(eesdba)    9719o(eesdba)   24519o(eesdba)    7888o(eesdba)   16988o(eesdba)   13152o(eesdba)    6333o(eesdba)    7065o(eesdba)    3171o(eesdba)   19191o(eesdba)     911o(eesdba)    1192o(eesdba)     107o(eesdba)     819o(eesdba)   15685o(eesdba)   25611o(eesdba)   26236o(eesdba)    1938o(eesdba)

tcsci012:root:/.root
# lsof /ees/shr/oradata10 |head -40
COMMAND   PID   USER   FD   TYPE      DEVICE    SIZE/OFF NODE NAME
oracle    107 eesdba   18u   REG 64,0x110001  2147491840   13 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle    819 eesdba   20u   REG 64,0x110001  2147491840   13 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle    911 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   1192 eesdba   17u   REG 64,0x110001  2147491840   13 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   1480 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   1938 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   2020 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   2828 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   2847 eesdba   17u   REG 64,0x110001  2147491840   13 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   3171 eesdba   19u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   3182 eesdba   17u   REG 64,0x110001  2147491840   13 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   4319 eesdba   17u   REG 64,0x110001  2147491840   13 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   6212 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   6312 eesdba   24u   REG 64,0x110001 13107208192    9 /ees/shr/oradata10/eescip20/index01u.dbf
oracle   6333 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   6360 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   7065 eesdba   17u   REG 64,0x110001  2147491840   13 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   7430 eesdba   17u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   7888 eesdba   15u   REG 64,0x110001  2147491840   13 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)
oracle   8059 eesdba   18u   REG 64,0x110001  2147491840   12 /ees/shr/oradata10 (/dev/ees_vg6/lv_shr-oradata10)