sysutils/puppet-agent: add log file

This commit is contained in:
Frank Wall
2021-10-11 23:43:50 +02:00
parent fed3659df1
commit f2980f9178
7 changed files with 74 additions and 4 deletions
+12
View File
@@ -5,3 +5,15 @@ hosts, along with obviously discrete elements like packages, services, and
files.
WWW: https://puppet.com/docs/puppet/latest/man/agent.html
Plugin Changelog
================
1.0
Added:
* add log file
0.1
* Initial release
@@ -1,5 +1,8 @@
<menu>
<Services>
<PuppetAgent VisibleName="Puppet Agent" url="/ui/puppetagent"/>
<PuppetAgent VisibleName="Puppet Agent" cssClass="fa fa-certificate fa-fw">
<Settings order="10" url="/ui/puppetagent"/>
<Logs order="20" url="/ui/diagnostics/log/core/puppet-agent"/>
</PuppetAgent>
</Services>
</menu>
@@ -1,8 +1,7 @@
<model>
<mount>//OPNsense/puppetagent</mount>
<description>
Manage Puppet Agent service
</description>
<version>1.0.0</version>
<description>Manage Puppet Agent service</description>
<items>
<!-- container -->
<general>
@@ -0,0 +1,50 @@
"""
Copyright (c) 2021 Frank Wall
Copyright (c) 2020 Ad Schellevis <ad@opnsense.org>
Copyright (c) 2020 devNan0 <nan0@nan0.dev>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
"""
import re
import datetime
from . import BaseLogFormat
puppet_timeformat = r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\s+[-+]{1}\d{4}).*'
class TelegrafLogFormat(BaseLogFormat):
def __init__(self, filename):
super(TelegrafLogFormat, self).__init__(filename)
self._priority = 100
def match(self, line):
return self._filename.find('puppet') > -1 and re.match(puppet_timeformat, line) is not None
@staticmethod
def timestamp(line):
tmp = re.match(puppet_timeformat, line)
grp = tmp.group(1)
return datetime.datetime.strptime(grp, "%Y-%m-%d %H:%M:%S %z").isoformat()
@staticmethod
def line(line):
return line[26:].strip()
@@ -1,2 +1,3 @@
puppetagent.conf:/usr/local/etc/puppet/puppet.conf
newsyslog.conf:/etc/newsyslog.conf.d/puppet-agent
rc.conf.d:/etc/rc.conf.d/puppet
@@ -0,0 +1,4 @@
{% if helpers.exists('OPNsense.puppetagent.general') and OPNsense.puppetagent.general.Enabled|default("0") == "1" %}
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/puppet-agent.log puppet:puppet 640 7 * @T00 JCB /var/run/puppet/agent.pid 1
{% endif %}
@@ -2,6 +2,7 @@
[main]
certname = {{ system.hostname|lower }}.{{ system.domain|lower }}
server = {{ OPNsense.puppetagent.general.FQDN|default("") }}
logdest = /var/log/puppet-agent.log
{% if helpers.exists('OPNsense.puppetagent.general') and not helpers.empty('OPNsense.puppetagent.general.Environment') %}
[agent]
environment = {{ OPNsense.puppetagent.general.Environment|default("") }}