added Radicle 0149524a
Steve · 2024-08-27 21:36 4 file(s) · +256 −170
index.html +47 −28
17 17
    />
18 18
    <meta property="og:url" content="https://pi.stevedylan.dev" />
19 19
    <meta property="og:site_name" content="Steve's Pi" />
20 -
    <meta
21 -
      property="og:image"
22 -
      content="https://stevedylan.dev/pi.png"
23 -
    />
20 +
    <meta property="og:image" content="https://stevedylan.dev/pi.png" />
24 21
    <meta property="og:image:width" content="1200" />
25 22
    <meta property="og:image:height" content="630" />
26 23
75 72
             align-items: center;
76 73
             gap: 1rem;
77 74
         }
75 +
         .truncate {
76 +
             display: inline-block;
77 +
             max-width: calc(100% - 30px); /* Adjust based on the width of "ID: " */
78 +
             white-space: nowrap;
79 +
             overflow: hidden;
80 +
             text-overflow: ellipsis;
81 +
             vertical-align: bottom;
82 +
         }
78 83
         p {
79 84
         	padding: 0;
80 85
          	margin: 0;
81 86
         }
82 87
         a {
83 88
             color:#C1C1C1;
89 +
         }
90 +
         img {
91 +
             height: 24px;
92 +
             width: 24px;
93 +
         }
94 +
         @media (max-width: 480px) {
95 +
             .truncate {
96 +
                 max-width: 300px;
97 +
             }
84 98
         }
85 99
    </style>
86 100
  </head>
94 108
        <a href="https://radicle.xyz" target="_blank">Radicle</a>.
95 109
      </p>
96 110
      <div class="ipfs-div">
97 -
        <svg
98 -
          xmlns="http://www.w3.org/2000/svg"
99 -
          width="24"
100 -
          height="24"
101 -
          viewBox="0 0 32 32"
102 -
        >
103 -
          <path
104 -
            fill="#888888"
105 -
            d="m28.504 8.136l-12-7a1 1 0 0 0-1.008 0l-12 7A1 1 0 0 0 3 9v14a1 1 0 0 0 .496.864l12 7a1 1 0 0 0 1.008 0l12-7A1 1 0 0 0 29 23V9a1 1 0 0 0-.496-.864M16 3.158L26.016 9L16 14.842L5.984 9ZM5 10.74l10 5.833V28.26L5 22.426Zm12 17.52V16.574l10-5.833v11.685Z"
106 -
          />
107 -
        </svg>
111 +
        <img src="https://dweb.mypinata.cloud/ipfs/QmbvEEN8zY657JC6wC2piMygmHcEKhwT5gkNWUs2qcnwKb" alt="ipfs-cube">
108 112
        <h3>IPFS Node</h3>
109 113
      </div>
110 114
      <p>RepoSize: <span id="repoSize">-</span></p>
116 120
      <p>Total Data Out: <span id="totalOut">-</span></p>
117 121
      <div class="system-info">
118 122
        <div class="ipfs-div">
119 -
          <svg
120 -
            xmlns="http://www.w3.org/2000/svg"
121 -
            width="24"
122 -
            height="24"
123 -
            viewBox="0 0 32 32"
124 -
          >
125 -
            <path
126 -
              fill="#888888"
