Skip to content

Commit

Permalink
DELTA-2641 Implement xdmod-ondemand-export for ACCESS metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jjackzhn committed Jan 31, 2024
1 parent 37c82c4 commit 41cdeff
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
15 changes: 15 additions & 0 deletions files/xdmod_export_conf.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is a configuration file used by xdmod_ondemand_export.py.
#
# Set the value of "url" in the [destination] section to specify where the logs
# will be POSTed.
#
# Set the values in the [logs] section to tell the script where to find logs
# and how to parse them.

[destination]
url = https://data.ccr.xdmod.org/ondemand/logs

[logs]
dir = /etc/httpd/logs
filename_pattern = *access*.log*
format = %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
include apache::mod::authz_user
include openondemand

include profile_ondemand::xdmod_export

package { 'nodejs':
ensure => $nodejs_version,
enable_only => true,
Expand Down
77 changes: 77 additions & 0 deletions manifests/xdmod_export.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# @summary Configure the xdmod export script
#
# @param enable_xdmod_export
# Whether to set up the script on the server. Defaults to false
#
# @param token
# Token used to authenticate with the log server
#
class profile_ondemand::xdmod_export (
Boolean $enable_xdmod_export = false,
String $token,
) {

if $enable_xdmod_export {
user { 'xdmod-ondemand-export':
shell => '/bin/false',
managehome => true,
password => '!DISABLED',
}

exec { '/usr/bin/python3 -m venv /home/xdmod-ondemand-export/venv':
user => 'xdmod-ondemand-export',
creates => '/home/xdmod-ondemand-export/venv',
require => Package['httpd'],
}
-> exec { 'python3 -m pip install xdmod-ondemand-export':
path => '/home/xdmod-ondemand-export/venv/bin:/usr/bin:/usr/sbin:/bin',
user => 'xdmod-ondemand-export',
creates => '/home/xdmod-ondemand-export/venv/bin/xdmod-ondemand-export',
}
-> exec { 'setfacl -m u:xdmod-ondemand-export:r-x /etc/httpd/logs':
path => '/usr/bin:/usr/sbin:/bin',
unless => 'getfacl /etc/httpd/logs/ | grep xdmod-ondemand-export',
}
-> exec { 'setfacl -m u:xdmod-ondemand-export:r-- /etc/httpd/logs/*':
path => '/usr/bin:/usr/sbin:/bin',
unless => 'getfacl /etc/httpd/logs/* | grep xdmod-ondemand-export',
}
-> exec { 'setfacl -dm u:xdmod-ondemand-export:r-- /etc/httpd/logs':
path => '/usr/bin:/usr/sbin:/bin',
unless => 'getfacl -d /etc/httpd/logs/ | grep xdmod-ondemand-export',
}

file { '/home/xdmod-ondemand-export/conf.ini':
ensure => 'file',
require => User['xdmod-ondemand-export'],
owner => 'xdmod-ondemand-export',
group => 'xdmod-ondemand-export',
mode => '0400',
content => file('profile_ondemand/xdmod_export_conf.ini'),
}

file { '/home/xdmod-ondemand-export/.token':
ensure => 'file',
require => User['xdmod-ondemand-export'],
owner => 'xdmod-ondemand-export',
group => 'xdmod-ondemand-export',
mode => '0400',
content => $token,
}

file { '/home/xdmod-ondemand-export/last-run.json':
ensure => 'present',
require => User['xdmod-ondemand-export'],
owner => 'xdmod-ondemand-export',
group => 'xdmod-ondemand-export',
mode => '0600',
}

cron { 'xdmod-ondemand-export':
command => "su -c '/home/xdmod-ondemand-export/venv/bin/xdmod-ondemand-export' -s /bin/bash xdmod-ondemand-export",
hour => fqdn_rand(24),
minute => fqdn_rand(60),
}

}
}

0 comments on commit 41cdeff

Please sign in to comment.