Code by Scott שאול בן ישוע
README.md 2.03 KB
Newer Older
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
1
2
3
4
# Monitor & Information Rest API for Raspberry PI

This is a very lean little project based on SpringBoot 2.0M7 and [Pi4J](http://pi4j.com).

Scott Grayban's avatar
edits    
Scott Grayban committed
5
6
# Projects using this java app

Scott Grayban's avatar
edits    
Scott Grayban committed
7
* Hubitat [Raspberry-Pi-Stats](https://github.com/sgrayban/Hubitat-Ports/tree/master/Drivers/rpi)
Scott Grayban's avatar
edits    
Scott Grayban committed
8

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
9
10
# Pre-requisites

Scott Grayban's avatar
edits    
Scott Grayban committed
11
12
* [JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) - apt install oracle-java8-jdk
* [Maven 3x](https://maven.apache.org/download.cgi) - apt install maven
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
13

Scott Grayban's avatar
edits    
Scott Grayban committed
14
15
16
17
18
# Download
Make sure you are in /root directory first then....

```git clone https://github.com/sgrayban/raspberrypi.monitor.git```

Scott Grayban's avatar
edits    
Scott Grayban committed
19
# Build as root
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
20
21
22
23

Simply

```bash
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
24
25
cd /root/raspberrypi.monitor

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
26
27
28
mvn clean install
```

29
# Install raspberrypi_monitor.service as a Systemd script to start at boot
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
30

Sha'ul ben Yeshua's avatar
edits    
Sha'ul ben Yeshua committed
31
32
```bash
cp raspberrypi_monitor.service /etc/systemd/system/raspberrypi_monitor.service
33
34
35
systemctl daemon-reload
systemctl enable raspberrypi_monitor.service
systemctl start raspberrypi_monitor.service
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
36
37
```

38
Then to make sure the app is running
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
39

Sha'ul ben Yeshua's avatar
edits    
Sha'ul ben Yeshua committed
40
41
42
```bash
systemctl status raspberrypi_monitor.service
```
Scott Grayban's avatar
edits    
Scott Grayban committed
43
44
45
46
47
48
49
50
51
52
53
Should yeld something like this

```bash
# systemctl status raspberrypi_monitor.service
● raspberrypi_monitor.service - Manage raspberrypi monitor service
   Loaded: loaded (/etc/systemd/system/raspberrypi_monitor.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-04-11 16:53:01 PDT; 2min 22s ago
 Main PID: 316 (java)
   CGroup: /system.slice/raspberrypi_monitor.service
           └─316 /usr/bin/java -jar /root/janipi/target/raspberrypi.janipi-0.0.1-SNAPSHOT.jar
```
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
54
55
56
57

# Usage

```
Scott Grayban's avatar
edits    
Scott Grayban committed
58
http://Rpi-IP:8080/api/pi
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
```

Would yield something like this:

```json
{
"cpuTemperature": 52.1,
"serialNumber": "0000000000000000",
"cpuCoreVoltage": 1.2,
"modelName": "ARMv7 Processor rev 4 (v7l)",
"boardType": "RaspberryPi_3B",
"totalMemory": 967700480,
"usedMemory": 221253632,
"freeMemory": 401907712,
"sharedMemory": 14475264,
"javaVersion": "1.8.0_152",
"hostname": "raspberrypi",
"ipAddresses": [
"192.168.1.40",
"172.17.0.1"
],
"cpuFrequency": 600000000
}
```
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
83