Skip to main content

Posts

Showing posts from August, 2012

ICMP Ping a Class C Network Subnet on Unix or Linux and return corresponding MAC Address

Ping a subnet by defining first three octets and return corresponding MAC Addresses for any IP addresses that respond to ICMP Ping on directly attached network.

You may have come across this requirement but I use it very often to update the inventory and status of my network. Something I maintain and find very useful to audit the network, find anomilies and know what is allocated to what. Also useful if you manage MAC Address filtering on your Router.


------------------- Begin of script ./multiping ----------------------

#!/bin/bash
echo "Usage: ./multiping [subnet e.g. 192.168.1]"
CURR=1
SUBNET="$1"
FILE=multiping.log

touch $FILE

function multiping() {
ping -c1 -t1 $SUBNET.$CURR 2>&1 >/dev/null
if [ "$?" -eq "0" ]; then
echo $(arp $SUBNET.$CURR) >> $FILE
fi
}

while [ $CURR -lt 255 ] ; do
multiping &
let CURR=$CURR+1
let MOD=$CURR%100
#this code is for prevent the saturation of the executable connections
if [[ $MOD -eq 0 ]]; then
wait
fi
done
wait
ca…

Linux Stress Testing Tips and Tricks

Disk Stress & Fault Test

Create a 1GB file with 1000 x 1MB blocks.
localhost:/$ dd if=/dev/zero of=/tmp/temp-file.tmp bs=1M count=1000

Output expected with time it takes and disk write speed in MB/s
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 6.83976 s, 153 MB/s

Now you can run a md5sum check to see if the infomration in memory and disk appears correctly and if all md5sums identify any mismatch which would indicate a faulty disk or RAM.



localhost:/$ for i in {1..5}; do md5sum /tmp/temp-file.tmp; done

Output usualyl expected in below format
e5c834fbdaa6bfd8eac5eb9404eefdd4  /tmp/temp-file.tmp
e5c834fbdaa6bfd8eac5eb9404eefdd4  /tmp/temp-file.tmp
e5c834fbdaa6bfd8eac5eb9404eefdd4  /tmp/temp-file.tmp
e5c834fbdaa6bfd8eac5eb9404eefdd4  /tmp/temp-file.tmp
e5c834fbdaa6bfd8eac5eb9404eefdd4  /tmp/temp-file.tmp



CPU Stress Test

Output a string repeatedly until killed and direct the output to nothing will consume very high cpu.
yes I am here >/dev/null

If above one process doesn'…