2017-03-17

Changing 'public' community string for SNMP in AIX

Needed to work on the message/output requested by one of our customer's security analyst.

Please change the default credentials. Plugin Name: BMC SNMP Agent Default Community Name (public) . Following is the description on what was detected : Plugin Output:
Requesting the OID 1.3 returned :
  OID   : 1.3.6.1.2.1.1.1.0
  Value : PEER Networks, a division of BMC Software, Inc., PATROL(R) SNMP Toolkit, OptiMaster Release 1.9.1 on AIX

So from "public" string I changed it to something else, "beowulf" using Perl.

AIX gelato 1 7 00B711FC4C10
$ sudo perl -p -i.bak -e 's/public/beowulf/g' /etc/snmpd.conf
$ ls -l /etc/snmpd.*
-rw-r--r--    1 root     system           37 Dec 22 2011  /etc/snmpd.boots
-rw-r-----    1 root     system        10139 Mar 17 12:04 /etc/snmpd.conf
-rw-r-----    1 root     system        10135 Feb 27 04:01 /etc/snmpd.conf.bak
-rw-r-----    1 root     system         2603 Feb 27 04:01 /etc/snmpd.peers
$ sudo stopsrc -s snmpd
0513-004 The Subsystem or Group, snmpd, is currently inoperative.

But it seems SNMP service isn't running so I just left it as it is.  Now I also need to check for other hosts as well.

mmond@nx03|826:~/ $ for i in $(cat dwc_detected.txt)
> do
> ssh -q $i -t "hostname;
> done
dappl01.nn.dk
Subsystem         Group            PID          Status
 snmpd            tcpip                         inoperative
dengn01.nn.dk
Subsystem         Group            PID          Status
 snmpd            tcpip                         inoperative
duengn01.nn.dk
Subsystem         Group            PID          Status
 snmpd            tcpip                         inoperative

2017-03-11

How to know if Oracle Database instance is Running

Quick check if there's Oracle database instance running - by checking the presence of smon and pmon.

$ uname -a
HP-UX sapprd01 B.11.31 U ia64 0574715905 unlimited-user license
$ sudo ps -ef | grep [p,s]mon | grep -v grep
Last successful login:       Sat Mar 11 13:31:51 MET 2017
Last authentication failure: Wed Jan  6 09:42:00 MET 2016 10.75.236.144
    root  3708     1  0  Oct  4  ?         2:29 /etc/opt/resmon/lbin/p_client
    root  3132     1  0  Oct  4  ?         0:00 /etc/opt/resmon/lbin/emsagent
  vipadm 10646     1  0  Oct  4  ?        44:04 ora_smon_VIP
  vipadm 10604     1  0  Oct  4  ?        102:57 ora_pmon_VIP

$ sudo /usr/sbin/cmviewcl
Last successful login:       Sat Mar 11 14:00:00 MET 2017
Last authentication failure: Wed Jan  6 09:42:00 MET 2016 10.120.3.100
CLUSTER        STATUS    
DLG_SAP        up        

  NODE           STATUS       STATE      
  saptst01        down         halted    
  sapprd01        up           running    
    PACKAGE        STATUS           STATE            AUTO_RUN    NODE      
    vip            up               running          disabled    sapprd  
 
UNOWNED_PACKAGES
    PACKAGE        STATUS           STATE            AUTO_RUN    NODE      
    rst            down             halted           disabled    unowned     

2017-03-08

My SHELL environment in HP-UX 11.31

Been having a hard time with absolute path for certain commands, and few errors I encountered using vi, and backspace key, so I decided to use my /home/mmond/.profile

[mmond@sol /home/mmond]# vi .profile
".profile" 11 lines, 176 characters
HISTSIZE=1024
HISTFILE=$HOME/.sh_history
PATH=/usr/sbin:$PATH

PS1="[`logname`@`hostname` "'${PWD}]# '
export HISTSIZE HISTFILE PS1
stty columns 160
stty erase ^?

How to define backspace and delete keys can be found here .  The rest of it can be found on Thomas Vogt's blog.

Patching HP-UX 11.31 server

Previously I have written an article describing on how to download patch from HPE for HP-UX server.  But one of my senior colleague told me not to use the software inventory tool and I have yet to check with him the reason behind.
Anyway, this Saturday I am going to patch a test server of one of our customer and need to put it in writing for me to be able to review and learn something out of it.

