Permalink
Browse files

tools/rmaint:

  - add functionality to restart mwcollectd, download the logfile and
    reset the logfile
  • Loading branch information...
Georg Wicherski
Georg Wicherski committed Jun 28, 2010
1 parent 11a15f5 commit 9c5477f83379a1fd8b6e893771d8477a1a282cf5
Showing with 24 additions and 0 deletions.
  1. +24 −0 tools/rmaint/rmaint.py
@@ -20,7 +20,10 @@ def usage():
autoconf autoreconf; configure
build make; make install
up Check if mwcollectd is running and if not start it
restart Send SIGINT to all mwcollectd processes, then run 'up'
conf Upload configuration from local host
log Download the mwcollectd.log file from all hosts.
clearlog Empty the mwcollectd logfile on all hosts.
""" % sys.argv[0])
sys.exit(0)
@@ -108,6 +111,24 @@ def run(self):
print 'Starting on %s:' % self.name
print '\n'.join(self.execute('cd /opt/mwcollectd; ./sbin/mwcollectd -c etc/mwcollectd/mwcollectd.conf'))
class RestartThread(CheckUpThread):
def run(self):
self.execute('killall -SIGINT mwcollectd')
CheckUpThread.run(self)
class GetLogThread(SshThread):
def run(self):
sftp = self.client.open_sftp()
sftp.get('/opt/mwcollectd/var/log/mwcollectd/mwcollectd.log', 'mwcollectd-%s.log' % self.name.replace('.', '_'))
class ClearLogThread(SshThread):
def run(self):
self.execute('echo \'\' > /opt/mwcollectd/var/log/mwcollectd/mwcollectd.log')
if __name__ == '__main__':
username = getpass.getuser()
key = None
@@ -149,7 +170,10 @@ def run(self):
'autoconf': AutoconfThread,
'build': BuildThread,
'up': CheckUpThread,
'restart': RestartThread,
'conf': PushConfThread,
'log': GetLogThread,
'clearlog': ClearLogThread,
}
if action not in modes:

0 comments on commit 9c5477f

Please sign in to comment.