Bash scripts to scan and monitor network

This article provides few simple scripts to scan and monitor network using combination of bash and ping command. Obviously, these scripts are no match to a full monitoring dedicated software like nagios but they could be useful for a small home brand networks, where implementing sophisticated monitoring system can become an overhead.

1. Scan network subnet

In this example the bash script will scan network for hosts attached to an IP address 10.1.1.1 – 255. The script will print message Node with IP: IP-address is up if ping command was successful. Feel free to modify the script to scan your hosts range.

#!/bin/bash

is_alive_ping()
{
  ping -c 1 $1 > /dev/null
  [ $? -eq 0 ] && echo Node with IP: $i is up.
}

for i in 10.1.1.{1..255}
do
is_alive_ping $i & disown
done

Execute:

./bash_ping_scan.sh

OUTPUT:

Node with IP: 10.1.1.1 is up.
Node with IP: 10.1.1.4 is up.
Node with IP: 10.1.1.9 is up.

 Continue reading "Bash scripts to scan and monitor network"

Using vimsh

egg

List information about a VM
vimsh -n -e “vmsvc/getallvms”

See a summary of the current host configuration
vimsh -n -e “hostsvc/hostsummary”

Enter maintence mode
vimsh -n -e /hostsvc/maintenance_mode_enter

Exit maintence mode
vimsh -n -e /hostsvc/maintenance_mode_exit