====== Status - Cachethq ====== Hop hop le tuto officiel : [[https://docs.cachethq.io/v1.0/docs/installing-cachet]] ==== Installation ==== === Début === On clone le dépot dans /var/www/, puis on install php et php-gd Ensuite, on crée le .env à la racine à partir du .env.example On crée la bdd mysql : CREATE DATABASE cachet collate='utf8_general_ci'; CREATE USER 'homestead'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON cachet.* TO 'homestead'@'localhost'; On enregistre les réglages dans le .env concernant la bdd : APP_ENV=production APP_DEBUG=false APP_URL=http://localhost APP_KEY=secretkey DB_DRIVER=mysql DB_HOST=localhost DB_UNIX_SOCKET=null DB_DATABASE=cachet DB_USERNAME=homestead DB_PASSWORD=WQSPbaOp//PU2 DB_PORT=null DB_PREFIX=null CACHE_DRIVER=apc SESSION_DRIVER=apc QUEUE_DRIVER=null CACHET_BEACON=true CACHET_EMOJI=false CACHET_AUTO_TWITTER=true MAIL_DRIVER=smtp MAIL_HOST=localhost MAIL_PORT=25 MAIL_USERNAME=cachet MAIL_PASSWORD=plopus MAIL_ADDRESS=no-reply@federez.net MAIL_NAME=null MAIL_ENCRYPTION=tls REDIS_HOST=null REDIS_DATABASE=null REDIS_PORT=null GITHUB_TOKEN=null NEXMO_KEY=null NEXMO_SECRET=null NEXMO_SMS_FROM=Cachet === Installation des composantes === On installe composer et on préconfigure les dépendances : curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer composer install --no-dev -o On génère la secret key php artisan key:generate On installe l'application php artisan app:install === Fin de l'installation === On écrit le site apache2, on force https : ServerName status.federez.net # Or whatever you want to use ServerAlias federez-wifi.federez.net cachet.federez.net # Make this the same as ServerName DocumentRoot "/var/www/Cachet/public" Require all granted # Used by Apache 2.4 Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all LogLevel warn ErrorLog ${APACHE_LOG_DIR}/cachet-error.log CustomLog ${APACHE_LOG_DIR}/cachet-access.log combined SSLCertificateFile /etc/letsencrypt/live/federez.net/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/federez.net/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf === Configuration === On se connecte sur le site ( status.federez.net) et on configure au clicodrome le compte admin, et le nom du site ==== Utilisation ==== On met à jour les services soit via l'interface, soit via l'api. Plus de doc ici : [[https://docs.cachethq.io/reference]] Exemple d'utilisation en python pour crée un nouveau service : import requests BASE_URL = "https://status.federez.net/api/v1/components" HEADERS = {"Content-Type": "application/json;", "X-Cachet-Token": SECRET_KEY} url = BASE_URL payload = "{\"name\":\"%s\",\"status\":1,\"description\":\"%s\",\"group_id\":\"%s\"}" % (asso.upper(), asso.upper() + ' ' + ', '.join(ASSOS_NAS_ID[asso]['pool']), group_id) requests.request("POST", url, data=payload, headers=HEADERS) L'équivalent en shell : curl --request POST \ --url https://demo.cachethq.io/api/v1/components \ --data '{"name":"Plop","status":1}' Le script de monitoring federez-wifi post via python. La secret-key se récupère sur l'interface admin en web.