127 -
              d="M21.479 23.12c-1.14 1.317-1.776 3.719-.943 4.495c.792.593 2.933.521 4.511-1.641c1.151-1.443.76-3.859.109-4.5c-.973-.739-2.369.22-3.677 1.663zm-10.739.396c-1.213-1.385-2.787-2.209-3.803-1.599c-.683.509-.807 2.249.161 3.957c1.437 2.032 3.464 2.24 4.297 1.745c.88-.651.401-2.855-.656-4.104zm5.473 4.192c-1.473-.031-3.735.589-3.703 1.38c-.027.537 1.776 2.095 3.609 2.016c1.765.041 3.593-1.52 3.573-2.197c-.005-.699-1.996-1.235-3.475-1.177zM16.115 9.12c-1.703-.041-3.339 1.244-3.339 1.989c-.005.907 1.344 1.833 3.349 1.86c2.057.009 3.353-.745 3.375-1.683c.021-1.057-1.86-2.183-3.36-2.167zm-4.099.708c-2.844-.459-5.213 1.199-5.12 4.255c.093 1.177 6.172-4.052 5.125-4.233zm13 4.333c.093-3.036-2.276-4.692-5.125-4.235c-1.047.183 5.031 5.417 5.125 4.235m.484 1.099c-1.651-.437-.557 6.735.787 6.156c1.479-1.161 1.953-4.599-.787-6.135zM5.636 21.495c1.343.599 2.437-6.573.785-6.135c-2.733 1.541-2.265 4.973-.785 6.156zm12.557-7.932c-1.532 1-1.808 3.24-.615 4.995c1.187 1.76 3.391 2.416 4.916 1.437c1.532-.973 1.808-3.213.62-4.995c-1.193-1.776-3.396-2.416-4.921-1.416zm-4.13.182c-1.527-.98-3.735-.339-4.917 1.416c-1.192 1.781-.916 4.016.615 5.016c1.527 1 3.729.359 4.923-1.417c1.177-1.76.896-4-.62-4.995zm5.822 9.547c-.011-1.855-1.667-3.355-3.703-3.333c-2.037.02-3.683 1.515-3.672 3.375v.036c.011 1.86 1.672 3.36 3.708 3.339c2.036 0 3.677-1.515 3.656-3.353v-.043zm4.282-20.177c-3.079 1.579-4.869 2.839-5.855 3.916c.505 2 3.125 2.079 4.089 2.016c-.199-.077-.365-.197-.423-.353c.24-.163 1.095-.021 1.693-.344c-.229-.037-.339-.079-.443-.261c.563-.176 1.167-.317 1.52-.619c-.187 0-.369.041-.619-.12c.5-.256 1.036-.48 1.457-.876c-.26 0-.541 0-.619-.099a5.2 5.2 0 0 0 1.167-.943c-.36.063-.516.027-.605-.036c.349-.344.792-.641 1-1.084c-.271.104-.52.12-.697 0c.125-.255.631-.416.921-1.036c-.285.041-.588.063-.651 0c.136-.521.36-.817.584-1.14c-.609 0-1.537 0-1.491-.037l.376-.38c-.595-.161-1.204.021-1.647.161c-.197-.14 0-.344.245-.541c-.521.083-.975.183-1.375.344c-.219-.204.135-.38.317-.584c-.797.161-1.12.36-1.459.557c-.24-.219-.02-.416.141-.593c-.6.219-.901.495-1.219.755c-.12-.14-.281-.239-.084-.599q-.622.361-.979.839c-.256-.177-.156-.401-.156-.599c-.443.359-.72.719-1.057 1.083c-.084-.041-.141-.203-.183-.463c-1.037 1-2.521 3.5-.38 4.473c1.796-1.459 3.973-2.536 6.375-3.339zm-16.344 0c2.396.803 4.557 1.88 6.371 3.359c2.124-1 .656-3.5-.381-4.473c-.052.255-.109.437-.176.479c-.339-.359-.615-.724-1.052-1.083c0 .203.104.443-.157.599a3.1 3.1 0 0 0-.963-.839c.197.344.031.443-.079.599c-.317-.296-.62-.577-1.197-.796c.161.197.4.401.161.62c-.319-.199-.661-.401-1.437-.563c.176.197.536.4.317.604a5.6 5.6 0 0 0-1.38-.349c.239.203.453.385.255.541c-.459-.161-1.073-.339-1.672-.176l.375.375c.043.052-.875.041-1.495.047c.224.303.453.599.584 1.14c-.063.057-.36.021-.645 0c.301.6.796.761.916 1.021c-.177.125-.417.099-.697 0c.219.417.661.719 1 1.079c-.1.057-.24.099-.62.052c.317.344.697.656 1.161.937c-.084.093-.365.088-.641.099c.417.407.959.62 1.459.885c-.26.183-.443.141-.62.141c.339.296.959.437 1.521.615c-.125.181-.219.224-.464.26c.599.339 1.437.183 1.683.359c-.063.161-.219.281-.421.365c.957.057 3.599-.021 4.099-2.021c-.985-1.077-2.781-2.339-5.86-3.896zM10.136.136c.312-.005.577.181.869.271c.703-.229.864.083 1.208.213c.771-.161 1.005.187 1.375.557l.428-.016c1.161.677 1.739 2.052 1.943 2.756c.203-.704.781-2.079 1.943-2.756l.427.011c.369-.375.604-.719 1.375-.557c.349-.141.505-.437 1.215-.219c.443-.141.828-.5 1.411-.063c.489-.197.969-.26 1.391.12c.661-.079.869.083 1.031.281c.147 0 1.079-.141 1.511.479c1.084-.12 1.423.62 1.032 1.317c.224.339.453.663-.063 1.303c.197.36.077.735-.365 1.213c.125.5-.099.844-.495 1.12c.079.683-.64 1.084-.839 1.219c-.083.401-.244.781-1.061.979c-.12.6-.62.699-1.1.819c1.584.9 2.917 2.077 2.917 4.973l.244.401c1.797 1.079 3.417 4.536.896 7.355c-.156.875-.437 1.495-.681 2.192c-.36 2.817-2.776 4.136-3.412 4.297c-.921.697-1.917 1.359-3.255 1.817c-1.261 1.281-2.636 1.781-3.996 1.781h-.119c-1.38 0-2.756-.5-4.016-1.781c-1.344-.459-2.344-1.115-3.265-1.817c-.641-.156-3.043-1.475-3.417-4.292c-.249-.697-.525-1.339-.687-2.219c-2.527-2.817-.912-6.271.885-7.355l.229-.396c0-2.895 1.337-4.077 2.916-4.973c-.479-.12-.959-.219-1.093-.823c-.823-.199-.985-.579-1.063-.98c-.199-.135-.917-.536-.839-1.233c-.401-.281-.62-.62-.5-1.141c-.417-.459-.536-.859-.36-1.219c-.52-.64-.281-.979-.061-1.297c-.381-.703-.037-1.457 1.041-1.337c.416-.62 1.359-.48 1.495-.48c.161-.203.38-.38 1.041-.301c.417-.381.901-.319 1.396-.136c.203-.161.38-.219.541-.219z"
