convenience, maintenance scripts
authorStephen Soltesz <soltesz@cs.princeton.edu>
Fri, 12 Jun 2009 19:17:01 +0000 (19:17 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Fri, 12 Jun 2009 19:17:01 +0000 (19:17 +0000)
statistics/copy-logs.sh [new file with mode: 0755]
zabbix/hosts.py [new file with mode: 0755]

diff --git a/statistics/copy-logs.sh b/statistics/copy-logs.sh
new file mode 100755 (executable)
index 0000000..634d873
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+cd /usr/share/monitor
+source agent.sh &> /dev/null
+
+rsync -qv -az -e ssh root@chloe.cs.princeton.edu:/vservers/www-current/var/log/httpd/*-* /var/lib/monitor/httpd-log
+rsync -qv -az -e ssh root@chloe.cs.princeton.edu:/vservers/www-current/var/log/httpd/*error* /var/lib/monitor/httpd-log
+
+rsync -qv -az -e ssh root@chloe.cs.princeton.edu:/vservers/www-current/var/log/*-filesystem* /var/lib/monitor/filesystem
+rsync -qv -az -e ssh root@chloe.cs.princeton.edu:/vservers/www-current/var/log/*-checkrpm* /var/lib/monitor/checkrpm
+
+rsync -qv -az -e ssh root@amber.cs.princeton.edu:/vservers/db-current/var/log/*-filesystem* /var/lib/monitor/filesystem
+rsync -qv -az -e ssh root@amber.cs.princeton.edu:/vservers/db-current/var/log/*-checkrpm* /var/lib/monitor/checkrpm
+
+rsync -qv -az -e ssh root@janine.cs.princeton.edu:/vservers/boot-current/var/log/*-filesystem* /var/lib/monitor/filesystem
+rsync -qv -az -e ssh root@janine.cs.princeton.edu:/vservers/boot-current/var/log/*-checkrpm* /var/lib/monitor/checkrpm
diff --git a/zabbix/hosts.py b/zabbix/hosts.py
new file mode 100755 (executable)
index 0000000..c2dbde7
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+
+from monitor.wrapper import plc
+import os
+
+api = plc.api
+
+HOSTS_FILE="/etc/hosts"
+
+def is_in_file(filename, pattern):
+       f = os.popen("grep %s %s" % ( pattern, filename))
+       content = f.read()
+       if len(content) > 0:
+               return True
+       else:
+               return False
+def add_to_file(filename, data):
+       os.system("echo '%s' >> %s" % (data, filename))
+       print "echo '%s' >> %s" % (data, filename)
+
+sites = api.GetSites({'login_base' : 'mlab*'}, ['node_ids'])
+for s in sites:
+       nodes = api.GetNodes(s['node_ids'], ['hostname', 'interface_ids'])
+       for node in nodes:
+               try:
+                       i = api.GetInterfaces({ 'interface_id' :  node['interface_ids'], 'is_primary' : True})
+                       print len(i), i
+                       print "%s %s" % (i[0]['ip'], node['hostname'])
+                       #if not is_in_file(HOSTS_FILE, node['hostname']):
+                       #       add_to_file(HOSTS_FILE, "%s %s" % (i[0]['ip'], node['hostname']))
+               except:
+                       pass