Beispiel #1
0
    def _install(self):
        # Execute install monit
        Common.execute("apt-get install monit")

        # Write system monitoring
        file = open("/etc/monit/conf.d/system", "w")
        file.write("check system local\n")
        file.write("    if loadavg (1min) > 4 then alert\n")
        file.write("    if loadavg (5min) > 2 then alert\n")
        file.write("    if memory usage > 80% then alert\n")
        file.write("    if cpu usage (user) > 80% then alert\n")
        file.write("    if cpu usage (system) > 50% then alert\n")
        file.write("    if cpu usage (wait) > 25% then alert\n")
        file.close()

        # Write apache monitoring
        file = open("/etc/monit/conf.d/apache2", "w")
        file.write("check process apache with pidfile /var/run/apache2.pid\n")
        file.write('    start program = "/etc/init.d/apache2 start"\n')
        file.write('    stop program = "/etc/init.d/apache2 stop"\n')
        file.write("    if failed host 127.0.0.1 port 80 protocol http\n")
        file.write('       and request "/monit/token" then restart\n')
        file.write("    if cpu is greater than 90% for 2 cycles then alert\n")
        file.write("    if cpu > 80%  for 5 cycles then restart\n")
        file.write("    if children > 250 then restart\n")
        file.write("    if loadavg(5min) greater than 10 for 8 cycles then stop\n")
        file.write("    if 3 restarts within 5 cycles then timeout\n")
        file.close()

        file = open("/etc/monit/conf.d/mysql", "w")
        file.write("check process mysql with pidfile /var/run/mysqld/mysqld.pid group database\n")
        file.write('    start program = "/etc/init.d/mysql start"\n')
        file.write('    stop program = "/etc/init.d/mysql stop"\n')
        file.write('    if failed unix "/var/run/mysqld/mysqld.sock" then restart\n')
        file.write("    if failed host 127.0.0.1 port 3306 then restart\n")
        file.write("    if 5 restarts within 5 cycles then timeout\n")
        file.close()

        # Execute monit restart
        Common.execute("/etc/init.d/monit reload")
        return True
 def _status(self):
     return Common.check_url("https://127.0.0.1:12321")
Beispiel #3
0
def test_timeparser():
    '''Timeparser test function'''
    print('test_timeparser')
    print(Common.parse_date('30 August, 2017'))
 def _status(self):
     return Common.exist("/etc/apache2/sites-enabled/phpmyadmin")
 def _disable(self):
     Common.execute("a2dissite phpmyadmin", "Disable site phpmyadmin")
     Common.execute('service apache2 reload', "Restart Apache")
     return True
Beispiel #6
0
 def _disable(self):
     Common.execute("/etc/webmin/stop")
     return True
Beispiel #7
0
 def _enable(self):
     Common.execute("/etc/webmin/start")
     return True
Beispiel #8
0
 def _status(self):
     data = Common.execute("/etc/init.d/monit status")
     if "monit is running" in data:
         return True
     return False
Beispiel #9
0
 def _disable(self):
     Common.execute("/etc/init.d/monit stop")
     return True
Beispiel #10
0
 def _enable(self):
     Common.execute("/etc/init.d/monit start")
     return True
Beispiel #11
0
 def _is_install(self):
     return Common.exist("/etc/monit/monitrc")
Beispiel #12
0
 def _status(self):
     response = Common.execute("cat /etc/default/shellinabox | grep DAEMON_START")
     if "=1" in response:
         return True
     return False
Beispiel #13
0
 def _disable(self):
     Common.execute("/etc/init.d/shellinabox stop", "Stopping Daemon")
     Common.execute('sed -i "s|SHELLINABOX_DAEMON_START=1|SHELLINABOX_DAEMON_START=0|" /etc/default/shellinabox', "Remove autostart config")
     return True
Beispiel #14
0
 def _enable(self):
     Common.execute("/etc/init.d/shellinabox start", "Starting Daemon")
     Common.execute('sed -i "s|SHELLINABOX_DAEMON_START=0|SHELLINABOX_DAEMON_START=1|" /etc/default/shellinabox', "Add autostart config")
     return True