128 -
            />
129 -
          </svg>
123 +
            <img src="https://dweb.mypinata.cloud/ipfs/QmVtXdzGAQYWYMFGCZR9XV1NFpT941F234Q4oaANTvPeqb" alt="radicle-alien">
124 +
          <h3>Radicle Node</h3>
125 +
        </div>
126 +
        <p>ID: <span class="truncate" id="radId">-</span></p>
127 +
        <p>Agent: <span id="radAgent">-</span></p>
128 +
        <p>Status: <span id="radStatus">-</span></p>
129 +
        <p>Seeding Policy: <span id="radPolicy">-</span></p>
130 +
      </div>
131 +
      <div class="system-info">
132 +
        <div class="ipfs-div">
133 +
          <img src="https://dweb.mypinata.cloud/ipfs/Qmaz5ih9noiMqNnAE5681cCPwGnomopKLUfF2LaSNmuV4P" alt="raspberry-pi-logo" />
130 134
          <h3>System Information</h3>
131 135
        </div>
132 136
        <p>OS: <span id="os">-</span></p>
139 143
        </p>
140 144
      </div>
141 145
      <div class="link-container">
142 -
      <a class="source-link" href="http://github.com/stevedylandev/pi-widget" target="_blank">Source Code</a>
143 -
      <a class="source-link" href="https://stevedylan.dev" target="_blank">Homepage</a>
146 +
        <a
147 +
          class="source-link"
148 +
          href="http://github.com/stevedylandev/pi-widget"
