trimming agent2 filesize

XMLWordPrintable

    • Type: Change Request
    • Resolution: Unresolved
    • Priority: Trivial
    • None
    • Affects Version/s: None
    • Component/s: Agent (G)
    • None

      Currently building the agent2 from source we're getting about this:

      $ ./bootstrap.sh; ./configure --enable-agent2 --enable-static; make
      $ ll src/go/bin/
      total 23316
      drwxr-xr-x 2 root root     4096 Sep  2 19:02 ./
      drwxr-xr-x 8 root root     4096 Sep  2 19:01 ../
      -rw-r--r-- 1 root root       26 Sep  2 18:57 .gitignore
      -rwxr-xr-x 1 root root  4043600 Sep  2 19:01 mock_server*
      -rwxr-xr-x 1 root root 19812776 Sep  2 19:02 zabbix_agent2*
      ```
      

      Adding "-s -w" to 'go build -ldflags="-s -w"' si trimming is somewhat

      $ ls -la src/go/bin/
      total 16308
      drwxr-xr-x 2 root root     4096 Sep  2 19:15 .
      drwxr-xr-x 8 root root     4096 Sep  2 19:06 ..
      -rw-r--r-- 1 root root       26 Sep  2 18:57 .gitignore
      -rwxr-xr-x 1 root root  2888912 Sep  2 19:15 mock_server
      -rwxr-xr-x 1 root root 13784664 Sep  2 19:15 zabbix_agent2
      

      Now with adding upx ( https://upx.github.io/ ) this can be brought down way more. I have had it running for a week now and didn't experience drawbacks (thought I haven't tested it on a broad range of targets).

      $ cp src/go/bin/zabbix_agent2 src/go/bin/zabbix_agent2_unpacked
      $ upx -1 src/go/bin/zabbix_agent2
                             Ultimate Packer for eXecutables
                                Copyright (C) 1996 - 2013
      UPX 3.91        Markus Oberhumer, Laszlo Molnar & John Reiser   Sep 30th 2013
      
              File size         Ratio      Format      Name
         --------------------   ------   -----------   -----------
        13784664 ->   6419452   46.57%  linux/ElfAMD   zabbix_agent2
      
      Packed 1 file.
      $ upx --best -o src/go/bin/zabbix_agent2_best src/go/bin/zabbix_agent2_unpacked
                             Ultimate Packer for eXecutables
                                Copyright (C) 1996 - 2013
      UPX 3.91        Markus Oberhumer, Laszlo Molnar & John Reiser   Sep 30th 2013
      
              File size         Ratio      Format      Name
         --------------------   ------   -----------   -----------
        13784664 ->   5364724   38.92%  linux/ElfAMD   zabbix_agent2_best
      
      Packed 1 file.
      $ ls -la src/go/bin/
      total 27812
      drwxr-xr-x 2 root root     4096 Sep  2 19:18 .
      drwxr-xr-x 8 root root     4096 Sep  2 19:06 ..
      -rw-r--r-- 1 root root       26 Sep  2 18:57 .gitignore
      -rwxr-xr-x 1 root root  2888912 Sep  2 19:17 mock_server
      -rwxr-xr-x 1 root root  6419452 Sep  2 19:17 zabbix_agent2
      -rwxr-xr-x 1 root root  5364724 Sep  2 19:17 zabbix_agent2_best
      -rwxr-xr-x 1 root root 13784664 Sep  2 19:17 zabbix_agent2_unpacked
      

            Assignee:
            Zabbix Support Team
            Reporter:
            Markus Fischbacher
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: