Thursday, August 30, 2018

snmpwalk using script

$ head retail1.snmpWorking.Seed.200
10.192.124.196 fw0527a
10.221.200.196 fw9815a
10.221.120.196 fw9783a
10.220.24.196 fw9817a
10.195.220.196 fw9788a
10.218.156.196 fw9811a
10.218.88.196 fw9800a
10.218.72.196 fw9791a
10.226.40.196 fw4152a
10.218.132.196 fw9832a


cat retail1.snmpWorking.Seed.200 | awk '{print "printf " $1 "\"-->\"" ";/bin/snmpwalk -v3  -l authNoPriv -u monitor -a MD5 -A pc15uck5 " $1 " sysObjectID"}' > letsSnmpWalk_v3.sh

cat retail1.snmpWorking.Seed.200 | awk '{print "printf " $1 "\" " $2 "\"\" --> \"" ";/bin/snmpwalk -v3  -l authNoPriv -u monitor -a MD5 -A pc15uck5 " $1 " sysObjectID"}' > letsSnmpWalk_v3-retail1.sh



cat retail1.snmpWorking.Seed.200 | awk '{print "printf " $1 "\" " $2 "\"\" --> \"" ";/usr/bin/snmpwalk  -v3 -l authPriv -u meraki -a SHA -A pc15uck5 -x DES -X pc15uck5 " $1 " sysObjectID"}' 

/usr/bin/snmpwalk -v3 -l authPriv -u meraki -a SHA -A pc15uck5 -x DES -X pc15uck5 10.244.52.196 sysObjectId

sh /tmp/notworking.snmp.sh > out 2>&1 > /tmp/snmp.result

sh /tmp/notworking.snmp.sh > snmpResult.R3 2>&1



cat retail3.snmpWorking.Seed.200 | awk '{print "printf " $1 "\"-->\"" ";/bin/snmpwalk -v3  -l authNoPriv -u monitor -a MD5 -A pc15uck5 " $1 sysObjectID}' > /tmp/notworking.snmp.sh

SNMP install

# yum install net-snmp-utils
Loaded plugins: fastestmirror, priorities
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
deployed                                                                                                                                    | 2.9 kB  00:00:00
internal                                                                                                                                    | 2.9 kB  00:00:00
pc_repo                                                                                                                                     | 2.5 kB  00:00:00
internal/primary_db                                                                                                                         |  30 kB  00:00:00
Determining fastest mirrors
 * deployed: d1yum.safeway.com
 * internal: d1yum.safeway.com
Resolving Dependencies
--> Running transaction check
---> Package net-snmp-utils.x86_64 1:5.7.2-24.el7 will be installed
--> Processing Dependency: net-snmp-libs = 1:5.7.2-24.el7 for package: 1:net-snmp-utils-5.7.2-24.el7.x86_64
--> Processing Dependency: libnetsnmp.so.31()(64bit) for package: 1:net-snmp-utils-5.7.2-24.el7.x86_64
--> Running transaction check
---> Package net-snmp-libs.x86_64 1:5.7.2-24.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================
 Package                                   Arch                              Version                                     Repository                           Size
===================================================================================================================================================================
Installing:
 net-snmp-utils                            x86_64                            1:5.7.2-24.el7                              deployed                            197 k
Installing for dependencies:
 net-snmp-libs                             x86_64                            1:5.7.2-24.el7                              deployed                            747 k

Transaction Summary
===================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 943 k
Installed size: 3.3 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): net-snmp-utils-5.7.2-24.el7.x86_64.rpm                                                                                               | 197 kB  00:00:00
(2/2): net-snmp-libs-5.7.2-24.el7.x86_64.rpm                                                                                                | 747 kB  00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                               12 MB/s | 943 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:net-snmp-libs-5.7.2-24.el7.x86_64                                                                                                             1/2
  Installing : 1:net-snmp-utils-5.7.2-24.el7.x86_64                                                                                                            2/2
  Verifying  : 1:net-snmp-utils-5.7.2-24.el7.x86_64                                                                                                            1/2
  Verifying  : 1:net-snmp-libs-5.7.2-24.el7.x86_64                                                                                                             2/2

Installed:
  net-snmp-utils.x86_64 1:5.7.2-24.el7

Dependency Installed:
  net-snmp-libs.x86_64 1:5.7.2-24.el7

Complete!
[root@pgv012245 msing90]# snmpwalk --help
USAGE: snmpwalk [OPTIONS] AGENT [OID]

  Version:  5.7.2
  Web:      http://www.net-snmp.org/
  Email:    net-snmp-coders@lists.sourceforge.net

Friday, August 24, 2018

Shell Script which uses sendmail

#!/bin/sh
#
# Generic script for forwarding Mail from Netcool/OMNIbus
#
# Parameters to be passed from Netcool/OMNIbus are;
# $1 - @Node
# $2 - @Severity
# $3 - "Message" - mail message header text
# $4 - "user" - user to receive mail
# $5 - @Summary
# $6 - @NodeAlias
#
cat <<EOF > /tmp/tmp.$$
To: $4
Subject: $3