149 +
          target="_blank"
150 +
          >Source Code</a
151 +
        >
152 +
        <a class="source-link" href="https://stevedylan.dev" target="_blank"
153 +
          >Homepage</a
154 +
        >
144 155
      </div>
145 156
    </div>
146 157
    <script>
182 193
        console.log("Received data:", event.data);
183 194
        try {
184 195
          const data = JSON.parse(event.data);
196 +
          // IPFS
185 197
          document.getElementById("repoSize").textContent = formatBytes(
186 198
            data.RepoSize,
187 199
          );
202 214
          document.getElementById("totalOut").textContent = formatBytes(
203 215
            data.TotalOut,
204 216
          );
217 +
          // Rad Node
218 +
          document.getElementById("radId").textContent = data.id;
219 +
          document.getElementById("radAgent").textContent = data.agent;
220 +
          document.getElementById("radStatus").textContent = data.state;
221 +
          document.getElementById("radPolicy").textContent = data.config.seedingPolicy.default;
222 +
223 +
          // System
205 224
          document.getElementById("os").textContent = data.os;
206 225
          document.getElementById("kernel").textContent = data.kernel;
207 226
          document.getElementById("uptime").textContent = data.uptime;
main.go +0 −142
5 5
	_ "embed"
6 6
	"encoding/json"
7 7
	"fmt"
8 -
	"io/ioutil"
9 8
	"log"
10 9
	"net/http"
11 10
	"os"
12 11
	"os/signal"
13 12
	"syscall"
14 13
	"time"
15 -
16 -
	"github.com/shirou/gopsutil/cpu"
17 -
	"github.com/shirou/gopsutil/host"
18 -
	"github.com/shirou/gopsutil/mem"
19 14
)
20 -
21 -
type SystemStats struct {
22 -
	CPUUsage    float64 `json:"cpuUsage"`
23 -
	MemoryUsed  uint64  `json:"memoryUsed"`
24 -
	MemoryTotal uint64  `json:"memoryTotal"`
25 -
	OS          string  `json:"os"`
26 -
	Kernel      string  `json:"kernel"`
27 -
	Uptime      string  `json:"uptime"`
28 -
	CPUModel    string  `json:"cpuModel"`
29 -
}
30 -
31 -
type IPFSRepoStats struct {
32 -
	RepoSize   int64  `json:"RepoSize"`
33 -
	StorageMax int64  `json:"StorageMax"`
34 -
	NumObjects int    `json:"NumObjects"`
35 -
	RepoPath   string `json:"RepoPath"`
36 -
	Version    string `json:"Version"`
37 -
}
38 -
39 -
type BandwidthStats struct {
40 -
	RateIn   float64 `json:"RateIn"`
41 -
	RateOut  float64 `json:"RateOut"`
42 -
	TotalIn  int64   `json:"TotalIn"`
43 -
	TotalOut int64   `json:"TotalOut"`
44 -
}
45 -
46 -
type CombinedStats struct {
47 -
	IPFSRepoStats
48 -
	BandwidthStats
49 -
	SystemStats
50 -
}
51 15
52 16
func main() {
53 17
	http.HandleFunc("/", serveHTML)
119 83
		time.Sleep(1 * time.Second)
120 84
	}
