Pandora FMS Community

Custom plugin Intensive Monitoring

sathaniel · 23 mar 2017, 7:41 · 5 mensajes · 65 visitas

  1. Inicio del debate

    Dear all I have been creating some custom plugins for monitoring some services, but with the last one I need it to report immediately if the service is down I have no problem with the configuration direct in the agent: module_begin module_name SSH Daemon module_type generic_data module exec ps aux | grep sshd | grep -v grep | wc -l module_intensive_condition = 0 module_end But I want to know if is possible to do this inside a custom plugin so I can just call it from my agent. module_plugin pandora_jboss.py Please advice

  2. Hello sathaniel, I'm not sure it is possible. It is true that agent plugins support additional options used on the modules, but keep in mind that the parameter "module_intensive condition" is receiving a numeric value, while a regular agent plugin will retrieve an XML result. So I don't think it is possible for plugins that retrieve XML with several modules, however if your plugins only retrieve one module (or you can split them in several different plugins that retrieve only one value) maybe you can change the output to retrieve a single numeric value instead of an XML. You can find docummentation about how to use additional options on agent plugins here: http://wiki.pandorafms.com/index.php?title=Pandora:Documentation\_en:Configuration#module\_plugin Please, let me know if this helps and if you will be able to adapt your plugins to the posibilities. Kind regards, Antonio.

  3. Hi Antonio Since the service is really critical, I  was hoping something like this module_begin module_plugin pandora_jboss.py "Jboss " http://localhost:8280/lol/ module_intensive_condition = 0 module_end could work but sadly doesn't. I start using something like module_name Jboss module_type generic_data module_exec curl -I  http://localhost:8080/lol/index.go 2>&1 | awk 'FNR == 4 {print $2}' module_description Status de el portal module_min_warning 300 module_max_warning 399 module_min_critical 400 module_max_critical 600 module_intensive_condition = 0 module_end and worked but when the service is down the answer doesn't match the warning and critical condition. It could be amazing if the first case could work module_begin module_plugin(or exec) pandora_jboss.py "Jboss " http://localhost:8280/lol/ module_intensive_condition = 0 module_end Thanks a lot

  4. Hello sathaniel, What does the execution of your plugin return? If it is a single value (numeric for example) you can execute it as module_exec with no problem, and then the module_intensive_condition should work, but keep in mind that the value used on module_intensive_condition has to match with the critical value, or it won't be reported immediatly. If your plugin returns an XML piece, you will need to use module_plugin. I don't quite get the values that it returns, taking a look at it, it seems to be retrieving more info than just status (due to the thresholds you are using). So it retrieves certain information with critical values between 400 and 600 but it will display "0" in case of service fail? I don't know if I'm assuming correctly, but if this is the case, maybe you could separate it on two different checks, one for the numeric values and other one only to check status (ok/not ok) and create it as a boolean data (always critical if the value is 0). Kind regards, Antonio.

  5. Hi Antonio The example with the curl command returns a 200 if is a success but if the webserver is failing return a value between 400 and 600 my problem is that if the jboss is down it won't return non of the codes i am expecting, it will return a string "curl: (22) The requested URL returned error: 404". For that reason I decided to create a plugin to be able to handle the exit of the commands in a better way but since the service is really critical to us I am having a hard time. this is the code of my plugin. #!/usr/bin/python import sys import requests import time if ( len( sys.argv ) < 3 ): #{   sys.stderr.write( "Uso: " + sys.argv[0] + "" + " n"  )   sys.stderr.flush();     exit(2); #}  else: #{   url = sys.argv[2];   service = sys.argv[1]; #} try:   start = time.time()   r = requests.get(url, timeout=5)   roundtrip = time.time() - start   res = r.status_code   if 300 <= res <= 399:     print("Servicio Warning")     print ('                       generic_data         400         600         300         399         ' % (service, service, res) )   elif 400 <= res <= 600:     #print("Servicio Critical")     print ('                         generic_data         400         600         300         399         ' % (service, service, res) )      else:     #print("Servicio OK, tiempo de respueta %s Segundos." % (roundtrip))     print ('n         n         n         generic_datan         400n         600n         300n         399n         n ' % (service, roundtrip, res) ) except requests.exceptions.Timeout as e:   #print("Error de timeout")   print ('n         n         n         generic_datan         400n         600n         300n         399n         n ' % service )  except requests.exceptions.TooManyRedirects:   #print("Demasiados redirects")   print ('n         n         n         generic_datan         400n         600n         300n         399n         n ' % service )   except (requests.exceptions.RequestException, requests.exceptions.ConnectionError) as e:   #print ("Servicio Critical", e)   print ('n         n         n         generic_datan         400n         600n         300n         399n         n ' % (service, e) ) As you recomend I am thinking in separete in two checks or reduce the interval to 60 and add the option module_interval to 5 in all our checks. I really hope in the future the agent could allow us to use intensive option in custom plugins. Thanks a lot for your help Antonio.

Entra en tu cuenta para publicar.