Skip to content

Instantly share code, notes, and snippets.

View flaf's full-sized avatar

François Lafont flaf

View GitHub Profile
@flaf
flaf / prometheus-range-query-add-values.md
Created November 2, 2023 18:36
Why values are added with a range query?

I have a dummy Prometheus exporter which handles the metric test_metric_integer_i with this very basic behavior:

# 1. Before 18:04 the value is always 42. Here the output of /metrics:
test_metric_integer_i{host="telegraf-container"} 42 <a-timestamp-before-18:04>

# 2. Between 18:04 and 18:08, no value at all. The output of /metrics is completely empty.

# 3. After 18:08, the value is always 1000. Here is the output of /metrics:
test_metric_integer_i{host="telegraf-container"} 1000 <a-timestamp-after-18:08>
@flaf
flaf / nc-oc-filecache.md
Created February 5, 2023 12:20
PostgreSQL and slow requests
dbnccl03=> \d+ oc_filecache
                                                               Table "nccl03.oc_filecache"
      Column      |          Type           | Collation | Nullable |                   Default                    | Storage  | Stats target | Description 
------------------+-------------------------+-----------+----------+----------------------------------------------+----------+--------------+-------------
 fileid           | bigint                  |           | not null | nextval('oc_filecache_fileid_seq'::regclass) | plain    |              | 
 storage          | bigint                  |           | not null | 0                                            | plain    |              | 
 path             | character varying(4000) |           |          | NULL::character varying                      | extended |              | 
 path_hash        | character varying(32)   |           | not null | ''::character varying                        | extended |              | 
 parent           |

Below, why

  • the pattern \dt sql_features doesn't print the table sql_features (in the schema information_schema),
  • but the pattern \dt pg_cast prints the table pg_cast (in the schema pg_catalog)?
dbnccl03=# \conninfo 
You are connected to database "dbnccl03" as user "pginc" via socket in "/tmp" at port "4900".

# There a table sql_features in the schema information_schema.
@flaf
flaf / ubuntu-22-04-lock-session.md
Last active August 21, 2022 15:05
Ubuntu 22.04 automatic lock session close my session

I have filed a bug here.

$ sudo journalctl -eb | cat
Aug 21 12:10:32 flhpz4 systemd[18255]: org.gnome.Shell@wayland.service: Failed with result 'core-dump'.
Aug 21 12:10:32 flhpz4 systemd[18255]: org.gnome.Shell@wayland.service: Triggering OnFailure= dependencies.
Aug 21 12:10:32 flhpz4 systemd[18255]: org.gnome.Shell@wayland.service: Consumed 7.570s CPU time.
Aug 21 12:10:32 flhpz4 systemd[18255]: Stopped target GNOME Wayland Session (session: ubuntu).
Aug 21 12:10:32 flhpz4 systemd[18255]: Stopped target Current graphical user session.
Aug 21 12:10:32 flhpz4 systemd[18255]: Stopped Path trigger for Apport crash notifications.
@flaf
flaf / postgres-perm-function.md
Created July 7, 2022 14:07
[PosgreSQL] Problem of permissions on function

My problem: impossible to execute the function pg_ls_dir() from the schema pg_catalog with the user racpg:

[pginc@pp-snp-pg11 ~]$ psql --host 10.242.20.5 --port 4900 --user racpg dbnccl01
psql (12.3)
Type "help" for help.

dbnccl01=> SELECT pg_catalog.pg_ls_dir('/tmp/');
ERROR:  permission denied for function pg_ls_dir
dbnccl01=> 
@flaf
flaf / drf-basic.md
Created February 13, 2022 02:45
Django REST, basic questions

Warning, I'm a Django beginner. I'm using Django 4.0.2 and DRF 3.13.1. My project (very basic) uses the default SQLite DB and I have 2 questions. Here is my code:

### My models.py ###

from django.db import models


class Template(models.Model):
    name = models.CharField(max_length=300, unique=True)
@flaf
flaf / keep-null-value.md
Last active November 26, 2021 12:40
[ansible] How to keep null value?

My playbook:

---
- hosts: "localhost"
  connection: "local"
  gather_facts: false
  vars:
    x: null
    y:
@flaf
flaf / cloud-init-network-config.md
Last active October 28, 2021 22:20
cloud-init: bad support of "networking config version 2"

TL;DR

  1. It seems that the device ID (id0 in my example) is always used in the rendered configuration, but a udev rule is added to rename this interface to the device ID. The only way where the device ID is not used for me it's when I use set-name: <ifname> to force another name for the interface.
  2. A match: rule with the name property doesn't work for me, in any case, with a fixed name or with globbing in name. The doc says that globbing in name can work only with networkd renderer (ie --output-kind networkd), but for me name has never worked in any case (the device ID is used and no udev rule is present).

Here is my environment:

@flaf
flaf / custom-syslog-forwarding-in-journald.md
Last active October 12, 2021 17:09
custom syslog forwarding in journald?

Here is a typicall event/message from journald (via journalctl -f -o json | jq for readability):

{
  "_AUDIT_LOGINUID": "0",
  "SYSLOG_IDENTIFIER": "conmon",
  "__REALTIME_TIMESTAMP": "1634057819962204",
  "_GID": "0",
  "_CAP_EFFECTIVE": "1ffffffffff",
  "_SYSTEMD_SLICE": "machine.slice",
@flaf
flaf / subiquity.md
Last active October 8, 2021 16:48
subiquity: "storage" key in user-data not well taken into account

Auto-installation of Ubuntu Focal Fossa via ubuntu-20.04.3-live-server-amd64.iso. Here is my user-data file:

#cloud-config
autoinstall:
  version: 1
  locale: en_US.UTF-8
  keyboard:
    layout: fr
    variant: ""