LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   check disk space of multiple computers in a network (https://www.linuxquestions.org/questions/linux-newbie-8/check-disk-space-of-multiple-computers-in-a-network-4175446538/)

linuxque 01-21-2013 01:08 AM

check disk space of multiple computers in a network
 
Hi,
Can I get the output of df -h of multiple systems in the network by a command or a script rather than checking each system.
For eg: Specifying the range of ip addresses viz..192.168.1.x to 192.168.1.x ...something like that.

Thanks,
Linuxque

tsester 01-21-2013 02:54 AM

to get remote df you can do : ssh $REMOTE_IP $COMMAND, for example ssh 192.168.0.2 df -h

shivaa 01-21-2013 05:01 AM

For just one time checking and if you can enter password each time with ssh command, you can:
Code:

#!/bin/bash
IPLIST=/tmp/listofips # Contains a list of ip addresses, each per line
RESULTFILE=/tmp/dfresult.txt
while read -r ip
do
echo "$ip" >> $RESULTFILE
echo "-------------------" >> $RESULTFILE
ssh username@$ip "df -h" >> $RESULTFILE # It will ask for username's password everytime it executes
echo "-------------------" >> $RESULTFILE
done < $IPLIST

On the other hand, if you want to do it daily or periodically (like automation or cronjob), you better go with concept of password less login on those system and then execute this script.

unSpawn 01-22-2013 05:51 AM

Wheel reinvention-wise there's tools dealing with ^whatever.on.*multiple hosts like ClusterSSH, Dsh, Fanout / Fanterm, Tentakel, Shocto, SwitchTower, MUC, Parallel SSH and RGANG. Going a whole different route getting stats without even requiring SSH or password-less logins is possible too with a simple (X)inetd-based script or using SNMP.

btmiller 01-22-2013 12:15 PM

Additionally, one can simply set up a network monitoring program such as Nagios or Zenoss to check the status and health of multiple computers, send alerts, etc. Ultimately, this is the most scalable solution, but it requires a bit more work up front to get going.

jmc1987 01-22-2013 12:45 PM

+1 nagios. I'm running a few servers (backup server, DNS servers, web Servers, Monitor servers) and I have 1 simple login to nagios which gives me the load, diskspace, login users, etc on a charge through nrpe plugin.

its simple to install but may be a little tough to configure at first but once you understand it becomes easy and highly configurable. It will all email notifications such as low diskspace. nagios doesn't use much resources at all either.


All times are GMT -5. The time now is 07:08 PM.