[mmond@saptst01 /var/opt/ignite/depot/patch-2017q1] # ls -l
total 5250416
-rw-r--r--   1 mmond       unixadm    180090880 Mar 22  2016 FEATURE11i_B.11.31.1603.422.depot
-rw-r--r--   1 mmond       unixadm    135157760 Mar 22  2016 HWEnable11i_B.11.31.1603.422.depot
-rw-r--r--   1 mmond       unixadm     438044 Aug  3  2016 PHCO_43870
-rw-r--r--   1 mmond       unixadm     685980 Mar 16  2015 PHCO_44168
-rw-r--r--   1 mmond       unixadm    10506440 Nov 21 18:08 PHKL_44565
-rw-r--r--   1 mmond       unixadm    10347590 Nov 29 10:35 PHNE_44547
-rw-r--r--   1 mmond       unixadm    2350909440 Mar 22  2016 QPK1131_B.11.31.1603.421a.depot
-rw-r--r--   1 mmond       unixadm       1779 Jul 29  2016 README_hp-ux
-rw-r--r--   1 mmond       unixadm       5789 Mar  3 19:30 create_depot_hpux.11.31
-rw-r--r--   1 mmond       unixadm        471 Mar  3 19:30 patch_manifest

[mmond@saptst01 /var/opt/ignite/depot/patch-2017q1]# sudo /usr/sbin/swlist -l depot

# Initializing...
# Target "saptst01" has the following depot(s):
  /var/opt/ignite/depot/patch-2016q1/depot

[mmond@saptst01 /home/mmond]# cd /var/opt/ignite/depot/patch-2017q1/
[mmond@saptst01 /var/opt/ignite/depot/patch-2017q1]# for i in PH*
> do
> sh $i
> done
x - PHCO_43870.text
x - PHCO_43870.depot [non-ascii]
x - PHCO_44168.text
x - PHCO_44168.depot [non-ascii]
x - PHKL_44565.text
x - PHKL_44565.depot [non-ascii]
x - PHNE_44547.text
x - PHNE_44547.depot [non-ascii]

[mmond@saptst01 /var/opt/ignite/depot/patch-2017q1]# ls -al
total 5281440
drwxr-xr-x   2 mmond       unixadm       8192 Mar  8 09:27 .
drwxrwxrwx   4 root       sys             96 Mar  7 09:16 ..
-rw-r--r--   1 mmond       unixadm    180090880 Mar 22  2016 FEATURE11i_B.11.31.1603.422.depot
-rw-r--r--   1 mmond       unixadm    135157760 Mar 22  2016 HWEnable11i_B.11.31.1603.422.depot
-rw-r--r--   1 mmond       unixadm     438044 Aug  3  2016 PHCO_43870
-rw-r--r--   1 mmond       unixadm     296960 Jul 28  2016 PHCO_43870.depot
-rw-r--r--   1 mmond       unixadm      16231 Aug  3  2016 PHCO_43870.text
-rw-r--r--   1 mmond       unixadm     685980 Mar 16  2015 PHCO_44168
-rw-r--r--   1 mmond       unixadm     471040 Feb  5  2015 PHCO_44168.depot
-rw-r--r--   1 mmond       unixadm      20494 Mar 16  2015 PHCO_44168.text
-rw-r--r--   1 mmond       unixadm    10506440 Nov 21 18:08 PHKL_44565
-rw-r--r--   1 mmond       unixadm    7270400 Nov 17 00:31 PHKL_44565.depot
-rw-r--r--   1 mmond       unixadm     321820 Nov 21 12:08 PHKL_44565.text
-rw-r--r--   1 mmond       unixadm    10347590 Nov 29 10:35 PHNE_44547
-rw-r--r--   1 mmond       unixadm    7239680 Nov 24 02:48 PHNE_44547.depot
-rw-r--r--   1 mmond       unixadm     205996 Nov 29 04:35 PHNE_44547.text
-rw-r--r--   1 mmond       unixadm    2350909440 Mar 22  2016 QPK1131_B.11.31.1603.421a.depot
-rw-r--r--   1 mmond       unixadm       1779 Jul 29  2016 README_hp-ux
-rw-r--r--   1 mmond       unixadm       5789 Mar  3 19:30 create_depot_hpux.11.31
-rw-r--r--   1 mmond       unixadm        471 Mar  3 19:30 patch_manifest
[mmond@saptst01 /var/opt/ignite/depot/patch-2017q1]# ls *.depot | while read dep; do
> sudo /usr/sbin/swcopy -x enforce_dependencies=false -s `pwd`/$dep \* @ /var/opt/ignite/depot/patch-2017q1/depot ;
> done
[mmond@saptst01 /var/opt/ignite/depot/patch-2017q1]# ls depot/ | wc -l
838
[mmond@saptst01 /var/opt/ignite/depot/patch-2017q1]# sudo /usr/sbin/swinstall -p -s `pwd`/depot
 
