Defined Type: wikistats::job::xmldump

Defined in:
modules/wikistats/manifests/job/xmldump.pp

Overview

a timer (job) to dump wikistats tables as XML

Parameters:

  • table (String)
  • minute (Integer)
  • db_pass (String)
  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • db_user (String) (defaults to: 'wikistatsuser')
  • db_name (String) (defaults to: 'wikistats')
  • file_path (Stdlib::Unixpath) (defaults to: '/var/www/wikistats/xml')
  • my_cnf (Stdlib::Unixpath) (defaults to: '/usr/lib/wikistats/.my.cnf')


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'modules/wikistats/manifests/job/xmldump.pp', line 2

define wikistats::job::xmldump(
    String $table,
    Integer $minute,
    String $db_pass,
    Wmflib::Ensure $ensure = 'present',
    String $db_user = 'wikistatsuser',
    String $db_name = 'wikistats',
    Stdlib::Unixpath $file_path = '/var/www/wikistats/xml',
    Stdlib::Unixpath $my_cnf = '/usr/lib/wikistats/.my.cnf',
){

    $query = $table ? {
        'wikipedias' => 'SELECT *,good/total AS ratio FROM wikipedias WHERE total IS NOT NULL ORDER BY good desc,total desc',
        default      => "SELECT *,good/total AS ratio FROM ${table} ORDER BY good desc,total desc",
    }

    $command = "/usr/bin/mysql --defaults-extra-file=${my_cnf} -X -u ${db_user} -e '${query}' ${db_name} > ${file_path}/${table}.xml 2>&1"

    systemd::timer::job { "wikistats-xmldump-${name}":
        ensure          => $ensure,
        user            => 'wikistatsuser',
        description     => "dump data from table ${name} in XML format",
        command         => $command,
        logging_enabled => true,
        logfile_basedir => '/var/log/wikistats/',
        logfile_name    => "xmldump-${name}.log",
        interval        => {'start' => 'OnCalendar', 'interval' => "*-*-* *:${minute}:00"},
    }

}