Skip to content

Commit

Permalink
tools/rmaint:
Browse files Browse the repository at this point in the history
  - add functionality to restart mwcollectd, download the logfile and
    reset the logfile
  • Loading branch information
Georg Wicherski committed Jun 28, 2010
1 parent 11a15f5 commit 9c5477f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tools/rmaint/rmaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9c5477f

Please sign in to comment.