- Create a file on the system in the same directory as you login is just fine, called mock-audit.c with contents from the mock-audit.c in this snippet.
- Compile it with:
gcc -o mock-audit mock-audit.c
- Run the program from the same directory with
./mock-audit
- If the system seems to be getting cripped, double the default 100000000, then double again if necessary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <signal.h> | |
#include <stdarg.h> | |
#include <time.h> | |
#include <unistd.h> | |
#include <sys/mman.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run me with python3 <thisfile.py> | |
import socket, ssl | |
import logging | |
import threading | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
ch = logging.StreamHandler() | |
ch.setLevel(logging.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import random | |
import socket | |
import time | |
HOST, PORT = "localhost", 9999 | |
def sendall(sock, msg): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton: | |
_instance = None # class attribute | |
def __new__(cls, *args, **kwargs): | |
if Singleton._instance is None: | |
Singleton._instance = object.__new__(cls) | |
return Singleton._instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Logger: | |
def print_log(self, message): | |
print(f'[Logger]: {message}') | |
class NetworkLogger: | |
def print_log(self, message): | |
print(f'[NetworkLogger]: {message}') | |
class Person: | |
def __init__(self, name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Iter: | |
def __init__(self, data): | |
self.data = data | |
self.index = 0 | |
def __next__(self): | |
if self.index >= len(self.data): | |
raise StopIteration | |
value = self.data[self.index] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import shlex | |
import subprocess | |
class ExceptionA(Exception): | |
pass | |
class ExceptionB(Exception): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Convert a time string into seconds; format is | |
* a sequence of: | |
* time[qualifier] | |
* | |
* Valid time qualifiers are: | |
* <none> seconds | |
* s|S seconds | |
* m|M minutes | |
* h|H hours |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate prometheus-compatible output, which could be used with node_exporter | |
# file collector. This script needs to be run periodically, perhaps via cron. | |
# | |
# format_memory_usage_metrics: Takes value of memory.usage_in_bytes | |
# file in the relevant cgroup and re-formats it to prometheus text format. | |
# | |
function format_memory_usage_metrics { |