And this is the output window.


Those PH* will be installed first before anything else as they are pre-requisites, and I will update this article one's I got the details on what these patch files for.

2017-03-02

Unable to change password in Linux

I just encountered recently that when I try changing a password of one of customer's user, it doesn't allow me to and shows an error similar to below.

passwd: Ukendt bruger for det underliggende godkendelsesmodul

dbip01:~ # chage -I -1 poj
Aging information changed.

dbip01:~ # chage -l poj
Minimum:        1
Maksimum:       70
Advarsel:       7
Inaktiv:        14
Sidste ændring:         aug 22, 2016
Adgangskode udløber:    okt 31, 2016
Adgangskode inaktiv:    nov 14, 2016
Konto udløber:  Aldrig

The error (the last part) when translated is "passwd: Unknown User of the underlying authentication module".  And I have checked my "cookbook" on  Linux as I think I encountered it already in the past.  

dbip01:~ # passwd poj
Ændrer adgangskode for poj.
Ny adgangskode:
Gentag ny adgangskode:
Adgangskode ændret.

So here's what I did. I also took note that in some systems pam_tally2 isn't present while faillog is there and vice versa. I only found a few servers who have both tools though.
dbip01:~ # pam_tally2 -u poj --reset
Login           Failures Latest failure     From
poj                 0  
dbip01:~ # faillog -u poj --reset

2017-03-01

Sending an Email with Attachments in HP-UX

While doing other stuff, I just tried to mail a file as I think this can be handy for my future needs.

[vinson:root]/root # uname -a
HP-UX vinson B.11.23 U ia64 2575904424 unlimited-user license
[vinson:root]/root # cd /var/adm

I need my backspace to delete so I used this - after typing "stty erase" simultaneously press CTRL + BAKCSPACE on the keyboard and hit ENTER.

[vinson:root]/var/adm # stty erase ^?

This is where the main part of course, how to send an email with attachments.

[vinson:root]/var/adm # uuencode new.secrets new.secrets | mailx -m -s "Send email to MMOND" mmond@nn.com
[vinson:root]/var/adm # tail -f /var/adm/syslog/mail.log
Mar  1 13:46:34 vinson sendmail[9108]: v21CkYD09108: from=mzmo, size=97, class=0, nrcpts=1, msgid=<201703011246.v21CkYD09108@vinson.nn.dk>, relay=root@localhost
Mar  1 13:46:35 vinson sendmail[9110]: v21CkYD09108: to=mmond@nn.com, ctladdr=mzmo (8811/804), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=120097, relay=relay.nnit.com. [10.1.200.149], dsn=2.0.0, stat=Sent (<201703011246.v21CkYD09108@vinson.nn.dk> [InternalId=76602766] Queued mail for delivery)

I also read this article about how to do it if we need multiple files though I haven't tried it myself.

Performance Tuning on Linux Systems

There have been lots of guides on the Internet about on how to tune Linux systems. Though I have yet to see detailed description on why and why-not, I just found this site appropriate to my needs.   And again, there's no bulletproof on tuning systems I believe as this has to be done in a controlled manner and different applications running on the system is also a variable that need to be considered.

http://fasterdata.es.net/host-tuning/linux/

I was asked by one of our application team to increase the value of net.core.rmem_max.

Non-persistent.

[root@ahiudv ~]# cp /etc/sysctl.conf /tmp/sysctl.conf.20170301
[root@ahiudv ~]# sysctl -a | grep rmem_max
net.core.rmem_max = 16777216
[root@ahiudv ~]# sysctl -w net.core.rmem_max=26214400
[root@ahiudv ~]# sysctl -p; clear; sysctl -a | grep rmem_max
net.core.rmem_max = 26214400

Persistent, needs to be rebooted.

[root@ahiudv ~]# val=$(grep net.core.rmem_max /etc/sysctl.conf | awk '{ print $3 }')
[root@ahiudv ~]# echo $val
16777216
[root@ahiudv ~]# sed -i "/net.core.rmem_max =/ s/$val/26214400/" /etc/sysctl.conf
[root@ahiudv ~]# grep net.core.rmem_max /etc/sysctl.conf
net.core.rmem_max =  26214400