This message refers to node $1 ($6) which has the following problem;

$5

The Severity is $2

Severity Table:
5 - Critical (Tickets)
4 - Major
3 - Minor
2 - Warning
1 - Indeterminate
0 - Clear (Resolution)

Sent by the Netcool/OMNIbus Automation system
EOF

# Find the send mail program: it is in different places on different platforms
for senddir in /usr/sbin /sbin /usr/lib /bin /usr/bin
do
        if [ -x "$senddir/sendmail" ]
        then
                break
        fi
done

# Run send mail
"$senddir/sendmail" $4 < /tmp/tmp.$$

rm /tmp/tmp.$$

Thursday, August 23, 2018

ITNM Startup Script - multiple domains

#!/bin/sh
###############################################################################
#
# chkconfig: 35 92 98
# description: Automatic startup/shutdown script for
# Netcool/Precision for IP Networks
#
### BEGIN INIT INFO
# Provides: ncp
# Required-Start: $network $sshd
# Required-Stop: $network $sshd
# X-UnitedLinux-Should-Start: portmap autofs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the ncp daemon
### END INIT INFO

# File ID:     itnm/src/process/templates/ncp_auto.sh, itnm, itnm1.1
# Version:     1.2
# Last Update: 4/20/07 14:00:21
#
# IBM Confidential
# Licensed Materials - Property of IBM
# (c) Copyright IBM Corp. 2007 All Rights Reserved.
#
###############################################################################
#
# To install this in the /etc directory, run ncp_create_control_scripts.sh
# from the installation directory as root.
#
# Usage: ncp start | stop
# Exit status: 0=success, 1=warning, 2=failure
#
###############################################################################
##  All comments here

ITNMUSER=netcool
#DOMAINLIST="NCPRD_P"
DOMAINLIST="RETAIL2_P RETAIL1_B"

# These variables are set by 'sed' in the creation script.
set_edited_vars () {
    NCHOME=/opt/ibm/tivoli/netcool
    ITNM_BIN_DIR=/opt/ibm/tivoli/netcool/precision/bin
    ITNM_CONTROL_FUNCS=/opt/ibm/tivoli/netcool/precision/bin/itnm_control_functions.sh
    ITNM_AUTO_LOG_FILE=/opt/ibm/tivoli/netcool/log/precision/boot.log
    export ITNM_AUTO_LOG_FILE
}

#########################################################################
#
#  MAIN
#
#########################################################################

set_edited_vars
. $ITNM_CONTROL_FUNCS
check_exec_exists ${ITNM_BIN_DIR}/ncp_control.sh

# Tell subordinate script that this is called from the /etc/init directory
AUTO_INIT=YES
export AUTO_INIT

if `grep "^admin=" $NCHOME/etc/itnm.cfg 1>/dev/null 2>&1`; then
   user=`grep "^admin=" $NCHOME/etc/itnm.cfg 2>/dev/null | cut -f2 -d=`
else
   user=`grep "^installer=" $NCHOME/etc/itnm.cfg 2>/dev/null | cut -f2 -d=`
fi

case "$1" in
start|stop)
        for DOMAIN in $DOMAINLIST
        do
                #echo "Starting Domain Name ....  " $DOMAIN
                su - $user -c "${ITNM_BIN_DIR}/ncp_control.sh -domain $DOMAIN $1"
        done
;;
restart|reload)
        $0 stop
        $0 start
        ;;
*)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac

exit $?

Wednesday, August 22, 2018

SNMPWALK v3


snmpwalk -v3  -l authNoPriv -u monitor -a MD5 -A pc15uck5 10.251.72.1 sysObjectID
snmpwalk -v3  -l authNoPriv -u monitor -a MD5 -A pc15uck5 172.27.132.28

R3 new - doesn't work
/usr/bin/snmpwalk -v3 -l authNoPriv -u monitor -a MD5 -A pc15uck5  10.244.52.196
snmpwalk -v3 -l authPriv -u meraki -a SHA -A pc15uck5 -x DES -X pc15uck5 10.244.52.196


[netcool@pgv01222f ~]$ /usr/bin/snmpwalk -v3 -l authPriv -u meraki -a SHA -A pc15uck5 -x DES -X pc15uck5 10.244.52.196
snmpwalk: Timeout
[netcool@pgv01222f ~]$


R3 old - works fine
/usr/bin/snmpwalk -v3 -l authNoPriv -u monitor -a MD5 -A pc15uck5  10.244.52.196

Thursday, August 2, 2018

sending snmp traps

yum install net-snmp
yum install net-snmp-utils

# snmptrap -c public -v 2c 172.26.41.189 "" 1.3.6.1.2.1.43.18.2.0.1

# snmptrap -v3 -e 0x111100000000000000000000 -u emsuser -a SHA -A  titpw4ems -x DES -X tiabpw4e 172.26.41.189:162 "" coldStart.0




- I have seen mttrapd probe didn't process these alarms because the firewalld was running and blocking the traffic