Ad Widget

Collapse

[Beginner] How to log status of scripts running on an agent machine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • osieben
    Junior Member
    • Apr 2018
    • 2

    #1

    [Beginner] How to log status of scripts running on an agent machine

    Hey there,

    pretty new to monitoring and zabbix. If you can point me what to google for or what to read I am happy.
    I think my task is not too non-std.

    I do run run several self-made import and export scripts on a cloud hosted system. The scripts differ from Bash, Python to Ruby.
    Zabbix agent is installed there and I am able to monitor on the zabbix server CPU, Disk, HTTP/HTTPS of that machine .. thats perfectly fine.

    But now I need to track my scripts, if they report errors, if they are crashed, or even if they run properly - thus give a warning, if they not run the last x-mins/hrs.

    So can you give me some hints how to accomplish that?

    Cheers,
    Oliver
  • aigars.kadikis
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2018
    • 208

    #2
    Hi, osieben!

    It is a great way to start set up log monitoring by using Zabbix own log file. This log will be definatelly readable by 'zabbix' user because it has been created by 'zabbix' user.

    Please setup item with key
    Code:
    log[/var/log/zabbix/zabbix_server.log]
    and make sure you selected Zabbix Agent (Active)

    Click image for larger version

Name:	log-file-monitoring-first-start-zabbix.png
Views:	2399
Size:	118.0 KB
ID:	357693

    Wait 100 seconds for the configuration to sync with the database. Then look under Monitoring -> Latest data
    Click image for larger version

Name:	latest-data-log.png
Views:	2109
Size:	57.6 KB
ID:	357692

    Regards,
    Aigars

    Comment

    • osieben
      Junior Member
      • Apr 2018
      • 2

      #3
      Not there yet, but works like charm ;-)

      Any code I could place in my scripts?

      Comment

      • aigars.kadikis
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Mar 2018
        • 208

        #4
        Originally posted by osieben
        Not there yet, but works like charm ;-)

        Any code I could place in my scripts?
        Does your scripts are configured to pass output to static log file?

        Regards,

        Comment

        • miaryan
          Junior Member
          • Apr 2018
          • 2

          #5
          I scheduled a procedure to run on a machine, and it has completed. The procedure completed with a FAIL and see a message similar to:

          ScriptName failed in THEN step 5

          Check the Agent Procedure Log for additional details

          Comment

          • aigars.kadikis
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Mar 2018
            • 208

            #6
            So if your script writes content (c:\script_output.log) such as
            Code:
            ScriptName failed in THEN step 5
            Check the Agent Procedure Log for additional details
            You can detect for example word "failed" in the last day. Trigger expression:
            Code:
            {host name:log[c:\script_output.log].iregexp(failed,1d)}=1
            To result whole string "ScriptName failed in THEN step 5" in trigger title you can name trigger:
            Code:
            {ITEM.VALUE1}
            Regards,

            Comment

            Working...