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 40065e75 authored by Antoine Blanquet's avatar Antoine Blanquet
Browse files

Massive Commit - Merge code, Reports Sparkline + Devices + MomentJS(Moment JS to test )

parents a66a9adc 85c97fad
......@@ -326,6 +326,15 @@
"type": "inject",
"z": "8ef8462d.3e5728",
"name": "CREATE DATABASE lorawan",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
......@@ -361,6 +370,7 @@
"rawOutput": false,
"precision": "",
"retentionPolicy": "",
"org": "",
"x": 560,
"y": 120,
"wires": [
......
{"jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNjU5NTcwOSwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTY1MDkzMDksInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.zeOC4P_bqR5o1MZu1RZWnQTmkt7KMTdPGpAxdhVBLGE"}
\ No newline at end of file
......@@ -6,7 +6,7 @@ process.argv.shift(); // skip path of js file
argv = process.argv.join(" ") // parse to keep only the string
function f(lastSeenAt) {
//console.log(lastSeenAt);
console.log(lastSeenAt);
lastSeenAt = new Date(lastSeenAt);
return moment(lastSeenAt).fromNow();
}
......
.result | sort_by(.lastSeenAt, .id) | reverse [] | ("<li><a href='" + @uri "https://lns.campusiot.imag.fr/#/organizations/\(.organizationID)/gateways/\(.id)" + "'>" + .id + "</a>: " + .name + " - (org " + .organizationID + ") - " + .lastSeenAt + "</li>" )
#!/bin/bash
# -------------------------------------------------
# Description: Generate HTML report of gateways
# List Command: x
# Usage: runned by get_gateways.sh (à détailler)
# Create by: CampusIoT Dev Team, 2021 - Copyright (C) CampusIoT, - All Rights Reserved
# Since: 09/09/2560 (DD/MM/YYYY)
# -------------------------------------------------
# Version: 1.0
# -------------------------------------------------
# Bug:
# -------------------------------------------------
# Parameters
if [[ $# -eq 0 ]]; then
echo "Aucun arguments renseignées : Usage: $0 GATEWAYS_LENGTH GATEWAYS TODAY"
exit 1
fi
GATEWAYS_LENGTH="$1"
args_len=$(($GATEWAYS_LENGTH + 2))
if [[ $# -ne args_len ]]; then
echo "Usage: $0 GATEWAYS_LENGTH GATEWAYS TODAY"
exit 1
fi
GATEWAYS=${@:2:$GATEWAYS_LENGTH} # on recupère les données de la gateway passés en paramètre en subsituant la taille et la date du jour.
TODAY="${@:$#}" # last parameter
# gateways_to_html : Step 1 : Generate header.
cat report_header.html >.gateways.html
echo '<title>CampusIoT LNS :: Gateways</title>' >>.gateways.html
echo '</head>' >>.gateways.html
echo '<body style="font-family:verdana;"><h1>CampusIoT LNS :: Gateways</h1>' >>.gateways.html
# 2.Generate Time
echo '<p>generated at ' >>.gateways.html
date +"%Y-%m-%d %T %Z" >>.gateways.html
echo ' - ' >>.gateways.html
TZ=GMT date +"%Y-%m-%d %T %Z" >>.gateways.html
echo '</p>' >>.gateways.html
# 3.Generate Active Gateways
echo '<h2>Active gateways</h2>' >>.gateways.html
echo "generate_sparkline_packets : \n ========== \n ========== \n "
for g in $GATEWAYS; do
packet_received=$(jq -r '.result | map(.rxPacketsReceivedOK) | join(",")' .gateway-${g}_stats.json)
jq --raw-output "( \"<li><a \"
+ \"href='https://lns.campusiot.imag.fr/#/organizations/\(.gateway.organizationID)/gateways/\(.gateway.id)'\" + \">\" + .gateway.id + \"</a>: \"
+ .gateway.name + \" - (org \" + .gateway.organizationID + \") - \"
+ .lastSeenAt
+ \" - packets received last month : <span class='inlinesparkline'>${packet_received}</span>\"
+ \"</li>\" )" .gateway-${g}.json | grep $TODAY >>.gateways.html
done
# 4.Generate Passive Gateways
echo '<h2>Passive gateways</h2>' >>.gateways.html
for g in $GATEWAYS; do
packet_received=$(jq -r '.result | map(.rxPacketsReceivedOK) | join(",")' .gateway-${g}_stats.json)
jq --raw-output "( \"<li><a \"
+ \"href='https://lns.campusiot.imag.fr/#/organizations/\(.gateway.organizationID)/gateways/\(.gateway.id)'\" + \">\" + .gateway.id + \"</a>: \"
+ .gateway.name + \" - (org \" + .gateway.organizationID + \") - \"
+ .lastSeenAt
+ \" - packets received last month : <span class='inlinesparkline'>${packet_received}</span>\"
+ \"</li>\" )" .gateway-${g}.json | grep -v $TODAY >>.gateways.html
done
echo '</body></html>' >>.gateways.html
.result | sort_by(.lastSeenAt, .id) | reverse [] | ("<li><a href='" + @uri "https://lns.campusiot.imag.fr/#/organizations/\(.organizationID)/gateways/\(.id)" + "'>" + .id + "</a>: " + .name + " - (org " + .organizationID + ") - " + .lastSeenAt + " - " + .lastState + "</li>" )
{"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"}]}
\ No newline at end of file
{"totalCount":"24","result":[{"id":"0000024b0805031a","name":"KER_107_POLYTECH","description":"LoRaServer Bridge","createdAt":"2020-08-12T12:49:20.213116Z","updatedAt":"2021-03-02T14:42:35.521524Z","firstSeenAt":"2020-11-30T14:33:34.452376Z","lastSeenAt":"2021-03-02T14:42:35.519734Z","organizationID":"6","networkServerID":"1","lastState":"active","location":{"latitude":45.18432,"longitude":5.7534,"altitude":232,"source":"UNKNOWN","accuracy":0}},{"id":"7276ff0039030716","name":"KER_FEMTO_030716_P307","description":"Kerlink Wirnet iFemtoCell LoRaWAN Academy\nhttps://www.kerlink.fr/produit/wirnet-ifemtocell/\n\neth0 70:76:FF:02:07:7A\nwlan0 98:84:E3:BF:C7:D2\nIP 129.88.104.13\n","createdAt":"2020-10-09T10:37:41.392857Z","updatedAt":"2021-03-02T14:42:34.531887Z","firstSeenAt":"2021-01-30T14:06:43.965996Z","lastSeenAt":"2021-03-02T14:42:34.530046Z","organizationID":"6","networkServerID":"1","lastState":"active","location":{"latitude":45.18439622301354,"longitude":5.753231048583985,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"7276ff0039030724","name":"KER_FEMTO_030724_P124","description":"Femto Kerlink - Semtech LoRa Academy\neth0 70:76:ff:02:07:88\nwlan0 F0:C7:7F:C9:DB:E7\nIP 129.88.104.12","createdAt":"2020-10-09T10:31:29.150691Z","updatedAt":"2021-03-02T14:42:34.460855Z","firstSeenAt":"2021-01-30T13:42:31.657870Z","lastSeenAt":"2021-03-02T14:42:34.457846Z","organizationID":"6","networkServerID":"1","lastState":"active","location":{"latitude":45.18424498325449,"longitude":5.75310230255127,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"7276ff0039030871","name":"KER_FEMTO_030871_NP","description":"Kerlink Wirnet iFemtoCell LoRaWAN Academy https://www.kerlink.fr/produit/wirnet-ifemtocell/\n\neth0 70:76:FF:02:08:D4\nwlan0 98:84:E3:48:88:A2","createdAt":"2020-10-09T10:38:35.279330Z","updatedAt":"2021-03-02T14:42:23.524637Z","firstSeenAt":"2020-10-21T09:50:03.963231Z","lastSeenAt":"2021-03-02T14:42:23.523005Z","organizationID":"6","networkServerID":"1","lastState":"active","location":{"latitude":45.19740133918228,"longitude":5.833740234375001,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff0153f1","name":"LRWAN2_0153F1_KEKA","description":"Enver KEKA/ Thibaud HUMBERT\nLocalisation : Proche CHAVANT (Enver) / Gare Grenoble (Alsace-Lorraine)\n","createdAt":"2021-02-23T16:42:29.229621Z","updatedAt":"2021-02-23T16:42:29.229621Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18545489007673,"longitude":5.731258188609468,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff011234","name":"LRWAN2_1234","description":"Gateway de Machin et de Bidule","createdAt":"2020-10-12T14:18:03.422439Z","updatedAt":"2021-02-01T16:18:10.914756Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18433572715811,"longitude":5.753402709960938,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff0153d7","name":"LRWAN2_153D7_SONZOGNI","description":"PM2M SONZOGNI","createdAt":"2021-02-23T16:33:58.381466Z","updatedAt":"2021-02-23T16:33:58.381466Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.19280830183293,"longitude":5.731676768131312,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"080027ffff052e4a","name":"LRWAN2_2E4A","description":"Gateway LoRaWAN2 d'Alexandre SALMON et Thomas FRION","createdAt":"2020-10-25T15:26:33.683397Z","updatedAt":"2020-10-25T16:00:41.686580Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.7226831,"longitude":5.9242678,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff014fe1","name":"LRWAN2_4FE1_ROFFET_ROBERT","description":"Gateway Antoine ROFFET / Francois ROBERT\n","createdAt":"2020-10-26T09:13:50.490139Z","updatedAt":"2021-02-23T13:15:09.330789Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.19050597326729,"longitude":5.753958682541712,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff014feb","name":"LRWAN2_4FEB_ROTIVAL","description":"Gateway de Antoine ROTIVAL","createdAt":"2020-12-06T13:05:02.270055Z","updatedAt":"2021-03-02T14:15:29.366507Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.182740125763594,"longitude":5.730657577514649,"altitude":238,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff01523c","name":"LRWAN2_523C_THOMAS_HERVE","description":"Gateway de Xiang SUN et Haoran ZHANG","createdAt":"2020-12-06T13:16:36.678108Z","updatedAt":"2021-02-23T13:31:04.306534Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.180297483446495,"longitude":5.744208097457887,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff01523e","name":"LRWAN2_523E_VIVIANI","description":"Nicolas Viviani / Antoine Rotival\n","createdAt":"2021-01-08T08:29:03.697667Z","updatedAt":"2021-02-23T16:35:48.543451Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.46783598133375,"longitude":4.474431487704341,"altitude":400,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015240","name":"LRWAN2_5240","description":"Addr Ethernet 00 80 e1 01 52 40","createdAt":"2021-02-01T14:27:24.122997Z","updatedAt":"2021-02-01T14:27:24.122997Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18424498325449,"longitude":5.753574371337891,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015241","name":"LRWAN2_5241","description":"Gateway de florian jacquin ","createdAt":"2020-12-04T11:39:16.707206Z","updatedAt":"2020-12-04T11:39:16.707206Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":0,"longitude":0,"altitude":-2,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015242","name":"LRWAN2_5242_HUMBERT","description":"Enver KEKA/ Thibaud HUMBERT\nLocalisation : Proche CHAVANT (Enver) / Gare Grenoble (Alsace-Lorraine)\n\n","createdAt":"2020-10-23T12:41:31.643182Z","updatedAt":"2021-02-23T16:40:38.076401Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.189144947063426,"longitude":5.721686275766365,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015244","name":"LRWAN2_5244","description":"Gateway de Dima ASSI et Houda EL AJI pour le projet WSN de INFO5/Polytech Grenoble","createdAt":"2020-12-24T15:03:33.158942Z","updatedAt":"2020-12-24T18:47:07.168703Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18502008277258,"longitude":5.746954679489137,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015252","name":"LRWAN2_5252","description":"gateway de valentin blumert","createdAt":"2021-01-08T09:04:37.357613Z","updatedAt":"2021-01-08T09:04:37.357613Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18633205644303,"longitude":5.705938785678001,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015253","name":"LRWAN2_5253","description":"Gateway pour le projet IoT LIANG Jichen","createdAt":"2020-12-06T14:12:19.996004Z","updatedAt":"2021-01-08T10:07:07.385911Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.1834546,"longitude":5.742217,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015256","name":"LRWAN2_5256","description":"Gateway Hugo RIBARD","createdAt":"2020-12-04T09:59:38.252876Z","updatedAt":"2020-12-04T09:59:38.252876Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.188097,"longitude":5.7514791999999995,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015257","name":"LRWAN2_5257_ROFFET_ROBERT","description":"Gateway PM2M ROFFET ROBERT","createdAt":"2021-01-08T10:37:34.317049Z","updatedAt":"2021-02-23T13:28:57.531612Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18130329003343,"longitude":5.762570500373841,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff01525e","name":"LRWAN2_525E","description":"Gateway de Flavien Mougeot et Gabriel Jaffres\n","createdAt":"2020-10-12T13:44:25.942475Z","updatedAt":"2021-01-08T10:34:06.708452Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18436597509387,"longitude":5.7533597946167,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff0153cc","name":"LRWAN2_53CC","description":"[IESE5] Gateway Benoit BARRE ","createdAt":"2021-01-08T09:30:40.541929Z","updatedAt":"2021-01-08T09:30:40.541929Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.1881042,"longitude":5.7737408,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015b18","name":"LRWAN2_5B18","description":"Gateway de Tony MAHIEUX","createdAt":"2020-12-06T13:10:48.842075Z","updatedAt":"2020-12-06T13:10:48.842075Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18916763110019,"longitude":5.727138519287109,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015abf","name":"LRWAN3_5ABF_EU433","description":"LRWAN3\nMac Addr Ethernet 00 80 e1 01 5a bf","createdAt":"2021-02-01T14:29:41.185058Z","updatedAt":"2021-02-01T14:29:41.185058Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","lastState":"passive","location":{"latitude":45.18424498325449,"longitude":5.753574371337891,"altitude":220,"source":"UNKNOWN","accuracy":0}}]}
\ No newline at end of file
{"totalCount":"24","result":[{"id":"0000024b0805031a","name":"KER_107_POLYTECH","description":"LoRaServer Bridge","createdAt":"2020-08-12T12:49:20.213116Z","updatedAt":"2021-03-02T14:42:35.521524Z","firstSeenAt":"2020-11-30T14:33:34.452376Z","lastSeenAt":"2021-03-02T14:42:35.519734Z","organizationID":"6","networkServerID":"1","location":{"latitude":45.18432,"longitude":5.7534,"altitude":232,"source":"UNKNOWN","accuracy":0}},{"id":"7276ff0039030716","name":"KER_FEMTO_030716_P307","description":"Kerlink Wirnet iFemtoCell LoRaWAN Academy\nhttps://www.kerlink.fr/produit/wirnet-ifemtocell/\n\neth0 70:76:FF:02:07:7A\nwlan0 98:84:E3:BF:C7:D2\nIP 129.88.104.13\n","createdAt":"2020-10-09T10:37:41.392857Z","updatedAt":"2021-03-02T14:42:34.531887Z","firstSeenAt":"2021-01-30T14:06:43.965996Z","lastSeenAt":"2021-03-02T14:42:34.530046Z","organizationID":"6","networkServerID":"1","location":{"latitude":45.18439622301354,"longitude":5.753231048583985,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"7276ff0039030724","name":"KER_FEMTO_030724_P124","description":"Femto Kerlink - Semtech LoRa Academy\neth0 70:76:ff:02:07:88\nwlan0 F0:C7:7F:C9:DB:E7\nIP 129.88.104.12","createdAt":"2020-10-09T10:31:29.150691Z","updatedAt":"2021-03-02T14:42:34.460855Z","firstSeenAt":"2021-01-30T13:42:31.657870Z","lastSeenAt":"2021-03-02T14:42:34.457846Z","organizationID":"6","networkServerID":"1","location":{"latitude":45.18424498325449,"longitude":5.75310230255127,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"7276ff0039030871","name":"KER_FEMTO_030871_NP","description":"Kerlink Wirnet iFemtoCell LoRaWAN Academy https://www.kerlink.fr/produit/wirnet-ifemtocell/\n\neth0 70:76:FF:02:08:D4\nwlan0 98:84:E3:48:88:A2","createdAt":"2020-10-09T10:38:35.279330Z","updatedAt":"2021-03-02T14:42:23.524637Z","firstSeenAt":"2020-10-21T09:50:03.963231Z","lastSeenAt":"2021-03-02T14:42:23.523005Z","organizationID":"6","networkServerID":"1","location":{"latitude":45.19740133918228,"longitude":5.833740234375001,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff0153f1","name":"LRWAN2_0153F1_KEKA","description":"Enver KEKA/ Thibaud HUMBERT\nLocalisation : Proche CHAVANT (Enver) / Gare Grenoble (Alsace-Lorraine)\n","createdAt":"2021-02-23T16:42:29.229621Z","updatedAt":"2021-02-23T16:42:29.229621Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18545489007673,"longitude":5.731258188609468,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff011234","name":"LRWAN2_1234","description":"Gateway de Machin et de Bidule","createdAt":"2020-10-12T14:18:03.422439Z","updatedAt":"2021-02-01T16:18:10.914756Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18433572715811,"longitude":5.753402709960938,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff0153d7","name":"LRWAN2_153D7_SONZOGNI","description":"PM2M SONZOGNI","createdAt":"2021-02-23T16:33:58.381466Z","updatedAt":"2021-02-23T16:33:58.381466Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.19280830183293,"longitude":5.731676768131312,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"080027ffff052e4a","name":"LRWAN2_2E4A","description":"Gateway LoRaWAN2 d'Alexandre SALMON et Thomas FRION","createdAt":"2020-10-25T15:26:33.683397Z","updatedAt":"2020-10-25T16:00:41.686580Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.7226831,"longitude":5.9242678,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff014fe1","name":"LRWAN2_4FE1_ROFFET_ROBERT","description":"Gateway Antoine ROFFET / Francois ROBERT\n","createdAt":"2020-10-26T09:13:50.490139Z","updatedAt":"2021-02-23T13:15:09.330789Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.19050597326729,"longitude":5.753958682541712,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff014feb","name":"LRWAN2_4FEB_ROTIVAL","description":"Gateway de Antoine ROTIVAL","createdAt":"2020-12-06T13:05:02.270055Z","updatedAt":"2021-03-02T14:15:29.366507Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.182740125763594,"longitude":5.730657577514649,"altitude":238,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff01523c","name":"LRWAN2_523C_THOMAS_HERVE","description":"Gateway de Xiang SUN et Haoran ZHANG","createdAt":"2020-12-06T13:16:36.678108Z","updatedAt":"2021-02-23T13:31:04.306534Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.180297483446495,"longitude":5.744208097457887,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff01523e","name":"LRWAN2_523E_VIVIANI","description":"Nicolas Viviani / Antoine Rotival\n","createdAt":"2021-01-08T08:29:03.697667Z","updatedAt":"2021-02-23T16:35:48.543451Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.46783598133375,"longitude":4.474431487704341,"altitude":400,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015240","name":"LRWAN2_5240","description":"Addr Ethernet 00 80 e1 01 52 40","createdAt":"2021-02-01T14:27:24.122997Z","updatedAt":"2021-02-01T14:27:24.122997Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18424498325449,"longitude":5.753574371337891,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015241","name":"LRWAN2_5241","description":"Gateway de florian jacquin ","createdAt":"2020-12-04T11:39:16.707206Z","updatedAt":"2020-12-04T11:39:16.707206Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":0,"longitude":0,"altitude":-2,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015242","name":"LRWAN2_5242_HUMBERT","description":"Enver KEKA/ Thibaud HUMBERT\nLocalisation : Proche CHAVANT (Enver) / Gare Grenoble (Alsace-Lorraine)\n\n","createdAt":"2020-10-23T12:41:31.643182Z","updatedAt":"2021-02-23T16:40:38.076401Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.189144947063426,"longitude":5.721686275766365,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015244","name":"LRWAN2_5244","description":"Gateway de Dima ASSI et Houda EL AJI pour le projet WSN de INFO5/Polytech Grenoble","createdAt":"2020-12-24T15:03:33.158942Z","updatedAt":"2020-12-24T18:47:07.168703Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18502008277258,"longitude":5.746954679489137,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015252","name":"LRWAN2_5252","description":"gateway de valentin blumert","createdAt":"2021-01-08T09:04:37.357613Z","updatedAt":"2021-01-08T09:04:37.357613Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18633205644303,"longitude":5.705938785678001,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015253","name":"LRWAN2_5253","description":"Gateway pour le projet IoT LIANG Jichen","createdAt":"2020-12-06T14:12:19.996004Z","updatedAt":"2021-01-08T10:07:07.385911Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.1834546,"longitude":5.742217,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015256","name":"LRWAN2_5256","description":"Gateway Hugo RIBARD","createdAt":"2020-12-04T09:59:38.252876Z","updatedAt":"2020-12-04T09:59:38.252876Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.188097,"longitude":5.7514791999999995,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015257","name":"LRWAN2_5257_ROFFET_ROBERT","description":"Gateway PM2M ROFFET ROBERT","createdAt":"2021-01-08T10:37:34.317049Z","updatedAt":"2021-02-23T13:28:57.531612Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18130329003343,"longitude":5.762570500373841,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff01525e","name":"LRWAN2_525E","description":"Gateway de Flavien Mougeot et Gabriel Jaffres\n","createdAt":"2020-10-12T13:44:25.942475Z","updatedAt":"2021-01-08T10:34:06.708452Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18436597509387,"longitude":5.7533597946167,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff0153cc","name":"LRWAN2_53CC","description":"[IESE5] Gateway Benoit BARRE ","createdAt":"2021-01-08T09:30:40.541929Z","updatedAt":"2021-01-08T09:30:40.541929Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.1881042,"longitude":5.7737408,"altitude":0,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015b18","name":"LRWAN2_5B18","description":"Gateway de Tony MAHIEUX","createdAt":"2020-12-06T13:10:48.842075Z","updatedAt":"2020-12-06T13:10:48.842075Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18916763110019,"longitude":5.727138519287109,"altitude":220,"source":"UNKNOWN","accuracy":0}},{"id":"0080e1ffff015abf","name":"LRWAN3_5ABF_EU433","description":"LRWAN3\nMac Addr Ethernet 00 80 e1 01 5a bf","createdAt":"2021-02-01T14:29:41.185058Z","updatedAt":"2021-02-01T14:29:41.185058Z","firstSeenAt":null,"lastSeenAt":null,"organizationID":"5","networkServerID":"1","location":{"latitude":45.18424498325449,"longitude":5.753574371337891,"altitude":220,"source":"UNKNOWN","accuracy":0}}]}
\ No newline at end of file
......@@ -13,7 +13,7 @@ PASSWORD=$(jq --raw-output ".password" .credentials.json)
JWT=$(./get_jwt.sh $USERNAME $PASSWORD)
./get_organizations.sh $JWT
./get_gateways_v2.sh $JWT
./get_gateways.sh $JWT
./get_devices.sh $JWT
# TODO send reports by email
......@@ -61,4 +61,4 @@ ${GET} \
--header "$AUTH" ${URL}'/api/applications?limit=9999&organizationID='${OID} \
> .organization${OID}_applications.json
jq '.result[] | ( .id + ": " + .name + " - " + .organizationID + " - " + .description)' .applications.json
# jq '.result[] | ( .id + ": " + .name + " - " + .organizationID + " - " + .description)' .applications.json
......@@ -4,21 +4,20 @@
# Written by CampusIoT Dev Team, 2016-2021
# ------------------------------------------------
# Get devices
# Get the stats of a get gateway
# ------------------------------------------------
# Parameters
if [[ $# -ne 1 ]] ; then
echo "Usage: $0 JWT"
if [[ $# -ne 3 ]] ; then
echo "Usage: $0 JWT GWID TODAY"
exit 1
fi
#TOKEN="$1"
TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNjUwNzA5OCwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTY0MjA2OTgsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.oFx7qWOiGY49FpgCKXAaAt6TkDVcQgtg3dz6mIyUj6w"
TOKEN="$1"
GWID="$2"
TODAY="$3"
AUTH="Grpc-Metadata-Authorization: Bearer $TOKEN"
#sudo npm install -g jwt-cli
#jwt $TOKEN
# Installation
if ! [ -x "$(command -v jq)" ]; then
......@@ -45,7 +44,6 @@ CONTENT_CSV="Content-Type: text/csv"
PORT=443
URL=https://lns.campusiot.imag.fr:$PORT
# Operations
# Operations
#CURL="curl --verbose"
CURL="curl -s --insecure"
......@@ -57,10 +55,13 @@ 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
PAST_MONTH=$(date -d "-1 month" +%Y-%m-%d)
INTERVAL="day"
#${GET} \
# --header "$AUTH" ${URL}'/api/applications?limit=9999&organizationID=6'
${GET} \
--header "$AUTH" ${URL}'/api/gateways/'${GWID}'/stats?interval='${INTERVAL}'&startTimestamp='${PAST_MONTH}'T00:00:00Z&endTimestamp='${TODAY}'T00:00:00Z' \
> .gateway-${GWID}_stats.json
#${GET} \
# --header "$AUTH" ${URL}'/api/devices?limit=9999&applicationID=58'
\ No newline at end of file
# 'https://lns.campusiot.imag.fr/api/gateways/7276ff0039030724/stats?interval=day&startTimestamp=2021-02-09T00%3A00%3A00Z&endTimestamp=2021-03-09T00%3A00%3A00Z'
# https://lns.campusiot.imag.fr:443'/api/gateways/'7276ff0039030871'/stats?interval='day'&startTimestamp=$'2021-02-09'T00:00:00Z&endTimestamp='2021-03-09'T00:00:00Z'
\ No newline at end of file
......@@ -59,33 +59,20 @@ ${GET} \
--header "$AUTH" ${URL}'/api/gateways?limit=1000&offset=0' \
> .gateways.json
echo '<html><head><title>CampusIoT LNS :: Gateways</title></head><body style="font-family:verdana;"><h1>CampusIoT LNS :: Gateways</h1>' > .gateways.html
TODAY=$(date +"%Y-%m-%d")
echo "$TODAY"
echo '<p>generated at ' >> .gateways.html
date +"%Y-%m-%d %T %Z" >> .gateways.html
echo ' - ' >> .gateways.html
TZ=GMT date +"%Y-%m-%d %T %Z" >> .gateways.html
echo '</p>' >> .gateways.html
echo '<h2>Active gateways</h2>' >> .gateways.html
jq --raw-output -f gateways_to_html.jq .gateways.json | grep $TODAY >> .gateways.html
echo '<h2>Passive gateways</h2>' >> .gateways.html
jq --raw-output -f gateways_to_html.jq .gateways.json | grep -v $TODAY >> .gateways.html
echo '</body></html>' >> .gateways.html
#generates json files of gateways informations and gateways statistics.
GATEWAYS=$(jq --raw-output ".result | sort_by(.lastSeenAt, .id) | reverse [] | (.id)" .gateways.json)
GATEWAYS_LEN=$(jq --raw-output ".totalCount" .gateways.json)
for g in $GATEWAYS
do
echo "get details for $g"
./get_gateway.sh $TOKEN $g
./get_gateway_stats.sh $TOKEN $g $TODAY
done
./get_id_gatewaysChange.sh
echo "generate html (with sparkline)"
./gateways_to_html.sh $GATEWAYS_LEN $GATEWAYS $TODAY
echo "Passive Active Check"
# ./get_id_gatewaysChange.sh
\ No newline at end of file
#!/bin/bash
# Copyright (C) CampusIoT, - All Rights Reserved
# Written by CampusIoT Dev Team, 2016-2021
# ------------------------------------------------
# Get getaways
# ------------------------------------------------
# Parameters
if [[ $# -ne 1 ]] ; then
echo "Usage: $0 JWT"
exit 1
fi
TOKEN="$1"
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
#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"\""
${GET} \
--header "$AUTH" ${URL}'/api/gateways?limit=1000&offset=0' \
> .gateways.json
echo '<html><head><title>CampusIoT LNS :: Gateways</title></head><body style="font-family:verdana;"><h1>CampusIoT LNS :: Gateways</h1>' > .gateways.html
TODAY=$(date +"%Y-%m-%d")
echo "$TODAY"
echo '<p>generated at ' >> .gateways.html
date +"%Y-%m-%d %T %Z" >> .gateways.html
echo ' - ' >> .gateways.html
TZ=GMT date +"%Y-%m-%d %T %Z" >> .gateways.html
echo '</p>' >> .gateways.html
echo '<h2>Active gateways</h2>' >> .gateways.html
jq --raw-output -f gateways_to_html_v2.jq gateways_today.json | grep $TODAY >> .gateways.html
echo '<h2>Passive gateways</h2>' >> .gateways.html
echo "<div style=\"color: red\">" >> .gateways.html
jq --raw-output -f gateways_to_html_v2.jq gateways_today.json | grep -v $TODAY >> .gateways.html
echo "</div>" >> .gateways.html
echo '</body></html>' >> .gateways.html
GATEWAYS=$(jq --raw-output ".result | sort_by(.lastSeenAt, .id) | reverse [] | (.id)" .gateways.json)
for g in $GATEWAYS
do
echo "get details for $g"
./get_gateway.sh $TOKEN $g
done
This diff is collapsed.
This diff is collapsed.
{
"totalCount": "24",
"totalCount": "23",
"result": [
{
"id": "0000024b0805031a",
......@@ -89,10 +89,6 @@
"id": "0080e1ffff0153cc",
"lastState": "passive"
},
{
"id": "0080e1ffff015b18",
"lastState": "passive"
},
{
"id": "0080e1ffff015abf",
"lastState": "passive"
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="jQuery_Sparklines/jquery-1.js"></script>
<script type="text/javascript" src="jQuery_Sparklines/jquery.js"></script>
<script type="text/javascript">
$(function () {
/** This code runs when everything has been loaded on the page */
/* Inline sparklines take their values from the contents of the tag */
$('.inlinesparkline').sparkline();
});
</script>
\ 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
# Training Sparkline.
```
Envoyer un mail avec un résumé très précis . (Sparkline)
PB : envoyer par mail, possiblement pas possible avec du javascript. Alternative : Générer Sparkline, générer image et générer doc en svg.
```
TODO :
* Step1 : Produire des faux rapports (HTML) avec des éléments Sparkline. (entrainement utilisation de sparkline)
* Step2 : Générer image du rapport HTML en SVG
* Step3 : Produire les rapports HTML avec les véritables informations des gateways.
\ 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