Browse Source

Add update date to frontend, add some instructions to README, undo TTY allocation

tags/v1.3
Moritz Marquardt 8 months ago
parent
commit
62ecfda2c3
4 changed files with 31 additions and 8 deletions
  1. +17
    -2
      README.md
  2. +1
    -1
      types/config.go
  3. +6
    -5
      web/index.html
  4. +7
    -0
      web/script.js

+ 17
- 2
README.md View File

@@ -1,10 +1,13 @@
# chihuahua
**The smallest watchdog on earth.** Tiny, [monitoring-plugins](https://www.monitoring-plugins.org/) compatible monitoring with a status page, built with [Go](https://golang.org), [Air](https://github.com/aofei/air), [Vue.js](https://vuejs.org/) and [Bulma](https://bulma.io/).

- Run nagios checks on a remote server
- Alert on state change via [Gotify](https://gotify.net) or email

![Screenshot](https://i.vgy.me/WKL8Dl.png)

## Getting Started
```
```bash
mkdir -p ./data/.ssh
ssh-keygen -b 2048 -f ./data/.ssh/id_rsa -P "" -C "Chihuahua Monitoring"
nano ./data/chihuahua.yml
@@ -33,6 +36,18 @@ servers:
disk-space: check_disk -w 15% -c 5% # monitoring-plugins compatible check command
```

## Example debian server setup
```bash
apt install monitoring-plugins
useradd -M -d /var/chihuahua -r chihuahua
mkdir -p /var/chihuahua/.ssh
echo '<ssh key from server setup>' > /var/chihuahua/.ssh/authorized_keys
echo 'PATH="/var/chihuahua/:/usr/lib/nagios/plugins/:$PATH"' > /var/chihuahua/.ssh/environment
echo 'PermitUserEnvironment yes' >> /etc/ssh/sshd_config
systemctl reload ssh
chown -R chihuahua /var/chihuahua
```

## API
```
GET /checks
@@ -42,7 +57,7 @@ GET /checks/:server/:check

## Development
Requires [Go](https://golang.org)
```
```bash
go get codeberg.org/momar/chihuahua/...
cd $GOPATH/src/codeberg.org/momar/chihuahua
cp chihuahua.example.yml chihuahua.yml && nano chihuahua.yml

+ 1
- 1
types/config.go View File

@@ -20,7 +20,7 @@ func (c *Config) GetServers() map[string]*Server {
Shell: []string{},
}
if server.SSH != "" {
result[serverName].Shell = append([]string{"ssh", "-t"}, strings.Split(server.SSH, " ")...)
result[serverName].Shell = append([]string{"ssh"}, strings.Split(server.SSH, " ")...)
}
for checkName, check := range server.Checks {
result[serverName].Checks[checkName] = &Check{

+ 6
- 5
web/index.html View File

@@ -27,11 +27,12 @@
<img class="icon" :src="iconByStatus(check.status)"></i>
{{ checkName }}
</p>
<div class="panel-block" style="padding: 0" v-if="check.details">
<pre style="white-space: pre-wrap; flex-grow: 1"><code><small>{{ check.details.trim() }}</small></code></pre>
</div>
<div class="panel-block" style="padding: 0" v-if="check.error">
<pre style="white-space: pre-wrap; flex-grow: 1"><code><small class="has-text-danger">{{ check.error.trim() }}</small></code></pre>
<div class="panel-block" style="padding: 0">
<pre style="white-space: pre-wrap; flex-grow: 1"><code
><div v-if="check.details && check.details.trim()"><small>{{ check.details.trim() }}</small></div
><div v-if="check.details && check.error.trim()"><small class="has-text-danger">{{ check.error.trim() }}</small></div
><small class="is-size-7 has-text-grey-light">{{ dateFormat(check["last-update"]) }}</small
></code></pre>
</div>
</article>
</div>

+ 7
- 0
web/script.js View File

@@ -1,3 +1,6 @@
// Leftpad - P(value, length, character, rightpad) - https://gist.github.com/moqmar/9ef4f0755d0a17b61458f35b91447bc1
function P(v,l,c,r) { v = v.toString(); while (v.length < l) v = r ? v + (c||0) : (c||0) + v; return v; }

window.app = new Vue({
el: "#app",
data: {
@@ -20,6 +23,10 @@ window.app = new Vue({
default: return "icons/question-mark-outline.svg";
}
},
dateFormat(dateString) {
let date = new Date(dateString);
return date.getFullYear() + "-" + P(date.getMonth() + 1, 2) + "-" + P(date.getDate(), 2) + " " + P(date.getHours(), 2) + ":" + P(date.getMinutes(), 2) + ":" + P(date.getSeconds(), 2);
}
},
});


Loading…
Cancel
Save