Skip to content

Instantly share code, notes, and snippets.

View meanother's full-sized avatar
🦖

Semenov Artur meanother

🦖
View GitHub Profile
@meanother
meanother / execute_statistics.py
Created August 26, 2024 15:27
Сборка статистики по использованию сети
#!/root/audit_env/bin/python
import psycopg2
import psycopg2.extras
import sqlite3
import socket
import json
import pathlib
import urllib.request
@meanother
meanother / index.js
Created July 26, 2024 07:22
New index.js with fix create new users
const wgService = require("./wgService");
const express = require("express");
const bodyParser = require("body-parser");
const cors = require('cors');
const config = require("./config");
const asyncHandler = require('express-async-handler');
const fs = require('fs');
const path = require("path");
const archiver = require('archiver');
@meanother
meanother / export_wg.py
Created July 24, 2024 20:58
Сбор данных по пользователям wg0
#!/usr/bin/python3
import json
import csv
from pathlib import Path
red_line, end_line = "\033[91m", "\033[0m"
export_path = Path.home()
#!/root/env/bin/python
import subprocess
from prettytable import PrettyTable
services = [
"wg-quick@wg0",
"wg-bot",
"wg-slave",
select
id
, title
, create_dt
, score
, status
, comments
, action
, valid_from
, coalesce(
create trigger banki_hist_insert_trigger after insert on home.dt_banki_responses
for each row execute procedure home.banki_hist_insert();
CREATE OR REPLACE FUNCTION home.banki_hist_insert()
RETURNS trigger
LANGUAGE plpgsql AS
$function$
BEGIN
INSERT INTO home.dth_banki_responses
(id, link, ... action, valid_from)
VALUES
(NEW.id, NEW.link, ... 'I', current_timestamp);
RETURN NEW;
create table if not exists home.dth_banki_responses (
id int,
link varchar(255) not null,
...
action char(1) not null,
valid_from timestamptz not null
);
select
round(
avg(date_part('day', bank_answer_date-create_dt)::int), 1
) as "Среднее время ответа в днях"
, round(
median(date_part('day', bank_answer_date-create_dt)::int), 1
) as "Медианное время ответа в днях"
from
home.dt_banki_responses
where
select
substr(create_dt::varchar,1,7) as month
, round(avg(coalesce(score, 0)), 1) as "Среднее"
, trunc(median(coalesce(score, 0))) as "Медиана"
, count(*) as "Общее кол-во"
, sum(case when score = 1 then 1 else 0 end) as "Оценка 1"
, sum(case when score = 2 then 1 else 0 end) as "Оценка 2"
, sum(case when score = 3 then 1 else 0 end) as "Оценка 3"
, sum(case when score = 4 then 1 else 0 end) as "Оценка 4"
, sum(case when score = 5 then 1 else 0 end) as "Оценка 5"