Ad Widget

Collapse

monitor linux services via zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kpax
    Member
    • Dec 2013
    • 52

    #1

    monitor linux services via zabbix

    Greetings,

    We are working with Zabbix Server version 4.2.

    It is possible to monitor the Linux host's services with Zabbix?

    I attache 'Template Linux OS' to these hosts without success, not data relating services gets in.

    is there a way to monitor these services without using external scripts?

    thanks, heaps.

    Kpax


  • gofree
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2017
    • 400

    #2
    guess you know you're on unsupported version - so the best thing would be to move to version 5 - use ( eg reinstall ) agents to agent2 which supports systmd services out of the box

    otherwise you might use search in integration portal or zabbix share ( usually thats a good start )




    Comment

    • frater
      Senior Member
      • Oct 2010
      • 340

      #3
      I wrote a simple discovery script that I have in use since I created it.
      It isn't clean in its concept. It detects far more processes than there are actual services. The idea is that you need to create exceptions for those.
      If you don't mind handling those exceptions and the bit of fuzzy nature it has, it could work for you.
      I knew I posted it some time ago and had to google it to find it.

      https://share.zabbix.com/operating-s...linux-services
      Now I see for the first time that it received a lot of reactions. I still need to read those.

      It's based on running processes that are running for a long time. You therefore need to keep that in mind with the timing you use for discovery and undiscover.

      I also don't know if my current script is still the same, so I will post the one I'm using now. It's not giving me any false positives.
      When it gives a false positive now I didn't alter the script, but I used regular expressions to deal with them.
      I could incorporate those in the script if you are interested.

      These false positives are typically commands you leave running in a terminal, like ncdu



      Click image for larger version  Name:	regular_expressions.PNG Views:	4 Size:	24.7 KB ID:	401323


      # cat /etc/zabbix/zabbix_agentd.d/services.conf
      Code:
      ### Discovery
      UserParameter=service.discovery,/etc/zabbix/scripts/service_discovery
      # cat /etc/zabbix/scripts/service_discovery
      Code:
      #!/bin/bash
      TMPDIR=`mktemp -t -d ${0//*\/}.XXXXXXXXXX`
      
      echo '^-
      ^_
      ^sleep$
      ^qmgr$
      ^showq$
      ^pickup$
      ^pigz$
      ^tar$
      ^pmm-ras$
      ^backupmng$
      ^proxymap$
      ^cleanup$
      ^tlsmgr$
      ^anvil$
      ^trivial-rewrite$
      ^dd$
      ^init$
      ^php
      ^perl$
      ^python$
      ^lua$
      ^sh$
      ^bash$
      ^auth$
      ^login$
      ^vi$
      ^imap
      ^accounts-daemon$
      ^config$
      ^ssl-params$
      ^vlogger$
      ^ssh$
      ^zabbix_agent
      ^systemd
      ^proxymap$
      zip$
      ^awk$
      ^log$
      ^run-parts$
      ^vhostmng
      ^plesk
      getty$
      ^smtp$
      ^smtpd$
      ^amavisd
      ^postgrey
      ^pure-ftpd
      ^proftpd
      ^Passenger
      ^qsync
      ^qWatchdogd
      ^sw-engine
      ^spamd$' >${TMPDIR}/filter
      
      ps aux | egrep -io '([a-z]+[0-9]+| 20[0-9][0-9]) +[0-9]+:[0-9]+ [A-Za-z0-9/_-]*( |:|$)' | \
      sed 's/.*\///g;s/[ :]$//g;s/.* //g' | grep '[a-z]' | \
      grep -vf ${TMPDIR}/filter | sort | uniq >${TMPDIR}/progs
      
      if [ -s ${TMPDIR}/progs ] ; then
      
      echo -e "{\n\t\"data\":["
      
      while read SERVICE ; do
      [ ${PRINTED} ] && echo ","
      PRINTED=true
      
      echo -en "\t\t{ \"{#SERVICE}\":\"${SERVICE}\" }"
      done <${TMPDIR}/progs
      
      echo -e "\n\t]\n}"
      fi
      rm -r ${TMPDIR}
      Last edited by frater; 17-05-2020, 12:48.
      Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

      Comment

      • Kpax
        Member
        • Dec 2013
        • 52

        #4
        bit late

        Thanks heaps !!!!

        Comment

        Working...