Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 6e1df0ed authored by Antoine Blanquet's avatar Antoine Blanquet
Browse files

Merge branch 'test_report_j-1' into reports-dev

parents 40ca53ef 39c07faa
{
"node-red": {
"name": "node-red",
"version": "1.2.7",
"version": "1.2.9",
"local": false,
"nodes": {
"inject": {
......
......@@ -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
......@@ -22,4 +22,4 @@ services:
file: grafana.yml
service: grafana
links:
- influxdb:influxdb
- influxdb:influxdb
\ No newline at end of file
node_modules/
admin.token.json
*.token.json
.*.json
.*.html
.DS_Store
......
{"jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNDc4NTg0OCwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTQ2OTk0NDgsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.EQgydowoS132k5n3cPYI0qg4eAksewkep2c1QAFG8xw"}
\ No newline at end of file
{"jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNDc4NTg0OCwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTQ2OTk0NDgsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.EQgydowoS132k5n3cPYI0qg4eAksewkep2c1QAFG8xw"}
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
......@@ -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&offset=0' \
> .applications.json
--header "$AUTH" ${URL}'/api/applications?limit=9999&organizationID='${OID} \
> .organization${OID}_applications.json
jq '.result[] | ( .id + ": " + .name + " - " + .organizationID + " - " + .description)' .applications.json
......@@ -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
......@@ -87,3 +87,5 @@ do
echo "get details for $g"
./get_gateway.sh $TOKEN $g
done
./get_id_gatewaysChange.sh
#!/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
......@@ -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
{
"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"
}
]
}
......@@ -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
#!/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
#!/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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment