Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Projets-INFO4
20-21
18
chirpstack-monitoring
Commits
6e1df0ed
Commit
6e1df0ed
authored
Mar 23, 2021
by
Antoine Blanquet
Browse files
Merge branch 'test_report_j-1' into reports-dev
parents
40ca53ef
39c07faa
Changes
16
Hide whitespace changes
Inline
Side-by-side
dashboard/configuration/nodered/.config.nodes.json
View file @
6e1df0ed
{
"node-red"
:
{
"name"
:
"node-red"
,
"version"
:
"1.2.
7
"
,
"version"
:
"1.2.
9
"
,
"local"
:
false
,
"nodes"
:
{
"inject"
:
{
...
...
dashboard/configuration/nodered/.config.nodes.json.backup
View file @
6e1df0ed
...
...
@@ -412,26 +412,6 @@
}
}
},
"node-red-contrib-cayenne-mqtt-client": {
"name": "node-red-contrib-cayenne-mqtt-client",
"version": "0.0.2",
"local": false,
"nodes": {
"client": {
"name": "client",
"types": [
"cayenne actuator-feedback",
"cayenne actuator",
"cayenne sensor",
"cayenne-client"
],
"enabled": true,
"local": false,
"module": "node-red-contrib-cayenne-mqtt-client",
"file": "/usr/src/node-red/node_modules/node-red-contrib-cayenne-mqtt-client/10-client.js"
}
}
},
"node-red-contrib-sms-free-mobile": {
"name": "node-red-contrib-sms-free-mobile",
"version": "0.1.0",
...
...
@@ -449,52 +429,5 @@
"file": "/usr/src/node-red/node_modules/node-red-contrib-sms-free-mobile/sms-free-mobile.js"
}
}
},
"node-red-contrib-ttn": {
"name": "node-red-contrib-ttn",
"version": "2.0.5",
"local": false,
"nodes": {
"ttn-app": {
"name": "ttn-app",
"types": [
"ttn app"
],
"enabled": true,
"local": false,
"module": "node-red-contrib-ttn",
"file": "/usr/src/node-red/node_modules/node-red-contrib-ttn/ttn-app/ttn-app.js"
},
"ttn-event": {
"name": "ttn-event",
"types": [
"ttn event"
],
"enabled": true,
"local": false,
"module": "node-red-contrib-ttn",
"file": "/usr/src/node-red/node_modules/node-red-contrib-ttn/ttn-event/ttn-event.js"
},
"ttn-uplink": {
"name": "ttn-uplink",
"types": [
"ttn uplink"
],
"enabled": true,
"local": false,
"module": "node-red-contrib-ttn",
"file": "/usr/src/node-red/node_modules/node-red-contrib-ttn/ttn-uplink/ttn-uplink.js"
},
"ttn-downlink": {
"name": "ttn-downlink",
"types": [
"ttn downlink"
],
"enabled": true,
"local": false,
"module": "node-red-contrib-ttn",
"file": "/usr/src/node-red/node_modules/node-red-contrib-ttn/ttn-downlink/ttn-downlink.js"
}
}
}
}
\ No newline at end of file
dashboard/docker-compose.yml
View file @
6e1df0ed
...
...
@@ -22,4 +22,4 @@ services:
file
:
grafana.yml
service
:
grafana
links
:
-
influxdb:influxdb
-
influxdb:influxdb
\ No newline at end of file
reports/.gitignore
View file @
6e1df0ed
node_modules/
admin.token.json
*.token.json
.*.json
.*.html
.DS_Store
...
...
reports/.mails.csv
0 → 100644
View file @
6e1df0ed
reports/ChirpstackMonitoring.token.json
View file @
6e1df0ed
{
"jwt"
:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNDc4NTg0OCwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTQ2OTk0NDgsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.EQgydowoS132k5n3cPYI0qg4eAksewkep2c1QAFG8xw"
}
\ No newline at end of file
{
"jwt"
:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNDc4NTg0OCwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTQ2OTk0NDgsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.EQgydowoS132k5n3cPYI0qg4eAksewkep2c1QAFG8xw"
}
reports/changeDateMomentjs.js
0 → 100644
View file @
6e1df0ed
const
moment
=
require
(
'
moment
'
);
var
argv
=
process
.
argv
;
// store the argument given
process
.
argv
.
shift
();
// skip path of node file
process
.
argv
.
shift
();
// skip path of js file
argv
=
process
.
argv
.
join
(
"
"
)
// parse to keep only the string
function
f
(
lastSeenAt
)
{
//console.log(lastSeenAt);
lastSeenAt
=
new
Date
(
lastSeenAt
);
return
moment
(
lastSeenAt
).
fromNow
();
}
console
.
log
(
f
(
argv
))
\ No newline at end of file
reports/get_applications.sh
View file @
6e1df0ed
...
...
@@ -8,12 +8,13 @@
# ------------------------------------------------
# Parameters
if
[[
$#
-ne
1
]]
;
then
echo
"Usage:
$0
JWT"
if
[[
$#
-ne
2
]]
;
then
echo
"Usage:
$0
JWT
OID
"
exit
1
fi
TOKEN
=
"
$1
"
OID
=
"
$2
"
AUTH
=
"Grpc-Metadata-Authorization: Bearer
$TOKEN
"
#sudo npm install -g jwt-cli
...
...
@@ -57,7 +58,7 @@ OPTIONS="${CURL} -X OPTIONS --header \""$ACCEPT_JSON"\""
HEAD
=
"
${
CURL
}
-X HEAD --header
\"
"
$ACCEPT_JSON
"
\"
"
${
GET
}
\
--header
"
$AUTH
"
${
URL
}
'/api/applications?limit=9999&o
ffset=0'
\
>
.applications.json
--header
"
$AUTH
"
${
URL
}
'/api/applications?limit=9999&o
rganizationID='
${
OID
}
\
>
.
organization
${
OID
}
_
applications.json
jq
'.result[] | ( .id + ": " + .name + " - " + .organizationID + " - " + .description)'
.applications.json
reports/get_devices.sh
View file @
6e1df0ed
...
...
@@ -56,9 +56,28 @@ DELETE="${CURL} -X DELETE --header \""$ACCEPT_JSON"\""
OPTIONS
=
"
${
CURL
}
-X OPTIONS --header
\"
"
$ACCEPT_JSON
"
\"
"
HEAD
=
"
${
CURL
}
-X HEAD --header
\"
"
$ACCEPT_JSON
"
\"
"
${
GET
}
\
--header
"
$AUTH
"
${
URL
}
'/api/devices?limit=9999&offset=0'
\
>
.devices.json
ids_org
=
$(
jq
--raw-output
".result[] | .id"
.organizations.json
)
ids_org_array
=(
$ids_org
)
for
((
i
=
0
;
i<
${#
ids_org_array
[@]
}
;
i++
))
do
ids_app
=
$(
jq
--raw-output
".result[] | .id"
.organization
${
ids_org_array
[i]
}
_applications.json
)
ids_app_array
=(
$ids_app
)
for
((
j
=
0
;
j<
${#
ids_app_array
[@]
}
;
j++
))
do
${
GET
}
\
--header
"
$AUTH
"
${
URL
}
'/api/devices?limit=9999&applicationID='
${
ids_app_array
[j]
}
\
>
.application
${
ids_app_array
[j]
}
_devices.json
done
done
jq
-s
'.[0].result = [.[].result | add] | .[0]'
.application
*
.json
>
.devices.json
#${GET} \
# --header "$AUTH" ${URL}'/api/devices?limit=9999&offset=0' \
# > .devices.json
echo
'<html><head><title>CampusIoT LNS :: Devices</title></head><body style="font-family:verdana;"><h1>CampusIoT LNS :: Devices</h1>'
>
.devices.html
...
...
@@ -78,5 +97,3 @@ echo '<h2>Passive devices</h2>' >> .devices.html
jq
--raw-output
-f
devices_to_html.jq .devices.json |
grep
-v
$TODAY
>>
.devices.html
echo
'</body></html>'
>>
.devices.html
reports/get_gateways.sh
View file @
6e1df0ed
...
...
@@ -87,3 +87,5 @@ do
echo
"get details for
$g
"
./get_gateway.sh
$TOKEN
$g
done
./get_id_gatewaysChange.sh
reports/get_id_gatewaysChange.sh
0 → 100755
View file @
6e1df0ed
#!/bin/bash
#TODAY="2021-03-02"
TODAY
=
"
$(
date
+
"%Y-%m-%d"
)
"
#On stock les ids des gateways d'aujourd'hui
ids
=
$(
jq
--raw-output
".result[] | .id"
.gateways.json
)
id
=()
i
=
0
for
ID
in
$ids
do
id
[
$i
]=
$ID
i
=
$((
i+1
))
done
#On stock les dates de dernière activité des gateways d'aujourd'hui
dates
=
$(
jq
--raw-output
".result[] | .lastSeenAt"
.gateways.json
)
date
=()
date
=(
$dates
)
state
=()
full_date
=()
d
=()
for
((
i
=
0
;
i<
${#
date
[@]
}
;
i++
))
do
if
[[
${
date
[
$i
]
}
==
"null"
]]
then
full_date[
$i
]=
${
date
[
$i
]
}
d[
$i
]=
${
full_date
[
$i
]
}
else
full_date[
$i
]=
$(
echo
$date
[
$i
]
|
tr
"T"
"
\n
"
)
for
arg
in
$full_date
[
$i
]
do
d[
$i
]=
$arg
break
done
fi
done
#On stock les states des gateways d'aujourd'hui dans un tableau en regardant la date
#de dernière activité des gateways
for
((
i
=
0
;
i<
${#
d
[@]
}
;
i++
))
do
if
[[
"
${
d
[
$i
]
}
"
==
"
$TODAY
"
]]
then
state[
$i
]=
"active"
else
state[
$i
]=
"passive"
fi
done
#On stock les ids des gateways d'hier
ids_2
=
$(
jq
--raw-output
".result[] | .id"
lastGatewaysStates.json
)
id_2
=()
i
=
0
for
ID
in
$ids_2
do
id_2[
$i
]=
$ID
i
=
$((
i+1
))
done
#On stock les states des gateways d'hier
full_state
=
$(
jq
--raw-output
".result[] | .lastState"
lastGatewaysStates.json
)
states_2
=()
j
=
0
for
s
in
$full_state
do
state_2[
$j
]=
$s
j
=
$((
j+1
))
done
#On compare les states des gateways d'aujourd'hui et hier
for
((
i
=
0
;
i<
${#
id
[@]
}
;
i++
))
do
for
((
j
=
0
;
j<
${#
id_2
[@]
}
;
j++
))
do
if
[[
"
$id
[
$i
]"
==
"
$id_2
[
$j
]"
]]
then
if
[[
"
${
state
[
$i
]
}
"
!=
"
${
state_2
[
$j
]
}
"
]]
then
if
[[
"
${
state
[
$i
]
}
"
==
"active"
]]
then
tmp
=
$(
grep
${
id
[
$i
]
}
< .gateways.html
)
replacement
=
${
tmp
/
"<li>"
/
"<li style="
color
:green
">"
}
else
tmp
=
$(
grep
${
id
[
$i
]
}
< .gateways.html
)
replacement
=
${
tmp
/
"<li>"
/
"<li style="
color
:red
">"
}
fi
sed
-i
"/
${
id
[
$i
]
}
/c
$replacement
"
.gateways.html
fi
fi
done
if
[[
${
date
[
$i
]
}
!=
"null"
]]
then
tmp
=
$(
grep
${
id
[
$i
]
}
< .gateways.html
)
dateFromNow
=
$(
node changeDateMomentjs.js
${
date
[
$i
]
}
)
replacement
=
${
tmp
/
${
date
[
$i
]
}
/
"
$dateFromNow
"
}
sed
-i
"/
${
id
[
$i
]
}
/c
$replacement
"
.gateways.html
fi
done
#On met à jour les states des gateways pour le prochain jour
echo
"{
\"
totalCount
\"
:
\"
${#
id
[@]
}
\"
,
\"
result
\"
: ["
>
lastGatewaysStates.json
for
((
i
=
0
;
i<
$((${#
id
[@]
}
-
1
))
;
i++
))
do
echo
" {
\"
id
\"
:
\"
${
id
[
$i
]
}
\"
,
\"
lastState
\"
:
\"
${
state
[
$i
]
}
\"
},"
>>
lastGatewaysStates.json
done
echo
" {
\"
id
\"
:
\"
${
id
[
$((${#
id
[@]
}
-
1
))
]
}
\"
,
\"
lastState
\"
:
\"
${
state
[
$((${#
id
[@]
}
-
1
))
]
}
\"
}
]
}"
>>
lastGatewaysStates.json
\ No newline at end of file
reports/get_organizations.sh
View file @
6e1df0ed
...
...
@@ -59,4 +59,13 @@ ${GET} \
--header
"
$AUTH
"
${
URL
}
'/api/organizations?limit=1000&offset=0'
\
>
.organizations.json
jq
'.result[] | ( .id + ": " + .name + " - " + .displayName)'
.organizations.json
ids
=
$(
jq
--raw-output
".result[] | .id"
.organizations.json
)
ids_array
=(
$ids
)
for
((
i
=
0
;
i<
${#
ids_array
[@]
}
;
i++
))
do
./get_applications.sh
$TOKEN
"
${
ids_array
[i]
}
"
done
reports/lastGatewaysStates.json
0 → 100644
View file @
6e1df0ed
{
"totalCount"
:
"24"
,
"result"
:
[
{
"id"
:
"0000024b0805031a"
,
"lastState"
:
"active"
},
{
"id"
:
"7276ff0039030716"
,
"lastState"
:
"active"
},
{
"id"
:
"7276ff0039030724"
,
"lastState"
:
"active"
},
{
"id"
:
"7276ff0039030871"
,
"lastState"
:
"active"
},
{
"id"
:
"0080e1ffff0153f1"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff011234"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff0153d7"
,
"lastState"
:
"passive"
},
{
"id"
:
"080027ffff052e4a"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff014fe1"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff014feb"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff01523c"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff01523e"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015240"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015241"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015242"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015244"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015252"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015253"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015256"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015257"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff01525e"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff0153cc"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015b18"
,
"lastState"
:
"passive"
},
{
"id"
:
"0080e1ffff015abf"
,
"lastState"
:
"passive"
}
]
}
reports/sendmail_reports.sh
View file @
6e1df0ed
...
...
@@ -7,10 +7,13 @@
# TODO /bin/bash
# TODO get TO for the .config.json
TO
=
"XX.XX@univ-grenoble-alpes.fr YY.YY@univ-grenoble-alpes.fr"
#TO="XX.XX@univ-grenoble-alpes.fr YY.YY@univ-grenoble-alpes.fr"
TO
=
"kevyung24@gmail.com"
SUBJECT
=
"Monitoring Report"
CONTENT_TYPE
=
"Content-type: text/html"
mail
-a
"
$CONTENT_TYPE
"
-s
"
$SUBJECT
"
-u
monitoring
$TO
<.gateways.html
mail
-a
"
$CONTENT_TYPE
"
-s
"
$SUBJECT
"
-u
monitoring
$TO
<.devices.html
#
mail -a "$CONTENT_TYPE" -s "$SUBJECT" -u monitoring $TO <.gateways.html
#
mail -a "$CONTENT_TYPE" -s "$SUBJECT" -u monitoring $TO <.devices.html
mailx
-a
"
$CONTENT_TYPE
"
-s
"
$SUBJECT
"
<.gateways.html
"
$TO
"
#mail -s "Test" kevyung24@gmail.com
\ No newline at end of file
reports/test.js
0 → 100644
View file @
6e1df0ed
#!/usr/bin/env node
const
moment
=
require
(
'
moment
'
);
var
argv
=
process
.
argv
;
// store the argument given
process
.
argv
.
shift
();
// skip path of node file
process
.
argv
.
shift
();
// skip path of js file
argv
=
process
.
argv
.
join
(
"
"
)
// parse to keep only the string
function
f
(
lastSeenAt
)
{
//console.log(lastSeenAt);
lastSeenAt
=
new
Date
(
lastSeenAt
);
return
moment
(
lastSeenAt
).
fromNow
();
}
console
.
log
(
f
(
argv
))
\ No newline at end of file
reports/test.sh
0 → 100755
View file @
6e1df0ed
#!/bin/bash
# Copyright (C) CampusIoT, - All Rights Reserved
# Written by CampusIoT Dev Team, 2016-2021
# ------------------------------------------------
# Get devices
# ------------------------------------------------
# Parameters
if
[[
$#
-ne
1
]]
;
then
echo
"Usage:
$0
JWT"
exit
1
fi
#TOKEN="$1"
TOKEN
=
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNjUwNzA5OCwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTY0MjA2OTgsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.oFx7qWOiGY49FpgCKXAaAt6TkDVcQgtg3dz6mIyUj6w"
AUTH
=
"Grpc-Metadata-Authorization: Bearer
$TOKEN
"
#sudo npm install -g jwt-cli
#jwt $TOKEN
# Installation
if
!
[
-x
"
$(
command
-v
jq
)
"
]
;
then
echo
'jq is not installed. Installing jq ...'
sudo
apt-get
install
-y
jq
fi
if
!
[
-x
"
$(
command
-v
curl
)
"
]
;
then
echo
'curl is not installed. Installing curl ...'
sudo
apt-get
install
-y
curl
fi
# Content-Type
ACCEPT_JSON
=
"Accept: application/json"
ACCEPT_CSV
=
"Accept: text/csv"
CONTENT_JSON
=
"Content-Type: application/json"
CONTENT_CSV
=
"Content-Type: text/csv"
# LOCAL
#PORT=8888
#URL=http://localhost:$PORT
# PROD
PORT
=
443
URL
=
https://lns.campusiot.imag.fr:
$PORT
# Operations
# Operations
#CURL="curl --verbose"
CURL
=
"curl -s --insecure"
#CURL="curl -s"
GET
=
"
${
CURL
}
-X GET --header
\"
"
$ACCEPT_JSON
"
\"
"
POST
=
"
${
CURL
}
-X POST --header
\"
"
$ACCEPT_JSON
"
\"
"
PUT
=
"
${
CURL
}
-X PUT --header
\"
"
$ACCEPT_JSON
"
\"
"
DELETE
=
"
${
CURL
}
-X DELETE --header
\"
"
$ACCEPT_JSON
"
\"
"
OPTIONS
=
"
${
CURL
}
-X OPTIONS --header
\"
"
$ACCEPT_JSON
"
\"
"
HEAD
=
"
${
CURL
}
-X HEAD --header
\"
"
$ACCEPT_JSON
"
\"
"
jq
-s
'.[0].result = [.[].result | add] | .[0]'
.test
*
.json
>
.test_devices.json
#${GET} \
# --header "$AUTH" ${URL}'/api/applications?limit=9999&organizationID=6'
#${GET} \
# --header "$AUTH" ${URL}'/api/devices?limit=9999&applicationID=58'
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment