Ad Widget

Collapse

How the best way to monitoring http requests

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cyberneticrat
    Junior Member
    • Nov 2021
    • 7

    #1

    How the best way to monitoring http requests

    Hello everyone.
    ​​​​I'm new on Zabbix, and I have to monitor lots of hosts with http requests. Firstly, I've made it using web scenarios, but it won't be the best way for me because I have to use a variable in one query field of each request. This field is my "token", and it have to change all the time, or I'll receive the "Token expired" reponse for all my http requests. To simplify: my http requests NEED to change this token variable, and I already have one of this requests that generates the token (and it works). I tried to use external scripts but it's also a bad way because I have many hosts, and external scripts can't be used a lot, as said in the zabbix documentation (I tried it anyway... bad idea) and I also tried to use one external script, that it's my token generator, and put it in "query fields" of web scenario, but it doesn't work.
    Any ideas? I'm just trying to find a way to do this
    Click image for larger version

Name:	Capturar.png
Views:	2748
Size:	55.3 KB
ID:	435079

    Attached Files
  • ISiroshtan
    Senior Member
    • Nov 2019
    • 324

    #2
    I don't know if there is a way to do it using only readily available tools in Zabbix, would be interested to see a good solution from some one more competent then myself. But I can propose one way it can be done:

    Have a shell/python/perl/whatever script run by crontab on interval key_lifetime minus 1-2 minutes. Script would go to a website and do auth, then using Zabbix API to push key into host level macro. And inside HTTP agent use host level macro as value for said query field.

    Complication is, if you gonna need different keys for different servers, you'd need either multiple scripts running by crontab or go few levels up in complexity, like doing API query to get list of hosts doing this check and for each: pull URL from host data, do auth for said server, push key back into host macro.


    Also saw interesting suggestion on forum: instead of using shell level script to achieve said result one could use JS item pre-processing in Zabbix and put all API calls in there. Did not tired it yet(and not sure I will anytime soon, as I'm bad with JS), but this idea is interesting in itself as it allows to do said solution fully in GUI without the need for SSH access and allows to not complicate script. As such item with pre-processing can be distributed to each desired host via template and be responsible for key of that particular host.


    My reply is probably too messy, but as I have no fully production-ready solution, that is probably the best reply I'm capable of. hope it helps!

    Comment


    • cyberneticrat
      cyberneticrat commented
      Editing a comment
      Thanks for your reply!! I'm interested about the JS preprocessing method... this is exactly what I was searching for. I'm just having some troubles to configure it on zabbix and with the JS, because I don't know much about JS too. I'll take a look in documentation and try to get back with the answer.
      Once again, thank you so much!
  • gofree
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2017
    • 400

    #3
    Originally posted by cyberneticrat
    Hello everyone.
    ​​​​I'm new on Zabbix, and I have to monitor lots of hosts with http requests. Firstly, I've made it using web scenarios, but it won't be the best way for me because I have to use a variable in one query field of each request. This field is my "token", and it have to change all the time, or I'll receive the "Token expired" reponse for all my http requests. To simplify: my http requests NEED to change this token variable, and I already have one of this requests that generates the token (and it works). I tried to use external scripts but it's also a bad way because I have many hosts, and external scripts can't be used a lot, as said in the zabbix documentation (I tried it anyway... bad idea) and I also tried to use one external script, that it's my token generator, and put it in "query fields" of web scenario, but it doesn't work.
    Any ideas? I'm just trying to find a way to do this
    Click image for larger version

Name:	Capturar.png
Views:	2748
Size:	55.3 KB
ID:	435079
    depends on how often is your token changed you could setup a global macro that will be updated via api - after use this macro in web scenario as placeholder ( if possible - check with docu ) - I used this approach where the value ( in you case token ) was updated once a day - but still you'll be fighting with situation where for any reason token will not be updated - so the update api script needs to be bulletproof as possible and also configuration cache parameter might come to play - for example config cache is updated on zabbix server by default every 1m ( thast good ) but on proxy it can be 1h ( thas not so good ) in case the host will be assigned to proxy ( might be better to do it with zabbix server )

    Comment

    Working...