fab-user
[Top][All Lists]
Advanced

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

[Fab-user] fabric question


From: Tim Leek
Subject: [Fab-user] fabric question
Date: Sun, 8 Sep 2013 14:16:50 -0400

Hi.  I've put together some useful scripts with fabric and am liking it.  But ... I can't figure out how to do the following.

I want to log in to a bunch of remote servers and determine if a particular process is running on each.  Then, aggregate the results.  27% of the servers are running the process.  or server1 and server13 seem to have lost the process.  That kind of thing. 

I'd have thought I'd do something like the following.  But perhaps I am very confused.  This completely fails.  "fab check_servers" seems to be asking what host I want to run it on.


Help?


num_servers_running

@hosts(servers)
def check_server():

  pids = run("ps auwx | grep service | grep -v grep | awk '{print $2}'")
  if pids != []:
    num_servers_running += 1  

def check_servers()
  global num_servers_running
  num_servers_running=0
  check_servers()
  print "%d servers running" % num_servers_running

--
When  I see an adult on a bicycle, I do not despair for the future of the human race. - H. G.Wells


reply via email to

[Prev in Thread] Current Thread [Next in Thread]