How to get info about all the nodes in the network via SSH ?
Logic:
1. Checking if the host is alive.
2. Getting info about them, via remote commands.
Steps:
1. Prepare password free SSH access.
2. Make a simple script to get host info.
Prepare password free SSH access:
$ssh-copy-id user@host
or
Make a simple script to get host info:
Step 1. Get the local ip say for eth0.
Step 2. Loop the range of ip and check if the host is alive.
Step 3. Use ssh to getinfo from /proc
Code
#!/bin/bash user=root getNodeinfo() { #Get the ip address for the range ip=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' | cut -d"." -f1,2,3) # ping test and list the hosts and echo the info for range in $ip ; do ping -c 1 -w 1 $ip > /dev/null 2> /dev/null >> /tmp/pinglog &&[ $? -eq 0 ] ; echo "Node $range is up" && echo "More info about the machine" ; echo "Kernel:$(ssh $user@$range cat /proc/version)" && echo "CPU info:$(ssh $user@$range cat /proc/cpuinfo )" && echo "Mem info:$(ssh $user@$range cat /proc/meminfo)" && echo "Release:$(ssh $user@$range lsb_release -a)" done }
Got better method? Give your idea
Recent blog posts
- watir-webdriver web inspector
- gem list to gemfile
- Packing ruby2.0 on debian.
- Made it into The Guinness Book!
- to_h in ruby 2.0
- Filter elements by pattern jQuery.
- Better HTML password fields for mobile ?
- Grayscale image when user offline
- nth-child CSS pseudo-class Christmas colors
- EventEmitter in nodejs