You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more
I'd normally claim to know what I'm doing with Linux scripting, but stumped by this and not sure what to google. I'd like to run a script on my client which interrogates something (another script?) on the server to find out some information about running processes. Is there any way to handle communications between different machines to do this with Linux shell scripting, or do I have to resort to C code and sockets (or AJAX, PHP, JQuery etc. - is it possible to send an AJAX request from a Linux shell script?)
I'm kind of thinking that AJAX / PHP might be the way to go - I'm familiar enough with PHP to be able to do the server side of things, though would presumably have to run a web server which I'd rather not. This is also dependent on being able to make the AJAX request from the client script.
Thanks for any help!
[url= http://www.thegeekstuff.com/2012/04/nc-command-examples/ ] Could nc be what you want?[/url]
Thanks - had forgotten about that - it might do what I want. Certainly what I'm after is very similar to the functionality that provides, creating a socket connection from a script.
I don't really know what you're up to, but if you have SSH keys all set up, then you can do
ssh server-hostname command
to run a command on a remote machine and it'll dump it in the client terminal
E.g. For me to list processes on the NAS on my home network is
ssh nas.local ps aux
EDIT: You don't [i]need[/i] to set up SSH keys, you can type in a password if you want...
I'd agree. The simplest solution is use ssh to run a remote script and capture the output.
I use the 'expect' command to do jobs like that, although chambord's suggestion is possibly more straightforward.
doh - why didn't I think of that - the ssh ps example is exactly what I want (might as well parse it locally). I knew there was an obvious answer! Thanks all.
...oh and in case anybody is interested I'm trying to do manual load balancing by checking the number of processes running on each server and starting a session on the one with the least.
The ssh suggestion is the way to go, as everyone else has said.
This has reminded me of how useful nc is. Back when I used to do firewall work, it was always handy for proving a port was open.
Are you going to incorporate something like top to see which machine is heavily loaded, too? Will process counting be enough? (Are you looking for particular instances of a process, or all processes?)
Just curious.
I bet if you just round robin, you'd get pretty much the same effect.
Even with our badass F5's, for the most part we just send a session to alternate servers. Load balancing is more useful for spreading availability, not load, if you see what I mean.
If it's for long running monitoring purposes, take a look at Splunk ( http://www.splunk.com/). Beautiful dashboards and free for 500MB of data a day.
I use the Splunk client on my raspberry pi.
setup SNMP
Clearly I should have given more detail. This is for a thin client system running in the local school. Currently we have two servers each serving part of the school, but sometimes run into problems with one of the servers getting overloaded (clearly we can't afford to just throw more processing at it). Have been looking into alternative VM software which provides clustering, but none of them seem to provide the functionality of our current system (well the paid for ones might, but we need something free), hence thinking of doing it manually using our current server software.
Therefore I'm only looking for the number of VM processes currently running (top wouldn't help much as I'm not interested in the current load, but the potential load from the number of concurrent VMs - typically new VM sessions get started when other sessions are idle). Can't really just alternate stuff on the servers, as each client only ever fires up a single process and I don't know which ones will get turned on - though as a first step to improve the current system we're going to alternate them physically which should work fairly well - as suggested we're also after improved availability.
Hopefully I'm not quite as daft as it would seem from not remembering I could do what I wanted using ps.
I suppose just in case I might as well mention the functionality most VM server software doesn't seem to provide. We have a "gold" VM image which is the only one which can be modified. The gold image is only run when we want to change something - in normal use all VMs are created dynamically from the gold image, so that any changes (kids messing with stuff, viruses etc.) get reverted when the VM is restarted. I'm surprised that this doesn't seem to be a widely available option as I'd have thought it is the sort of thing people use VMs for - everything else I've tried only allows you to manually clone VMs and doesn't have an option for them to be immutable.
I'm open to suggestions for (free) software which provides this dynamic VM creation functionality along with clustering.