121 85
}
122 -
123 -
func getStats() (CombinedStats, error) {
124 -
	repoStats, err := getIpfsRepoStat()
125 -
	if err != nil {
126 -
		return CombinedStats{}, err
127 -
	}
128 -
129 -
	bwStats, err := getBandwidthStats()
130 -
	if err != nil {
131 -
		return CombinedStats{}, err
132 -
	}
133 -
134 -
	sysStats, err := getSystemStats()
135 -
	if err != nil {
136 -
		return CombinedStats{}, err
137 -
	}
138 -
139 -
	return CombinedStats{
140 -
		IPFSRepoStats:  repoStats,
141 -
		BandwidthStats: bwStats,
142 -
		SystemStats:    sysStats,
143 -
	}, nil
144 -
}
145 -
146 -
func getIpfsRepoStat() (IPFSRepoStats, error) {
147 -
	client := &http.Client{}
148 -
	req, err := http.NewRequest("POST", "http://127.0.0.1:5001/api/v0/repo/stat", nil)
149 -
	if err != nil {
150 -
		return IPFSRepoStats{}, fmt.Errorf("error creating request: %v", err)
151 -
	}
152 -
153 -
	resp, err := client.Do(req)
154 -
	if err != nil {
155 -
		return IPFSRepoStats{}, fmt.Errorf("error fetching IPFS Repo Stats: %v", err)
156 -
	}
157 -
	defer resp.Body.Close()
158 -
159 -
	body, err := ioutil.ReadAll(resp.Body)
160 -
	if err != nil {
161 -
		return IPFSRepoStats{}, fmt.Errorf("error reading response body: %v", err)
162 -
	}
163 -
164 -
	var stats IPFSRepoStats
165 -
	err = json.Unmarshal(body, &stats)
166 -
	if err != nil {
167 -
		return IPFSRepoStats{}, fmt.Errorf("error unmarshaling JSON: %v", err)
168 -
	}
169 -
170 -
	return stats, nil
171 -
}
172 -
173 -
func getBandwidthStats() (BandwidthStats, error) {
174 -
	client := &http.Client{}
175 -
	req, err := http.NewRequest("POST", "http://127.0.0.1:5001/api/v0/stats/bw", nil)
176 -
	if err != nil {
177 -
		return BandwidthStats{}, fmt.Errorf("error creating request: %v", err)
178 -
	}
179 -
180 -
	resp, err := client.Do(req)
181 -
	if err != nil {
182 -
		return BandwidthStats{}, fmt.Errorf("error fetching Bandwidth Stats: %v", err)
183 -
	}
184 -
	defer resp.Body.Close()
185 -
186 -
	body, err := ioutil.ReadAll(resp.Body)
187 -
	if err != nil {
188 -
		return BandwidthStats{}, fmt.Errorf("error reading response body: %v", err)
189 -
	}
190 -
191 -
	var stats BandwidthStats
192 -
	err = json.Unmarshal(body, &stats)
193 -
	if err != nil {
194 -
		return BandwidthStats{}, fmt.Errorf("error unmarshaling JSON: %v", err)
195 -
	}
196 -
197 -
	return stats, nil
198 -
}
199 -
200 -
func getSystemStats() (SystemStats, error) {
201 -
	v, err := mem.VirtualMemory()
202 -
	if err != nil {
203 -
		return SystemStats{}, err
204 -
	}
205 -
206 -
	c, err := cpu.Percent(0, false)
207 -
	if err != nil {
208 -
		return SystemStats{}, err
209 -
	}
210 -
211 -
	hostInfo, err := host.Info()
212 -
	if err != nil {
213 -
		return SystemStats{}, err
214 -
	}
215 -
216 -
	uptime := time.Duration(hostInfo.Uptime) * time.Second
217 -
218 -
	return SystemStats{
219 -
		CPUUsage:    c[0],
220 -
		MemoryUsed:  v.Used,
221 -
		MemoryTotal: v.Total,
222 -
		OS:          "Debian GNU/Linux 12 (bookworm) aarch64",
223 -
		Kernel:      hostInfo.KernelVersion,
224 -
		Uptime:      FormatUptime(uptime),
225 -
		CPUModel:    "BCM2835 (4) @ 1.800GHz",
226 -
	}, nil
227 -
}
stats.go (added) +165 −0
1 +
package main
2 +
3 +
import (
4 +
	"encoding/json"
5 +
	"fmt"
6 +
	"io/ioutil"
7 +
	"net/http"
8 +
	"time"
9 +
10 +
	"github.com/shirou/gopsutil/cpu"
11 +
	"github.com/shirou/gopsutil/host"
12 +
	"github.com/shirou/gopsutil/mem"
13 +
)
14 +
15 +
func getStats() (CombinedStats, error) {
16 +
	repoStats, err := getIpfsRepoStat()
17 +
	if err != nil {
18 +
		return CombinedStats{}, err
19 +
	}
20 +
21 +
	bwStats, err := getBandwidthStats()
22 +
	if err != nil {
23 +
		return CombinedStats{}, err
24 +
	}
25 +
26 +
	radicleNodeStats, err := getRadicleStats()
27 +
	if err != nil {
28 +
		return CombinedStats{}, err
29 +
	}
30 +
31 +
	sysStats, err := getSystemStats()
32 +
	if err != nil {
33 +
		return CombinedStats{}, err
34 +
	}
35 +
36 +
	return CombinedStats{
37 +
		IPFSRepoStats:  repoStats,
38 +
		BandwidthStats: bwStats,
39 +
		SystemStats:    sysStats,
40 +
		RadNodeInfo:    radicleNodeStats,
41 +
	}, nil
42 +
}
43 +
44 +
func getIpfsRepoStat() (IPFSRepoStats, error) {
45 +
	client := &http.Client{}
46 +
	req, err := http.NewRequest("POST", "http://127.0.0.1:5001/api/v0/repo/stat", nil)
47 +
	if err != nil {
48 +
		return IPFSRepoStats{}, fmt.Errorf("error creating request: %v", err)
49 +
	}
50 +
51 +
	resp, err := client.Do(req)
52 +
	if err != nil {
53 +
		return IPFSRepoStats{}, fmt.Errorf("error fetching IPFS Repo Stats: %v", err)
54 +
	}
55 +
	defer resp.Body.Close()
56 +
57 +
	body, err := ioutil.ReadAll(resp.Body)
58 +
	if err != nil {
59 +
		return IPFSRepoStats{}, fmt.Errorf("error reading response body: %v", err)
60 +
	}
61 +
62 +
	var stats IPFSRepoStats
63 +
	err = json.Unmarshal(body, &stats)
64 +
	if err != nil {
65 +
		return IPFSRepoStats{}, fmt.Errorf("error unmarshaling JSON: %v", err)
66 +
	}
67 +
68 +
	return stats, nil
69 +
}
70 +
71 +
func getBandwidthStats() (BandwidthStats, error) {
72 +
	client := &http.Client{}
73 +
	req, err := http.NewRequest("POST", "http://127.0.0.1:5001/api/v0/stats/bw", nil)
74 +
	if err != nil {
75 +
		return BandwidthStats{}, fmt.Errorf("error creating request: %v", err)
76 +
	}
77 +
78 +
	resp, err := client.Do(req)
79 +
	if err != nil {
80 +
		return BandwidthStats{}, fmt.Errorf("error fetching Bandwidth Stats: %v", err)
81 +
	}
82 +
	defer resp.Body.Close()
83 +
84 +
	body, err := ioutil.ReadAll(resp.Body)
85 +
	if err != nil {
86 +
		return BandwidthStats{}, fmt.Errorf("error reading response body: %v", err)
87 +
	}
88 +
89 +
	var stats BandwidthStats
90 +
	err = json.Unmarshal(body, &stats)
91 +
	if err != nil {
92 +
		return BandwidthStats{}, fmt.Errorf("error unmarshaling JSON: %v", err)
93 +
	}
94 +
95 +
	return stats, nil
96 +
}
97 +
98 +
func getRadicleStats() (RadNodeInfo, error) {
99 +
	client := &http.Client{}
100 +
	req, err := http.NewRequest("GET", "http://127.0.0.1:8888/api/v1/node", nil)
101 +
	if err != nil {
102 +
		return RadNodeInfo{}, fmt.Errorf("error creating request: %v", err)
103 +
	}
104 +
105 +
	resp, err := client.Do(req)
106 +
	if err != nil {
107 +
		return RadNodeInfo{}, fmt.Errorf("error fetching Rad Node Stats: %v", err)
108 +
	}
109 +
	defer resp.Body.Close()
110 +
111 +
	body, err := ioutil.ReadAll(resp.Body)
112 +
	if err != nil {
113 +
		return RadNodeInfo{}, fmt.Errorf("error reading response body: %v", err)
114 +
	}
115 +
116 +
	var stats RadNodeInfo
117 +
	err = json.Unmarshal(body, &stats)
118 +
	if err != nil {
119 +
		return RadNodeInfo{}, fmt.Errorf("error unmarshaling JSON: %v", err)
120 +
	}
121 +
122 +
	simplifiedStats := RadNodeInfo{
123 +
		ID:    stats.ID,
124 +
		Agent: stats.Agent,
125 +
		State: stats.State,
126 +
		Config: struct {
127 +
			SeedingPolicy struct {
128 +
				Default string `json:"default"`
129 +
			} `json:"seedingPolicy"`
130 +
		}{
131 +
			SeedingPolicy: stats.Config.SeedingPolicy,
132 +
		},
133 +
	}
134 +
135 +
	return simplifiedStats, nil
136 +
}
137 +
138 +
func getSystemStats() (SystemStats, error) {
139 +
	v, err := mem.VirtualMemory()
140 +
	if err != nil {
141 +
		return SystemStats{}, err
142 +
	}
143 +
144 +
	c, err := cpu.Percent(0, false)
145 +
	if err != nil {
146 +
		return SystemStats{}, err
147 +
	}
148 +
149 +
	hostInfo, err := host.Info()
150 +
	if err != nil {
151 +
		return SystemStats{}, err
152 +
	}
153 +
154 +
	uptime := time.Duration(hostInfo.Uptime) * time.Second
155 +
156 +
	return SystemStats{
157 +
		CPUUsage:    c[0],
158 +
		MemoryUsed:  v.Used,
159 +
		MemoryTotal: v.Total,
160 +
		OS:          "Debian GNU/Linux 12 (bookworm) aarch64",
161 +
		Kernel:      hostInfo.KernelVersion,
162 +
		Uptime:      FormatUptime(uptime),
163 +
		CPUModel:    "BCM2835 (4) @ 1.800GHz",
164 +
	}, nil
165 +
}
types.go (added) +44 −0
1 +
package main
2 +
3 +
type RadNodeInfo struct {
4 +
	ID     string `json:"id"`
5 +
	Agent  string `json:"agent"`
6 +
	State  string `json:"state"`
7 +
	Config struct {
8 +
		SeedingPolicy struct {
9 +
			Default string `json:"default"`
10 +
		} `json:"seedingPolicy"`
11 +
	} `json:"config"`
12 +
}
13 +
14 +
type SystemStats struct {
15 +
	CPUUsage    float64 `json:"cpuUsage"`
16 +
	MemoryUsed  uint64  `json:"memoryUsed"`
17 +
	MemoryTotal uint64  `json:"memoryTotal"`
18 +
	OS          string  `json:"os"`
19 +
	Kernel      string  `json:"kernel"`
20 +
	Uptime      string  `json:"uptime"`
21 +
	CPUModel    string  `json:"cpuModel"`
22 +
}
23 +
24 +
type IPFSRepoStats struct {
25 +
	RepoSize   int64  `json:"RepoSize"`
26 +
	StorageMax int64  `json:"StorageMax"`
27 +
	NumObjects int    `json:"NumObjects"`
28 +
	RepoPath   string `json:"RepoPath"`
29 +
	Version    string `json:"Version"`
30 +
}
31 +
32 +
type BandwidthStats struct {
33 +
	RateIn   float64 `json:"RateIn"`
34 +
	RateOut  float64 `json:"RateOut"`
35 +
	TotalIn  int64   `json:"TotalIn"`
36 +
	TotalOut int64   `json:"TotalOut"`
37 +
}
38 +
39 +
type CombinedStats struct {
40 +
	IPFSRepoStats
41 +
	BandwidthStats
42 +
	SystemStats
43 +
	RadNodeInfo
44 +
}