LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2008, 08:20 AM   #1
sun_sun
LQ Newbie
 
Registered: Nov 2007
Posts: 21

Rep: Reputation: 15
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.

thanks,
sun_sun
 
Old 02-04-2008, 10:17 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

First (unless you want to type in the passwords each time), set up passwordless SSH keys on all the servers for a user:
http://www.linuxquestions.org/linux/...ation_with_ssh

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.

Dave

Last edited by ilikejam; 02-04-2008 at 10:23 AM.
 
Old 02-04-2008, 10:26 AM   #3
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 38
snmpwalk/snmp polling on the server and a specialized script on the client that outputs the usage of that directory?
 
Old 02-09-2008, 06:37 AM   #4
sun_sun
LQ Newbie
 
Registered: Nov 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Late in saying Thanks..that worked ..

Quote:
Originally Posted by ilikejam View Post
Hi.

First (unless you want to type in the passwords each time), set up passwordless SSH keys on all the servers for a user:
http://www.linuxquestions.org/linux/...ation_with_ssh

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.

Dave
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to securing /tmp , /var/tmp and /dev/shm hackintosh Linux - Security 7 10-17-2007 11:26 PM
samba/network issue. copies files to /var/tmp kazuma333 Linux - Networking 0 03-18-2007 11:26 PM
kde, /tmp, /var/tmp and all that garba Linux - Software 4 06-17-2005 12:31 PM
/tmp /var/tmp Manuel-H Linux - General 3 04-23-2005 05:30 AM
Newbie question - /tmp /var/tmp Mr happy Linux - Security 3 01-27-2003 01:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration