Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/awstats: refactor module #73959

Merged
merged 1 commit into from Dec 24, 2019
Merged

nixos/awstats: refactor module #73959

merged 1 commit into from Dec 24, 2019

Conversation

aristaeus
Copy link
Contributor

Motivation for this change

After some discussion in #72961, I took over as the maintainer for awstats with a mandate to refactor it. The new module is much more flexible, and should cover most use cases.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Examples
service.awstats = {
  enable = true;
  configs = {
    "basic.com" = {
      logFile = "/path/to/log/file";
      # in this case you can access the stats at basic.com/awstats
    };
    "advancedconfig" = {
      logFile = "/path/to/log/file";
      domain = "foo.com";
      hostAliases = "www.foo.com";
      extraConfig = {
        "ValidHTTPCodes" = "404";
      };
      webService = {
        hostname = "awstats.foo.com";
	urlPrefix = "";
      };
    };
    "mail.com" = {
      type = "mail";
      logFile = "journalctl $OLD_CURSOR -u postfix.service | ${pkgs.perl}/bin/perl ${package.out}/share/awstats/tools/maillogconvert.pl standard |";
      logFormat = "%time2 %email %email_r %host %host_r %method %url %code %bytesd";
    };
  };
  updateAt = "hourly";
};

@griff I haven't tested the mail config but it should mostly work - let me know how you go.

If anyone else can test this too that would be good. @aanderse

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Well done. Just a few minor changes requested. Thanks for your work on this.

nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
@aanderse
Copy link
Member

aanderse commented Dec 6, 2019

@aristaeus I'd like to move this along so I will probably try to do some testing on this. Can you provide me with a minimal configuration to get this up and running? I have an apache server with 2 domains I can test this on.

@aristaeus
Copy link
Contributor Author

services.awstats = {
  enable = true;
  configs."foobar.com" = {
    logFile = "/path/to/logs/access.log";
    webService = {
      enable = true;
      hostname = "awstats.foobar.com";
      urlPrefix = "/stats";
    };
  };
  updateAt = "minutely";
};

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing with httpd (I don't run nginx) so I had make a few adjustments in my configuration.nix to match your code.

nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
@aanderse
Copy link
Member

@aristaeus ping

@aanderse
Copy link
Member

aanderse commented Dec 18, 2019

@aristaeus all folders under /var/lib/awstats are coming out as 744 with permissions. I think we need 755 or such?

"${opts.webService.urlPrefix}/" = {
alias = "${cfg.dataDir}/${name}/";
extraConfig = ''
autoindex on;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aristaeus optional suggestion, but it looks like you might want to direct users to awstats.${name}.html instead of a directory listing here.

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aristaeus you should also add an entry to the release notes. You can advertise your great work here!

nixos/modules/services/logging/awstats.nix Outdated Show resolved Hide resolved
@aanderse aanderse changed the title refactor awstats module nixos/awstatsrefactor awstats module Dec 24, 2019
@aanderse aanderse changed the title nixos/awstatsrefactor awstats module nixos/awstats: refactor module Dec 24, 2019
@aanderse aanderse merged commit 08bd639 into NixOS:master Dec 24, 2019
@ArdaXi
Copy link
Contributor

ArdaXi commented Dec 25, 2019

I haven't quite figured out why this happens yet but this change seems to have broken builds of the manual for me:

<3>
<3>manual-combined.xml:74241: element link: validity error : IDREF attribute linkend references an unknown ID "opt-services.httpd"
<3> 74237     <listitem>
<3> 74238      <para>
<3> 74239       The <link linkend="opt-services.awstats">awstats</link> module has been rewritten
<3> 74240       to serve stats via static html pages, updated on a timer, over <link linkend="opt-services.nginx.virtualHosts">nginx</link>,
<3> 74241       instead of dynamic cgi pages over <link linkend="opt-services.httpd">apache</link>.
<3> 74242      </para>
<3> 74243      <para>
<3>
<3>manual-combined.xml:74239: element link: validity error : IDREF attribute linkend references an unknown ID "opt-services.awstats"
<3> 74235      </itemizedlist>
<3> 74236     </listitem>
<3> 74237     <listitem>
<3> 74238      <para>
<3> 74239       The <link linkend="opt-services.awstats">awstats</link> module has been rewritten
<3> 74240       to serve stats via static html pages, updated on a timer, over <link linkend="opt-services.nginx.virtualHosts">nginx</link>,
<3> 74241       instead of dynamic cgi pages over <link linkend="opt-services.httpd">apache</link>.
<3>
<3>manual-combined.xml:74245: element link: validity error : IDREF attribute linkend references an unknown ID "opt-services.awstats"
<3> 74241       instead of dynamic cgi pages over <link linkend="opt-services.httpd">apache</link>.
<3> 74242      </para>
<3> 74243      <para>
<3> 74244       Minor changes will be required to migrate existing configurations. Details of the
<3> 74245       required changes can seen by looking through the <link linkend="opt-services.awstats">awstats</link>
<3> 74246       module.
<3> 74247      </para>
<3>
<3>manual-combined.xml fails to validate
<3>builder for '/nix/store/cz0hj40312p7ajf88ii2hvc5p1kmgfz1-nixos-manual-combined.drv' failed with exit code 3

I can dig into this more after the holidays, but I wanted to put this here so I know where to look and in case someone else can already see what's happening.

@danbst
Copy link
Contributor

danbst commented Dec 25, 2019

@ArdaXi fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants