calculate /var/tmp usage for different machines on network
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
calculate /var/tmp usage for different machines on network
hi,
i want to list the /var/tmp usage for each machine on the network, through a script.
basically, whenever the script is run, it should tell me the desired thing.
but, how do i calculate this of all the machines on the network. i have 3 platforms(2 different versions of linux(linux, linux redhat), and one another) which have many machines.
any idea how can i proceed on this would be helpful.
Then create a list of hostnames you want to query (one hostname per line), and save it as 'hostlist'.
Here's the script I use to do this sort of thing. I call it 'comget'.
Code:
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Not enough arguments"
exit 1
fi
#----Change these to suit----
USERNAME=YourUserNameInHere
HOSTLIST=hostlist
#----------------------------
COMMAND="$1"
COMSANE=`echo "$COMMAND" | sed 's/[^a-zA-Z0-9.,]/-/g'`
SCRATCH="comget.$COMSANE"
if ! mkdir "$SCRATCH"
then
echo "Could not create scratch directory $SCRATCH"
exit 1
fi
NOSSH=""
for go in `cat "$HOSTLIST"`
do
ssh -o Compression=yes -o PreferredAuthentications=publickey $USERNAME@$go "$COMMAND" > "$SCRATCH/$go" 2> $SCRATCH/$go".err &
done
wait
find "$SCRATCH" -type f -size 0 -name '*.err' -exec rm {} \;
You can run the script with any command as the argument, and it'll run that command on every host in the hostlist file. e.g.
Code:
./comget 'df -k /var'
You'll end up with a directory called comget.XXXXXXX, depending on the command run, which will contain a file (and possibly a .err file too) for each host.
Then create a list of hostnames you want to query (one hostname per line), and save it as 'hostlist'.
Here's the script I use to do this sort of thing. I call it 'comget'.
Code:
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Not enough arguments"
exit 1
fi
#----Change these to suit----
USERNAME=YourUserNameInHere
HOSTLIST=hostlist
#----------------------------
COMMAND="$1"
COMSANE=`echo "$COMMAND" | sed 's/[^a-zA-Z0-9.,]/-/g'`
SCRATCH="comget.$COMSANE"
if ! mkdir "$SCRATCH"
then
echo "Could not create scratch directory $SCRATCH"
exit 1
fi
NOSSH=""
for go in `cat "$HOSTLIST"`
do
ssh -o Compression=yes -o PreferredAuthentications=publickey $USERNAME@$go "$COMMAND" > "$SCRATCH/$go" 2> $SCRATCH/$go".err &
done
wait
find "$SCRATCH" -type f -size 0 -name '*.err' -exec rm {} \;
You can run the script with any command as the argument, and it'll run that command on every host in the hostlist file. e.g.
Code:
./comget 'df -k /var'
You'll end up with a directory called comget.XXXXXXX, depending on the command run, which will contain a file (and possibly a .err file too) for each host.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.