[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: doing jobs at an remote machin, how to do it in an cshell scripts ?



Use the following (small) c program which will generate an xml feeed
with pretty much everything you need to know about each machine.. very
easy to parse to see which is "fastest" / etc.

The output looks like this :

http://dev1.netkinetics.net/xmlpulse/xmlpulse.xml

The source itself is here

http://dev1.netkinetics.net/xmlpulse/xmlpulse.c

Easily modified to spit out variables in such a way that a shell script
can simply import them, you'd need to use a language that allowed nested
arrays should you want to include the network info.

To use it, just call it via ssh with a key-pair setup (or your favorite
rpc method). 

It was written to emulate the popular phpsysinfo script .. this does
well running every minute via cron , i.e.

/usr/sbin/xmlpulse > /var/www/htdocs/status/status.xml

gcc -o /usr/sbin/xmlpulse xmlpulse.c && strip /usr/sbin/xmlpulse to
compile, resulting binary is only 7.8k .. very handy :) PHP compiled
typically with gd and friends is 12M.

A note, "Loadprec" is the 1 5 and 15 minute loads as found, # of
processes in queue verses cpu time spent on each, a little more precise
than 1.23 0.01, but both are outputted for ease. Its just the value
before dividing by 65536 to get the human readable averages. Since this
was built for cluster monitoring, that precision is needed as a tie
breaker to determine the fastest node. 

Better explained by this code snippet :

printf( "    <loadprec>%.1d %.1d %.1d</loadprec>\n",
		s_info.loads[0],
		s_info.loads[1],
		s_info.loads[2] );
printf( "    <loadavg>%.2f %.2f %.2f</loadavg>\n",
                (float)s_info.loads[0] / 65536,
                (float)s_info.loads[1] / 65536,
                (float)s_info.loads[2] / 65536 );


Bash loves whole numbers, so I put the floats in another tag. Made
sense. loadprec is the tag you'd be most interested in along with swap.

When coupled with lighttpd + ssl it makes a great network monitor that
doesn't consume much in the way of resources. Just have 1 management
server collect the data each minute from your "hive" so you can make
automated decisions centrally. Parse XML with your favorite xml
parser :)

Hope you find it useful. I have a *ton* of tools we're very shortly
going to be donating to the public domain via this list that solve these
sorts of problems. All were developed and in use on Debian systems, so I
figured this list is the best place to "let them out" for testing and
adoption.

Best,
-Tim

On Sun, 2006-10-22 at 23:29 -0500, Ron Johnson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Well, you *can't* run local binaries on a remote machine.
> 
> Maybe you could rcp the local script to the remote machine and then
> execute it.
> 
> On 10/22/06 22:26, Aidan Shaw wrote:
> > Thank you Ron !
> > definitely, the resean I want to ask this question is that, we have 50
> > linux
> > computers
> > When I want to run an CPU intensive job, I need to find the load average of
> > each machine first. surpose remotePC05's load is very low, then I log on to
> > that machine to do the job.
> > 
> > is I login to RemotePC05 manualy,   PC05/bin/csh  ...somescripts.csh, it do
> > as I espected.
> > 
> > the problem how can I write an script, execute it in local computer,  the
> > scripts automaticly login  to remotePC05 and run an task on remotePC05
> > 
> > 
> > 
> > 
> > On 10/18/06, Ron Johnson <ron.l.johnson@cox.net> wrote:
> >>
> > On 10/18/06 07:59, Aidan Shaw wrote:
> >> Hi List
> > 
> >> I want to write a simple c-shell scripts whick will performe the
> > following
> >> task:
> > 
> >> 1. remote login to an machine named "RemotePC05"
> >>   rsh  RemotePC05   ( no passward is needed in our network )
> > 
> >> 2. at RemotePC05, I wnat do several things, suck as  du -sh
> >> /pathto/dirname;  touch filename
> > 
> >> 3. exit RemotePC05, and come back to the terminal I evoke this scripts.
> > 
> > 
> > 
> >> Of couse I do some homework before I aske in this list. I can do the
> > job
> > by
> >> writing an simple Makefile
> > 
> >> ------------------------------------
> >> 05:
> >>     @rsh RemotePC05 " touch  filename"
> >> --------------------------------------
> > 
> > 
> >> the problem is, I need an pretty and consice scripts in c-shell. can
> >> anybody
> >> help me?
> > 
> >> Any suggestion is welcom.
> > 
> > the csh interpreter would have to be on RemotePC05, as would the
> > script and you'd do something like:
> >    @rsh RemotePC05 /bin/csh /usr/local/bin/some.script.csh
> > 
> > But then the same script would have to be on each machine.
> 
> - --
> Ron Johnson, Jr.
> Jefferson LA  USA
> 
> Is "common sense" really valid?
> For example, it is "common sense" to white-power racists that
> whites are superior to blacks, and that those with brown skins
> are mud people.
> However, that "common sense" is obviously wrong.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (GNU/Linux)
> 
> iD8DBQFFPEU/S9HxQb37XmcRAsf/AKCyuXYZxWP0dahSqt6dz/FPS6M0rwCfS68Y
> +szy8dgvK4Ep232wsTtni1A=
> =I1Ep
> -----END PGP SIGNATURE-----
> 
> 



Reply to: