Archive for August, 2008

SNMP Basic Configuration

August 27, 2008

The following link contains the very basic configuration for snmp to work……

Installing Net-SNMP

Set your PATH.

$ export PATH=$PATH:/usr/ccs/bin:/usr/local/bin:/usr/sfw/bin
Stop and disable Sun’s SNMP.

svcadm disable svc:/application/management/snmpdx:default

svcadm disable svc:/application/management/sma:default

svcadm disable svc:/application/management/dmi:default
# mv /etc/rc3.d/K76snmpdx /etc/rc3.d/S76snmpdx

Edit the /etc/services file and change the existing SNMP entry to reflect the following:

net-snmpd 161/udp
Download and install Net-SNMP.

$ wget

$ gunzip -c net-snmp-5.3.1.tar.gz | tar -xvf –

$ cd net-snmp-5.3.1

$ ./configure –with-mib-modules=”host disman/event-mib ucd-snmp/diskio smux agentx mibII/mta_sendmail” –with-cc=gcc
You will be prompted with series of questions when you run the configure. Use SNMP version 1 when prompted and you can use the defaults for the rest of the questions. Once you have answered all the questions and completed the configure, complete the Net-SNMP install.

$ make

# make install

Now Create the /usr/local/share/snmp/snmpd.conf Net-SNMP configuration file running snmpconf command.
Add Net-SNMP to the Service Management Facility (SMF) by creating the /var/svc/manifest/network/net-snmp.xml Net-SNMP manifest, which defines what services are required for Net-SNMP to run.[collect the net-snmp.xml file from any host where SNMP already configured]

# chown root:sys /var/svc/manifest/network/net-snmp.xml
# chmod 444 /var/svc/manifest/network/net-snmp.xml

Finally, Create the /lib/svc/method/svc-net-snmp SMF method file, which is used to start the Net-SNMP service.

       . /lib/svc/share/
      # Start processes required for snmpd
      if [ -x /usr/local/sbin/snmpd ]; then
          echo "snmpd is missing or not executable."
          exit $SMF_EXIT_ERR_CONFIG
      exit $SMF_EXIT_OK

Set the appropriate ownership and permissions on the method file.

# chown root:bin /lib/svc/method/svc-net-snmp
# chmod 555 /lib/svc/method/svc-net-snmp

Validate the manifest file and import the new net-snmp service.

# svccfg validate /var/svc/manifest/network/net-snmp.xml
# svccfg import /var/svc/manifest/network/net-snmp.xml

Verify the service is installed.

# svcs net-snmp
STATE          STIME    FMRI
disabled       11:02:56 svc:/system/net-snmp:default

Start the Net-SNMP ervice.

# svcadm enable net-snmp
# svcs net-snmp
STATE          STIME    FMRI
online         11:05:38 svc:/system/net-snmp:default
 Created a /etc/rc3.d/S78net-snmp startup script
 with the following in it:
  # /etc/rc3.d/S78net-snmp
  # pkill has moved over the years so we need to find it
  X=`which pkill`
  # /etc/rc3.d/S78net-snmp
  # pkill has moved over the years so we need to find it
  X=`which pkill`
  case "$1" in
        $X -TERM -x -u 0 snmpd
        echo "Usage: $0 { start | stop }"
        exit 1
  exit 0
Then I did a "chmod 744 /etc/rc3.d/S78net-snmp"
I killed the running instance of snmpd and then ran
   "/etc/rc3.d/S78net-snmp start"
to start it up again.

SNMP quick commands-
Testing your Configuration
snmpwalk localhost -c public -v1

Testing Remote host Configuration
snmpwalk -v 2c -c public remotemachineipaddress system

Testing SNMP status of localhost
snmpstatus -c public localhost -v2c

Testing SNMP tables
snmptable -v 2c -c public -Os localhost sysORTable

Basic diagonsis commands

August 8, 2008

Basic diagnosis commands in solaris and in linux

1. To check icmp request

ping -s hostname (Solaris)

2. To view load, cpu usage and memory usage

top and press M (Linux)

prstat or prstat -a (Solaris)

ps -eo pcpu,pid,user,args| grep process | sort -r -k1

3. To view size of physical memory

free -m

prtconf -pv | grep Memory

4. To view cpu information

more /proc/cpuinfo


5. To view info about particular port or open session on a port or routing table

netstat -ntpl [linux]

netstat -f inet -an|grep LISTEN [view the list of port open on the host]

netstat -an| grep ‘ESTABLISHED’ [view different conn established on different port]

netstat -an| grep ‘ESTABLISHED’| grep ‘ip.port’ [same as above]

netstat -nr [view routing table]

6. To check wheter port is alive or not

telnet ip port

7. To compress or uncompess a file

gzip filename

gunzip -c file.gz| tar xvf –

tar zxf file.tar.gz or gtar zxf file.tar.gz

8. To determine route of a request

traceroute <ip or hostname>

9. To view a particular process is running or not and its argument

ps -ef | grep process

pargs <PID>

10. Remove or replace with find

find . -name ".mp3" -exec rm -f {} \; [find the .mp3 file and then remove them]

find ./ -name ‘*.clm’ -exec mv {} {}\.txt \; [find all .clm file & then move all to .txt]

11. Matching pattern using grep

grep abc /etc/passwd [match whether ‘abc’ exists or not]

grep -R -l ‘clamav’ /usr/share/doc [List the file names of all files that contains clamav under /usr/share/doc ]

grep "2008-07-17\ 13:[1-5][0-9]:[0-5][0-9]" [Matching lines using regular expression]