Missing Semester - Lecture 4

# journalctl run remotely, grep run locally ssh myserver journalctl | grep sshd # both commands run remotely ssh myserver "journalctl | grep sshd" sed sed (Stream Editor) is a powerful command-line tool in Unix/Linux that is used for parsing and transforming text, typically used for finding, replacing, or deleting content in a file or input stream. Common sed Commands: Substitution (s): sed 's/pattern/replacement/' file s: The substitution command. pattern: The string or pattern to search for. replacement: The string to replace the pattern with. Example: ...

October 15, 2024 · 7 min · KKKZOZ

Missing Semester - Lecture 2

Shell Tools and Scripting Shell Scripting To assign variables in bash, use the syntax foo=bar and access the value of the variable with $foo. Note that foo = bar will not work since it is interpreted as calling the foo program with arguments = and bar. bash uses a variety of special variables to refer to arguments, error codes, and other relevant variables: $0 - Name of the script $1 to $9 - Arguments to the script. $1 is the first argument and so on. $@ - All the arguments $# - Number of arguments $? - Return code of the previous command $$ - Process identification number (PID) for the current script !! - Entire last command, including arguments. A common pattern is to execute a command only for it to fail due to missing permissions; you can quickly re-execute the command with sudo by doing sudo !! $_ - Last argument from the last command. If you are in an interactive shell, you can also quickly get this value by typing Esc followed by . or Alt+. Exit codes can be used to conditionally execute commands using && (and operator) and || (or operator). ...

October 11, 2024 · 5 min · KKKZOZ

Missing Semester - Lecture 1

The shell How does the shell know how to find the date or echo programs? The shell is a programming environment, just like Python, and so it has variables, conditionals, loops, and functions. If the shell is asked to execute a command that doesn’t match one of its programming keywords, it consults an environment variable called $PATH that lists which directories the shell should search for programs when it is given a command ...

October 9, 2024 · 2 min · KKKZOZ

Watchdogs in OpenFaaS

Classic Watchdog OpenFaaS 的 Classic Watchdog 是一个用于处理无服务器(Serverless)函数请求的核心组件。它是 OpenFaaS 的默认函数执行器,用于在容器内运行用户定义的函数代码,并通过 HTTP 请求与外部进行通信。 工作原理 Classic Watchdog 主要负责以下任务: 启动函数: 当容器启动时,Classic Watchdog 会启动并监听 HTTP 端口。 它会执行用户提供的函数代码,通过 exec 启动一个新的进程运行函数。 处理请求: Classic Watchdog 监听指定端口上的 HTTP 请求。 当收到请求时,它会将请求的内容传递给函数进程,并等待函数的响应。 返回响应: 函数进程处理请求后,将结果返回给 Classic Watchdog。 Classic Watchdog 将函数的响应封装成 HTTP 响应,并返回给调用方。 A tiny web-server or shim that forks your desired process for every incoming HTTP request Every function needs to embed this binary and use it as its ENTRYPOINT or CMD, in effect it is the init process for your container. Once your process is forked the watchdog passses in the HTTP request via stdin and reads a HTTP response via stdout. This means your process does not need to know anything about the web or HTTP. ...

August 25, 2024 · 7 min · KKKZOZ

A Piece Of: Logs

Log Levels Log levels for software applications have a rich history dating back to the 1980s. One of the earliest and most influential logging solutions for Unix systems, Syslog, introduced a range of severity levels, which provided the first standardized framework for categorizing log entries based on their impact or urgency. The following are the levels defined by Syslog in descending order of severity: Emergency (emerg): indicates that the system is unusable and requires immediate attention. Alert (alert): indicates that immediate action is necessary to resolve a critical issue. Critical (crit): signifies critical conditions in the program that demand intervention to prevent system failure. Error (error): indicates error conditions that impair some operation but are less severe than critical situations. Warning (warn): signifies potential issues that may lead to errors or unexpected behavior in the future if not addressed. Notice (notice): applies to normal but significant conditions that may require monitoring. Informational (info): includes messages that provide a record of the normal operation of the system. Debug (debug): intended for logging detailed information about the system for debugging purposes. The specific log levels available to you may defer depending on the programming language, logging framework, or service in use. However, in most cases, you can expect to encounter levels such as FATAL, ERROR, WARN, INFO, DEBUG, and TRACE. ...

May 13, 2024 · 5 min · KKKZOZ