added -Pn flag to nmap (fixes error for hosts blocking nmap)
Some checks failed
continuous-integration/drone/push Build is failing

added arm docker image
added renovate.json
improved README.md
This commit is contained in:
Samuel Philipp 2020-07-09 21:04:57 +02:00
parent 1a166bc80f
commit 789a5416ac
5 changed files with 119 additions and 18 deletions

View file

@ -1,12 +1,96 @@
kind: pipeline
name: default
type: docker
name: linux-amd64
platform:
os: linux
arch: amd64
steps:
- name: build
image: node:alpine
commands:
- npm install
- npm run build:ssr
- name: docker
image: plugins/docker
settings:
auto_tag: true
auto_tag_suffix: linux-amd64
repo: samuelph/cachet-monitor
username:
from_secret: USERNAME
password:
from_secret: PASSWORD
from_secret: PASSWORD
trigger:
branch:
- master
event:
- push
---
kind: pipeline
type: docker
name: linux-arm
platform:
os: linux
arch: arm
steps:
- name: build
image: node:alpine
commands:
- npm install
- npm run build:ssr
- name: docker
image: plugins/docker
settings:
auto_tag: true
auto_tag_suffix: linux-arm
repo: samuelph/cachet-monitor
username:
from_secret: USERNAME
password:
from_secret: PASSWORD
when:
branch:
- master
event:
- push
---
kind: pipeline
type: docker
name: manifest
platform:
os: linux
arch: arm
steps:
- name: publish
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
target: samuelph/cachet-monitor
template: samuelph/cachet-monitor:OS-ARCH
platforms:
- linux/amd64
- linux/arm
username:
from_secret: USERNAME
password:
from_secret: PASSWORD
depends_on:
- linux-amd64
- linux-arm
trigger:
branch:
- master
event:
- push

View file

@ -1,4 +1,4 @@
FROM node:13-alpine
FROM node:14.5.0-alpine
MAINTAINER mail@sp-codes.de
@ -11,4 +11,4 @@ RUN mkdir -p /monitor/data \
&& npm install \
&& apk del git
CMD ["node", "index.js"]
CMD ["node", "index.js"]

View file

@ -95,9 +95,11 @@ services:
```bash
npm run start
```
__Important: If you want `UDP` checks, you need to run it as `root`, because `nmap` allows `UDP` scans only for `root`.__
## License
[![GNU GPLv3 Image](https://www.gnu.org/graphics/gplv3-127x51.png)](https://www.gnu.org/licenses/gpl-3.0)
cachet-monitor is Free Software: It is licensed under GNU GPL v3 (See [LICENSE](LICENSE) for more information).
cachet-monitor is Free Software: It is licensed under GNU GPL v3 (See [LICENSE](LICENSE) for more information).

View file

@ -57,26 +57,32 @@ const checkHttp = async (url, performanceTimeout, requestTimeout) => {
const checkPort = async (host, port, type, performanceTimeout, requestTimeout) => {
return await new Promise(resolve => {
nmap.scan({
flags: ['-Pn'],
range: [host],
ports: port.toString(),
timeout: requestTimeout,
udp: type === 'udp'
}, (error, report) => {
if (error) {
resolve({status: "OFFLINE", message: error});
} else {
const result = report[host].host[0];
const time = parseInt(result.item.endtime) - parseInt(result.item.starttime);
const status = result.ports[0].port[0].state[0].item;
if (status.state.includes('open')) {
if (time > performanceTimeout * 1000) {
resolve({status: "SLOW", message: status.state});
} else {
resolve({status: "ONLINE", message: status.state});
}
try {
if (error) {
resolve({status: "OFFLINE", message: error});
} else {
resolve({status: "OFFLINE", message: status.state});
const result = report[host].host[0];
const time = parseInt(result.item.endtime) - parseInt(result.item.starttime);
const status = result.ports[0].port[0].state[0].item;
if (status.state.includes('open')) {
if (time > performanceTimeout * 1000) {
resolve({status: "SLOW", message: status.state});
} else {
resolve({status: "ONLINE", message: status.state});
}
} else {
resolve({status: "OFFLINE", message: status.state});
}
}
} catch (e) {
console.error(e);
resolve({status: "OFFLINE", message: 'an unexpected error occurred'});
}
});
});

9
renovate.json Normal file
View file

@ -0,0 +1,9 @@
{
"assignees": [
"samuel-p"
],
"baseBranches": [
"master"
],
"rangeStrategy": "bump"
}