Nagios DNS A record check

Domain adresini guncelleyip, 2 adet A kaydinin cevap verdiginin kontrolunu yapan nagios scripti.

#!/bin/bash
# a/b site a record dns check
cihdomain=www.vmninja.com
cihresult=`dig A $ggdomain +multiline +noall +answer +nocmd @8.8.8.8 | awk '/IN A ([[:digit:]]+\.){3}/{gsub(/\.$/,"",$1); print $1","$NF}' |grep -i 11`

if [[ "$cihresult" == *11* ]] 
    then 
                echo -e "a/b dns ok \n$cihresult"
                exit 2
        else
                echo -e "a/b dns not ok \n$cihresult"
                exit 0
fi

Port scan python script with nmap module

Python modülünü kullanarak bir port tarama aracı;

import nmap

def nmap_scan(target, ports=None):
scanner = nmap.PortScanner()
if ports:
scanner.scan(target, ports=ports)
else:
scanner.scan(target)

for host in scanner.all_hosts():
    print(f'Host: {host}')
    for proto in scanner[host].all_protocols():
        print(f'Protocol: {proto}')
        ports = scanner[host][proto].keys()
        for port in ports:
            state = scanner[host][proto][port]['state']
            print(f'Port: {port}\tState: {state}')

if name == 'main':
target_host = input("Enter the target IP address: ")
port_range = input("Enter the port range (e.g., '1-1000', or leave empty for default): ")
if port_range:
start_port, end_port = map(int, port_range.split('-'))
ports = f'{start_port}-{end_port}'
else:
ports = None
nmap_scan(target_host, ports)

Bu kod, nmap modülünü kullanarak daha gelişmiş bir port tarama aracı sağlar. nmap.PortScanner() sınıfını kullanarak bir tarama nesnesi oluşturulur ve scan() yöntemi hedef IP adresi ve (opsiyonel olarak) bir port aralığıyla çağrılır. Sonuçlar taranan portlar ve durumları hakkında bilgi içerir ve bu bilgiler ekrana yazdırılır.

MacOS host file editor

  1. Gas Mask (Mac):
    • Gas Mask is a simple hosts file manager for macOS with a graphical interface.
    • It allows you to edit, update, enable, or disable hosts entries easily.
    • You can download it from: Gas Mask
  2. Hosts (Mac):
    • Hosts is another hosts file manager for macOS that provides a clean and minimalistic interface.
    • It allows you to toggle between different hosts files easily.
    • You can download it from: Hosts
  3. Hosts File Editor (Windows, Mac, Linux):
    • Hosts File Editor is a cross-platform tool that allows you to easily manage your hosts file.
    • It provides a simple GUI for editing, adding, and removing entries.
    • You can download it from: Hosts File Editor
  4. Text Editors (Any Platform):
    • You can use any text editor with elevated privileges to manually edit the hosts file.
    • For Mac, you can use the Terminal and a text editor like nano or vim with sudo to edit the hosts file directly.

SAN Brocade Firmware commit failed – Firmwarecommit failed. (0x1a)

Workaround 1:

Run command supportsave -R.

The -R option removes all cores files on the Control Processor (CP) and Blade Processor (BP). This option cannot be used with any other options.

Note: On director switches run this command on each CP.

Workaround 2:

Run cleanup utility.

Note: This utility will check for any obsoleted files that are in the file system that do not belong to any package, and will then remove them. These files may be resulted from firmwareCommit command. The list of directories it checks is in /etc/cleanup.conf. This utility can only be run from root account. Be aware the tool will remove all unauthorized code under following directories on BOTH partitions:        

/bin
/lib
/fabos
/root
/usr
/core_files

 

  1. Validate space by running df -kh  as root
  2. Run du -h /mnt/xx/xx to verify space usage of a directory.

Example:

