diff --git a/.gitignore b/.gitignore index 4295c0910f83d7ac19dd2237a26c6407e1c1fd89..0dbdb364eaef9ae3f3dc2d4bb9d46bb7005026df 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,7 @@ npm-debug.log yarn-error.log .env +/volumes/ + monitor monitor-*.zip diff --git a/composer.json b/composer.json index 47c23909192fefbd77c8a09ef957f123a5b70cb2..36db2e2ab7d217287dc18744318ef6f3ed5ab0ae 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "laravel/framework": "^6.0", "laravel/helpers": "^1.2", "laravel/tinker": "~1.0", - "php-ai/php-ml": "^0.9.0" + "php-ai/php-ml": "^0.9.0", + "predis/predis": "^2.2" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.6", diff --git a/composer.lock b/composer.lock index 37c30c1dacd69611fafe96f90af074c7f15a4ef5..4b5b446ab5e5e0f27ec42dc54c7df1bce3911f15 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "397e86d52c0cb45d251390e6b67fa74e", + "content-hash": "f625ad51aa1c862b44d3e110c0109394", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -2164,6 +2164,67 @@ ], "time": "2023-02-25T19:38:58+00:00" }, + { + "name": "predis/predis", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/predis/predis.git", + "reference": "33b70b971a32b0d28b4f748b0547593dce316e0d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/predis/predis/zipball/33b70b971a32b0d28b4f748b0547593dce316e0d", + "reference": "33b70b971a32b0d28b4f748b0547593dce316e0d", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.3", + "phpstan/phpstan": "^1.9", + "phpunit/phpunit": "^8.0 || ~9.4.4" + }, + "suggest": { + "ext-relay": "Faster connection with in-memory caching (>=0.6.2)" + }, + "type": "library", + "autoload": { + "psr-4": { + "Predis\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Till Krüss", + "homepage": "https://till.im", + "role": "Maintainer" + } + ], + "description": "A flexible and feature-complete Redis client for PHP.", + "homepage": "http://github.com/predis/predis", + "keywords": [ + "nosql", + "predis", + "redis" + ], + "support": { + "issues": "https://github.com/predis/predis/issues", + "source": "https://github.com/predis/predis/tree/v2.2.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/tillkruss", + "type": "github" + } + ], + "time": "2023-06-14T10:37:31+00:00" + }, { "name": "psr/container", "version": "1.1.2", diff --git a/database/migrations/2023_08_05_093415_create_table_records.php b/database/migrations/2023_08_05_093415_create_table_records.php index c81abb39534e9c06b59b86e07ffc785dad28841c..50e9e031fe8b5c1e6503628cbc2676cf850f4028 100644 --- a/database/migrations/2023_08_05_093415_create_table_records.php +++ b/database/migrations/2023_08_05_093415_create_table_records.php @@ -16,7 +16,7 @@ class CreateTableRecords extends Migration Schema::create('records', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer("time")->index(); - $table->integer("server_id"); + $table->unsignedInteger("server_id"); $table->longText("data"); $table->foreign("server_id")->references("id")->on("servers"); diff --git a/database/migrations/2023_08_06_143857_create_table_status_changes.php b/database/migrations/2023_08_06_143857_create_table_status_changes.php index bc220e87032c629649f018b45ee3db598ebde58e..20f6fd1d59e94fc7942358fa75b988254e69e50f 100644 --- a/database/migrations/2023_08_06_143857_create_table_status_changes.php +++ b/database/migrations/2023_08_06_143857_create_table_status_changes.php @@ -16,9 +16,9 @@ class CreateTableStatusChanges extends Migration Schema::create('status_changes', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer("time")->index(); - $table->integer("server_id"); + $table->unsignedInteger("server_id"); $table->integer("status"); - $table->integer("record_id"); + $table->unsignedBigInteger("record_id"); $table->foreign("server_id")->references("id")->on("servers"); $table->foreign("record_id")->references("id")->on("records"); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..74adfce1cd1de939470690e02dc7453d28633c34 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,74 @@ +# +# monitoring +# +# this docker-compose can be used to run a development environment +# + +version: "3.7" + +services: + web: + image: cylab/laravel-dev + depends_on: + - redis + - mysql + ports: + - 8080:80 + volumes: + - .:/var/www/html + env_file: env.dev + environment: + WAIT_HOSTS: mysql:3306 + + queue: + image: cylab/laravel-dev + depends_on: + - web + volumes: + - .:/var/www/html + command: ["php", "artisan", "queue:work", "--verbose", "--tries=3", "--timeout=60"] + restart: unless-stopped + env_file: env.dev + environment: + WAIT_HOSTS: web:80 + + scheduler: + image: cylab/laravel-dev + depends_on: + - web + volumes: + - .:/var/www/html + command: ["/scheduler.sh"] + env_file: env.dev + environment: + WAIT_HOSTS: web:80 + + node: + image: node:16.15.0-alpine + working_dir: /app + volumes: + - .:/app + entrypoint: /bin/sh -c "npm install && npm run watch-poll" + depends_on: + - web + + redis: + image: redis:4-alpine + volumes: + - ./volumes/redis:/data + + mysql: + image: mysql:5.7 + volumes: + - ./volumes/mysql:/var/lib/mysql + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: laravel + + mailhog: + image: mailhog/mailhog + ports: + - 1025:1025 + - 8025:8025 + + diff --git a/env.dev b/env.dev index dd2a843ed9e5eef7da32923e2db80d825c159578..84cb2f94ce224607ffc39fb40e239f6e333f229d 100644 --- a/env.dev +++ b/env.dev @@ -1,34 +1,39 @@ -APP_NAME=Laravel -APP_ENV=local -APP_KEY= +# +# monitoring +# env.dev +# +# env file used for developement envirionement +# see docker-compose.yaml +# + +APP_NAME=monitoring +APP_ENV=testing +APP_KEY=base64:ezEe4jH/6EUM2fMWLnco3kuMz1OMStq/XfV456ZwMhc= APP_DEBUG=true APP_LOG_LEVEL=debug -APP_URL=http://localhost - -DB_CONNECTION=sqlite +APP_URL=http://localhost:8080 -#DB_CONNECTION=mysql -#DB_HOST=127.0.0.1 -#DB_PORT=3306 -#DB_DATABASE=homestead -#DB_USERNAME=homestead -#DB_PASSWORD=secret +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=laravel +DB_USERNAME=root +DB_PASSWORD=root BROADCAST_DRIVER=log -CACHE_DRIVER=file -SESSION_DRIVER=file +CACHE_DRIVER=redis +SESSION_DRIVER=redis SESSION_LIFETIME=120 -QUEUE_DRIVER=sync +QUEUE_DRIVER=redis -REDIS_HOST=127.0.0.1 +REDIS_HOST=redis REDIS_PASSWORD=null REDIS_PORT=6379 -MAIL_DRIVER=log -#MAIL_DRIVER=smtp -#MAIL_HOST=127.0.0.1 -#MAIL_PORT=1025 -#MAIL_USERNAME=null -#MAIL_PASSWORD=null -#MAIL_ENCRYPTION=null +MAIL_DRIVER=smtp +MAIL_HOST=mailhog +MAIL_PORT=1025 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null