Added terrible setup instructions
This commit is contained in:
parent
51f8181b1f
commit
5abefbc02a
83
README.md
83
README.md
|
@ -1,4 +1,83 @@
|
||||||
# twm-sysctl
|
# twm-sysctl
|
||||||
|
Sysctl, a bot for reporting the status of the daemons running on its host and other hosts.
|
||||||
|
|
||||||
Sysctl, a bot for reporting the status of the daemons running on its host and other hosts.
|
## Setup
|
||||||
This wasn't originally going to even be uploaded here, so expect some jank. I may polish this eventually... but probably not.
|
For now, I will only provide a general setup tutorial. Someone who knows about web development should know a bit more about this.
|
||||||
|
|
||||||
|
### 1.) SCNITS - Self-Contained Node Information Transfer Server
|
||||||
|
#### What is a SCNITS
|
||||||
|
Each of my nodes have a PHP-enabled web server intended to let nodes tell other nodes information, which is not accessible from the internet. These servers run on port 9050.
|
||||||
|
|
||||||
|
#### Starting a SCNITS (or something like it)
|
||||||
|
Sysctl bots use this server. What it cares about (as of now) is the contents of `/server/`. Let's pretend you want to track three daemons - `matrix`, `nginx`, and `gitea`. In this case, `/server/index.php` would contain the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
<?php
|
||||||
|
echo "matrix\n";
|
||||||
|
echo "nginx\n";
|
||||||
|
echo "gitea";
|
||||||
|
?>
|
||||||
|
```
|
||||||
|
|
||||||
|
That would tell the bot that it needs to check `/server/matrix/`, `/server/nginx/`, and `/server/gitea/`.
|
||||||
|
|
||||||
|
Assuming you use `systemctl`, ach PHP script in these folders are pretty similar (except nginx, in my case).
|
||||||
|
|
||||||
|
Matrix:
|
||||||
|
```
|
||||||
|
<?php
|
||||||
|
$active = shell_exec("systemctl is-active synapse-matrix.service");
|
||||||
|
if ($active == "active\n") {
|
||||||
|
echo 1;
|
||||||
|
} else {
|
||||||
|
echo 0;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
```
|
||||||
|
|
||||||
|
Nginx:
|
||||||
|
```
|
||||||
|
<?php
|
||||||
|
// Theres no way you'd be reading if Nginx wasn't running.
|
||||||
|
echo 1;
|
||||||
|
?>
|
||||||
|
```
|
||||||
|
|
||||||
|
Gitea:
|
||||||
|
```
|
||||||
|
<?php
|
||||||
|
$active = shell_exec("systemctl is-active gitea.service");
|
||||||
|
if ($active == "active\n") {
|
||||||
|
echo 1;
|
||||||
|
} else {
|
||||||
|
echo 0;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
```
|
||||||
|
|
||||||
|
And so on.
|
||||||
|
|
||||||
|
### 2.) Setting up the bot itself.
|
||||||
|
#### Dependencies
|
||||||
|
First off, this bot requires some dependencies. Install them with `pip3`: matrix-nio, urllib3, and ping3.
|
||||||
|
|
||||||
|
Matrix-nio is the library I use to communicate with the Matrix server. URLLib3 lets me get webpages. Ping3 pings machines.
|
||||||
|
|
||||||
|
Also, this bot has only been tested on Python 3.7. It SHOULD work on version 3.0 and newer, but no guarantees. It is not compatible with Python 2.x.
|
||||||
|
|
||||||
|
#### Actual setup
|
||||||
|
Now we are ready to set up the bot. First, download `sysctl.py` from this repository and place it somewhere. In the same folder, create a new `sysctl.ini` file. This file is the configuration file the bot will read on startup.
|
||||||
|
|
||||||
|
Information on what to put in your `sysctl.ini` file is located in the `sysctl.ini.template` file in this repository.
|
||||||
|
|
||||||
|
Now, you can run it with `python sysctl.py`, or `python3.7 sysctl.py` in some cases.
|
||||||
|
|
||||||
|
#### Hold it! We need an account!
|
||||||
|
Yeah my bad. You must create an account for your bot. I usually do with with [Electron.io](https://electron.io/), a web client for Matrix. Create your account, and use those for the `username` and `password` fields.
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
#### Why is the password storage so insecure?
|
||||||
|
Haha... yeahhh...
|
||||||
|
|
||||||
|
#### It doesn't work!
|
||||||
|
Please leave an issue, I'd be glad to help you out!
|
Loading…
Reference in a new issue