Ad Widget

Collapse

SSH check size problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Adriano Trindade
    Junior Member
    • May 2022
    • 19

    #1

    SSH check size problem

    Hello people!

    I´m using Zabbix 6.0.2 in one of our environments. Searched for this problem on the web and on this forum with no luck.

    I use SSH checks to query certain equipment, and in one of these checks, the result is a really big amount of XML data, so I receive a "Command output exceeded limit of 512 KB" error.

    How can I increase this limit?

    Thans in advance!
  • orbenet
    Junior Member
    • May 2022
    • 5

    #2
    Hello Adriano,

    Have you tried using Zabbix Active Agent with Active checks instead? If not possible I will tell you what I do to overcome some limitations like this.

    I have a storage array I want to monitor disks for failure but cannot use SSH, or install Zabbix Agent so I compliment it with python script and cronjob.

    What I am able to do is execute a specific program via batch/python script and then use the Zabbix active agent to shoot that data into Zabbix.

    See below for general python script to allow retrieval of data from ssh and sending via Zabbix Active agent or using Log Item (you can store this script on your Zabbix Server)

    import paramiko
    import os

    server = "enter server IP you ssh into"
    username= "enter ssh username"
    password = "enter ssh password"
    cmd_to_execute = "enter command you execute on server to retrieve data"

    zabbix_server = "enter zabbix server IP - 127.0.0.1 if script lives on Zabbix Server"
    zabbix_key = "Name of the Active Key that Zabbix has where data will go to"

    ssh = paramiko.SSHClient()
    ssh.connect(server, username=username, password=password)
    ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(cmd_to_execute)



    This will get the data into ssh_stdout variable. Then you have a few routes. You can use Zabbix active agent like so (in python script):

    os.system('zabbix_sender -z {} -s "{}" -k {} -o "{}"'.format(ZABBIX_SERVER,ZABBIX_HOSTNAME,ZABBIX_ KEY,ssh_stdout))


    or like so (each line will be entry in zabbix key):

    for line in ssh_stdout.split('\n'):
    os.system('zabbix_sender -z {} -s "{}" -k {} -o "{}"'.format(ZABBIX_SERVER,ZABBIX_HOSTNAME,ZAB BIX_ KEY,line))



    or a more simple approach is to save that data as a file and have Zabbix use log monitor to monitor the file and then use pre-processing to get it to look like what you want.

    file = open('file_to_monitor','w')
    for line in ssh_stdout.split('\n'):
    file.write(line)
    file.write('\n')
    file.flush()
    file.close()


    Hope this helps - If you can get me more detailed information, I can help you figure out the exact way to get the data into Zabbix.

    Comment

    • Adriano Trindade
      Junior Member
      • May 2022
      • 19

      #3
      Hello!

      Your suggestion is welcome.

      I am avoiding using scripts/crontab because I want things as simple as possible. And without custom external scripts, if I need to restore a backup of Zabbix, everything is working without the need to manually create/adjust scripts.

      If I can't find a way to increase SSH result size, I will try to use an external script. But not using crontab, instead using an UserParameter on Zabbix Agent, so I don't need to rely on crontab/zabbix_sender, and can put everythng on the Zabbix Agent include directory, and can pass parameters.

      But if this doesn't work, my last resort would be an approach like you suggested. I will wait a little more to see if anyone know a way to circumvent this SSH result size limitation.

      Many thanks!

      Comment

      • orbenet
        Junior Member
        • May 2022
        • 5

        #4
        I will be checking on this periodically to see if anyone can provide a solution. From my understanding, the limit is hardcoded into a Go file in

        Source https://github.com/zabbix/zabbix/blo...xcmd/zbxcmd.go

        I think if you modified the constant in that file const MaxExecuteOutputLenB = 512 * 1024 and changed to a higher value you can get rid of the limit. But this would require you to build from source and hope it does not cause stability issues.

        If you look at https://github.com/zabbix/zabbix/blo.../zbxcmd_nix.go

        Function execute is where you will see that error being called out. You could also technically remove the check for size limit - there is a zbxcmd_windows.go file as well if you were to target windows based machine.

        This is all theoretical so I haven't actually tested anything.

        Good luck Sir!

        Comment

        Working...