Thursday, 14 April 2011

SNMP

chkconfig snmpd on

Firewall port 161

semanage port -l  | grep snmp
sealert -a /var/log/audit/audit.log

/usr/share/snmp/mibs

yum install net-snmp*

snmptranslate -On -TB hrSystemUptime
.1.3.6.1.2.1.25.1.1
snmptranslate  -TB '.*memory.*'
UCD-SNMP-MIB::memory
HOST-RESOURCES-TYPES::hrDeviceNonVolatileMemory
HOST-RESOURCES-TYPES::hrDeviceVolatileMemory
HOST-RESOURCES-MIB::hrMemorySize
HOST-RESOURCES-TYPES::hrStorageFlashMemory
HOST-RESOURCES-TYPES::hrStorageVirtualMemory

snmptranslate  -On HOST-RESOURCES-MIB::hrMemorySize
.1.3.6.1.2.1.25.2.2

snmptranslate -Oq .1.3.6.1.2.1.25.2.2
HOST-RESOURCES-MIB::hrMemorySize



SNMPGET

When using Names always remember to use the index like this
[root@ex442-1 ~]# snmpget -v1 -c ex442 localhost ipForwarding.0

other wise

[root@ex442-1 ~]# snmpget -v1 -c ex442 localhost ipForwarding
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: IP-MIB::ipForwarding

SNMPD CONF

 #ro_versus_rw
rocommunity     lockeddown                   192.168.48.0/24                 .1
rocommunity     NOTSECRET     192.168.48.0/255.255.255.0      .1
rwcommunity     NOTGOOD

rocommunity  all 0.0.0.0 .1.3.6.1.2.1.1
rwcommunity  lockedDown 192.168.48.0/24
rwcommunity  admin localhost

#Custom Views defined here
group   demogroup       usm             demouser
view    demoview        included        .1

SNMP CONF

Use ~/.snmp/snmp.conf for settings per user level

defVersion (1|2c|3)
defCommunity public

create snmp v3 users

service snmp stop
net-snmp-config --create-snmpv3-user -ro -a password -x sharedsecret -X DES -A MD5 username

vim snmpd.conf

rouser rhr
rouser rh

#       groupName       secMod  secName
group   gr_limited           usm     limited
group   gr_unlimited          usm     unlimited

#       name           incl/excl     subtree
view    view_lm         included   .1.3.6.1.2.1.1
view    view_ul        included   .1

#               context secMod seclvl       prefix      read            write  notif
access gr_limited    ""      any       auth      exact       view_lm         none   none
access gr_unlimited   ""      any       auth      exact       view_ul        none    none

Sysstat

add alias sar='LANG=C sar' to bashrc for better sorting of date
#yum install sysstat -y

add disk stats to collecter

#vim /usr/lib/sa/sa1

        exec ${ENDIR}/sadc -d -F -L 1 1 -
else
        exec ${ENDIR}/sadc -d -F -L $* -

run 3 times to get results

#/usr/lib/sa/sa1
#/usr/lib/sa/sa1
#/usr/lib/sa/sa1

shows device names with p option
#sar -dp

Fragmentation

Check file fragmentation
#filefrag -v /filename

Check the state of a filesystem
#dumpe2fs /dev/sda1

Fragmentation can be avoided by having reserved space available on a filesystem
#tune2fs -m reserved-percentage

#tune2fs -m reserved-block-count

Filesystem Journaling

Journal Options

There are 3 possible settings for Journaling. They are ordered, journal and writeback

These can be set at mount time
#mount -o data=TYPE

ordered is the default and writes only the metadata

journal writes metadata and data at the same time

writeback is just metadata but there is no garuntee on commits

It is also possible to change the frequency of journal commits, the default is 5 seconds
#mount -o commit=30

Journal Placement

It is possible to put the journal on another device which can improve performance

remove the journal
#tune2fs -O ^has_journal /dev/sda1

Create the external journal
#mkfs -O journal_dev -b blocksize /dev/sdb1

Tell the FS to use the new journal
#tune2fs -j -J device=/dev/sdb1 /dev/sda1

RAID Performance

CHUNK

Calculate the chunk size by using iostat

#iostat -x

Device:         rrqm/s   wrqm/s   r/s   w/s             rsec/s   wsec/s    avgrq-sz avgqu-sz   await  svctm  %util
dm-0              0.00     0.00       0.00 4548.51     0.00 36388.12    40.00   203.91       44.83   0.02  10.69
Take the average request size and times it by 512 then divide by the amount of disks in the RAID array. So if you have a raid 5 with three disks you would divide by 2 as one of the disks is for parity, for example

(40*512)/1024/2=10
So the optimum chucnk size for this would be 8K because you always round down to the nearest 2 to the power. You can create the array with this chunk witht he following commamd

#mdadm -C /dev/md1 -l5 -n3 --chunk=8/dev/sd[def] -a yes


STRIDE
The optimum stride is calculated using chunk divided by block size so for the above array it will be

8/4=2

mke2fs -j -b 4096 -E stride=2 /dev/md1

HUGE PAGES

HUGE PAGES

These can be created by editing sysctl.conf and adding

vm.nr_hugepages=INTEGER

You can also use the following kernel parameter

hugepages=INTEGER

You can check the settings using the following

#cat /proc/meminfo | grep -i huge
HugePages_Total:    20
HugePages_Free:     20
HugePages_Rsvd:      0
Hugepagesize:     4096 kB

If the application uses mmap to request pages then they must be mounted as a filesystem
#mkdir /hugepages
#mount -t hugetlbfs none /hugepages

ARP CACHE

The cache can be viewed with the following command

#ip neighbor list
192.168.48.1 dev eth0 lladdr 00:50:56:c0:00:08 REACHABLE
192.168.48.190 dev eth0 lladdr 00:0c:29:5e:1c:46 REACHABLE

The cache can be flushed with this command
#ip neighbor flush dev eth0

The follwing settings can be modified
# sysctl  -a | grep "4.neigh.default.gc"
net.ipv4.neigh.default.gc_thresh3 = 1024 #This is the HARD upper limit
net.ipv4.neigh.default.gc_thresh2 = 512   #This is the SOFT upper limit
net.ipv4.neigh.default.gc_thresh1 = 128
net.ipv4.neigh.default.gc_interval = 30      #This is the garbage collection interval in seconds
net.ipv4.neigh.default.gc_stale_time = 60
You will only need to adjust the limits if you need to allow for lots of simultaneous connections