From f1a553aac617b4752620d2676d11b73e3119adcf Mon Sep 17 00:00:00 2001 From: "pi@skippy" Date: Tue, 29 Aug 2023 16:54:05 +0200 Subject: [PATCH 1/4] updated fork from original --- docker-compose.yml | 81 ++++++++++++++---------------------------- docker-compose.yml.bkp | 58 ++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 55 deletions(-) create mode 100755 docker-compose.yml.bkp diff --git a/docker-compose.yml b/docker-compose.yml index 7418d13a..866210e5 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,58 +1,29 @@ version: "3" + + services: - pialert: - privileged: true - build: - dockerfile: Dockerfile - context: . - cache_from: - - type=registry,ref=docker.io/jokob-sk/pi.alert:buildcache - container_name: pialert - network_mode: host - # restart: unless-stopped - volumes: - - ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config - # - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config - - ${APP_DATA_LOCATION}/pialert_dev/db:/home/pi/pialert/db - # - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db - # (optional) useful for debugging if you have issues setting up the container - - ${LOGS_LOCATION}:/home/pi/pialert/front/log - # --------------------------------------------------------------------------- - # DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes - - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp1.leases:/mnt/dhcp1.leases - - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp2.leases:/mnt/dhcp2.leases - - ${APP_DATA_LOCATION}/pihole/etc-pihole/pihole-FTL.db:/etc/pihole/pihole-FTL.db - - ${DEV_LOCATION}/pialert:/home/pi/pialert/pialert - - ${DEV_LOCATION}/back/report_template.html:/home/pi/pialert/back/report_template.html - - ${DEV_LOCATION}/back/report_template_new_version.html:/home/pi/pialert/back/report_template_new_version.html - - ${DEV_LOCATION}/back/report_template.txt:/home/pi/pialert/back/report_template.txt - - ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles - - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini - # - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api - - ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css - - ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE - - ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js - - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api - - ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php - - ${DEV_LOCATION}/front/deviceDetails.php:/home/pi/pialert/front/deviceDetails.php - - ${DEV_LOCATION}/front/devices.php:/home/pi/pialert/front/devices.php - - ${DEV_LOCATION}/front/events.php:/home/pi/pialert/front/events.php - - ${DEV_LOCATION}/front/plugins.php:/home/pi/pialert/front/plugins.php - - ${DEV_LOCATION}/front/pluginsCore.php:/home/pi/pialert/front/pluginsCore.php - - ${DEV_LOCATION}/front/help_faq.php:/home/pi/pialert/front/help_faq.php - - ${DEV_LOCATION}/front/index.php:/home/pi/pialert/front/index.php - - ${DEV_LOCATION}/front/maintenance.php:/home/pi/pialert/front/maintenance.php - - ${DEV_LOCATION}/front/network.php:/home/pi/pialert/front/network.php - - ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php - - ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php - - ${DEV_LOCATION}/front/systeminfo.php:/home/pi/pialert/front/systeminfo.php - - ${DEV_LOCATION}/front/report.php:/home/pi/pialert/front/report.php - - ${DEV_LOCATION}/front/flows.php:/home/pi/pialert/front/flows.php - - ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins - # DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes - # --------------------------------------------------------------------------- + pialert_staging: + container_name: pialert_staging + image: gitlab.baupal.ch:5050/infra/pialert_gl:staging + environment: - - TZ=${TZ} - - PORT=${PORT} - - HOST_USER_ID=${HOST_USER_ID} - - HOST_USER_GID=${HOST_USER_GID} + TZ: 'Europe/Zurich' + PORT: 20223 + + volumes: + - 'staging_config_st:/home/pi/pialert/config' + - 'staging_db_st:/home/pi/pialert/db' + - 'staging_logs_st:/home/pi/pialert/front/log' + #- '/home/pi/gitrepos/pialert_gl/front/plugins/unifi_import/script.py:/home/pi/pialert/front/plugins/unifi_import/script.py' + #- '/home/pi/gitrepos/pialert_gl/front/plugins/unifi_import/config.json:/home/pi/pialert/front/plugins/unifi_import/config.json' + - '/var/lib/docker/volumes/pihole/_data/pihole-FTL.db:/etc/pihole/pihole-FTL.db:ro' + - '/var/lib/docker/volumes/pihole/_data/dhcp.leases:/etc/pihole/dhcp.leases:ro' + network_mode: "host" + + restart: unless-stopped + +volumes: + staging_config_st: + staging_db_st: + staging_logs_st: + diff --git a/docker-compose.yml.bkp b/docker-compose.yml.bkp new file mode 100755 index 00000000..7418d13a --- /dev/null +++ b/docker-compose.yml.bkp @@ -0,0 +1,58 @@ +version: "3" +services: + pialert: + privileged: true + build: + dockerfile: Dockerfile + context: . + cache_from: + - type=registry,ref=docker.io/jokob-sk/pi.alert:buildcache + container_name: pialert + network_mode: host + # restart: unless-stopped + volumes: + - ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config + # - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config + - ${APP_DATA_LOCATION}/pialert_dev/db:/home/pi/pialert/db + # - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db + # (optional) useful for debugging if you have issues setting up the container + - ${LOGS_LOCATION}:/home/pi/pialert/front/log + # --------------------------------------------------------------------------- + # DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes + - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp1.leases:/mnt/dhcp1.leases + - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp2.leases:/mnt/dhcp2.leases + - ${APP_DATA_LOCATION}/pihole/etc-pihole/pihole-FTL.db:/etc/pihole/pihole-FTL.db + - ${DEV_LOCATION}/pialert:/home/pi/pialert/pialert + - ${DEV_LOCATION}/back/report_template.html:/home/pi/pialert/back/report_template.html + - ${DEV_LOCATION}/back/report_template_new_version.html:/home/pi/pialert/back/report_template_new_version.html + - ${DEV_LOCATION}/back/report_template.txt:/home/pi/pialert/back/report_template.txt + - ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles + - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini + # - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api + - ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css + - ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE + - ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js + - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api + - ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php + - ${DEV_LOCATION}/front/deviceDetails.php:/home/pi/pialert/front/deviceDetails.php + - ${DEV_LOCATION}/front/devices.php:/home/pi/pialert/front/devices.php + - ${DEV_LOCATION}/front/events.php:/home/pi/pialert/front/events.php + - ${DEV_LOCATION}/front/plugins.php:/home/pi/pialert/front/plugins.php + - ${DEV_LOCATION}/front/pluginsCore.php:/home/pi/pialert/front/pluginsCore.php + - ${DEV_LOCATION}/front/help_faq.php:/home/pi/pialert/front/help_faq.php + - ${DEV_LOCATION}/front/index.php:/home/pi/pialert/front/index.php + - ${DEV_LOCATION}/front/maintenance.php:/home/pi/pialert/front/maintenance.php + - ${DEV_LOCATION}/front/network.php:/home/pi/pialert/front/network.php + - ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php + - ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php + - ${DEV_LOCATION}/front/systeminfo.php:/home/pi/pialert/front/systeminfo.php + - ${DEV_LOCATION}/front/report.php:/home/pi/pialert/front/report.php + - ${DEV_LOCATION}/front/flows.php:/home/pi/pialert/front/flows.php + - ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins + # DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes + # --------------------------------------------------------------------------- + environment: + - TZ=${TZ} + - PORT=${PORT} + - HOST_USER_ID=${HOST_USER_ID} + - HOST_USER_GID=${HOST_USER_GID} From b28165200922945c9f0a6c01f2feef0e7cd4143b Mon Sep 17 00:00:00 2001 From: stefan-linux Date: Wed, 30 Aug 2023 13:18:53 +0200 Subject: [PATCH 2/4] changed unifi_import to only export online devices --- front/plugins/unifi_import/script.py | 32 +++++++++++----------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/front/plugins/unifi_import/script.py b/front/plugins/unifi_import/script.py index e4917067..e10b68c5 100755 --- a/front/plugins/unifi_import/script.py +++ b/front/plugins/unifi_import/script.py @@ -129,8 +129,7 @@ def get_entries(newEntries): name = get_unifi_val(ap, 'name') hostName = get_unifi_val(ap, 'hostname') - if name == 'null' and hostName != 'null': - name = hostName + name = set_name(name, hostName) tmpPlugObj = plugin_object_class( ap['mac'], @@ -153,13 +152,6 @@ def get_entries(newEntries): for cl in c.get_clients(): # print(f'{json.dumps(cl)}') - - name = get_unifi_val(cl, 'name') - hostName = get_unifi_val(cl, 'hostname') - - if name == 'null' and hostName != 'null': - name = hostName - online_macs.add(cl['mac']) unifi_logger.debug(f'Found {len(online_macs)} Online Clients') @@ -178,17 +170,19 @@ def get_entries(newEntries): status = 1 if user['mac'] in online_macs else 0 - tmpPlugObj = plugin_object_class( - user['mac'], - get_unifi_val(user, 'last_ip'), - name, - get_unifi_val(user, 'oui'), - 'Other', - status, - get_unifi_val(user, 'last_connection_network_name') - ) + if status == 1: - newEntries.append(tmpPlugObj) + tmpPlugObj = plugin_object_class( + user['mac'], + get_unifi_val(user, 'last_ip'), + name, + get_unifi_val(user, 'oui'), + 'Other', + status, + get_unifi_val(user, 'last_connection_network_name') + ) + + newEntries.append(tmpPlugObj) unifi_logger.debug(f'Found {len(newEntries)} Clients overall') return newEntries From 8ae8d6aa279fb4cda651758c401f563b4bcac73a Mon Sep 17 00:00:00 2001 From: stefan-linux Date: Wed, 30 Aug 2023 14:06:48 +0200 Subject: [PATCH 3/4] set logging to INFO and updated log message --- front/plugins/unifi_import/script.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/plugins/unifi_import/script.py b/front/plugins/unifi_import/script.py index e10b68c5..7e04a087 100755 --- a/front/plugins/unifi_import/script.py +++ b/front/plugins/unifi_import/script.py @@ -32,7 +32,7 @@ logging.basicConfig( format='%(asctime)s:%(levelname)s:%(name)s:%(message)s' ) unifi_logger = logging.getLogger('[UNIFI]') -unifi_logger.setLevel(logging.DEBUG) +unifi_logger.setLevel(logging.INFO) requests.packages.urllib3.disable_warnings(InsecureRequestWarning) @@ -87,7 +87,7 @@ def main(): # Insert list into the log service_monitoring_log(e.primaryId, e.secondaryId, e.created, e.watched1, e.watched2, e.watched3, e.watched4, e.extra, e.foreignKey ) - unifi_logger.info(f'Scan finished, added {len(newEntries)} devices') + unifi_logger.info(f'Scan finished, found {len(newEntries)} devices') # ----------------------------------------------------------------------------- def get_entries(newEntries): From 6032667ea7d2db5b9432bbeb8cf0fa2137cd3f70 Mon Sep 17 00:00:00 2001 From: stefan-linux Date: Wed, 30 Aug 2023 14:22:44 +0200 Subject: [PATCH 4/4] removed changes to compose file --- docker-compose.yml | 81 ++++++++++++++++++++++++++++-------------- docker-compose.yml.bkp | 58 ------------------------------ 2 files changed, 55 insertions(+), 84 deletions(-) delete mode 100755 docker-compose.yml.bkp diff --git a/docker-compose.yml b/docker-compose.yml index 866210e5..7418d13a 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,29 +1,58 @@ version: "3" - - services: - pialert_staging: - container_name: pialert_staging - image: gitlab.baupal.ch:5050/infra/pialert_gl:staging - - environment: - TZ: 'Europe/Zurich' - PORT: 20223 - + pialert: + privileged: true + build: + dockerfile: Dockerfile + context: . + cache_from: + - type=registry,ref=docker.io/jokob-sk/pi.alert:buildcache + container_name: pialert + network_mode: host + # restart: unless-stopped volumes: - - 'staging_config_st:/home/pi/pialert/config' - - 'staging_db_st:/home/pi/pialert/db' - - 'staging_logs_st:/home/pi/pialert/front/log' - #- '/home/pi/gitrepos/pialert_gl/front/plugins/unifi_import/script.py:/home/pi/pialert/front/plugins/unifi_import/script.py' - #- '/home/pi/gitrepos/pialert_gl/front/plugins/unifi_import/config.json:/home/pi/pialert/front/plugins/unifi_import/config.json' - - '/var/lib/docker/volumes/pihole/_data/pihole-FTL.db:/etc/pihole/pihole-FTL.db:ro' - - '/var/lib/docker/volumes/pihole/_data/dhcp.leases:/etc/pihole/dhcp.leases:ro' - network_mode: "host" - - restart: unless-stopped - -volumes: - staging_config_st: - staging_db_st: - staging_logs_st: - + - ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config + # - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config + - ${APP_DATA_LOCATION}/pialert_dev/db:/home/pi/pialert/db + # - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db + # (optional) useful for debugging if you have issues setting up the container + - ${LOGS_LOCATION}:/home/pi/pialert/front/log + # --------------------------------------------------------------------------- + # DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes + - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp1.leases:/mnt/dhcp1.leases + - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp2.leases:/mnt/dhcp2.leases + - ${APP_DATA_LOCATION}/pihole/etc-pihole/pihole-FTL.db:/etc/pihole/pihole-FTL.db + - ${DEV_LOCATION}/pialert:/home/pi/pialert/pialert + - ${DEV_LOCATION}/back/report_template.html:/home/pi/pialert/back/report_template.html + - ${DEV_LOCATION}/back/report_template_new_version.html:/home/pi/pialert/back/report_template_new_version.html + - ${DEV_LOCATION}/back/report_template.txt:/home/pi/pialert/back/report_template.txt + - ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles + - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini + # - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api + - ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css + - ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE + - ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js + - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api + - ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php + - ${DEV_LOCATION}/front/deviceDetails.php:/home/pi/pialert/front/deviceDetails.php + - ${DEV_LOCATION}/front/devices.php:/home/pi/pialert/front/devices.php + - ${DEV_LOCATION}/front/events.php:/home/pi/pialert/front/events.php + - ${DEV_LOCATION}/front/plugins.php:/home/pi/pialert/front/plugins.php + - ${DEV_LOCATION}/front/pluginsCore.php:/home/pi/pialert/front/pluginsCore.php + - ${DEV_LOCATION}/front/help_faq.php:/home/pi/pialert/front/help_faq.php + - ${DEV_LOCATION}/front/index.php:/home/pi/pialert/front/index.php + - ${DEV_LOCATION}/front/maintenance.php:/home/pi/pialert/front/maintenance.php + - ${DEV_LOCATION}/front/network.php:/home/pi/pialert/front/network.php + - ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php + - ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php + - ${DEV_LOCATION}/front/systeminfo.php:/home/pi/pialert/front/systeminfo.php + - ${DEV_LOCATION}/front/report.php:/home/pi/pialert/front/report.php + - ${DEV_LOCATION}/front/flows.php:/home/pi/pialert/front/flows.php + - ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins + # DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes + # --------------------------------------------------------------------------- + environment: + - TZ=${TZ} + - PORT=${PORT} + - HOST_USER_ID=${HOST_USER_ID} + - HOST_USER_GID=${HOST_USER_GID} diff --git a/docker-compose.yml.bkp b/docker-compose.yml.bkp deleted file mode 100755 index 7418d13a..00000000 --- a/docker-compose.yml.bkp +++ /dev/null @@ -1,58 +0,0 @@ -version: "3" -services: - pialert: - privileged: true - build: - dockerfile: Dockerfile - context: . - cache_from: - - type=registry,ref=docker.io/jokob-sk/pi.alert:buildcache - container_name: pialert - network_mode: host - # restart: unless-stopped - volumes: - - ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config - # - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config - - ${APP_DATA_LOCATION}/pialert_dev/db:/home/pi/pialert/db - # - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db - # (optional) useful for debugging if you have issues setting up the container - - ${LOGS_LOCATION}:/home/pi/pialert/front/log - # --------------------------------------------------------------------------- - # DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes - - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp1.leases:/mnt/dhcp1.leases - - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp2.leases:/mnt/dhcp2.leases - - ${APP_DATA_LOCATION}/pihole/etc-pihole/pihole-FTL.db:/etc/pihole/pihole-FTL.db - - ${DEV_LOCATION}/pialert:/home/pi/pialert/pialert - - ${DEV_LOCATION}/back/report_template.html:/home/pi/pialert/back/report_template.html - - ${DEV_LOCATION}/back/report_template_new_version.html:/home/pi/pialert/back/report_template_new_version.html - - ${DEV_LOCATION}/back/report_template.txt:/home/pi/pialert/back/report_template.txt - - ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles - - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini - # - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api - - ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css - - ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE - - ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js - - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api - - ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php - - ${DEV_LOCATION}/front/deviceDetails.php:/home/pi/pialert/front/deviceDetails.php - - ${DEV_LOCATION}/front/devices.php:/home/pi/pialert/front/devices.php - - ${DEV_LOCATION}/front/events.php:/home/pi/pialert/front/events.php - - ${DEV_LOCATION}/front/plugins.php:/home/pi/pialert/front/plugins.php - - ${DEV_LOCATION}/front/pluginsCore.php:/home/pi/pialert/front/pluginsCore.php - - ${DEV_LOCATION}/front/help_faq.php:/home/pi/pialert/front/help_faq.php - - ${DEV_LOCATION}/front/index.php:/home/pi/pialert/front/index.php - - ${DEV_LOCATION}/front/maintenance.php:/home/pi/pialert/front/maintenance.php - - ${DEV_LOCATION}/front/network.php:/home/pi/pialert/front/network.php - - ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php - - ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php - - ${DEV_LOCATION}/front/systeminfo.php:/home/pi/pialert/front/systeminfo.php - - ${DEV_LOCATION}/front/report.php:/home/pi/pialert/front/report.php - - ${DEV_LOCATION}/front/flows.php:/home/pi/pialert/front/flows.php - - ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins - # DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes - # --------------------------------------------------------------------------- - environment: - - TZ=${TZ} - - PORT=${PORT} - - HOST_USER_ID=${HOST_USER_ID} - - HOST_USER_GID=${HOST_USER_GID}