File tree Expand file tree Collapse file tree 10 files changed +553
-0
lines changed
Expand file tree Collapse file tree 10 files changed +553
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ OUTPUT_DIR=" "
5+ TEDGE_CONFIG_DIR=${TEDGE_CONFIG_DIR:-/ etc/ tedge}
6+ COMMAND=" "
7+
8+ # Parse arguments
9+ while [ $# -gt 0 ]; do
10+ case " $1 " in
11+ --output-dir)
12+ OUTPUT_DIR=" $2 "
13+ shift 2
14+ ;;
15+ --config-dir)
16+ TEDGE_CONFIG_DIR=" $2 "
17+ shift 2
18+ ;;
19+ collect)
20+ COMMAND=" collect"
21+ shift
22+ ;;
23+ * )
24+ shift
25+ ;;
26+ esac
27+ done
28+
29+ # Check if the output directory exists
30+ if [ -n " $OUTPUT_DIR " ] && [ ! -d " $OUTPUT_DIR " ]; then
31+ echo " Error: Output directory does not exist: $OUTPUT_DIR " >&2
32+ exit 1
33+ fi
34+
35+ # Collect logs for a given service
36+ collect_logs () {
37+ SERVICE=" $1 "
38+ if command -V journalctl > /dev/null 2>&1 ; then
39+ journalctl -u " $SERVICE " -n 1000 --no-pager > " $OUTPUT_DIR /${SERVICE} .log" 2>&1 || :
40+ fi
41+ }
42+
43+ collect () {
44+ # tedge-agent
45+ collect_logs " tedge-agent"
46+
47+ # Collect logs for each mapper
48+ CLOUDS=" c8y az aws"
49+ for cloud in $CLOUDS ; do
50+ if tedge config get " ${cloud} .url" > /dev/null 2>&1 ; then
51+ collect_logs " tedge-mapper-${cloud} "
52+ fi
53+ done
54+
55+ # Collectd mapper log
56+ if systemctl list-unit-files tedge-mapper-collectd.service > /dev/null 2>&1 ; then
57+ collect_logs tedge-mapper-collectd
58+ fi
59+
60+ # Copy tedge.toml
61+ cp " $TEDGE_CONFIG_DIR " /tedge.toml " $OUTPUT_DIR " /tedge.toml
62+
63+ # tedge config list
64+ tedge config list --all > " $OUTPUT_DIR " /tedge-config-list.log
65+ }
66+
67+ # Execute the specified command
68+ case " $COMMAND " in
69+ collect)
70+ collect
71+ ;;
72+ * )
73+ echo " Unknown command" >&2
74+ exit 1
75+ ;;
76+ esac
77+
78+ exit 0
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ COMMAND=" "
5+
6+ # Parse arguments
7+ while [ $# -gt 0 ]; do
8+ case " $1 " in
9+ collect)
10+ COMMAND=" collect"
11+ shift
12+ ;;
13+ * )
14+ shift
15+ ;;
16+ esac
17+ done
18+
19+ collect () {
20+ if [ -f /etc/os-release ]; then
21+ echo " /etc/os-release"
22+ cat /etc/os-release
23+ fi
24+
25+ echo " system information"
26+ uname -a
27+ }
28+
29+
30+ case " $COMMAND " in
31+ collect)
32+ collect
33+ ;;
34+ * )
35+ echo " Unknown command" >&2
36+ exit 1
37+ ;;
38+ esac
39+
40+ exit 0
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ OUTPUT_DIR=" "
5+ COMMAND=" "
6+
7+ # Parse arguments
8+ while [ $# -gt 0 ]; do
9+ case " $1 " in
10+ --output-dir)
11+ OUTPUT_DIR=" $2 "
12+ shift 2
13+ ;;
14+ collect)
15+ COMMAND=" collect"
16+ shift
17+ ;;
18+ * )
19+ shift
20+ ;;
21+ esac
22+ done
23+
24+ # Check if the output directory exists
25+ if [ -n " $OUTPUT_DIR " ] && [ ! -d " $OUTPUT_DIR " ]; then
26+ echo " Error: Output directory does not exist: $OUTPUT_DIR " >&2
27+ exit 1
28+ fi
29+
30+
31+ collect () {
32+ if command -V tedge > /dev/null 2>&1 ; then
33+ echo " tedge mqtt sub '#' --duration 5s" > " $OUTPUT_DIR " /tedge-mqtt-sub.log 2>&1
34+ tedge mqtt sub ' #' --duration 5s >> " $OUTPUT_DIR " /tedge-mqtt-sub.log 2>&1
35+ echo " tedge mqtt sub '#' --duration 1s --retained-only" > " $OUTPUT_DIR " /tedge-mqtt-sub-retained-only.log 2>&1
36+ tedge mqtt sub ' #' --duration 1s --retained-only >> " $OUTPUT_DIR " /tedge-mqtt-sub-retained-only.log 2>&1
37+ fi
38+ }
39+
40+ case " $COMMAND " in
41+ collect)
42+ collect
43+ ;;
44+ * )
45+ echo " Unknown command" >&2
46+ exit 1
47+ ;;
48+ esac
49+
50+ exit 0
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ OUTPUT_DIR=" "
5+ COMMAND=" "
6+ LOGS_PATH=" $( tedge config get logs.path) "
7+
8+ # Parse arguments
9+ while [ $# -gt 0 ]; do
10+ case " $1 " in
11+ --output-dir)
12+ OUTPUT_DIR=" $2 "
13+ shift 2
14+ ;;
15+ collect)
16+ COMMAND=" collect"
17+ shift
18+ ;;
19+ * )
20+ shift
21+ ;;
22+ esac
23+ done
24+
25+ # Check if the output directory exists
26+ if [ -n " $OUTPUT_DIR " ] && [ ! -d " $OUTPUT_DIR " ]; then
27+ echo " Error: Output directory does not exist: $OUTPUT_DIR " >&2
28+ exit 1
29+ fi
30+
31+
32+ collect () {
33+ if [ -d " $LOGS_PATH " /agent ]; then
34+ for file in " $LOGS_PATH " /agent/* ; do
35+ cp " $file " " $OUTPUT_DIR " /
36+ done
37+ else
38+ echo " ${LOGS_PATH} not found" >&2
39+ fi
40+ }
41+
42+
43+ case " $COMMAND " in
44+ collect)
45+ collect
46+ ;;
47+ * )
48+ echo " Unknown command" >&2
49+ exit 1
50+ ;;
51+ esac
52+
53+ exit 0
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ COMMAND=" "
5+
6+ # Parse arguments
7+ while [ $# -gt 0 ]; do
8+ case " $1 " in
9+ collect)
10+ COMMAND=" collect"
11+ shift
12+ ;;
13+ * )
14+ shift
15+ ;;
16+ esac
17+ done
18+
19+ collect () {
20+ if command -V tedge > /dev/null 2>&1 ; then
21+ echo " tedge http get /te/v1/entities"
22+ if command -V jq > /dev/null 2>&1 ; then
23+ tedge http get /te/v1/entities | jq
24+ else
25+ tedge http get /te/v1/entities
26+ fi
27+ fi
28+ }
29+
30+ case " $COMMAND " in
31+ collect)
32+ collect
33+ ;;
34+ * )
35+ echo " Unknown command" >&2
36+ exit 1
37+ ;;
38+ esac
39+
40+ exit 0
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ OUTPUT_DIR=" "
5+ TEDGE_CONFIG_DIR=${TEDGE_CONFIG_DIR:-/ etc/ tedge}
6+ COMMAND=" "
7+
8+ # Parse arguments
9+ while [ $# -gt 0 ]; do
10+ case " $1 " in
11+ --output-dir)
12+ OUTPUT_DIR=" $2 "
13+ shift 2
14+ ;;
15+ --config-dir)
16+ TEDGE_CONFIG_DIR=" $2 "
17+ shift 2
18+ ;;
19+ collect)
20+ COMMAND=" collect"
21+ shift
22+ ;;
23+ * )
24+ shift
25+ ;;
26+ esac
27+ done
28+
29+ # Check if the output directory exists
30+ if [ -n " $OUTPUT_DIR " ] && [ ! -d " $OUTPUT_DIR " ]; then
31+ echo " Error: Output directory does not exist: $OUTPUT_DIR " >&2
32+ exit 1
33+ fi
34+
35+ entity_store () {
36+ if [ -f " $TEDGE_CONFIG_DIR " /.agent/entity_store.jsonl ]; then
37+ cp " $TEDGE_CONFIG_DIR " /.agent/entity_store.jsonl " $OUTPUT_DIR " /
38+ elif [ -f " $TEDGE_CONFIG_DIR " /.tedge-mapper-c8y/entity_store.jsonl ]; then
39+ cp " $TEDGE_CONFIG_DIR " /.tedge-mapper-c8y/entity_store.jsonl " $OUTPUT_DIR " /
40+ else
41+ echo " entity_store.jsonl not found" >&2
42+ fi
43+ }
44+
45+ collect () {
46+ entity_store
47+ }
48+
49+ case " $COMMAND " in
50+ collect)
51+ collect
52+ ;;
53+ * )
54+ echo " Unknown command" >&2
55+ exit 1
56+ ;;
57+ esac
58+
59+ exit 0
You can’t perform that action at this time.
0 commit comments