refs #1719 adds filebeat function installer
parent
d4e0b88f44
commit
d4baaed765
|
@ -144,6 +144,41 @@ def boottoolsInitrdGenerate (osrelease):
|
||||||
os.chdir ('/tmp')
|
os.chdir ('/tmp')
|
||||||
shutil.rmtree ('undone')
|
shutil.rmtree ('undone')
|
||||||
|
|
||||||
|
def setup_filebeat():
|
||||||
|
deb_path = "/etc/filebeat/filebeat-oss-7.12.1-amd64.deb"
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Instalar Filebeat desde el .deb directamente
|
||||||
|
subprocess.run(["dpkg", "-i", "--force-overwrite", deb_path], check=True)
|
||||||
|
|
||||||
|
# (Opcional) Garantizar permisos adecuados sobre los certificados y configuraciones
|
||||||
|
subprocess.run(["chmod", "644", "/etc/filebeat/ogagent-fb.mytld.crt.pem"], check=True)
|
||||||
|
subprocess.run(["chmod", "600", "/etc/filebeat/ogagent-fb.mytld.key.pem"], check=True)
|
||||||
|
subprocess.run(["chmod", "644", "/etc/ssl/certs/ca.crt.pem"], check=True)
|
||||||
|
subprocess.run(["chmod", "644", "/etc/filebeat/filebeat.yml"], check=True)
|
||||||
|
|
||||||
|
# Añadir entrada al /etc/hosts
|
||||||
|
oglog_ip = os.getenv('OGAGENTCFG_OGLOG_IP', '192.168.2.4')
|
||||||
|
with open('/etc/hosts', 'a') as f:
|
||||||
|
f.write(f"{oglog_ip} oglog-os.mytld\n")
|
||||||
|
|
||||||
|
# Ejecutar Filebeat directamente sin systemd
|
||||||
|
subprocess.Popen([
|
||||||
|
"/usr/bin/filebeat",
|
||||||
|
"-c", "/etc/filebeat/filebeat.yml",
|
||||||
|
"--path.home", "/usr/share/filebeat",
|
||||||
|
"--path.config", "/etc/filebeat",
|
||||||
|
"--path.data", "/var/lib/filebeat",
|
||||||
|
"--path.logs", "/var/log/filebeat"
|
||||||
|
])
|
||||||
|
|
||||||
|
print("Filebeat instalado y ejecutándose correctamente.")
|
||||||
|
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Error instalando Filebeat: {e}")
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
print(f"Error inesperado al configurar Filebeat: {ex}")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -165,3 +200,4 @@ if __name__ == '__main__':
|
||||||
boottoolsRemovePackages()
|
boottoolsRemovePackages()
|
||||||
setup_resolvconf() ## do this again, since someone seems to be overwriting the file
|
setup_resolvconf() ## do this again, since someone seems to be overwriting the file
|
||||||
boottoolsInitrdGenerate (args.osrelease)
|
boottoolsInitrdGenerate (args.osrelease)
|
||||||
|
setup_filebeat()
|
||||||
|
|
Loading…
Reference in New Issue