Skip to content

Commit 9d4ff09

Browse files
committed
Added usage information as systemd service
1 parent 14ae442 commit 9d4ff09

File tree

2 files changed

+91
-42
lines changed

2 files changed

+91
-42
lines changed

README.md

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,64 @@ An intuitive remotely-accessible system performance monitoring and task manageme
33

44
## Features
55
- Simplistic implementation of asynchronous periodic AJAX calls to fetch information
6-
- Relatively low overhead from the server during stat (approx. 4MB over runtime usage)
6+
- Relatively low overhead from the server during stat (approx. 4MB over Python 3 runtime usage)
77
- Easy and flexible customization of interface by replacing the assets with your own
88
- Tweakable refresh times for dynamic information with endpoints powered by **`psutil`**
99
- Report printing and dynamic refreshing buttons available at disposal
1010
- Hybrid cross-client theming engine built with upto 21 supported theming options
11-
- Complex process management with per-task **`TERMINATE`**, **`KILL`**, **`SUSPEND`** and **`RESUME`**
12-
13-
## Usage
14-
1. Install and upgrade virtualenv if not already done by executing `pip3 install virtualenv --user`
15-
2. Clone the repository on your local drive and make it your current working directory
16-
3. Create a virtual environment by executing `virtualenv venv`
17-
4. Activate the virtual environment by executing `source venv/bin/activate`
18-
5. Install all dependencies for the project by executing `pip3 install -r requirements.txt`
19-
6. Run the project server by executing `python3 main.py`
20-
7. Take a note of the computer's IP address and make sure that it is reachable
21-
8. Visit `http://<YOUR-IP-ADDRESS>:9696/primary` from the other device (or `http://localhost:9696/primary` on the same PC)
22-
9. Take a look at the different themes available, refresh the monitor or print reports when needed.
23-
10. When done tinkering, deactivate the virtual environment by executing `deactivate`
24-
11. Give stars to the repository if it was helpful
11+
- Complex process management with per-task **`TERMINATE`**, **`KILL`**, **`SUSPEND`** and **`RESUME`** operations
12+
13+
## Using the **`sysmon`** binary
14+
- Download the latest binary from the [**releases**](https://github.com/t0xic0der/sysmon/releases) page.
15+
- Make the binary **executable** by running `sudo chmod +x WebStationSYSMON`.
16+
- **Execute** the binary with `./WebStationSYSMON -p 6969 -6`. This runs the webserver at port 6969 and is accessible via all IPv4 and IPv6 addresses.
17+
- **Tweak** the binary to run it with the options of your liking.
18+
```shell script
19+
Options:
20+
-p, --portdata TEXT Set the port value [0-65536]
21+
-6, --ipprotv6 Start the server on an IPv6 address
22+
-4, --ipprotv4 Start the server on an IPv4 address
23+
--version Show the version and exit.
24+
--help Show this message and exit.
25+
```
26+
- Open up a browser in a device reachable to your PC and visit `http://<IP-ADDRESS>:<PORT-NUMBER>/primary` to get started.
27+
- When done tinkering, **shut down** the SYSMON server by pressing `[Ctrl+C]`.
28+
- Give stars to the repository if it was helpful.
29+
30+
## Enabling **`sysmon`** as a `systemd` service
31+
- Download the latest binary from the [**releases**](https://github.com/t0xic0der/sysmon/releases) page.
32+
- Execute `sudo nano /etc/systemd/system/WebStationSYSMON.service` and add the following lines.
33+
```shell script
34+
[Unit]
35+
After=network.target
36+
37+
[Service]
38+
ExecStart=/usr/local/bin/WebStationSYSMON -p 6969 -6
39+
40+
[Install]
41+
WantedBy=default.target
42+
```
43+
The above example is a `systemd` service for the binary which would execute it on boot on port number **6969** and would be accessible to both IPv4 and IPv6 addresses.
44+
- The following options are available for **tweaking** as per your choice.
45+
```shell script
46+
Options:
47+
-p, --portdata TEXT Set the port value [0-65536]
48+
-6, --ipprotv6 Start the server on an IPv6 address
49+
-4, --ipprotv4 Start the server on an IPv4 address
50+
--version Show the version and exit.
51+
--help Show this message and exit.
52+
```
53+
- Copy the downloaded `WebStationSYSMON` file to `/usr/local/bin/` directory.
54+
- Make the binary **executable** by running `sudo chmod 744 /usr/local/bin/disk-space-check.sh`.
55+
- Make the `systemd` service file **executable** by running `sudo chmod 664 /etc/systemd/system/WebStationSYSMON.service`.
56+
- **Reload** new `systemd` service configuration files by running `sudo systemctl daemon-reload`.
57+
- **Enable** the newly created service by running `sudo systemctl enable WebStationSYSMON.service`.
58+
- To **test** the script before a reboot, execute `sudo systemctl start WebStationSYSMON.service`.
59+
- Check the service **status** by running `sudo systemctl status WebStationSYSMON.service`.
60+
- Open up a browser in a device reachable to your PC and visit `http://<IP-ADDRESS>:<PORT-NUMBER>/primary` to get started.
61+
- To **stop** the service, execute `sudo systemctl stop WebStationSYSMON.service` - It will start again on boot.
62+
- To **disable** the service, execute `sudo systemctl disable WebStationSYSMON.service` - It will need **enabling** to work.
63+
- Give stars to the repository if it was helpful.
2564

2665
## Screenshots
2766

@@ -52,6 +91,20 @@ An intuitive remotely-accessible system performance monitoring and task manageme
5291
### Sensors and Thermal Overview [Maroon]
5392
![](pictures/sensinfo.png)
5493

94+
## Using the script
95+
1. Install and upgrade virtualenv if not already done by executing `pip3 install virtualenv --user`.
96+
2. Clone the repository on your local drive and make it your current working directory.
97+
3. Create a virtual environment by executing `virtualenv venv`.
98+
4. Activate the virtual environment by executing `source venv/bin/activate`.
99+
5. Install all dependencies for the project by executing `pip3 install -r requirements.txt`.
100+
6. Run the project server by executing `python3 main.py`.
101+
7. Take a note of the computer's IP address and make sure that it is reachable.
102+
8. Visit `http://<YOUR-IP-ADDRESS>:9696/primary` from the other device (or `http://localhost:9696/primary` on the same PC).
103+
9. Take a look at the different themes available, refresh the monitor or print reports when needed.
104+
10. Select processes to open up modals - `TERMINATE`, `KILL`, `SUSPEND` and `RESUME` processes at will.
105+
11. When done tinkering, deactivate the virtual environment by executing `deactivate`.
106+
12. Give stars to the repository if it was helpful.
107+
55108
## To-do
56109
- [X] Write driver code and endpoint access code for **Processor** page
57110
- [X] Write client-side Jinja template and AJAX calls for **Processor** information
@@ -97,8 +150,8 @@ An intuitive remotely-accessible system performance monitoring and task manageme
97150
- [ ] Add functionality to switch the units for thermal data between celsius and fahrenheit
98151
- [ ] Add an obligatory dark mode feature (for everybody else has it now)
99152
- [ ] Change `onclick` highlighting color on dropdown menus (It is by-default `primary` for all accents)
100-
- [ ] Package it in a binary file with [`click`](https://click.palletsprojects.com/en/7.x/) to set command-line options
101-
- [ ] Make the binary (along with command-line options) usable as a `systemd` service
153+
- [X] Package it in a binary file with [`click`](https://click.palletsprojects.com/en/7.x/) to set command-line options
154+
- [X] Make the binary (along with command-line options) usable as a `systemd` service
102155
- [ ] Add user login feature as with complex process management, control cannot be left open
103156
- [X] `[Would not be implemented as it breaks tab-switching feature]` Replace all card tabs `anchors` with `document.location.href` attributes
104157
- [ ] Replace all `getElementById` with JQuery methods for speed up

main.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
1-
from flask import Flask, render_template, request, redirect, url_for, session, jsonify
2-
import psutil, back
1+
from flask import Flask, render_template, jsonify
2+
import back, click
33

4-
main = Flask(__name__)
5-
6-
7-
# background process hmainening without any refreshing
8-
@main.route('/background_process_test')
9-
def background_process_test():
10-
print("Hello")
11-
return "nothing"
124

13-
14-
@main.route('/_stuff', methods= ['GET'])
15-
def stuff():
16-
cpu=str(psutil.cpu_freq(True))
17-
return jsonify(cpu=cpu)
5+
main = Flask(__name__)
186

197

208
@main.route("/virtdata/", methods=["GET"])
219
def virtdata():
2210
retndata = back.GetVirtualMemoryData()
23-
retnjson = jsonify(virttomr=retndata["Total"],
24-
virtavbl=retndata["Available"],
25-
virtperc=retndata["Percent"],
26-
virtused=retndata["Used"],
27-
virtactv=retndata["Active"],
28-
virtbufr=retndata["Buffers"],
29-
virtcach=retndata["Cached"],
30-
virtshrd=retndata["Shared"],
31-
virtslab=retndata["Slab"])
3211
retnjson = jsonify(virtdata=retndata)
3312
return retnjson
3413

@@ -154,5 +133,22 @@ def custpage(thmcolor="maroon"):
154133
thmcolor=thmcolor)
155134

156135

136+
@click.command()
137+
@click.option("-p", "--portdata", "portdata", help="Set the port value [0-65536]", default="9696")
138+
@click.option("-6", "--ipprotv6", "netprotc", flag_value="ipprotv6", help="Start the server on an IPv6 address")
139+
@click.option("-4", "--ipprotv4", "netprotc", flag_value="ipprotv4", help="Start the server on an IPv4 address")
140+
@click.version_option(version="0.1.0", prog_name="WebStation SYSMON by t0xic0der")
141+
def mainfunc(portdata, netprotc):
142+
print(" * Starting WebStation SYSMON by t0xic0der...")
143+
print(" * Port number : " + str(portdata))
144+
netpdata = ""
145+
if netprotc == "ipprotv6":
146+
print(" * IP version : 6")
147+
netpdata = "::"
148+
elif netprotc == "ipprotv4":
149+
print(" * IP version : 4")
150+
netpdata = "0.0.0.0"
151+
main.run(port=portdata, host=netpdata)
152+
157153
if __name__ == "__main__":
158-
main.run(port=9696, host="0.0.0.0")
154+
mainfunc()

0 commit comments

Comments
 (0)