Setting up MONIT

Discussion in 'Server Operation' started by redundancymad, Jul 22, 2007.

  1. redundancymad

    redundancymad New Member

    Hey,

    I've got a problem, within monit my first time of using it ever so still noob in it but in any case, am expanding my horizons. What i have a problem is, this part :


    Code:
    check process apache with pidfile /var/run/httpd.pid 
       start program = "/etc/init.d/httpd start" 
       stop program  = "/etc/init.d/httpd stop" 
       if cpu > 60% for 2 cycles then alert 
       if cpu > 80% for 5 cycles then restart 
       if totalmem > 200.0 MB for 5 cycles then restart 
       if children > 250 then restart 
       if loadavg(5min) greater than 10 for 8 cycles then stop 
       if failed host 192.168.1.2 port 80 protocol http 
          and request "/webwarning.htm" 
          then exec "/root/testing.bash" 
    #    if failed port 443 type tcpssl protocol http 
    #       with timeout 15 seconds 
    #       then restart 
       if 3 restarts within 5 cycles then timeout 
    #    depends on apache_bin 
       group server 
    
    its the (then exec "/root/testing.bash") i thought this should execute my script file, but it just doesn't work, even though the file is set as executable and works fine if i just run it as normal from the konsole.

    This test all works fine and before hand it was just a (then alert) and i changed it because i wanted it to run my script instead which doesn't seem to happen.

    Does anyone have an idea as to what the problem could be
     
  2. falko

    falko Super Moderator ISPConfig Developer

    Do you use fulll paths in your script /root/testing.bash?
     
  3. redundancymad

    redundancymad New Member

    erm what are full paths, do you mean i should remove the quotes?

    Thanks for your help
     
  4. edge

    edge Active Member Moderator

    Full path is something like
    Code:
    /var/www/web1/place/of/script
    (it's always seen from the root)

    So make sure that you use full path(s) in your testing.bash script.
     
  5. redundancymad

    redundancymad New Member

    oo i get it, well yes it is anyway, the beginning point of the filesystem top of the tree to say is "/" then i open folder root then the script is in there. And i always use full paths within the script itself

    So does that mean it should be working properly??

    Cheers
     
  6. edge

    edge Active Member Moderator

    I think that it could also be an owner problem.

    If Monit is running as user Monit, it will not execute a scriped who is owned by root.
     
  7. redundancymad

    redundancymad New Member

    well, i don't think thats an issue as i set it to really bad 777 chmod, just to try get it working and same problems, but by the sounds of it the code in the monitrc file is ok or should work?
     
  8. falko

    falko Super Moderator ISPConfig Developer

    Can you post the contents of your script?
     
  9. redundancymad

    redundancymad New Member

    Its only very simple as i will put my real coding in once i know its actually executing my script properly, but this code would obviously work under normal conditions

    Code:
    #!/bin/bash
    echo "Testing if monit executes script" > /root/Desktop/testin.txt
    exit
    
     
  10. redundancymad

    redundancymad New Member

    Hey thanks for your previous help but the problem is fine now for some reason, i've reinstalled my test machine and set it all up again and it seems to work fine now, however there is one other thing which isn't a major problem but i would like to know if its possible or why it doesn't work??

    the script i run i know it runs fine because i get the exec script to just keep printing the date within another file, but also i was trying to get it to execute an Xdialog command. Now this works fine if i just run exec or run the script in any method from the konsole or by just double clicking on it using GUI, but why does it not work if executed by monit??

    cheers for your help
     

Share This Page