Brocade:root>du -h /mnt/var/log/mstatdir/*

423M   /mnt/var/log/mstatdir/memorystatus

  1. If  a directory has a huge space (for example:/mnt/var/log/mstatdir/memorystatus):
    1. Run supportsave -R command
    2. Run  cleanup command
    3. Check again  /mnt/var/log/mstatdir to see if the memorystatus file(s) are still there.

Note: It should have been several memorystatus files, each generated on a daily basis. If it is only 1 huge memorystatus file, again that will confirm the out of space issue seen on FOS as a result of the log rotation mechanism not working (Brocade Defect DEFECT000543727)

  1. If the issue persists, perform the following:
  •  Delete memorystatus file from /mnt/var/log/mstatdir on the second partition

Example:

Brocade:root>rm /mnt/var/log/mstatdir/memorystatus

  •  Check with df /mnt command to see if space has been regained.
  1. If space is not regained, it would mean that there is a process that has memorystatus file open and the process needs to close the file
  • Run fuser /mnt/var/log/mstatdir command to find out if a process has the file open.

Snapmirror Throttling (7mode)

Ozellikle ayni anda planlanmis snapmirror var ise bant genisligini yonetmenize yardimci olacak bir komut dizisi.

filer1> snapmirror initialize -k 5000 -S source_filer:source_vol destination_filer:destination_vol

Bu komut dizisini snapmirror.conf’ eklenmis ornegi:

source_filer:source_vol destination_filer:destination_vol kbs=5000 0 21 * *

ESXi nfs datastore komut satırından bağlanmak

Bu komutları ESXi 5.5’te denedim ve kullanıyorum.

NFS mount alanların listesi;

[homesxi01] ~ # esxcli storage nfs list (esxcfg-nas -l)

Volume Name Host Share Accessible Mounted Read-Only Hardware Acceleration
VMROOTs01 192.168.0.100 /vol/VMROOTs01 true true false Not Supported

Yeni bir nfs datastore eklemek için;

[homesxi01] ~ # esxcli storage nfs add -H 192.168.0.100 -s /vol/VMROOTs01 -v VMROOTs01 (esxcfg-nas -a -o 192.168.0.100 -s /vol/VMROOTs01 VMROOTs01)

Connecting to NAS volume: VMROOTs01
VMROOTs01 created and connected.

Netapp 7mode stats komutu

Yakın zamanda işimi kolaylaştıran stats komutunun kullanımı;

Aşağıdak görüldüğü gibi toplayabileceğimiz statslar. Tabiki bunlarında alt kırılımları bulunuyor.

homelab01> stats list objects

Objects:

cpx

rquota

aggregate

audit_ng

cifs

disk

dump

ext_cache_obj

ext_cache

fcp

hostadapter

wafl_hya_per_aggr

wafl_hya_sizer

wafl_hya_sizer_vvol

wafl_hya_sizer_interval

ifnet

iscsi_conn

iscsi_lif

iscsi

logical_replication_destination

logical_replication_source

lun

ndmp

nfsv3

nfsv4

path

processor

qtree

quota

raid

spinhi

system

target_port

target

vfiler

volume

Beni en cok ilgilendiren volume ile ilgili stat’lar.

homelab01> stats list counters volume

Counters for object name: volume

instance_name

node_name

node_uuid

process_name

vserver_name

vserver_uuid

avg_latency

total_ops

read_data

read_latency

total_protocol_read_latency

read_ops

write_data

write_latency

total_protocol_write_latency

write_ops

other_latency

total_protocol_other_latency

other_ops

nfs_protocol_read_latency

nfs_protocol_write_latency

nfs_protocol_other_latency

cifs_protocol_read_latency

cifs_protocol_write_latency

cifs_protocol_other_latency

fcp_protocol_read_latency

fcp_protocol_write_latency

fcp_protocol_other_latency

iscsi_protocol_read_latency

iscsi_protocol_write_latency

iscsi_protocol_other_latency

spinvfs_protocol_read_latency

spinvfs_protocol_write_latency

spinvfs_protocol_other_latency

Storage’ta bulunan volume listesi;

homelab01> stats list instances volume

Instances for object name: volume

vol0

nfstest01

Volume ile ilgili stats’ları toplamaya başlıyalım. Stats başlattığımızda açık unutmamız gerekiyor. Performans sorununa yol açabilir.

homelab01> stats start -I volstats volume:nfstest01

Volume için toplanan stats’lara inceleyelim. Volume hakkında detaylar uzun uzun gelecektir.

homelab01> stats show -I volstats

StatisticsID: volstats

volume:nfstest01:instance_name:nfstest01

volume:nfstest01:node_name:

volume:nfstest01:node_uuid:

volume:nfstest01:process_name:

volume:nfstest01:vserver_name:

volume:nfstest01:vserver_uuid:

volume:nfstest01:avg_latency:1254.66us

volume:nfstest01:total_ops:143/s

volume:nfstest01:read_data:412547b/s

volume:nfstest01:read_latency:3382.53us

Stats ları durdurmak için;

homelab01> stats stop -I volstats

Shellshock vulnerabilities for vmware

VMware’in linux appliance shellshock’tan etkileniyor. ESXi 4 sürümü bash açığını dün gece patch duyurdu. Eğer VMware Update Manager kullanıyorsanız. Kolayca hostlarınıza updateleri uygulayabilirsiniz. ESXi 5.x sürümleri bu açıktan etkilenmiyor. Detayları aşağıdaki linkte bulabilirsiniz.

http://www.vmware.com/security/advisories/VMSA-2014-0010.html

http://blogs.vmware.com/security/2014/09/new-vmware-security-advisory-vmsa-2014-0010-shellshock.html

ShellShock hakkında detayı aşağıdaki linkten edinebilirsiniz.

https://blog.cloudflare.com/inside-shellshock/

shellshock_Linux_check.jpeg

Add static route on Netapp

Netapp filer’in üzerine static route eklemek;

filer01> route
usage:
route [-fn] add [inet] [host|net] <destination>[&netmask|/prefixlen] <gateway> <metric>
route [-fn] add [inet] default <gateway> <metric>
route [-fn] delete [inet] [host|net] <destination>
route [-fn] delete [inet] default
route -s

Örnek;

route add inet host 10.10.10.202 10.10.5.222 1

Riverbad yada alternatif wan optimizer kullanırsanız, static route yazmak gerekebiliyor.

ESXi multipath policy değiştirme

ESXi storage’tan gelen fiber(SAN) disk’lerin multipath policy ayarlarını aşağıdaki gibi değiştirebilirsiniz.
Genelde path fixed olarak kullanılır ama önerilen round robin olarak kullanılması. Bu seçim tamamen sizin oluşturacağınız alt yapı ile ilgilidir.

Listemizi oluşturup hızlıdan path’leri round robin yapalım;

# esxcli storage nmp device list

naa.60a98000000e0f000c0a000c0f000000 (naa. ile başlıyalan satırlar bizim için önemli)
Device Display Name: NETAPP Fibre Channel Disk (naa.60a98000000e0f000c0a000c0f000000)
Storage Array Type: VMW_SATP_DEFAULT_AA
Storage Array Type Device Config: SATP VMW_SATP_DEFAULT_AA does not support device configuration.
Path Selection Policy: VMW_PSP_FIXED (bu alanı VMW_PSP_RR yapacağız)
Path Selection Policy Device Config: {preferred=vmhba2:C0:T4:L8;current=vmhba2:C0:T4:L8}
Path Selection Policy Device Custom Config:
Working Paths: vmhba2:C0:T4:L8
Is Local SAS Device: false
Is Boot USB Device: false

# esxcli storage nmp device set –device=naa.60a98000000e0f000c0a000c0f000000 –psp=VMW_PSP_RR

tekrar device listesini aldığımızda round robine döndüğünü görebilirsiniz. Bu işlemleri yaptığınız ESXi host’unuzu reboot etmeniz gerekmektedir.

 # esxcli storage nmp device list

naa.60a98000000e0f000c0a000c0f000000
Device Display Name: NETAPP Fibre Channel Disk (naa.60a98000000e0f000c0a000c0f000000)
Storage Array Type: VMW_SATP_ALUA
Storage Array Type Device Config: {implicit_support=on;explicit_support=off; explicit_allow=on;alua_followover=on;{TPG_id=3,TPG_state=ANO}{TPG_id=2,TPG_state=AO}}
Path Selection Policy: VMW_PSP_RR
Path Selection Policy Device Config: {policy=rr,iops=1000,bytes=10485760,useANO=0;lastPathIndex=2: NumIOsPending=0,numBytesPending=0}
Path Selection Policy Device Custom Config:
Working Paths: vmhba2:C0:T3:L12, vmhba2:C0:T4:L12, vmhba1:C0:T3:L12, vmhba2:C0:T5:L12, vmhba1:C0:T4:L12, vmhba1:C0:T5:L12
Is Local SAS Device: false
Is Boot USB Device: false