From 85194fe2be4acb5de34c064884654ae2074a149a Mon Sep 17 00:00:00 2001 From: rafael <rafael.ameijeiras@artica.es> Date: Fri, 21 Jul 2023 11:23:31 +0200 Subject: [PATCH 1/5] 11757 adding inventory demo data script to load util --- .../util/load/generate_inventory_data.sh | 66 +++++ .../load/templates/inventory_linux.template | 192 +++++++++++++ .../load/templates/inventory_windows.template | 257 ++++++++++++++++++ 3 files changed, 515 insertions(+) create mode 100755 pandora_server/util/load/generate_inventory_data.sh create mode 100644 pandora_server/util/load/templates/inventory_linux.template create mode 100644 pandora_server/util/load/templates/inventory_windows.template diff --git a/pandora_server/util/load/generate_inventory_data.sh b/pandora_server/util/load/generate_inventory_data.sh new file mode 100755 index 0000000000..b91ac24af7 --- /dev/null +++ b/pandora_server/util/load/generate_inventory_data.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# (c) 2023 Pandora FMS + +if [ ! -e pandora_xml_stress.agents ] +then + echo "Error, cant find pandora_xml_stress.agets file" + exit +fi + +linux_inventory=1 +windows_inventory=1 + +# Variables +agent_count=5 + +data_in=/var/spool/pandora/data_in/ +description='Demo data Agent' +group='Servers' +current_date=`date +"%Y/%m/%d %H:%M:%S"` +current_utimestamp=`date +%s` + +if [ $linux_inventory -eq 1 ] ; then + + if [ ! -e templates/inventory_linux.template ]; then + echo "Error, cant find inventory linux template" + exit + fi + + echo "Enable linux invetory: adding invetory data to ${agent_count} linux agent" + + for agent_name in $(cat pandora_xml_stress.agents | head ${agent_conunt}); do + echo " - Adding invetory data to ${agent_name} linux agent" + ip_add="10.0.0.$(( RANDOM % 255 + 1 ))" + rand_number=$(( RANDOM % 10 + 1 )) + cat "templates/inventory_linux.template" \ + | sed -e "s/{{description}}/${description}/g" \ + -e "s/{{group}}/${group}/g" \ + -e "s/{{agent_name}}/${agent_name}/g" \ + -e "s|{{date}}|${current_date}|g" \ + -e "s|{{ip_address}}|${ip_add}|g" \ + -e "s|{{rand_number}}|${rand_number}|g" \ + > /${data_in}/${agent_name}.${current_utimestamp}.data + done +fi + +if [ $windows_inventory -eq 1 ]; then + if [ ! -e templates/inventory_windows.template ]; then + echo "Error, cant find inventory Windows template" + exit + fi + echo "Enable Windows invetory: adding invetory data to ${agent_count} Windows agent" + + for agent_name in $(cat pandora_xml_stress.agents | tail ${agent_conunt}); do + echo " - Adding invetory data to ${agent_name} windows agent" + ip_add="172.16.5.$(( RANDOM % 255 + 1 ))" + rand_number=$(( RANDOM % 100 + 1 )) + cat "templates/inventory_windows.template" \ + | sed -e "s/{{description}}/${description}/g" \ + -e "s/{{group}}/${group}/g" \ + -e "s/{{agent_name}}/${agent_name}/g" \ + -e "s|{{date}}|${current_date}|g" \ + -e "s|{{rand_number}}|${rand_number}|g" \ + -e "s|{{ip_address}}|${ip_add}|g" \ + > /${data_in}/${agent_name}.${current_utimestamp}.data + done +fi \ No newline at end of file diff --git a/pandora_server/util/load/templates/inventory_linux.template b/pandora_server/util/load/templates/inventory_linux.template new file mode 100644 index 0000000000..3e1cb25627 --- /dev/null +++ b/pandora_server/util/load/templates/inventory_linux.template @@ -0,0 +1,192 @@ +<?xml version='1.0' encoding='UTF-8'?> +<agent_data description='{{description}}' group='{{group}}' os_name='linux' os_version='Rocky Linux 8.7 (Green Obsidian)' interval='300' version='' timestamp='{{date}}' agent_name='{{agent_name}}' agent_alias='' timezone_offset='0' custom_id='' url_address='' address=''> + +<inventory> + <inventory_module> + <name><![CDATA[IP]]></name> + <datalist> + <data><![CDATA[eth0;{{ip_address}} ]]></data> + <data><![CDATA[lo;127.0.0.1 ]]></data> + </datalist> + </inventory_module> + <inventory_module> + <name><![CDATA[File system]]></name> + <datalist> + <data><![CDATA[overlay;38G;919G;/]]></data> + <data><![CDATA[tmpfs;0;64M;/dev]]></data> + <data><![CDATA[tmpfs;0;16G;/sys/fs/cgroup]]></data> + <data><![CDATA[shm;0;64M;/dev/shm]]></data> + <data><![CDATA[/dev/sdc;39G;918G;/tmp/pandora_code]]></data> + <data><![CDATA[none;108K;16G;/tmp/.X11-unix]]></data> + <data><![CDATA[/dev/sde;38G;919G;/etc/hosts]]></data> + <data><![CDATA[tmpfs;0;16G;/proc/acpi]]></data> + <data><![CDATA[tmpfs;0;16G;/sys/firmware]]></data> + </datalist> + </inventory_module> + <inventory_module> + <name><![CDATA[Process]]></name> + <datalist> + <data><![CDATA[/bin/bash /tmp/pandora_code/projects/qa_utils/run_pandora_qa/local_install_qa.sh]]></data> + <data><![CDATA[sudo -u mysql mysqld]]></data> + <data><![CDATA[mysqld]]></data> + <data><![CDATA[php-fpm: master process (/etc/php-fpm.conf)]]></data> + <data><![CDATA[php-fpm: pool www]]></data> + <data><![CDATA[php-fpm: pool www]]></data> + <data><![CDATA[php-fpm: pool www]]></data> + <data><![CDATA[php-fpm: pool www]]></data> + <data><![CDATA[php-fpm: pool www]]></data> + <data><![CDATA[httpd -k start]]></data> + <data><![CDATA[httpd -k start]]></data> + <data><![CDATA[httpd -k start]]></data> + <data><![CDATA[httpd -k start]]></data> + <data><![CDATA[httpd -k start]]></data> + <data><![CDATA[php-fpm: pool www]]></data> + <data><![CDATA[httpd -k start]]></data> + <data><![CDATA[/usr/bin/perl /usr/bin/tentacle_server -F /etc/tentacle/tentacle_server.conf]]></data> + <data><![CDATA[/usr/bin/perl /usr/bin/pandora_ha -d -p /var/run/pandora_ha.pid /etc/pandora/pandora_server.conf]]></data> + <data><![CDATA[/usr/bin/perl /usr/bin/pandora_agent /etc/pandora]]></data> + <data><![CDATA[/usr/bin/php /var/www/html/pandora_console/ws.php]]></data> + <data><![CDATA[/usr/bin/gotty --permit-arguments -a 127.0.0.1 -w --port 8081 ssh]]></data> + <data><![CDATA[/usr/bin/gotty --permit-arguments -a 127.0.0.1 -w --port 8082 telnet]]></data> + <data><![CDATA[crond]]></data> + <data><![CDATA[/bin/bash]]></data> + <data><![CDATA[/usr/bin/perl /usr/bin/pandora_server /etc/pandora/pandora_server.conf -D]]></data> + <data><![CDATA[/usr/bin/perl /etc/pandora/plugins/inventory 0]]></data> + <data><![CDATA[sh -c ps -eo command | tail -n +2]]></data> + <data><![CDATA[ps -eo command]]></data> + <data><![CDATA[/usr/bin/coreutils --coreutils-prog-shebang=tail /usr/bin/tail -n +2]]></data> + </datalist> + </inventory_module> + <inventory_module> + <name><![CDATA[Kernel]]></name> + <datalist> + <data><![CDATA[Linux pandorafms 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux +]]></data> + </datalist> + </inventory_module> + <inventory_module> + <name><![CDATA[Software]]></name> + <datalist> + <data><![CDATA[abattis-cantarell-fonts;0.0.{{rand_number}};Cantarell, a Humanist sans-serif font family]]></data> + <data><![CDATA[acl;2.2.53;Access control list utilities]]></data> + <data><![CDATA[adobe-mappings-cmap;20171205;CMap resources for Adobe's character collections]]></data> + <data><![CDATA[adobe-mappings-cmap-deprecated;20171205;Deprecated CMap resources for Adobe's character collections]]></data> + <data><![CDATA[adobe-mappings-pdf;20180407;PDF mapping resources from Adobe]]></data> + <data><![CDATA[adwaita-cursor-theme;3.28.0;Adwaita cursor theme]]></data> + <data><![CDATA[adwaita-icon-theme;3.{{rand_number}}.0;Adwaita icon theme]]></data> + <data><![CDATA[alsa-lib;1.2.7.2;The Advanced Linux Sound Architecture (ALSA) library]]></data> + <data><![CDATA[annobin;10.67;Annotate and examine compiled binary files]]></data> + <data><![CDATA[apr;1.6.3;Apache Portable Runtime library]]></data> + <data><![CDATA[apr-util;1.6.1;Apache Portable Runtime Utility library]]></data> + <data><![CDATA[python39;3.9.{{rand_number}};Version 3.9 of the Python interpreter]]></data> + <data><![CDATA[python39-libs;3.9.{{rand_number}};Python runtime libraries]]></data> + <data><![CDATA[python39-pip;20.{{rand_number}}.4;A tool for installing and managing Python3 packages]]></data> + <data><![CDATA[python39-pip-wheel;20.2.4;The pip wheel]]></data> + <data><![CDATA[python39-setuptools;50.3.2;Easily build and distribute Python 3 packages]]></data> + <data><![CDATA[python39-setuptools-wheel;50.3.2;The setuptools wheel]]></data> + <data><![CDATA[python39-tkinter;3.9.13;A GUI toolkit for Python]]></data> + <data><![CDATA[python3-audit;3.0.7;Python3 bindings for libaudit]]></data> + <data><![CDATA[python3-bind;9.11.36;A module allowing rndc commands to be sent from Python programs]]></data> + <data><![CDATA[python3-dateutil;2.6.1;Powerful extensions to the standard datetime module]]></data> + <data><![CDATA[python3-dbus;1.2.4;D-Bus bindings for python3]]></data> + <data><![CDATA[python3-dnf;4.7.0;Python 3 interface to DNF]]></data> + <data><![CDATA[python3-dnf-plugins-core;4.0.21;Core Plugins for DNF]]></data> + <data><![CDATA[python3-gpg;1.13.1;gpgme bindings for Python 3]]></data> + <data><![CDATA[python3-hawkey;0.63.0;Python 3 bindings for the hawkey library]]></data> + <data><![CDATA[python3-libcomps;0.1.18;Python 3 bindings for libcomps library]]></data> + <data><![CDATA[python3-libdnf;0.63.0;Python 3 bindings for the libdnf library.]]></data> + <data><![CDATA[python3-libs;3.6.8;Python runtime libraries]]></data> + <data><![CDATA[python3-libselinux;2.9;SELinux python 3 bindings for libselinux]]></data> + <data><![CDATA[python3-libsemanage;2.9;semanage python 3 bindings for libsemanage]]></data> + <data><![CDATA[python3-pip-wheel;9.0.3;The pip wheel]]></data> + <data><![CDATA[python3-ply;3.9;Python Lex-Yacc]]></data> + <data><![CDATA[python3-policycoreutils;2.9;SELinux policy core python3 interfaces]]></data> + <data><![CDATA[python3-pyparsing;2.1.10;Python package with an object-oriented approach to text processing]]></data> + <data><![CDATA[python3-rpm;4.14.3;Python 3 bindings for apps which will manipulate RPM packages]]></data> + <data><![CDATA[python3-rpm-macros;3;RPM macros for building Python 3 packages]]></data> + <data><![CDATA[python3-setools;4.3.0;Policy analysis tools for SELinux]]></data> + <data><![CDATA[python3-setuptools-wheel;39.2.0;The setuptools wheel]]></data> + <data><![CDATA[python3-six;1.11.0;Python 2 and 3 compatibility utilities]]></data> + <data><![CDATA[python-rpm-macros;3;The unversioned Python RPM macros]]></data> + <data><![CDATA[python-srpm-macros;3;RPM macros for building Python source packages]]></data> + <data><![CDATA[qt5-srpm-macros;5.15.3;RPM macros for source Qt5 packages]]></data> + <data><![CDATA[readline;7.0;A library for editing typed command lines]]></data> + <data><![CDATA[redhat-rpm-config;130;Red Hat specific rpm configuration files]]></data> + <data><![CDATA[remi-libssh2;1.10.0;A library implementing the SSH2 protocol]]></data> + <data><![CDATA[remi-release;8.7;YUM configuration for remi repository]]></data> + <data><![CDATA[rest;0.8.1;A library for access to RESTful web services]]></data> + <data><![CDATA[rocky-gpg-keys;8.7;Rocky RPM GPG Keys]]></data> + <data><![CDATA[rocky-indexhtml;8.0;Browser default start page for Rocky Linux]]></data> + <data><![CDATA[rocky-logos-httpd;86.3;Rocky related icons and pictures used by httpd]]></data> + <data><![CDATA[rocky-release;8.7;Rocky Linux release files]]></data> + <data><![CDATA[rocky-repos;8.7;Rocky Linux Package Repositories]]></data> + <data><![CDATA[rootfiles;8.1;The basic required files for the root user's directory]]></data> + <data><![CDATA[rpm;4.14.3;The RPM package management system]]></data> + <data><![CDATA[rpm-build-libs;4.14.3;Libraries for building and signing RPM packages]]></data> + <data><![CDATA[rpm-libs;4.14.3;Libraries for manipulating RPM packages]]></data> + <data><![CDATA[rrdtool;1.7.0;Round Robin Database Tool to store and display time-series data]]></data> + <data><![CDATA[rsync;3.1.3;A program for synchronizing files over a network]]></data> + <data><![CDATA[rust-srpm-macros;5;RPM macros for building Rust source packages]]></data> + <data><![CDATA[samba-client-libs;4.16.4;Samba client libraries]]></data> + <data><![CDATA[samba-common;4.16.4;Files used by both Samba servers and clients]]></data> + <data><![CDATA[samba-common-libs;4.16.4;Libraries used by both Samba servers and clients]]></data> + <data><![CDATA[samba-winexe;4.16.4;Samba Winexe Windows Binary]]></data> + <data><![CDATA[sed;4.5;A GNU stream text editor]]></data> + <data><![CDATA[setup;2.12.2;A set of system configuration and setup files]]></data> + <data><![CDATA[shadow-utils;4.6;Utilities for managing accounts and shadow password files]]></data> + <data><![CDATA[shared-mime-info;1.9;Shared MIME information database]]></data> + <data><![CDATA[sound-theme-freedesktop;0.8;freedesktop.org sound theme]]></data> + <data><![CDATA[sqlite-libs;3.26.0;Shared library for the sqlite3 embeddable SQL database engine.]]></data> + <data><![CDATA[sscg;3.0.0;Simple SSL certificate generator]]></data> + <data><![CDATA[sudo;1.8.29;Allows restricted root access for specified users]]></data> + <data><![CDATA[svt-av1-libs;0.8.7;SVT-AV1 libraries]]></data> + <data><![CDATA[systemd;239;System and Service Manager]]></data> + <data><![CDATA[systemd-libs;239;systemd libraries]]></data> + <data><![CDATA[systemd-pam;239;systemd PAM module]]></data> + <data><![CDATA[systemd-udev;239;Rule-based device node and kernel event manager]]></data> + <data><![CDATA[systemtap-sdt-devel;4.7;Static probe support tools]]></data> + <data><![CDATA[tar;1.30;A GNU file archiving program]]></data> + <data><![CDATA[tcl;8.6.8;Tool Command Language, pronounced tickle]]></data> + <data><![CDATA[tk;8.6.8;The graphical toolkit for the Tcl scripting language]]></data> + <data><![CDATA[tpm2-tss;2.3.2;TPM2.0 Software Stack]]></data> + <data><![CDATA[tree;1.7.0;File system tree viewer]]></data> + <data><![CDATA[ttmkfdir;3.0.9;Utility to create fonts.scale files for truetype fonts]]></data> + <data><![CDATA[tzdata;2022g;Timezone data]]></data> + <data><![CDATA[tzdata-java;2022g;Timezone data for Java]]></data> + <data><![CDATA[unixODBC;2.3.7;A complete ODBC driver manager for Linux]]></data> + <data><![CDATA[unzip;6.0;A utility for unpacking zip files]]></data> + <data><![CDATA[util-linux;2.32.1;A collection of basic system utilities]]></data> + <data><![CDATA[vim-common;8.0.1763;The common files needed by any version of the VIM editor]]></data> + <data><![CDATA[vim-enhanced;8.0.1763;A version of the VIM editor which includes recent enhancements]]></data> + <data><![CDATA[vim-filesystem;8.0.1763;VIM filesystem layout]]></data> + <data><![CDATA[vim-minimal;8.0.1763;A minimal version of the VIM editor]]></data> + <data><![CDATA[VMware-vSphere-Perl-SDK;6.5.0;VMware libraries for Perl. Allows connect to remote VSphere/VCenter/ESXi device.]]></data> + <data><![CDATA[wget;1.19.5;A utility for retrieving files using the HTTP or FTP protocols]]></data> + <data><![CDATA[which;2.21;Displays where a particular program in your path is located]]></data> + <data><![CDATA[whois;5.5.1;Improved WHOIS client]]></data> + <data><![CDATA[whois-nls;5.5.1;Gettext catalogs for whois tools]]></data> + <data><![CDATA[wmic;1.4;PandoraFMS wmic binary]]></data> + <data><![CDATA[x11vnc;0.9.16;VNC server for the current X11 session]]></data> + <data><![CDATA[xkeyboard-config;2.28;X Keyboard Extension configuration data]]></data> + <data><![CDATA[xterm;331;Terminal emulator for the X Window System]]></data> + <data><![CDATA[xterm-resize;331;Set environment and terminal settings to current window size]]></data> + <data><![CDATA[xz;5.2.4;LZMA compression utilities]]></data> + <data><![CDATA[xz-devel;5.2.4;Devel libraries & headers for liblzma]]></data> + <data><![CDATA[xz-libs;5.2.4;Libraries for decoding LZMA compression]]></data> + <data><![CDATA[yum;4.7.0;Package manager]]></data> + <data><![CDATA[yum-utils;4.0.21;Yum-utils CLI compatibility layer]]></data> + <data><![CDATA[zip;3.0;A file compression and packaging utility compatible with PKZIP]]></data> + <data><![CDATA[zlib;1.2.11;The compression and decompression library]]></data> + <data><![CDATA[zlib-devel;1.2.{{rand_number}};Header files and libraries for Zlib development]]></data> + </datalist> + </inventory_module> + <inventory_module> + <name><![CDATA[Routes]]></name> + <datalist> + <data><![CDATA[default;_gateway;0.0.0.0;UG;0;0;eth0]]></data> + <data><![CDATA[{{ip_address}};0.0.0.0;255.255.0.0;U;0;0;eth0]]></data> + </datalist> + </inventory_module> +</inventory> + +</agent_data> diff --git a/pandora_server/util/load/templates/inventory_windows.template b/pandora_server/util/load/templates/inventory_windows.template new file mode 100644 index 0000000000..127ca1dfba --- /dev/null +++ b/pandora_server/util/load/templates/inventory_windows.template @@ -0,0 +1,257 @@ +<?xml version='1.0' encoding='UTF-8'?> +<agent_data description='{{description}}' group='{{group}}' os_name='windows' os_version='Windows 11' interval='300' version='' timestamp='{{date}}' agent_name='{{agent_name}}' agent_alias='' timezone_offset='0' custom_id='' url_address='' address=''> + + <inventory> + <inventory_module> + <name>CPU</name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz;3696 MHz;Intel64 Family 6 Model 158 Stepping 10]]></data> + <data><![CDATA[Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz;3696 MHz;Intel64 Family 6 Model 158 Stepping 10]]></data> + <data><![CDATA[Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz;3696 MHz;Intel64 Family 6 Model 158 Stepping 10]]></data> + <data><![CDATA[Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz;3696 MHz;Intel64 Family 6 Model 158 Stepping 10]]></data> + </datalist> + </inventory_module> + + <inventory_module> + <name>HD</name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[XENSRC PVDISK SCSI Disk Device;100 GB;4c0ae98e-d414-4c ]]></data> + <data><![CDATA[XENSRC PVDISK SCSI Disk Device;100 GB;afd0d8a2-84d3-49 ]]></data> + </datalist> + </inventory_module> + + <inventory_module> + <name>Video</name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[Citrix Indirect Display Adapter;;PCI\VEN_5853&DEV_1003\1&79F5D87&2&03]]></data> + <data><![CDATA[Microsoft Basic Display Adapter;0 MB;PCI\VEN_1013&DEV_00B8&SUBSYS_00015853&REV_00\3&267A616A&0&10]]></data> + </datalist> + </inventory_module> + + <inventory_module> + <name>NIC</name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[XenServer PV Network Device;BE:99:07:B0:E6:8F;{{ip_address}}]]></data> + <data><![CDATA[XenServer PV Network Device;C6:4E:9F:12:99:27;]]></data> + </datalist> + </inventory_module> + + <inventory_module> + <name>Monitors</name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[Generic Non-PnP Monitor;DISPLAY\DEFAULT_MONITOR\4&251819FC&0&UID0]]></data> + </datalist> + </inventory_module> + + <inventory_module> + <name>RAM</name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[DIMM 0;4092 MB;18756 MHz]]></data> + <data><![CDATA[DIMM 1;4092 MB;18756 MHz]]></data> + </datalist> + </inventory_module> + + <inventory_module> + <name><![CDATA[Software]]></name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[Microsoft Office 32-bit Components 2016 ;16.0.{{rand_number}}.1000]]></data> + <data><![CDATA[Microsoft Office Shared 32-bit MUI (Spanish) 2016 ;16.0.4417.1000]]></data> + <data><![CDATA[Microsoft Skype for Business MUI (Spanish) 2016;16.0.4417.1000]]></data> + <data><![CDATA[Microsoft Office Proofing (Spanish) 2016 ;16.0.4417.1000]]></data> + <data><![CDATA[Microsoft Skype for Business Entry 2016 ;16.0.4417.1000]]></data> + <data><![CDATA[Microsoft Office Shared MUI (Spanish) 2016 ;16.0.4417.1000]]></data> + <data><![CDATA[Eines de correcció del Microsoft Office 2016: català ;16.0.4417.1000]]></data> + <data><![CDATA[Revisores de Texto do Microsoft Office 2016 – Português (Brasil) ;16.0.4417.1000]]></data> + <data><![CDATA[Ferramentas de verificación de Microsoft Office 2016 - Galego ;16.0.4417.1000]]></data> + <data><![CDATA[Microsoft Office Proofing Tools 2016 - English ;16.0.4417.1000]]></data> + <data><![CDATA[Herramientas de corrección de Microsoft Office 2016: español;16.0.4417.1000]]></data> + <data><![CDATA[Microsoft Office zuzenketa-tresnak 2016 - Euskara ;16.0.4417.1000]]></data> + <data><![CDATA[Microsoft OLE DB Driver for SQL Server;18.6.5.0]]></data> + <data><![CDATA[Integration Services ;16.0.5107.0]]></data> + <data><![CDATA[Remote Desktop ;1.2.{{rand_number}}.0]]></data> + <data><![CDATA[XCP-ng Center 20.04.01;20.04.01.33]]></data> + <data><![CDATA[Universal CRT Headers Libraries and Sources ;10.1.18362.1]]></data> + <data><![CDATA[MSI Development Tools ;10.1.22000.194]]></data> + <data><![CDATA[Windows SDK Redistributables;10.1.18362.1]]></data> + <data><![CDATA[MSI Development Tools ;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 XEvent;16.0.1000.6]]></data> + <data><![CDATA[Windows SDK Desktop Tools x86 ;10.1.18362.1]]></data> + <data><![CDATA[CrossChex Standard ;1.1.0.0]]></data> + <data><![CDATA[Windows SDK Desktop Tools x64 ;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 Shared Management Objects;16.0.1000.6]]></data> + <data><![CDATA[WinRT Intellisense PPI - en-us ;10.1.18362.1]]></data> + <data><![CDATA[WinRT Intellisense UAP - Other Languages ;10.1.18362.1]]></data> + <data><![CDATA[Microsoft .NET Framework 4.8 Targeting Pack ;4.8.03761]]></data> + <data><![CDATA[Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219 ;10.0.40219]]></data> + <data><![CDATA[Windows SDK AddOn ;10.1.0.0]]></data> + <data><![CDATA[GlobalProtect ;5.2.13]]></data> + <data><![CDATA[Windows SDK ;10.1.18362.1]]></data> + <data><![CDATA[Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219 ;10.0.40219]]></data> + <data><![CDATA[Windows SDK for Windows Store Apps Contracts;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK Signing Tools;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 Database Engine Shared;16.0.1000.6]]></data> + <data><![CDATA[Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005 ;12.0.21005]]></data> + <data><![CDATA[Windows SDK EULA;10.1.18362.1]]></data> + <data><![CDATA[Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005 ;12.0.21005]]></data> + <data><![CDATA[WPTx64 (DesktopEditions) ;10.1.22000.194]]></data> + <data><![CDATA[Citrix XenServer Windows Management Agent;7.2.1555]]></data> + <data><![CDATA[Microsoft Visual C++ 2019 X64 Minimum Runtime - 14.29.30139 ;14.29.30139]]></data> + <data><![CDATA[Microsoft Visual C++ 2019 X64 Additional Runtime - 14.29.30139 ;14.29.30139]]></data> + <data><![CDATA[SDK Debuggers ;10.1.22000.194]]></data> + <data><![CDATA[Windows SDK ARM Desktop Tools ;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 Connection Info;16.0.1000.6]]></data> + <data><![CDATA[VMware Horizon HTML5 Multimedia Redirection Client;7.8.0]]></data> + <data><![CDATA[Microsoft Analysis Services OLE DB Provider ;16.0.5143.0]]></data> + <data><![CDATA[Windows Mobile Extension SDK Contracts;10.1.18362.1]]></data> + <data><![CDATA[WinRT Intellisense PPI - Other Languages ;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK for Windows Store Apps Metadata ;10.1.18362.1]]></data> + <data><![CDATA[VMware Horizon Client ;5.0.0.5596]]></data> + <data><![CDATA[Microsoft SQL Server 2022 Setup (English);16.0.{{rand_number}}.5]]></data> + <data><![CDATA[SQL Server 2022 Connection Info;16.0.1000.6]]></data> + <data><![CDATA[WinRT Intellisense Desktop - en-us;10.1.18362.1]]></data> + <data><![CDATA[Microsoft Visual Studio Tools for Applications 2019 x64 Hosting Support ;16.0.31110]]></data> + <data><![CDATA[Universal CRT Tools x64 ;10.1.18362.1]]></data> + <data><![CDATA[Application Verifier x64 External Package;10.1.22000.194]]></data> + <data><![CDATA[SSMS Post Install Tasks ;19.0.20209.0]]></data> + <data><![CDATA[MSI Wrapper 10.0.50.0 ;10.0.50.0]]></data> + <data><![CDATA[Windows SDK DirectX x86 Remote ;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 Database Engine Services ;16.0.1000.6]]></data> + <data><![CDATA[Microsoft Web Platform Installer 5.1 ;5.1.51515.0]]></data> + <data><![CDATA[Self-service Plug-in ;21.7.0.28]]></data> + <data><![CDATA[SDK ARM Redistributables ;10.1.18362.1]]></data> + <data><![CDATA[Citrix Web Helper ;21.7.0.28]]></data> + <data><![CDATA[FortiClient ;6.0.10.0297]]></data> + <data><![CDATA[Microsoft Visual Studio Tools for Applications 2019 x86 Hosting Support ;16.0.31110]]></data> + <data><![CDATA[Windows SDK EULA;10.1.22000.194]]></data> + <data><![CDATA[Microsoft Visual C++ 2019 X86 Additional Runtime - 14.29.30139 ;14.29.30139]]></data> + <data><![CDATA[SQL Server 2022 Common Files;16.0.1000.6]]></data> + <data><![CDATA[Windows Mobile Extension SDK;10.1.18362.1]]></data> + <data><![CDATA[Citrix WorkSpace Browser ;21.7.0.2]]></data> + <data><![CDATA[Python 2.7.15 ;2.7.15150]]></data> + <data><![CDATA[WinRT Intellisense IoT - Other Languages ;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 Database Engine Services ;16.0.1000.6]]></data> + <data><![CDATA[Java 8 Update 201 ;8.0.2010.9]]></data> + <data><![CDATA[Java 8 Update 201 (64-bit) ;8.0.2010.9]]></data> + <data><![CDATA[Microsoft .NET Framework 4.8 SDK ;4.8.03928]]></data> + <data><![CDATA[SQL Server 2022 Shared Management Objects Extensions ;16.0.1000.6]]></data> + <data><![CDATA[SQL Server 2022 Database Engine Services ;16.0.1000.6]]></data> + <data><![CDATA[VIP Access ;2.2.4.44]]></data> + <data><![CDATA[Microsoft Visual C++ 2019 X86 Minimum Runtime - 14.29.30139 ;14.29.30139]]></data> + <data><![CDATA[Microsoft Analysis Services OLE DB Provider ;16.0.5143.0]]></data> + <data><![CDATA[RSA SecurID Software Token ;5.0.2.440]]></data> + <data><![CDATA[Windows SDK Facade Windows WinMD Versioned ;10.1.18362.1]]></data> + <data><![CDATA[Browser for SQL Server 2022 ;16.0.1000.6]]></data> + <data><![CDATA[SQL Server Management Studio Language Pack - English ;19.0.20209.0]]></data> + <data><![CDATA[PowerShell 7-x64;7.2.11.0]]></data> + <data><![CDATA[Microsoft Help Viewer 2.3;2.3.28307]]></data> + <data><![CDATA[Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005 ;12.0.21005]]></data> + <data><![CDATA[Online Plug-in ;21.7.0.17]]></data> + <data><![CDATA[Microsoft Visual C++ 2008 Redistributable - x64 9.0.{{rand_number}}.6161 ;9.0.30729.6161]]></data> + <data><![CDATA[SDK ARM Additions ;10.1.18362.1]]></data> + <data><![CDATA[Universal CRT Tools x86 ;10.1.18362.1]]></data> + <data><![CDATA[Citrix Screen Casting for Windows ;19.11.100.48]]></data> + <data><![CDATA[WPTx64 (OnecoreUAP);10.1.22000.194]]></data> + <data><![CDATA[Windows IoT Extension SDK Contracts;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 DMF;16.0.1000.6]]></data> + <data><![CDATA[Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161 ;9.0.30729.6161]]></data> + <data><![CDATA[Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005 ;12.0.21005]]></data> + <data><![CDATA[Windows SDK for Windows Store Apps Tools ;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK for Windows Store Managed Apps Libs;10.1.18362.1]]></data> + <data><![CDATA[Check Point VPN;98.61.3407]]></data> + <data><![CDATA[Windows SDK for Windows Store Apps;10.1.18362.1]]></data> + <data><![CDATA[Application Verifier x64 External Package;10.1.18362.1]]></data> + <data><![CDATA[Universal General MIDI DLS Extension SDK ;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK Desktop Libs x86;10.1.18362.1]]></data> + <data><![CDATA[Windows App Certification Kit x64 ;10.1.18362.1]]></data> + <data><![CDATA[Citrix Workspace(DV) ;21.7.0.17]]></data> + <data><![CDATA[SQL Server 2022 Database Engine Shared;16.0.1000.6]]></data> + <data><![CDATA[SQL Server 2022 SQL Diagnostics;16.0.1000.6]]></data> + <data><![CDATA[Microsoft VSS Writer for SQL Server 2022 ;16.0.1000.6]]></data> + <data><![CDATA[WPT Redistributables ;10.1.22000.194]]></data> + <data><![CDATA[Kits Configuration Installer;10.1.22000.194]]></data> + <data><![CDATA[Windows SDK for Windows Store Apps Libs ;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 Batch Parser;16.0.1000.6]]></data> + <data><![CDATA[SQL Server 2022 XEvent;16.0.1000.6]]></data> + <data><![CDATA[Windows SDK Desktop Libs x64;10.1.18362.1]]></data> + <data><![CDATA[SMA Connect Agent ;1.0.13]]></data> + <data><![CDATA[Windows SDK Desktop Tools arm64;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK DirectX x64 Remote ;10.1.18362.1]]></data> + <data><![CDATA[Microsoft SQL Server 2022 RsFx Driver ;16.0.1000.6]]></data> + <data><![CDATA[Citrix Workspace(USB) ;21.7.0.17]]></data> + <data><![CDATA[Universal CRT Extension SDK ;10.1.18362.1]]></data> + <data><![CDATA[Check MK Agent 1.6 ;1.6.0p5]]></data> + <data><![CDATA[SQL Server 2022 Shared Management Objects;16.0.1000.6]]></data> + <data><![CDATA[SQL Server 2022 Shared Management Objects Extensions ;16.0.1000.6]]></data> + <data><![CDATA[WinRT Intellisense UAP - en-us ;10.1.18362.1]]></data> + <data><![CDATA[BIG-IP Edge Client ;72.22.0308....]]></data> + <data><![CDATA[Orca ;3.1.3790.0000]]></data> + <data><![CDATA[Cisco AnyConnect Secure Mobility Client ;4.9.06037]]></data> + <data><![CDATA[WinRT Intellisense IoT - en-us ;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 Common Files;16.0.1000.6]]></data> + <data><![CDATA[Windows IP Over USB;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK Desktop Headers arm;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 Database Engine Services ;16.0.1000.6]]></data> + <data><![CDATA[Windows App Certification Kit SupportedApiList x86;10.1.18362.1]]></data> + <data><![CDATA[Windows IoT Extension SDK;10.1.18362.1]]></data> + <data><![CDATA[MySQL Workbench 8.0 CE;8.0.23]]></data> + <data><![CDATA[Windows Desktop Extension SDK ;10.1.18362.1]]></data> + <data><![CDATA[Microsoft ODBC Driver 17 for SQL Server ;17.10.3.1]]></data> + <data><![CDATA[Google Chrome ;114.0.5735.199]]></data> + <data><![CDATA[Windows Desktop Extension SDK Contracts ;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK Modern Versioned Developer Tools;10.1.18362.1]]></data> + <data><![CDATA[Windows Team Extension SDK ;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK for Windows Store Apps DirectX x86 Remote;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK Desktop Libs arm64 ;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK Desktop Headers x64;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK Modern Non-Versioned Developer Tools ;10.1.18362.1]]></data> + <data><![CDATA[Windows App Certification Kit Native Components;10.1.18362.1]]></data> + <data><![CDATA[SQL Server 2022 DMF;16.0.1000.6]]></data> + <data><![CDATA[Citrix Authentication Manager ;21.7.0.2]]></data> + <data><![CDATA[Citrix Gateway Plug-in;12.1.55.18]]></data> + <data><![CDATA[Windows SDK Signing Tools;10.1.22000.194]]></data> + <data><![CDATA[Citrix Hypervisor PV Tools ;9.0.33]]></data> + <data><![CDATA[Windows SDK Desktop Headers arm64 ;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK Desktop Headers x86;10.1.18362.1]]></data> + <data><![CDATA[CrossChex Lite ;1.1.0.0]]></data> + <data><![CDATA[PuTTY release 0.70 (64-bit) ;0.70.0.0]]></data> + <data><![CDATA[SQL Server Management Studio;19.0.20209.0]]></data> + <data><![CDATA[Windows SDK Desktop Libs arm;10.1.18362.1]]></data> + <data><![CDATA[Visual Studio 2017 Isolated Shell for SSMS ;15.0.28308.421]]></data> + <data><![CDATA[Java Auto Updater ;2.8.{{rand_number}}.9]]></data> + <data><![CDATA[WinRT Intellisense Mobile - en-us ;10.1.18362.1]]></data> + <data><![CDATA[Windows SDK for Windows Store Apps Headers ;10.1.18362.1]]></data> + <data><![CDATA[Citrix Workspace Inside ;21.7.0.19]]></data> + <data><![CDATA[Universal CRT Redistributable ;10.1.18362.1]]></data> + <data><![CDATA[VMware Horizon Media Engine 8.0.0.561 (64-bit) ;8.0.0.561]]></data> + <data><![CDATA[WinAppDeploy;10.1.18362.1]]></data> + <data><![CDATA[Windows Team Extension SDK Contracts ;10.1.18362.1]]></data> + <data><![CDATA[WinRT Intellisense Desktop - Other Languages;10.1.18362.1]]></data> + </datalist> + </inventory_module> + + <inventory_module> + <name>Users</name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[PROJECTS;Roberto]]></data> + </datalist> + </inventory_module> + + <inventory_module> + <name>product_ID</name> + <type><![CDATA[generic_data_string]]></type> + <datalist> + <data><![CDATA[00429-00101-62363-AA558 ]]></data> + </datalist> + </inventory_module> + + </inventory> + +</agent_data> From b0aa8f3fb2220c376ce49e3f928492344a10bb54 Mon Sep 17 00:00:00 2001 From: rafael <rafael.ameijeiras@pandorafms.com> Date: Wed, 23 Aug 2023 10:34:19 +0200 Subject: [PATCH 2/5] adding autoinstall for tools and docs --- pandora_console/install.php | 1348 ----------------- pandora_server/util/load/README.MD | 44 +- .../util/load/create_usersandgroups.sh | 4 +- .../util/load/generate_inventory_data.sh | 6 +- pandora_server/util/load/install_load_data.sh | 55 + .../util/load/pandora_xml_stress.log | 24 + tentacle/tentacle_client | 2 +- 7 files changed, 123 insertions(+), 1360 deletions(-) delete mode 100644 pandora_console/install.php mode change 100644 => 100755 pandora_server/util/load/create_usersandgroups.sh create mode 100755 pandora_server/util/load/install_load_data.sh create mode 100644 pandora_server/util/load/pandora_xml_stress.log diff --git a/pandora_console/install.php b/pandora_console/install.php deleted file mode 100644 index 336ee13671..0000000000 --- a/pandora_console/install.php +++ /dev/null @@ -1,1348 +0,0 @@ -<?php -/** - * Extension to manage a list of gateways and the node address where they should - * point to. - * - * @category Extensions - * @package Pandora FMS - * @subpackage Community - * @version 1.0.0 - * @license See below - * - * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | - * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| - * - * ============================================================================ - * Copyright (c) 2005-2023 Pandora FMS - * Please see https://pandorafms.com/community/ for full contribution list - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation for version 2. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * ============================================================================ - */ - -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>Pandora FMS - Installation Wizard</title> - <meta http-equiv="expires" content="0"> - <meta http-equiv="content-type" content="text/html; charset=utf-8"> - <meta name="resource-type" content="document"> - <meta name="distribution" content="global"> - <meta name="author" content="Pandora FMS Development Team"> - <meta name="copyright" content="This is GPL software. Created by Sancho Lerena and many others"> - <meta name="keywords" content="pandora, fms, monitoring, network, system, GPL, software"> - <meta name="robots" content="index, follow"> - <link rel="icon" href="images/pandora.ico" type="image/ico"> - <script type="text/javascript" src="include/javascript/jquery-3.3.1.min.js"></script> - <script type="text/javascript" src="include/javascript/select2.min.js"></script> - <link rel="stylesheet" href="include/styles/select2.min.css" type="text/css"> - <link rel="stylesheet" href="include/styles/install.css" type="text/css"> - </head> - <script type="text/javascript"> - options_text = new Array('An existing Database','A new Database'); - options_values = new Array('db_exist','db_new'); - - var userHasConfirmed = false; - - function ChangeDBDrop(causer) { - if (causer.value != 'db_exist') { - window.document.step2_form.drop.checked = 0; - window.document.step2_form.drop.disabled = 1; - } - else { - window.document.step2_form.drop.disabled = 0; - } - } - function ChangeDBAction(causer) { - var i = 0; - if (causer.value == 'oracle') { - window.document.step2_form.db_action.length = 1; - } - else { - window.document.step2_form.db_action.length = 2; - } - while (i < window.document.step2_form.db_action.length) { - window.document.step2_form.db_action.options[i].value = options_values[i]; - window.document.step2_form.db_action.options[i].text = options_text[i]; - i++; - } - window.document.step2_form.db_action.options[window.document.step2_form.db_action.length-1].selected=1; - ChangeDBDrop(window.document.step2_form.db_action); - } - function CheckDBhost(value){ - if (( value != "localhost") && ( value != "127.0.0.1")) { - document.getElementById('tr_dbgrant').style["display"] = "table-row"; - } - else { - document.getElementById('tr_dbgrant').style["display"] = "none"; - } - } - function popupShow(){ - document.getElementsByTagName('body')[0].style["margin"] = "0"; - document.getElementById('add-lightbox').style["visibility"] = "visible"; - document.getElementById('open_popup').style["display"] = "block"; - document.getElementById('open_popup').style["visibility"] = "visible"; - } - function popupClose(){ - document.getElementById('add-lightbox').style["visibility"] = "hidden"; - document.getElementById('open_popup').style["display"] = "none"; - document.getElementById('open_popup').style["visibility"] = "hidden"; - } - function handleConfirmClick (event) { - userHasConfirmed = true; - var step3_form = document.getElementsByName('step2_form')[0]; - step3_form.submit(); - } - function handleStep3FormSubmit (event) { - var dbOverride = document.getElementById("drop").checked; - if (dbOverride && !userHasConfirmed) { - event.preventDefault(); - popupShow(); - return false; - } - } - </script> - <body> - <div id='add-lightbox' onclick='popupClose();' class='popup-lightbox'></div> - <div id='open_popup' class='popup' style='visibility:hidden;display: block;'> - <div class='popup-title'> - <span id='title_popup'>Warning</span> - <a href='#' onclick='popupClose();'><img src='./images/icono_cerrar.png' alt='close' title='Close' style='float:right;'/></a> - </div> - <div class='popup-inner' style='padding: 20px 40px;'> - <?php - echo '<p><strong>Attention</strong>, you are going to <strong>overwrite the data</strong> of your current installation.</p> - <p>This means that if you do not have a backup <strong>you will irremissibly LOSE ALL THE STORED DATA</strong>, the configuration and everything relevant to your installation.</p><p><strong>Are you sure of what you are going to do?</strong></p>'; - echo "<div style='text-align:right;';>"; - echo "<button type='button' class='btn_primary outline' onclick='javascript:handleConfirmClick();'><span class='btn_install_next_text'>Yes, I'm sure I want to delete everything</span></button>"; - echo "<button type='button' class='btn_primary' onclick='javascript:popupClose();'><span class='btn_install_next_text'>Cancel</span></button>"; - echo '</div>'; - ?> - </div> - </div> - <div style='padding-bottom: 50px'> - <?php - $version = '7.0NG.773.1'; - $build = '230823'; - $banner = "v$version Build $build"; - error_reporting(0); - - // --------------- - // Main page code - // --------------- - if (! isset($_GET['step'])) { - install_step1(); - } else { - $step = $_GET['step']; - switch ($step) { - case 11: install_step1_licence(); - break; - - case 2: install_step2(); - break; - - case 3: install_step3(); - break; - - case 4: install_step4(); - break; - - case 5: install_step5(); - break; - } - } - ?> - </div> - </body> -</html> - -<?php -/** - * Check the php extension and print a - * new row in the table with the result - * - * @param string $ext Extension. - * @param string $label Label extension. - * - * @return integer status - */ -function check_extension($ext, $label) -{ - echo '<tr><td>'; - echo "<span class='arr'> $label </span>"; - echo '</td><td>'; - if (!extension_loaded($ext)) { - echo "<span class='incomplete'>incomplete</span>"; - return 1; - } else { - echo "<span class='checked'>checked</span>"; - return 0; - } - - echo '</td></tr>'; -} - -/** - * Check if file exist and print a - * new row in the table with the result - * - * @param string $file File. - * @param string $label Label file. - * - * @return integer status - */ -function check_exists($file, $label) -{ - echo '<tr><td>'; - echo "<span class='arr'> $label </span>"; - echo '</td><td>'; - if (!file_exists($file)) { - echo " <span class='incomplete'>incomplete</span>"; - return 1; - } else { - echo " <span class='checked'>checked</span>"; - return 0; - } - - echo '</td></tr>'; -} - - -/** - * Check variable ok and return row - * with 'checked' if is 1 or 'incomplete' if is 0 - * - * @param integer $ok Status. - * @param string $label Label to show. - * - * @return integer status - */ -function check_generic($ok, $label) -{ - echo '<tr><td>'; - if ($ok == 0) { - echo "<span class='arr'> $label </span>"; - echo '<td>'; - echo " <span class='incomplete'>incomplete</span>"; - echo '</td>'; - echo '</td></tr>'; - return 1; - } else { - echo "<span class='arr'> $label </span>"; - echo '<td>'; - echo " <span class='checked'>checked</span>"; - echo '</td>'; - echo '</td></tr>'; - return 0; - } -} - - -/** - * Check if path is writable and print a - * new row in the table with the result. - * - * @param string $fullpath Path folder or file. - * @param string $label Label to show. - * - * @return integer status - */ -function check_writable($fullpath, $label) -{ - echo '<tr><td>'; - if (file_exists($fullpath)) { - if (is_writable($fullpath)) { - echo "<span class='arr'> $label </span>"; - echo '</td>'; - echo '<td>'; - echo "<span class='checked'>checked</span>"; - echo '</td>'; - echo '</tr>'; - return 0; - } else { - echo "<span class='arr'> $label </span>"; - echo '</td>'; - echo '<td>'; - echo "<span class='incomplete'>incomplete</span>"; - echo '</td>'; - echo '</tr>'; - return 1; - } - } else { - echo "<span class='arr'> $label </span>"; - echo '<td>'; - echo "<span class='incomplete'>incomplete</span>"; - echo '</td>'; - echo '</td></tr>'; - return 1; - } -} - - -/** - * Check if $var is equal to $value and - * print result in a row. - * - * @param string $var Variable. - * @param string $value Value to check. - * @param string $label Label to show. - * @param integer $mode Mode. - * - * @return integer status - */ -function check_variable($var, $value, $label, $mode) -{ - echo '<tr><td>'; - echo "<span class='arr'> $label </span>"; - echo '</td><td>'; - if ($mode == 1) { - if ($var >= $value) { - echo "<span class='checked'>checked</span>"; - return 0; - } else { - echo "<span class='incomplete'>incomplete</span>"; - return 1; - } - } else if ($var == $value) { - echo "<span class='checked'>checked</span>"; - return 0; - } else { - echo "<span class='incomplete'>incomplete</span>"; - return 1; - } - - echo '</td></tr>'; -} - - -function parse_mysql_dump($url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysql_query($query)) { - echo mysql_error(); - // Uncomment for debug - echo "<i><br>$query<br></i>"; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -/** - * Parse sql to script dump, execute it - * and return if exist error. - * - * @param object $connection Connection sql. - * @param string $url Path file sql script. - * - * @return integer status - */ -function parse_mysqli_dump($connection, $url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysqli_query($connection, $query)) { - if (mysqli_error($connection)) { - return mysqli_error($connection).'<i><br>'.$query.'<br></i>'; - } - - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -/** - * Generate a random password - * - * Admits a huge mount of ASCII chars. - * - * @param integer $size Size of the password returned. - * - * @return string $output - */ -function random_name(int $size) -{ - $output = ''; - - // Range pair of ASCII position for allow A-Z, a-z, 0-9 and special chars. - $rangeSeed = [ - '48:57', - '65:90', - '97:122', - '40:47', - ]; - - // Size of the password must be over range seed count. - $size = ($size >= count($rangeSeed)) ? $size : count($rangeSeed); - - $auxIndex = 0; - for ($i = 0; $i < $size; $i++) { - $tmpSeedValues = explode(':', $rangeSeed[$auxIndex]); - $output = $output.chr(rand($tmpSeedValues[1], $tmpSeedValues[0])); - $auxIndex++; - if ($auxIndex >= 4) { - $auxIndex = 0; - } - } - - // Remix the string for strong the password. - return str_shuffle($output); -} - - -/** - * Print the header installation - * - * @param integer $step Number of step. - * - * @return string Html output. - */ -function print_logo_status($step) -{ - global $banner; - - $header = ' - <div class="header"> - <h3 class="title-pandora">Pandora FMS OpenSource Installer - <span class="build-banner">'.$banner.'</span> - </h3> - <div class="steps"> - <span class="step '.(($step === 11 || $step === 1) ? 'active' : '').'">1</span> - <hr class="step-separator"/> - <span class="step '.(($step === 2) ? 'active' : '').'">2</span> - <hr class="step-separator"/> - <span class="step '.(($step === 3) ? 'active' : '').'">3</span> - <hr class="step-separator"/> - <span class="step '.(($step === 4) ? 'active' : '').'">4</span> - <hr class="step-separator"/> - <span class="step '.(($step === 5) ? 'active' : '').'">5</span> - <hr class="step-separator"/> - <span class="step '.(($step === 6) ? 'active' : '').'">6</span> - - </div> - </div> - '; - - return $header; -} - - -/** - * This function adjusts path settings in pandora db for FreeBSD. - * All packages and configuration files except operating system's base files - * are installed under /usr/local in FreeBSD. So, path settings in pandora db - * for some programs should be changed from the Linux default. - * - * @param string $engine Type of engine. - * @param object $connection Connection database. - * - * @return integer Status. - */ -function adjust_paths_for_freebsd($engine, $connection=false) -{ - $adjust_sql = [ - "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');", - "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';", - "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');", - "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');", - "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');", - "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');", - "insert into tconfig (token, value) VALUES ('graphviz_bin_dir', '/usr/local/bin');", - ]; - - for ($i = 0; $i < count($adjust_sql); $i++) { - switch ($engine) { - case 'mysql': - $result = mysql_query($adjust_sql[$i]); - break; - - case 'mysqli': - $result = mysqli_query($connection, $adjust_sql[$i]); - break; - - case 'oracle': - // Delete the last semicolon from current query - $query = substr($adjust_sql[$i], 0, (strlen($adjust_sql[$i]) - 1)); - $sql = oci_parse($connection, $query); - $result = oci_execute($sql); - break; - - case 'pgsql': - pg_send_query($connection, $adjust_sql[$i]); - $result = pg_get_result($connection); - break; - } - - if (!$result) { - return 0; - } - } - - return 1; -} - - -/** - * Print all step 1 - * - * @return void - */ -function install_step1() -{ - echo " - <div id='install_container'> - <div id='wizard'> - ".print_logo_status(1, 6)." - <div class='row'> - <div class='col-md-6'> - <div id='install_box'> - <h2 class='title'>Welcome to Pandora FMS installation Wizard</h2> - <p class='text'>This wizard helps you to quick install Pandora FMS console and main database in your system. - In four steps, this installer will check all dependencies and will create your configuration, ready to use.</p> - <p class='text'>For more information, please refer to <a class='link' href='https://pandorafms.com/en/documentation/' target='_blank'>documentation →</a></p> - "; - if (file_exists('include/config.php')) { - echo "<div class='warn'> You already have a config.php file. - Configuration and database would be overwritten if you continued.</div>"; - } - - echo '<br>'; - echo '<table class="check-table">'; - $writable = check_writable('include', './include is writable'); - if (file_exists('include/config.php')) { - $writable += check_writable('include/config.php', 'include/config.php is writable'); - } - - echo '</table>'; - - echo "<div class='warn'>This installer will <b>overwrite and destroy</b> - your existing Pandora FMS configuration and <b>Database</b>. Before continue, - please <b>be sure that you have no valuable Pandora FMS data in your Database</b>.<br> - </div>"; - - if ($writable !== 0) { - echo "<div class='err'>You need to setup permissions to be able to write in ./include directory</div>"; - } - - echo '</div>'; - - echo "<div style='clear:both;'></div>"; - echo " - </div> - <div class='col-md-6 hide-phone'> - <div class='content-animation'> - <div class='popuphero'> - <div class='popupgear1'><img src='images/Pandora-FMS-installer-gear.png'></div> - <div class='popupgear2'><img src='images/Pandora-FMS-installer-gear.png'></div> - <div class='popuplaptop'><img src='images/Pandora-FMS-installer.png'></div> - </div> - </div> - </div> - </div> - </div> - <div id='foot_install'> - <div class='content-footer'> - <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> - </span>"; - if ($writable === 0) { - echo "<a id='step11' href='install.php?step=11'><button type='submit' class='btn_primary'>Start installation</button></a>"; - } - - echo '</div></div></div>'; -} - - -/** - * Print license content - * - * @return void - */ -function install_step1_licence() -{ - echo " - <div id='install_container'> - <div id='wizard'> - ".print_logo_status(2, 6)." - <div id='install_box'> - <h2 class='subtitle'>GPL2 Licence terms agreement</h2> - <p class='text'>Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, <i>you must accept the licence terms.</i>. - <p class='text'>For more information, please refer to our website at https://pandorafms.com/community/ and contact us if you have any kind of question about the usage of Pandora FMS</p> - <p>If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.</p> - "; - - if (!file_exists('COPYING')) { - echo "<div class='warn'><b>Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file.</b>"; - echo '</div>'; - } else { - echo "<textarea name='gpl2' cols=52 rows=15 style='width: 100%;'>"; - echo file_get_contents('COPYING'); - echo '</textarea>'; - echo '<p>'; - } - - echo '</div>'; - - echo "</div> - <div id='foot_install'> - <div class='content-footer'> - <a href='install.php'><button class='btn_primary outline'>Previous step</button></a> - <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> - </span>"; - if (file_exists('COPYING')) { - echo "<a href='install.php?step=2'><button id='btn_accept' class='btn_primary'>Yes, I accept licence terms</button></a>"; - } - - echo '</div></div></div>'; -} - - -/** - * Print all step 2 - * - * @return void - */ -function install_step2() -{ - echo " - <div id='install_container'> - <div id='wizard'> - ".print_logo_status(3, 6)." - <div id='install_box'>"; - echo '<h2 class="subtitle">Checking software dependencies</h2>'; - echo ' - <div class="row reverse"> - <div class="col-md-6"> - <table class="check-table">'; - $res = 0; - $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1); - $res += check_extension('gd', 'PHP GD extension'); - $res += check_extension('ldap', 'PHP LDAP extension'); - $res += check_extension('snmp', 'PHP SNMP extension'); - $res += check_extension('session', 'PHP session extension'); - $res += check_extension('gettext', 'PHP gettext extension'); - $res += check_extension('mbstring', 'PHP Multibyte String'); - $res += check_extension('zip', 'PHP Zip'); - $res += check_extension('zlib', 'PHP Zlib extension'); - $res += check_extension('json', 'PHP json extension'); - $res += check_extension('curl', 'CURL (Client URL Library)'); - $res += check_extension('filter', 'PHP filter extension'); - $res += check_extension('calendar', 'PHP calendar extension'); - if (PHP_OS == 'FreeBSD') { - $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); - } else if (PHP_OS == 'NetBSD') { - $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); - } else if (substr(PHP_OS, 0, 3) == 'WIN') { - $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); - } else { - $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); - } - - echo '<tr><td>'; - echo "<span style='display: block; margin-top: 2px; font-weight: bolder; color: white; font-size: 22px;'>DB Engines</span>"; - echo '</td><td>'; - echo '</td></tr>'; - check_extension('mysqli', 'PHP MySQL(mysqli) extension'); - echo '</table></div>'; - if ($res > 0) { - echo "<div class='col-md-6'> - <div class='err'>You have some incomplete - dependencies. Please correct them or this installer - will not be able to finish your installation. - </div> - <div class='err'> - Remember, if you install any PHP module to comply - with these dependences, you <b>need to restart</b> - your HTTP/Apache server after it to use the new - modules. - </div> - </div>"; - } - - echo '</div>'; - echo "</div></div> - <div id='foot_install'> - <div class='content-footer'> - <a href='install.php?step=11'><button class='btn_primary outline'>Previous step</button></a> - <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> - </span>"; - if ($res > 0) { - echo "<span class='text' style='margin-right: 10px'>Ignore it.</span><a id='step3' href='install.php?step=3'><button class='btn_primary'>Force install</button></a>"; - } else { - echo "<a id='step3' href='install.php?step=3'><button class='btn_primary'>Next Step</button></a>"; - } - - echo '</div></div>'; -} - - -/** - * Print all step 3 - * - * @return void - */ -function install_step3() -{ - $options = []; - if (extension_loaded('mysql')) { - $options['mysql'] = 'MySQL'; - } - - if (extension_loaded('mysqli')) { - $options['mysqli'] = 'MySQL(mysqli)'; - } - - $error = false; - if (empty($options)) { - $error = true; - } - - echo " - <div id='install_container'> - <div id='wizard'> - ".print_logo_status(4, 6)." - <div id='install_box'> - <div class='row'> - <div class='col-md-6'> - <h2 class='subtitle'>Environment and database setup</h2> - <p class='text'> - This wizard will create your Pandora FMS database, - and populate it with all the data needed to run for the first time. - </p> - <p class='text'> - You need a privileged user to create database schema, this is usually <b>root</b> user. - Information about <b>root</b> user will not be used or stored anymore. - </p> - <p class='text'> - You can also deploy the scheme into an existing Database. - In this case you need a privileged Database user and password of that instance. - </p> - <p class='text'> - Now, please, complete all details to configure your database and environment setup. - </p> - <div class='warn'> - This installer will <b>overwrite and destroy</b> your existing - Pandora FMS configuration and <b>Database</b>. Before continue, - please <b>be sure that you have no valuable Pandora FMS data in your Database.</b> - <br><br> - </div>"; - if ($error) { - echo "<div class='warn'> - You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. - </div>"; - } - - if (extension_loaded('oci8')) { - echo "<div class='warn'>For Oracle installation an existing Database with a privileged user is needed.</div>"; - } - - echo '</div>'; - echo '<div class="col-md-6">'; - if (!$error) { - echo "<form method='post' name='step2_form' action='install.php?step=4'>"; - } - - echo "<table class='table-config-database' cellpadding=6 width=100% border=0 style='text-align: left;'>"; - - if (!$error) { - echo '<tr><td>'; - echo '<p class="input-label">DB Engine</p>'; - - echo '<select id="engine" name="engine" - style="width: - 100%" - data-select2-id="engine" - tabindex="-1" - class="select2-hidden-accessible" - aria-hidden="true">'; - - foreach ($options as $key => $value) { - echo '<option value="'.$key.'">'.$value.'</option>'; - } - - echo '</select>'; - - echo '<script type="text/javascript">$("#engine").select2({closeOnSelect: true});</script>'; - - echo '<td>'; - echo '<p class="input-label">Installation in </p>'; - - echo '<select id="db_action" - name="db_action" - style="width: - 100%" - data-select2-id="db_action" - tabindex="-1" - class="select2-hidden-accessible" - aria-hidden="true"> - <option value="db_new">A new Database</option> - <option value="db_exist">An existing Database</option> - </select>'; - - echo '<script type="text/javascript">$("#db_action").select2({closeOnSelect: true});</script>'; - } - - echo "<tr> - <td> - <p class='input-label'>DB User with privileges</p> - <input class='login' type='text' name='user' value='root' size=20> - </td> - <td> - <p class='input-label'>DB Password for this user</p> - <input class='login' type='password' name='pass' value='' size=20> - </td> - </tr> - <tr> - <td> - <p class='input-label'>DB Hostname</p> - <input class='login' type='text' name='host' value='localhost' onkeyup='CheckDBhost(this.value);'size=20> - </td> - <td> - <p class='input-label'>DB Name (pandora by default)</p> - <input class='login' type='text' name='dbname' value='pandora' size=20> - </td> - </tr>"; - - // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost - echo "<tr id='tr_dbgrant' style='display: none;'> - <td colspan=\"2\"> - <p class='input-label'>DB Host Access<img style='cursor:help;' src='/pandora_console/images/tip.png' title='Ignored if DB Hostname is localhost or 127.0.0.1'/></p> - <input class='login' type='text' name='dbgrant' value='".$_SERVER['SERVER_ADDR']."'> - </td> - </tr>"; - - echo "<tr> - <td colspan='2'> - <p class='input-label'>Full path to HTTP publication directory</p> - <p class='example-message'>For example /var/www/pandora_console/</p> - <input class='login' type='text' name='path' value='".dirname(__FILE__)."'> - </td> - </tr>"; - echo " - <tr> - <td colspan='2'> - <p class='input-label'>URL path to Pandora FMS Console</p> - <p class='example-message'>For example '/pandora_console'</p> - <input class='login' type='text' name='url' value='".dirname($_SERVER['SCRIPT_NAME'])."'> - </td> - </tr>"; - - echo "<tr> - <td colspan='2' class='inline'> - <label class='switch'> - <input type='checkbox' name='drop' id='drop' value=1> - <span class='slider round'></span> - </label> - <p class='input-label'>Drop Database if exists</p> - </td> - </tr>"; - - echo '</table>'; - - echo '</div>'; - - echo '</div></div>'; - echo '</div>'; - echo "<div id='foot_install'> - <div class='content-footer'> - <a href='install.php?step=2' class='btn_primary outline'>Previous step</a> - <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> - </span>"; - if (!$error) { - echo "<button class='btn_primary' type='submit' id='step4'>Next Step</button>"; - echo '</form>'; - ?> - <script type="text/javascript"> - var step3_form = document.getElementsByName('step2_form')[0]; - step3_form.addEventListener("submit", handleStep3FormSubmit); - </script> - <?php - } - - echo '</div></div>'; -} - - -/** - * Print all step 4 - * - * @return void - */ -function install_step4() -{ - $pandora_config = 'include/config.php'; - - if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) - || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) - ) { - $dbpassword = ''; - $dbuser = ''; - $dbhost = ''; - $dbname = ''; - $engine = ''; - $dbaction = ''; - $dbgrant = ''; - } else { - $engine = $_POST['engine']; - $dbpassword = $_POST['pass']; - $dbuser = $_POST['user']; - $dbhost = $_POST['host']; - $dbaction = $_POST['db_action']; - if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { - $dbgrant = $_POST['dbgrant']; - } else { - $dbgrant = $_SERVER['SERVER_ADDR']; - } - - if (isset($_POST['drop'])) { - $dbdrop = $_POST['drop']; - } else { - $dbdrop = 0; - } - - $dbname = $_POST['dbname']; - if (isset($_POST['url'])) { - $url = $_POST['url']; - } else { - $url = 'http://localhost'; - } - - if (isset($_POST['path'])) { - $path = $_POST['path']; - $path = str_replace('\\', '/', $path); - // Windows compatibility - } else { - $path = '/var/www'; - } - } - - $everything_ok = 0; - $step1 = 0; - $step2 = 0; - $step3 = 0; - $step4 = 0; - $step5 = 0; - $step6 = 0; - $step7 = 0; - $errors = []; - echo " - <div id='install_container'> - <div id='wizard'> - ".print_logo_status(5, 6)." - <div id='install_box'> - <div class='row reverse'> - <div class='col-md-6'> - <table class='check-table'>"; - switch ($engine) { - case 'mysql': - if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysql_query("DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysql_query("CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysql_select_db($dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysql_dump('pandoradb.sql'); - - if ($step3 !== 0 && $step3 !== 1) { - $errors[] = $step3; - $step3 = 0; - } - - check_generic($step3, 'Creating schema'); - $step4 = parse_mysql_dump('pandoradb_data.sql'); - - if ($step4 !== 0 && $step4 !== 1) { - $errors[] = $step4; - $step4 = 0; - } - - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysql_query( - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysql_query('FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: <b>$random_password</b><p>Please write it down, you will need to setup your Pandora FMS server, editing the </i>/etc/pandora/pandora_server.conf</i> file</p>"); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = '<?php - // Begin of automatic config file - $config["dbtype"] = "'.$dbtype.'"; //DB type (mysql, postgresql...in future others) - $config["dbname"]="'.$dbname.'"; // MySQL DataBase name - $config["dbuser"]="pandora"; // DB User - $config["dbpass"]="'.$random_password.'"; // DB Password - $config["dbhost"]="'.$dbhost.'"; // DB Host - $config["homedir"]="'.$path.'"; // Config homedir - // ----------Rebranding-------------------- - // Uncomment this lines and add your customs text and paths. - // $config["custom_logo_login_alt"] ="login_logo.png"; - // $config["custom_splash_login_alt"] = "splash_image_default.png"; - // $config["custom_title1_login_alt"] = "WELCOME TO Pandora FMS"; - // $config["custom_title2_login_alt"] = "NEXT GENERATION"; - // $config["rb_product_name_alt"] = "Pandora FMS"; - // $config["custom_docs_url_alt"] = "http://wiki.pandorafms.com/"; - // $config["custom_support_url_alt"] = "https://support.pandorafms.com"; - - - - /* - ----------Attention-------------------- - Please note that in certain installations: - - reverse proxy. - - web server in other ports. - - https - - This variable might be dynamically altered. - - But it is save as backup in the - $config["homeurl_static"] - for expecial needs. - ----------Attention-------------------- - */ - $config["homeurl"]="'.$url.'"; // Base URL - $config["homeurl_static"]="'.$url.'"; // Don\'t delete - // End of automatic config file - ?>'; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - - case 'mysqli': - $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); - if (mysqli_connect_error() > 0) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysqli_select_db($connection, $dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); - if ($step3 !== 0 && $step3 !== 1) { - $errors[] = $step3; - $step3 = 0; - } - - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); - - if ($step4 !== 0 && $step4 !== 1) { - $errors[] = $step4; - $step4 = 0; - } - - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine, $connection); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysqli_query( - $connection, - "CREATE USER IF NOT EXISTS pandora@$host" - ); - - mysqli_query( - $connection, - "SET PASSWORD FOR 'pandora'@'".$host."' = '".$random_password."'" - ); - - $step5 |= mysqli_query( - $connection, - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host" - ); - mysqli_query($connection, 'FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: <b>$random_password</b><p>Please write it down, you will need to setup your Pandora FMS server, editing the </i>/etc/pandora/pandora_server.conf</i> file</p>"); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = '<?php - // Begin of automatic config file - $config["dbtype"] = "'.$dbtype.'"; //DB type (mysql, postgresql...in future others) - $config["mysqli"] = true; - $config["dbname"]="'.$dbname.'"; // MySQL DataBase name - $config["dbuser"]="pandora"; // DB User - $config["dbpass"]="'.$random_password.'"; // DB Password - $config["dbhost"]="'.$dbhost.'"; // DB Host - $config["homedir"]="'.$path.'"; // Config homedir - // ----------Rebranding-------------------- - // Uncomment this lines and add your customs text and paths. - // $config["custom_logo_login_alt"] ="login_logo.png"; - // $config["custom_splash_login_alt"] = "splash_image_default.png"; - // $config["custom_title1_login_alt"] = "WELCOME TO Pandora FMS"; - // $config["custom_title2_login_alt"] = "NEXT GENERATION"; - // $config["rb_product_name_alt"] = "Pandora FMS"; - // $config["custom_docs_url_alt"] = "http://wiki.pandorafms.com/"; - // $config["custom_support_url_alt"] = "https://support.pandorafms.com"; - - /* - ----------Attention-------------------- - Please note that in certain installations: - - reverse proxy. - - web server in other ports. - - https - - This variable might be dynamically altered. - - But it is save as backup in the - $config["homeurl_static"] - for expecial needs. - ----------Attention-------------------- - */ - $config["homeurl"]="'.$url.'"; // Base URL - $config["homeurl_static"]="'.$url.'"; // Don\'t delete - // End of automatic config file - ?>'; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - } - - echo '</table>'; - echo '</div>'; - echo '<div class="col-md-6" id="content-errors">'; - echo "<h2 class='subtitle'>Creating database and default configuration file</h2>"; - if ($everything_ok !== 1) { - $info = ''; - - if (!empty($errors)) { - foreach ($errors as $key => $err) { - $info .= '<div class="err-sql">'.$err.'</div>'; - } - - $info .= "<div class='err'>If you use MySQL 8 make sure to include the - following parameter in your installation's my.cnf configuration file<br /> - sql_mode=\"\"</div>"; - } - - $info .= "<div class='err'><b>There were some problems. - Installation was not completed.</b> - <p>Please correct failures before trying again. - All database "; - - if ($engine == 'oracle') { - $info .= 'objects '; - } else { - $info .= 'schemes '; - } - - $info .= 'created in this step have been dropped. </p> - </div>'; - echo $info; - - switch ($engine) { - case 'mysql': - if (mysql_error() != '') { - echo "<div class='err'>".mysql_error().'.</div>'; - echo "<div class='err'>If you use MySQL 8 make sure to include the - following parameter in your installation's my.cnf configuration file<br /> - sql_mode=\"\"</div>"; - } - - if ($step1 == 1) { - mysql_query("DROP DATABASE $dbname"); - } - break; - - case 'mysqli': - if ($connection && mysqli_error($connection) != '') { - echo "<div class='err'>".mysqli_error($connection).'.</div>'; - echo "<div class='err'>If you use MySQL 8 make sure to include the - following parameter in your installation's my.cnf configuration file<br /> - sql_mode=\"\"</div>"; - } - - if ($step1 == 1) { - mysqli_query($connection, "DROP DATABASE $dbname"); - } - break; - } - } - - echo '</div>'; - echo '</div>'; - echo '</div></div>'; - echo " - <div id='foot_install'> - <div class='content-footer'> - <a href='install.php?step=3' class='btn_primary outline'>Previous step</a> - <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> - </span>"; - if ($everything_ok === 1) { - echo "<a id='step5' href='install.php?step=5'> - <button class='btn_primary' type='submit'>Next Step</button> - </a>"; - } - - echo '</div></div>'; -} - - -/** - * Print all step 5 - * - * @return void - */ -function install_step5() -{ - echo " - <div id='install_container'> - <div id='wizard'> - ".print_logo_status(6, 6)." - <div id='install_box'> - <h2 class='subtitle'>Installation complete</h2> - <p class='text'>For security, you now must manually delete this installer - ('<i>install.php</i>') file before trying to access to your Pandora FMS console. - <p class='text'>You should also install Pandora FMS Servers before trying to monitor anything; - please read documentation on how to install it.</p> - <p class='text'>Default user is <b>'admin'</b> with password <b>'pandora'</b>, - please change it both as soon as possible.</p> - <p class='text'>Don't forget to check <a href='https://pandorafms.com' class='link'>https://pandorafms.com</a> - for updates. - <p class='text'>Select if you want to rename '<i>install.php</i>'.</p> - <form method='post' action='index.php'> - <button class='btn_primary outline' type='submit' name='rn_file'><span class='btn_install_next_text'>Yes, rename the file</span></button> - <input type='hidden' name='rename_file' value='1'> - </form> - </p> - </div> - </div> - <div id='foot_install'> - <div class='content-footer'> - <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> - </span> - <a id='access_pandora' href='index.php'> - <button class='btn_primary'>Click here to access to your Pandora FMS console</button> - </a> - </div> - </div> - </div>"; -} diff --git a/pandora_server/util/load/README.MD b/pandora_server/util/load/README.MD index d042cb1503..c7556e3a07 100644 --- a/pandora_server/util/load/README.MD +++ b/pandora_server/util/load/README.MD @@ -1,7 +1,38 @@ -### Purpose of this toolkit +## Purpose of this toolkit This directory contains configuration files and small scripts to generate an environment with simulated data for testing purposes. +### Quik start +To add monitoring data, inventory, groups and users to a pandorafms environment automatically Just execute: +``` +/usr/share/pandora_server/util/load/install_load_data.sh +``` + +This command will creates: +- 30 Agents with inventory linux +- 30 Agents whith inventory Windows +- 300 Agents +- 44 Groups +- 34 Users + +Will randonly add users to groups and move agents to groups. +Creates a cronjob to generate agent data each 5 min and inventory data once a day. + +_note: make sure you have a licence with at least 300 agents or modify the /usr/share/pandora_server/util/load/pandora_xml_stress.agents to use max your licence limit agent amount before execute_ + +## Toolset description. +Here we describe the specific use for all the toolset the `install_load_data.sh` used automatically, to be used individualy if its needed + +### Generation of inventory agents +The script will use th file pandora_xml_stress.agents take by default the first 30 listed agents and add linux inventory and the last 30 listed agents and add windows inventory. +This will generate xml data using the templates on `templates` folder. + +to run it, execute +``` +cd pandorafms/pandora_server/util/load +./generate_inventory_data.sh +``` + ### Generation of XML files to simulate agent load There is a tool that comes configured with Pandora FMS to generate test data (pandora_xml_stress) and that generates XML. It has different options and in this directory is provided a configuration file and all the dictionaries and additional files to generate data of 300 agents, with pseudo-random names (like for example "7fb8a1a734c24cc22a5c75eb"). @@ -9,18 +40,18 @@ There is a tool that comes configured with Pandora FMS to generate test data (pa These agents are defined in the "pandora_xml_stress.agents" file. If you want less agents, you can delete elements in this file. To execute the XML generation manually from the code repository: - +``` cd pandorafms/pandora_server/util/load perl ../pandora_xml_stress.pl pandora_xml_stress.conf - +``` This will generate 300 XML in the /var/spool/pandora/data_in directory. If you create a scheduled execution of this command every 5 minutes (e.g. through cron), keep in mind that if the PandoraFMS server stops, it could have hundreds of thousands of XML files pending to be processed. Create /etc/cron.d/pandora_stress with this content: - +``` */5 * * * * root <putyourscripthere> - +``` ### Generation of groups and users @@ -31,6 +62,7 @@ On the other hand, it will also create a series of groups, taking as source the Finally, it will take all the agents available in Pandora FMS and it will distribute them in an equal and random way among the available groups. You should only run it once: - +``` cd pandorafms/pandora_server/util/load ./create_userandgroups.sh +``` \ No newline at end of file diff --git a/pandora_server/util/load/create_usersandgroups.sh b/pandora_server/util/load/create_usersandgroups.sh old mode 100644 new mode 100755 index 36534bbf0b..418efa322d --- a/pandora_server/util/load/create_usersandgroups.sh +++ b/pandora_server/util/load/create_usersandgroups.sh @@ -35,7 +35,7 @@ done TOTAL_GROUPS=`cat groupnames.txt | wc -l` for username in `cat usernames.txt` do - RAN=`echo $RANDOM % $TOTAL_GROUPS + 1 | bc` + RAN=`echo $(($RANDOM % $TOTAL_GROUPS + 1))` GROUP_NAME=`cat groupnames.txt | tail -$RAN | head -1` /usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --add_profile $username "Operator (Read)" $GROUP_NAME @@ -45,7 +45,7 @@ done TOTAL_GROUPS=`cat groupnames.txt | wc -l` for agentname in `/usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --get_agents | cut -f 2 -d ","` do - RAN=`echo $RANDOM % $TOTAL_GROUPS + 1 | bc` + RAN=`echo $(($RANDOM % $TOTAL_GROUPS + 1))` GROUP_NAME=`cat groupnames.txt | tail -$RAN | head -1` /usr/share/pandora_server/util/pandora_manage.pl /etc/pandora/pandora_server.conf --update_agent $agentname group_name $GROUP_NAME done diff --git a/pandora_server/util/load/generate_inventory_data.sh b/pandora_server/util/load/generate_inventory_data.sh index b91ac24af7..cfd537d67e 100755 --- a/pandora_server/util/load/generate_inventory_data.sh +++ b/pandora_server/util/load/generate_inventory_data.sh @@ -11,7 +11,7 @@ linux_inventory=1 windows_inventory=1 # Variables -agent_count=5 +agent_count=30 data_in=/var/spool/pandora/data_in/ description='Demo data Agent' @@ -28,7 +28,7 @@ if [ $linux_inventory -eq 1 ] ; then echo "Enable linux invetory: adding invetory data to ${agent_count} linux agent" - for agent_name in $(cat pandora_xml_stress.agents | head ${agent_conunt}); do + for agent_name in $(cat pandora_xml_stress.agents | head -n ${agent_count}); do echo " - Adding invetory data to ${agent_name} linux agent" ip_add="10.0.0.$(( RANDOM % 255 + 1 ))" rand_number=$(( RANDOM % 10 + 1 )) @@ -50,7 +50,7 @@ if [ $windows_inventory -eq 1 ]; then fi echo "Enable Windows invetory: adding invetory data to ${agent_count} Windows agent" - for agent_name in $(cat pandora_xml_stress.agents | tail ${agent_conunt}); do + for agent_name in $(cat pandora_xml_stress.agents | tail -n ${agent_count}); do echo " - Adding invetory data to ${agent_name} windows agent" ip_add="172.16.5.$(( RANDOM % 255 + 1 ))" rand_number=$(( RANDOM % 100 + 1 )) diff --git a/pandora_server/util/load/install_load_data.sh b/pandora_server/util/load/install_load_data.sh new file mode 100755 index 0000000000..b2bcdfa18f --- /dev/null +++ b/pandora_server/util/load/install_load_data.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# (c) 2023 Pandora FMS +# This script is used to install a set of tools to load data automatically +# by default it will creates a set of users, groups and agents +# then set a cronjob to insert fake monitoring data to agents each 5 min +# and inventory data once a day. + +PREFIX='' + +# Moving directory +init_dir=$(pwd) +# Get the directory where the script is located +script_dir="$(dirname "$0")" +# Change the working directory to the script's directory +cd "$script_dir" || exit 1 + +# Check needed file exists +echo ' [INFO] Checking file requirements:' +if [ -f $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl ] && \ + [ -f $(pwd)/pandora_xml_stress.agents ] && \ + [ -f $(pwd)/pandora_xml_stress.conf ] && \ + [ -f $(pwd)/create_usersandgroups.sh ] && \ + [ -f $(pwd)/generate_inventory_data.sh ] && \ + [ -f $(pwd)/templates/inventory_linux.template ] && \ + [ -f $(pwd)/templates/inventory_windows.template] && \ + [ -f $(pwd)/pandora_xml_stress_module_source.txt ]; then + echo ' [INFO] All file exist, continue' +else + echo ' [ERROR] Missing files, please check.' && exit -1 +fi +# Create a set of users and grups +echo ' [INFO] Creating demo users and groups:' +$(pwd)/generate_inventory_data.sh +echo ' [INFO] Waiting for inventory agents to be created:' +while [ $(ls $PREFIX/var/spool/pandora/data_in/ | wc -l) -ge 10 ]; do + sleep 2 + echo -ne . +done +# Load init monitoring data +echo ' [INFO] Creating demo agent data:' +perl $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl $(pwd)/pandora_xml_stress.conf || echo ' [ERROR] Generating agent data cant be completed' +echo ' [INFO] Waiting for agents to be created:' +while [ $(ls $PREFIX/var/spool/pandora/data_in/ | wc -l) -ge 10 ]; do + sleep 2 + echo -ne . +done +# Create a set of users and grups +echo ' [INFO] Creating demo users and groups:' +$(pwd)/create_usersandgroups.sh +# Set cronjobs in /etc/crotab +echo ' [INFO] Adding data and inventory data to cronjob' +echo "*/5 * * * * root cd $(pwd) && perl $PREFIX/usr/share/pandora_server/util/pandora_xml_stress.pl $(pwd)/pandora_xml_stress.conf " >> /etc/crontab +echo "0 0 * * * root cd $(pwd) && $(pwd)/generate_inventory_data.sh" >> /etc/crontab +# Get back init directory +cd $init_dir \ No newline at end of file diff --git a/pandora_server/util/load/pandora_xml_stress.log b/pandora_server/util/load/pandora_xml_stress.log new file mode 100644 index 0000000000..35a677d1a6 --- /dev/null +++ b/pandora_server/util/load/pandora_xml_stress.log @@ -0,0 +1,24 @@ +[1692774345] Generating XML data files for 300 agents from 2023-08-23 09:05:45 to 2023-08-23 09:05:45 interval 300. +[1692774345] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6964 per second) +[1692774481] Generating XML data files for 300 agents from 2023-08-23 09:08:01 to 2023-08-23 09:08:01 interval 300. +[1692774481] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6996 per second) +[1692775236] Generating XML data files for 300 agents from 2023-08-23 09:20:36 to 2023-08-23 09:20:36 interval 300. +[1692775236] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (7036 per second) +[1692775282] Generating XML data files for 300 agents from 2023-08-23 09:21:22 to 2023-08-23 09:21:22 interval 300. +[1692775282] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6935 per second) +[1692775320] Generating XML data files for 300 agents from 2023-08-23 09:22:00 to 2023-08-23 09:22:00 interval 300. +[1692775320] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6921 per second) +[1692775629] Generating XML data files for 300 agents from 2023-08-23 09:27:09 to 2023-08-23 09:27:09 interval 300. +[1692775629] Total agents: 300 + Total modules: 3600 (12 per agent) + Total XML: 300 (6927 per second) diff --git a/tentacle/tentacle_client b/tentacle/tentacle_client index ecc2da18bb..d90d21f344 100755 --- a/tentacle/tentacle_client +++ b/tentacle/tentacle_client @@ -1095,7 +1095,7 @@ Protocol description and more info at: L<< https://pandorafms.com/manual/en/docu =head1 COPYRIGHT -Copyright (c) 2005-2023 Pandora FMS. +Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L =cut From 0d172ec7c6af6914228b9cc8417f9bfbab11e43c Mon Sep 17 00:00:00 2001 From: rafael <rafael.ameijeiras@pandorafms.com> Date: Wed, 23 Aug 2023 10:36:23 +0200 Subject: [PATCH 3/5] adding autoinstall for tools and docs --- pandora_console/install.php | 1348 +++++++++++++++++++++++++++++++++++ 1 file changed, 1348 insertions(+) create mode 100644 pandora_console/install.php diff --git a/pandora_console/install.php b/pandora_console/install.php new file mode 100644 index 0000000000..336ee13671 --- /dev/null +++ b/pandora_console/install.php @@ -0,0 +1,1348 @@ +<?php +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> + <head> + <title>Pandora FMS - Installation Wizard</title> + <meta http-equiv="expires" content="0"> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <meta name="resource-type" content="document"> + <meta name="distribution" content="global"> + <meta name="author" content="Pandora FMS Development Team"> + <meta name="copyright" content="This is GPL software. Created by Sancho Lerena and many others"> + <meta name="keywords" content="pandora, fms, monitoring, network, system, GPL, software"> + <meta name="robots" content="index, follow"> + <link rel="icon" href="images/pandora.ico" type="image/ico"> + <script type="text/javascript" src="include/javascript/jquery-3.3.1.min.js"></script> + <script type="text/javascript" src="include/javascript/select2.min.js"></script> + <link rel="stylesheet" href="include/styles/select2.min.css" type="text/css"> + <link rel="stylesheet" href="include/styles/install.css" type="text/css"> + </head> + <script type="text/javascript"> + options_text = new Array('An existing Database','A new Database'); + options_values = new Array('db_exist','db_new'); + + var userHasConfirmed = false; + + function ChangeDBDrop(causer) { + if (causer.value != 'db_exist') { + window.document.step2_form.drop.checked = 0; + window.document.step2_form.drop.disabled = 1; + } + else { + window.document.step2_form.drop.disabled = 0; + } + } + function ChangeDBAction(causer) { + var i = 0; + if (causer.value == 'oracle') { + window.document.step2_form.db_action.length = 1; + } + else { + window.document.step2_form.db_action.length = 2; + } + while (i < window.document.step2_form.db_action.length) { + window.document.step2_form.db_action.options[i].value = options_values[i]; + window.document.step2_form.db_action.options[i].text = options_text[i]; + i++; + } + window.document.step2_form.db_action.options[window.document.step2_form.db_action.length-1].selected=1; + ChangeDBDrop(window.document.step2_form.db_action); + } + function CheckDBhost(value){ + if (( value != "localhost") && ( value != "127.0.0.1")) { + document.getElementById('tr_dbgrant').style["display"] = "table-row"; + } + else { + document.getElementById('tr_dbgrant').style["display"] = "none"; + } + } + function popupShow(){ + document.getElementsByTagName('body')[0].style["margin"] = "0"; + document.getElementById('add-lightbox').style["visibility"] = "visible"; + document.getElementById('open_popup').style["display"] = "block"; + document.getElementById('open_popup').style["visibility"] = "visible"; + } + function popupClose(){ + document.getElementById('add-lightbox').style["visibility"] = "hidden"; + document.getElementById('open_popup').style["display"] = "none"; + document.getElementById('open_popup').style["visibility"] = "hidden"; + } + function handleConfirmClick (event) { + userHasConfirmed = true; + var step3_form = document.getElementsByName('step2_form')[0]; + step3_form.submit(); + } + function handleStep3FormSubmit (event) { + var dbOverride = document.getElementById("drop").checked; + if (dbOverride && !userHasConfirmed) { + event.preventDefault(); + popupShow(); + return false; + } + } + </script> + <body> + <div id='add-lightbox' onclick='popupClose();' class='popup-lightbox'></div> + <div id='open_popup' class='popup' style='visibility:hidden;display: block;'> + <div class='popup-title'> + <span id='title_popup'>Warning</span> + <a href='#' onclick='popupClose();'><img src='./images/icono_cerrar.png' alt='close' title='Close' style='float:right;'/></a> + </div> + <div class='popup-inner' style='padding: 20px 40px;'> + <?php + echo '<p><strong>Attention</strong>, you are going to <strong>overwrite the data</strong> of your current installation.</p> + <p>This means that if you do not have a backup <strong>you will irremissibly LOSE ALL THE STORED DATA</strong>, the configuration and everything relevant to your installation.</p><p><strong>Are you sure of what you are going to do?</strong></p>'; + echo "<div style='text-align:right;';>"; + echo "<button type='button' class='btn_primary outline' onclick='javascript:handleConfirmClick();'><span class='btn_install_next_text'>Yes, I'm sure I want to delete everything</span></button>"; + echo "<button type='button' class='btn_primary' onclick='javascript:popupClose();'><span class='btn_install_next_text'>Cancel</span></button>"; + echo '</div>'; + ?> + </div> + </div> + <div style='padding-bottom: 50px'> + <?php + $version = '7.0NG.773.1'; + $build = '230823'; + $banner = "v$version Build $build"; + error_reporting(0); + + // --------------- + // Main page code + // --------------- + if (! isset($_GET['step'])) { + install_step1(); + } else { + $step = $_GET['step']; + switch ($step) { + case 11: install_step1_licence(); + break; + + case 2: install_step2(); + break; + + case 3: install_step3(); + break; + + case 4: install_step4(); + break; + + case 5: install_step5(); + break; + } + } + ?> + </div> + </body> +</html> + +<?php +/** + * Check the php extension and print a + * new row in the table with the result + * + * @param string $ext Extension. + * @param string $label Label extension. + * + * @return integer status + */ +function check_extension($ext, $label) +{ + echo '<tr><td>'; + echo "<span class='arr'> $label </span>"; + echo '</td><td>'; + if (!extension_loaded($ext)) { + echo "<span class='incomplete'>incomplete</span>"; + return 1; + } else { + echo "<span class='checked'>checked</span>"; + return 0; + } + + echo '</td></tr>'; +} + +/** + * Check if file exist and print a + * new row in the table with the result + * + * @param string $file File. + * @param string $label Label file. + * + * @return integer status + */ +function check_exists($file, $label) +{ + echo '<tr><td>'; + echo "<span class='arr'> $label </span>"; + echo '</td><td>'; + if (!file_exists($file)) { + echo " <span class='incomplete'>incomplete</span>"; + return 1; + } else { + echo " <span class='checked'>checked</span>"; + return 0; + } + + echo '</td></tr>'; +} + + +/** + * Check variable ok and return row + * with 'checked' if is 1 or 'incomplete' if is 0 + * + * @param integer $ok Status. + * @param string $label Label to show. + * + * @return integer status + */ +function check_generic($ok, $label) +{ + echo '<tr><td>'; + if ($ok == 0) { + echo "<span class='arr'> $label </span>"; + echo '<td>'; + echo " <span class='incomplete'>incomplete</span>"; + echo '</td>'; + echo '</td></tr>'; + return 1; + } else { + echo "<span class='arr'> $label </span>"; + echo '<td>'; + echo " <span class='checked'>checked</span>"; + echo '</td>'; + echo '</td></tr>'; + return 0; + } +} + + +/** + * Check if path is writable and print a + * new row in the table with the result. + * + * @param string $fullpath Path folder or file. + * @param string $label Label to show. + * + * @return integer status + */ +function check_writable($fullpath, $label) +{ + echo '<tr><td>'; + if (file_exists($fullpath)) { + if (is_writable($fullpath)) { + echo "<span class='arr'> $label </span>"; + echo '</td>'; + echo '<td>'; + echo "<span class='checked'>checked</span>"; + echo '</td>'; + echo '</tr>'; + return 0; + } else { + echo "<span class='arr'> $label </span>"; + echo '</td>'; + echo '<td>'; + echo "<span class='incomplete'>incomplete</span>"; + echo '</td>'; + echo '</tr>'; + return 1; + } + } else { + echo "<span class='arr'> $label </span>"; + echo '<td>'; + echo "<span class='incomplete'>incomplete</span>"; + echo '</td>'; + echo '</td></tr>'; + return 1; + } +} + + +/** + * Check if $var is equal to $value and + * print result in a row. + * + * @param string $var Variable. + * @param string $value Value to check. + * @param string $label Label to show. + * @param integer $mode Mode. + * + * @return integer status + */ +function check_variable($var, $value, $label, $mode) +{ + echo '<tr><td>'; + echo "<span class='arr'> $label </span>"; + echo '</td><td>'; + if ($mode == 1) { + if ($var >= $value) { + echo "<span class='checked'>checked</span>"; + return 0; + } else { + echo "<span class='incomplete'>incomplete</span>"; + return 1; + } + } else if ($var == $value) { + echo "<span class='checked'>checked</span>"; + return 0; + } else { + echo "<span class='incomplete'>incomplete</span>"; + return 1; + } + + echo '</td></tr>'; +} + + +function parse_mysql_dump($url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysql_query($query)) { + echo mysql_error(); + // Uncomment for debug + echo "<i><br>$query<br></i>"; + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +/** + * Parse sql to script dump, execute it + * and return if exist error. + * + * @param object $connection Connection sql. + * @param string $url Path file sql script. + * + * @return integer status + */ +function parse_mysqli_dump($connection, $url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysqli_query($connection, $query)) { + if (mysqli_error($connection)) { + return mysqli_error($connection).'<i><br>'.$query.'<br></i>'; + } + + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +/** + * Generate a random password + * + * Admits a huge mount of ASCII chars. + * + * @param integer $size Size of the password returned. + * + * @return string $output + */ +function random_name(int $size) +{ + $output = ''; + + // Range pair of ASCII position for allow A-Z, a-z, 0-9 and special chars. + $rangeSeed = [ + '48:57', + '65:90', + '97:122', + '40:47', + ]; + + // Size of the password must be over range seed count. + $size = ($size >= count($rangeSeed)) ? $size : count($rangeSeed); + + $auxIndex = 0; + for ($i = 0; $i < $size; $i++) { + $tmpSeedValues = explode(':', $rangeSeed[$auxIndex]); + $output = $output.chr(rand($tmpSeedValues[1], $tmpSeedValues[0])); + $auxIndex++; + if ($auxIndex >= 4) { + $auxIndex = 0; + } + } + + // Remix the string for strong the password. + return str_shuffle($output); +} + + +/** + * Print the header installation + * + * @param integer $step Number of step. + * + * @return string Html output. + */ +function print_logo_status($step) +{ + global $banner; + + $header = ' + <div class="header"> + <h3 class="title-pandora">Pandora FMS OpenSource Installer + <span class="build-banner">'.$banner.'</span> + </h3> + <div class="steps"> + <span class="step '.(($step === 11 || $step === 1) ? 'active' : '').'">1</span> + <hr class="step-separator"/> + <span class="step '.(($step === 2) ? 'active' : '').'">2</span> + <hr class="step-separator"/> + <span class="step '.(($step === 3) ? 'active' : '').'">3</span> + <hr class="step-separator"/> + <span class="step '.(($step === 4) ? 'active' : '').'">4</span> + <hr class="step-separator"/> + <span class="step '.(($step === 5) ? 'active' : '').'">5</span> + <hr class="step-separator"/> + <span class="step '.(($step === 6) ? 'active' : '').'">6</span> + + </div> + </div> + '; + + return $header; +} + + +/** + * This function adjusts path settings in pandora db for FreeBSD. + * All packages and configuration files except operating system's base files + * are installed under /usr/local in FreeBSD. So, path settings in pandora db + * for some programs should be changed from the Linux default. + * + * @param string $engine Type of engine. + * @param object $connection Connection database. + * + * @return integer Status. + */ +function adjust_paths_for_freebsd($engine, $connection=false) +{ + $adjust_sql = [ + "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');", + "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';", + "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');", + "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');", + "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');", + "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');", + "insert into tconfig (token, value) VALUES ('graphviz_bin_dir', '/usr/local/bin');", + ]; + + for ($i = 0; $i < count($adjust_sql); $i++) { + switch ($engine) { + case 'mysql': + $result = mysql_query($adjust_sql[$i]); + break; + + case 'mysqli': + $result = mysqli_query($connection, $adjust_sql[$i]); + break; + + case 'oracle': + // Delete the last semicolon from current query + $query = substr($adjust_sql[$i], 0, (strlen($adjust_sql[$i]) - 1)); + $sql = oci_parse($connection, $query); + $result = oci_execute($sql); + break; + + case 'pgsql': + pg_send_query($connection, $adjust_sql[$i]); + $result = pg_get_result($connection); + break; + } + + if (!$result) { + return 0; + } + } + + return 1; +} + + +/** + * Print all step 1 + * + * @return void + */ +function install_step1() +{ + echo " + <div id='install_container'> + <div id='wizard'> + ".print_logo_status(1, 6)." + <div class='row'> + <div class='col-md-6'> + <div id='install_box'> + <h2 class='title'>Welcome to Pandora FMS installation Wizard</h2> + <p class='text'>This wizard helps you to quick install Pandora FMS console and main database in your system. + In four steps, this installer will check all dependencies and will create your configuration, ready to use.</p> + <p class='text'>For more information, please refer to <a class='link' href='https://pandorafms.com/en/documentation/' target='_blank'>documentation →</a></p> + "; + if (file_exists('include/config.php')) { + echo "<div class='warn'> You already have a config.php file. + Configuration and database would be overwritten if you continued.</div>"; + } + + echo '<br>'; + echo '<table class="check-table">'; + $writable = check_writable('include', './include is writable'); + if (file_exists('include/config.php')) { + $writable += check_writable('include/config.php', 'include/config.php is writable'); + } + + echo '</table>'; + + echo "<div class='warn'>This installer will <b>overwrite and destroy</b> + your existing Pandora FMS configuration and <b>Database</b>. Before continue, + please <b>be sure that you have no valuable Pandora FMS data in your Database</b>.<br> + </div>"; + + if ($writable !== 0) { + echo "<div class='err'>You need to setup permissions to be able to write in ./include directory</div>"; + } + + echo '</div>'; + + echo "<div style='clear:both;'></div>"; + echo " + </div> + <div class='col-md-6 hide-phone'> + <div class='content-animation'> + <div class='popuphero'> + <div class='popupgear1'><img src='images/Pandora-FMS-installer-gear.png'></div> + <div class='popupgear2'><img src='images/Pandora-FMS-installer-gear.png'></div> + <div class='popuplaptop'><img src='images/Pandora-FMS-installer.png'></div> + </div> + </div> + </div> + </div> + </div> + <div id='foot_install'> + <div class='content-footer'> + <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> + </span>"; + if ($writable === 0) { + echo "<a id='step11' href='install.php?step=11'><button type='submit' class='btn_primary'>Start installation</button></a>"; + } + + echo '</div></div></div>'; +} + + +/** + * Print license content + * + * @return void + */ +function install_step1_licence() +{ + echo " + <div id='install_container'> + <div id='wizard'> + ".print_logo_status(2, 6)." + <div id='install_box'> + <h2 class='subtitle'>GPL2 Licence terms agreement</h2> + <p class='text'>Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, <i>you must accept the licence terms.</i>. + <p class='text'>For more information, please refer to our website at https://pandorafms.com/community/ and contact us if you have any kind of question about the usage of Pandora FMS</p> + <p>If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.</p> + "; + + if (!file_exists('COPYING')) { + echo "<div class='warn'><b>Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file.</b>"; + echo '</div>'; + } else { + echo "<textarea name='gpl2' cols=52 rows=15 style='width: 100%;'>"; + echo file_get_contents('COPYING'); + echo '</textarea>'; + echo '<p>'; + } + + echo '</div>'; + + echo "</div> + <div id='foot_install'> + <div class='content-footer'> + <a href='install.php'><button class='btn_primary outline'>Previous step</button></a> + <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> + </span>"; + if (file_exists('COPYING')) { + echo "<a href='install.php?step=2'><button id='btn_accept' class='btn_primary'>Yes, I accept licence terms</button></a>"; + } + + echo '</div></div></div>'; +} + + +/** + * Print all step 2 + * + * @return void + */ +function install_step2() +{ + echo " + <div id='install_container'> + <div id='wizard'> + ".print_logo_status(3, 6)." + <div id='install_box'>"; + echo '<h2 class="subtitle">Checking software dependencies</h2>'; + echo ' + <div class="row reverse"> + <div class="col-md-6"> + <table class="check-table">'; + $res = 0; + $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1); + $res += check_extension('gd', 'PHP GD extension'); + $res += check_extension('ldap', 'PHP LDAP extension'); + $res += check_extension('snmp', 'PHP SNMP extension'); + $res += check_extension('session', 'PHP session extension'); + $res += check_extension('gettext', 'PHP gettext extension'); + $res += check_extension('mbstring', 'PHP Multibyte String'); + $res += check_extension('zip', 'PHP Zip'); + $res += check_extension('zlib', 'PHP Zlib extension'); + $res += check_extension('json', 'PHP json extension'); + $res += check_extension('curl', 'CURL (Client URL Library)'); + $res += check_extension('filter', 'PHP filter extension'); + $res += check_extension('calendar', 'PHP calendar extension'); + if (PHP_OS == 'FreeBSD') { + $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); + } else if (PHP_OS == 'NetBSD') { + $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); + } else if (substr(PHP_OS, 0, 3) == 'WIN') { + $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); + } else { + $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); + } + + echo '<tr><td>'; + echo "<span style='display: block; margin-top: 2px; font-weight: bolder; color: white; font-size: 22px;'>DB Engines</span>"; + echo '</td><td>'; + echo '</td></tr>'; + check_extension('mysqli', 'PHP MySQL(mysqli) extension'); + echo '</table></div>'; + if ($res > 0) { + echo "<div class='col-md-6'> + <div class='err'>You have some incomplete + dependencies. Please correct them or this installer + will not be able to finish your installation. + </div> + <div class='err'> + Remember, if you install any PHP module to comply + with these dependences, you <b>need to restart</b> + your HTTP/Apache server after it to use the new + modules. + </div> + </div>"; + } + + echo '</div>'; + echo "</div></div> + <div id='foot_install'> + <div class='content-footer'> + <a href='install.php?step=11'><button class='btn_primary outline'>Previous step</button></a> + <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> + </span>"; + if ($res > 0) { + echo "<span class='text' style='margin-right: 10px'>Ignore it.</span><a id='step3' href='install.php?step=3'><button class='btn_primary'>Force install</button></a>"; + } else { + echo "<a id='step3' href='install.php?step=3'><button class='btn_primary'>Next Step</button></a>"; + } + + echo '</div></div>'; +} + + +/** + * Print all step 3 + * + * @return void + */ +function install_step3() +{ + $options = []; + if (extension_loaded('mysql')) { + $options['mysql'] = 'MySQL'; + } + + if (extension_loaded('mysqli')) { + $options['mysqli'] = 'MySQL(mysqli)'; + } + + $error = false; + if (empty($options)) { + $error = true; + } + + echo " + <div id='install_container'> + <div id='wizard'> + ".print_logo_status(4, 6)." + <div id='install_box'> + <div class='row'> + <div class='col-md-6'> + <h2 class='subtitle'>Environment and database setup</h2> + <p class='text'> + This wizard will create your Pandora FMS database, + and populate it with all the data needed to run for the first time. + </p> + <p class='text'> + You need a privileged user to create database schema, this is usually <b>root</b> user. + Information about <b>root</b> user will not be used or stored anymore. + </p> + <p class='text'> + You can also deploy the scheme into an existing Database. + In this case you need a privileged Database user and password of that instance. + </p> + <p class='text'> + Now, please, complete all details to configure your database and environment setup. + </p> + <div class='warn'> + This installer will <b>overwrite and destroy</b> your existing + Pandora FMS configuration and <b>Database</b>. Before continue, + please <b>be sure that you have no valuable Pandora FMS data in your Database.</b> + <br><br> + </div>"; + if ($error) { + echo "<div class='warn'> + You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. + </div>"; + } + + if (extension_loaded('oci8')) { + echo "<div class='warn'>For Oracle installation an existing Database with a privileged user is needed.</div>"; + } + + echo '</div>'; + echo '<div class="col-md-6">'; + if (!$error) { + echo "<form method='post' name='step2_form' action='install.php?step=4'>"; + } + + echo "<table class='table-config-database' cellpadding=6 width=100% border=0 style='text-align: left;'>"; + + if (!$error) { + echo '<tr><td>'; + echo '<p class="input-label">DB Engine</p>'; + + echo '<select id="engine" name="engine" + style="width: + 100%" + data-select2-id="engine" + tabindex="-1" + class="select2-hidden-accessible" + aria-hidden="true">'; + + foreach ($options as $key => $value) { + echo '<option value="'.$key.'">'.$value.'</option>'; + } + + echo '</select>'; + + echo '<script type="text/javascript">$("#engine").select2({closeOnSelect: true});</script>'; + + echo '<td>'; + echo '<p class="input-label">Installation in </p>'; + + echo '<select id="db_action" + name="db_action" + style="width: + 100%" + data-select2-id="db_action" + tabindex="-1" + class="select2-hidden-accessible" + aria-hidden="true"> + <option value="db_new">A new Database</option> + <option value="db_exist">An existing Database</option> + </select>'; + + echo '<script type="text/javascript">$("#db_action").select2({closeOnSelect: true});</script>'; + } + + echo "<tr> + <td> + <p class='input-label'>DB User with privileges</p> + <input class='login' type='text' name='user' value='root' size=20> + </td> + <td> + <p class='input-label'>DB Password for this user</p> + <input class='login' type='password' name='pass' value='' size=20> + </td> + </tr> + <tr> + <td> + <p class='input-label'>DB Hostname</p> + <input class='login' type='text' name='host' value='localhost' onkeyup='CheckDBhost(this.value);'size=20> + </td> + <td> + <p class='input-label'>DB Name (pandora by default)</p> + <input class='login' type='text' name='dbname' value='pandora' size=20> + </td> + </tr>"; + + // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost + echo "<tr id='tr_dbgrant' style='display: none;'> + <td colspan=\"2\"> + <p class='input-label'>DB Host Access<img style='cursor:help;' src='/pandora_console/images/tip.png' title='Ignored if DB Hostname is localhost or 127.0.0.1'/></p> + <input class='login' type='text' name='dbgrant' value='".$_SERVER['SERVER_ADDR']."'> + </td> + </tr>"; + + echo "<tr> + <td colspan='2'> + <p class='input-label'>Full path to HTTP publication directory</p> + <p class='example-message'>For example /var/www/pandora_console/</p> + <input class='login' type='text' name='path' value='".dirname(__FILE__)."'> + </td> + </tr>"; + echo " + <tr> + <td colspan='2'> + <p class='input-label'>URL path to Pandora FMS Console</p> + <p class='example-message'>For example '/pandora_console'</p> + <input class='login' type='text' name='url' value='".dirname($_SERVER['SCRIPT_NAME'])."'> + </td> + </tr>"; + + echo "<tr> + <td colspan='2' class='inline'> + <label class='switch'> + <input type='checkbox' name='drop' id='drop' value=1> + <span class='slider round'></span> + </label> + <p class='input-label'>Drop Database if exists</p> + </td> + </tr>"; + + echo '</table>'; + + echo '</div>'; + + echo '</div></div>'; + echo '</div>'; + echo "<div id='foot_install'> + <div class='content-footer'> + <a href='install.php?step=2' class='btn_primary outline'>Previous step</a> + <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> + </span>"; + if (!$error) { + echo "<button class='btn_primary' type='submit' id='step4'>Next Step</button>"; + echo '</form>'; + ?> + <script type="text/javascript"> + var step3_form = document.getElementsByName('step2_form')[0]; + step3_form.addEventListener("submit", handleStep3FormSubmit); + </script> + <?php + } + + echo '</div></div>'; +} + + +/** + * Print all step 4 + * + * @return void + */ +function install_step4() +{ + $pandora_config = 'include/config.php'; + + if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) + || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) + ) { + $dbpassword = ''; + $dbuser = ''; + $dbhost = ''; + $dbname = ''; + $engine = ''; + $dbaction = ''; + $dbgrant = ''; + } else { + $engine = $_POST['engine']; + $dbpassword = $_POST['pass']; + $dbuser = $_POST['user']; + $dbhost = $_POST['host']; + $dbaction = $_POST['db_action']; + if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { + $dbgrant = $_POST['dbgrant']; + } else { + $dbgrant = $_SERVER['SERVER_ADDR']; + } + + if (isset($_POST['drop'])) { + $dbdrop = $_POST['drop']; + } else { + $dbdrop = 0; + } + + $dbname = $_POST['dbname']; + if (isset($_POST['url'])) { + $url = $_POST['url']; + } else { + $url = 'http://localhost'; + } + + if (isset($_POST['path'])) { + $path = $_POST['path']; + $path = str_replace('\\', '/', $path); + // Windows compatibility + } else { + $path = '/var/www'; + } + } + + $everything_ok = 0; + $step1 = 0; + $step2 = 0; + $step3 = 0; + $step4 = 0; + $step5 = 0; + $step6 = 0; + $step7 = 0; + $errors = []; + echo " + <div id='install_container'> + <div id='wizard'> + ".print_logo_status(5, 6)." + <div id='install_box'> + <div class='row reverse'> + <div class='col-md-6'> + <table class='check-table'>"; + switch ($engine) { + case 'mysql': + if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysql_query("DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysql_query("CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysql_select_db($dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysql_dump('pandoradb.sql'); + + if ($step3 !== 0 && $step3 !== 1) { + $errors[] = $step3; + $step3 = 0; + } + + check_generic($step3, 'Creating schema'); + $step4 = parse_mysql_dump('pandoradb_data.sql'); + + if ($step4 !== 0 && $step4 !== 1) { + $errors[] = $step4; + $step4 = 0; + } + + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysql_query( + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host + IDENTIFIED BY '".$random_password."'" + ); + mysql_query('FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: <b>$random_password</b><p>Please write it down, you will need to setup your Pandora FMS server, editing the </i>/etc/pandora/pandora_server.conf</i> file</p>"); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = '<?php + // Begin of automatic config file + $config["dbtype"] = "'.$dbtype.'"; //DB type (mysql, postgresql...in future others) + $config["dbname"]="'.$dbname.'"; // MySQL DataBase name + $config["dbuser"]="pandora"; // DB User + $config["dbpass"]="'.$random_password.'"; // DB Password + $config["dbhost"]="'.$dbhost.'"; // DB Host + $config["homedir"]="'.$path.'"; // Config homedir + // ----------Rebranding-------------------- + // Uncomment this lines and add your customs text and paths. + // $config["custom_logo_login_alt"] ="login_logo.png"; + // $config["custom_splash_login_alt"] = "splash_image_default.png"; + // $config["custom_title1_login_alt"] = "WELCOME TO Pandora FMS"; + // $config["custom_title2_login_alt"] = "NEXT GENERATION"; + // $config["rb_product_name_alt"] = "Pandora FMS"; + // $config["custom_docs_url_alt"] = "http://wiki.pandorafms.com/"; + // $config["custom_support_url_alt"] = "https://support.pandorafms.com"; + + + + /* + ----------Attention-------------------- + Please note that in certain installations: + - reverse proxy. + - web server in other ports. + - https + + This variable might be dynamically altered. + + But it is save as backup in the + $config["homeurl_static"] + for expecial needs. + ----------Attention-------------------- + */ + $config["homeurl"]="'.$url.'"; // Base URL + $config["homeurl_static"]="'.$url.'"; // Don\'t delete + // End of automatic config file + ?>'; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + + case 'mysqli': + $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); + if (mysqli_connect_error() > 0) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysqli_select_db($connection, $dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); + if ($step3 !== 0 && $step3 !== 1) { + $errors[] = $step3; + $step3 = 0; + } + + check_generic($step3, 'Creating schema'); + + $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); + + if ($step4 !== 0 && $step4 !== 1) { + $errors[] = $step4; + $step4 = 0; + } + + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine, $connection); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysqli_query( + $connection, + "CREATE USER IF NOT EXISTS pandora@$host" + ); + + mysqli_query( + $connection, + "SET PASSWORD FOR 'pandora'@'".$host."' = '".$random_password."'" + ); + + $step5 |= mysqli_query( + $connection, + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host" + ); + mysqli_query($connection, 'FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: <b>$random_password</b><p>Please write it down, you will need to setup your Pandora FMS server, editing the </i>/etc/pandora/pandora_server.conf</i> file</p>"); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = '<?php + // Begin of automatic config file + $config["dbtype"] = "'.$dbtype.'"; //DB type (mysql, postgresql...in future others) + $config["mysqli"] = true; + $config["dbname"]="'.$dbname.'"; // MySQL DataBase name + $config["dbuser"]="pandora"; // DB User + $config["dbpass"]="'.$random_password.'"; // DB Password + $config["dbhost"]="'.$dbhost.'"; // DB Host + $config["homedir"]="'.$path.'"; // Config homedir + // ----------Rebranding-------------------- + // Uncomment this lines and add your customs text and paths. + // $config["custom_logo_login_alt"] ="login_logo.png"; + // $config["custom_splash_login_alt"] = "splash_image_default.png"; + // $config["custom_title1_login_alt"] = "WELCOME TO Pandora FMS"; + // $config["custom_title2_login_alt"] = "NEXT GENERATION"; + // $config["rb_product_name_alt"] = "Pandora FMS"; + // $config["custom_docs_url_alt"] = "http://wiki.pandorafms.com/"; + // $config["custom_support_url_alt"] = "https://support.pandorafms.com"; + + /* + ----------Attention-------------------- + Please note that in certain installations: + - reverse proxy. + - web server in other ports. + - https + + This variable might be dynamically altered. + + But it is save as backup in the + $config["homeurl_static"] + for expecial needs. + ----------Attention-------------------- + */ + $config["homeurl"]="'.$url.'"; // Base URL + $config["homeurl_static"]="'.$url.'"; // Don\'t delete + // End of automatic config file + ?>'; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + } + + echo '</table>'; + echo '</div>'; + echo '<div class="col-md-6" id="content-errors">'; + echo "<h2 class='subtitle'>Creating database and default configuration file</h2>"; + if ($everything_ok !== 1) { + $info = ''; + + if (!empty($errors)) { + foreach ($errors as $key => $err) { + $info .= '<div class="err-sql">'.$err.'</div>'; + } + + $info .= "<div class='err'>If you use MySQL 8 make sure to include the + following parameter in your installation's my.cnf configuration file<br /> + sql_mode=\"\"</div>"; + } + + $info .= "<div class='err'><b>There were some problems. + Installation was not completed.</b> + <p>Please correct failures before trying again. + All database "; + + if ($engine == 'oracle') { + $info .= 'objects '; + } else { + $info .= 'schemes '; + } + + $info .= 'created in this step have been dropped. </p> + </div>'; + echo $info; + + switch ($engine) { + case 'mysql': + if (mysql_error() != '') { + echo "<div class='err'>".mysql_error().'.</div>'; + echo "<div class='err'>If you use MySQL 8 make sure to include the + following parameter in your installation's my.cnf configuration file<br /> + sql_mode=\"\"</div>"; + } + + if ($step1 == 1) { + mysql_query("DROP DATABASE $dbname"); + } + break; + + case 'mysqli': + if ($connection && mysqli_error($connection) != '') { + echo "<div class='err'>".mysqli_error($connection).'.</div>'; + echo "<div class='err'>If you use MySQL 8 make sure to include the + following parameter in your installation's my.cnf configuration file<br /> + sql_mode=\"\"</div>"; + } + + if ($step1 == 1) { + mysqli_query($connection, "DROP DATABASE $dbname"); + } + break; + } + } + + echo '</div>'; + echo '</div>'; + echo '</div></div>'; + echo " + <div id='foot_install'> + <div class='content-footer'> + <a href='install.php?step=3' class='btn_primary outline'>Previous step</a> + <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> + </span>"; + if ($everything_ok === 1) { + echo "<a id='step5' href='install.php?step=5'> + <button class='btn_primary' type='submit'>Next Step</button> + </a>"; + } + + echo '</div></div>'; +} + + +/** + * Print all step 5 + * + * @return void + */ +function install_step5() +{ + echo " + <div id='install_container'> + <div id='wizard'> + ".print_logo_status(6, 6)." + <div id='install_box'> + <h2 class='subtitle'>Installation complete</h2> + <p class='text'>For security, you now must manually delete this installer + ('<i>install.php</i>') file before trying to access to your Pandora FMS console. + <p class='text'>You should also install Pandora FMS Servers before trying to monitor anything; + please read documentation on how to install it.</p> + <p class='text'>Default user is <b>'admin'</b> with password <b>'pandora'</b>, + please change it both as soon as possible.</p> + <p class='text'>Don't forget to check <a href='https://pandorafms.com' class='link'>https://pandorafms.com</a> + for updates. + <p class='text'>Select if you want to rename '<i>install.php</i>'.</p> + <form method='post' action='index.php'> + <button class='btn_primary outline' type='submit' name='rn_file'><span class='btn_install_next_text'>Yes, rename the file</span></button> + <input type='hidden' name='rename_file' value='1'> + </form> + </p> + </div> + </div> + <div id='foot_install'> + <div class='content-footer'> + <span class='signature'>Pandora FMS is an OpenSource software project registered at <a target='_blank' href='http://pandora.sourceforge.net'>SourceForge →</a> + </span> + <a id='access_pandora' href='index.php'> + <button class='btn_primary'>Click here to access to your Pandora FMS console</button> + </a> + </div> + </div> + </div>"; +} From cce9ee3043b6318555a6279d57fdf6b58b3ea3fa Mon Sep 17 00:00:00 2001 From: rafael <rafael.ameijeiras@pandorafms.com> Date: Wed, 23 Aug 2023 10:38:26 +0200 Subject: [PATCH 4/5] fix typo --- tentacle/tentacle_client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tentacle/tentacle_client b/tentacle/tentacle_client index d90d21f344..be989f541f 100755 --- a/tentacle/tentacle_client +++ b/tentacle/tentacle_client @@ -2,7 +2,7 @@ ################################################################################ # # Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es> -# Copyright (c) 2007-2023 Pandora FMS. +# Copyright (c) 2007-2023 Pandora FMS. # # tentacle_client.pl Tentacle Client. See https://pandorafms.com/docs/ for # protocol description. From 30f4a27638dcb35b9cfe34974baebc700472482a Mon Sep 17 00:00:00 2001 From: rafael <rafael.ameijeiras@pandorafms.com> Date: Wed, 23 Aug 2023 10:39:36 +0200 Subject: [PATCH 5/5] fix typo --- tentacle/tentacle_client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tentacle/tentacle_client b/tentacle/tentacle_client index be989f541f..da917863d6 100755 --- a/tentacle/tentacle_client +++ b/tentacle/tentacle_client @@ -1095,7 +1095,7 @@ Protocol description and more info at: L<< https://pandorafms.com/manual/en/docu =head1 COPYRIGHT -Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L +Copyright (c) 2005-2023 Pandora FMS. =cut