mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-14 21:20:28 +01:00
bbf.diag: use JSON API instead of relying on hardcoded strings
This commit is contained in:
parent
eddef9c116
commit
8617886e6a
5 changed files with 48 additions and 29 deletions
|
|
@ -1,33 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
BBF_DIAG_SCRIPTS="/usr/share/bbfdm/bbf_diag"
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
case "$1" in
|
||||
list)
|
||||
# Open the JSON object
|
||||
output_json="{"
|
||||
|
||||
first_iteration=true
|
||||
json_init
|
||||
|
||||
for file in "${BBF_DIAG_SCRIPTS}"/*; do
|
||||
[ -f "${file}" ] || continue
|
||||
|
||||
file_output=$(sh "${file}" "$1")
|
||||
|
||||
# Add a comma for all iterations after the first one
|
||||
[ "$first_iteration" = true ] || output_json="${output_json},"
|
||||
first_iteration=false
|
||||
|
||||
# Concatenate the output to the result
|
||||
output_json="${output_json}${file_output}"
|
||||
. "${file}" "${1}"
|
||||
done
|
||||
|
||||
# Close the JSON object
|
||||
output_json="${output_json}}"
|
||||
|
||||
# Return the concatenated JSON output
|
||||
echo "$output_json"
|
||||
json_dump
|
||||
;;
|
||||
call)
|
||||
# Read the arguments
|
||||
|
|
|
|||
|
|
@ -4,11 +4,19 @@
|
|||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
. "$(dirname "${0}")/../bbf_api"
|
||||
. /usr/share/bbfdm/bbf_api
|
||||
|
||||
ipping_list() {
|
||||
echo '"ipping" : { "host": "str", "iface": "str", "ip_proto": "str", "nbr_of_rep": "str", "timeout": "str", "data_size": "str", "dscp": "str", "proto": "str" }'
|
||||
json_add_object "ipping"
|
||||
json_add_string "host" "str"
|
||||
json_add_string "iface" "str"
|
||||
json_add_string "ip_proto" "str"
|
||||
json_add_string "nbr_of_rep" "str"
|
||||
json_add_string "timeout" "str"
|
||||
json_add_string "data_size" "str"
|
||||
json_add_string "dscp" "str"
|
||||
json_add_string "proto" "str"
|
||||
json_close_object
|
||||
}
|
||||
|
||||
ipping_error() {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
. "$(dirname "${0}")/../bbf_api"
|
||||
. /usr/share/bbfdm/bbf_api
|
||||
|
||||
get_nslookup_log_file() {
|
||||
IDX=1
|
||||
|
|
@ -19,7 +18,14 @@ get_nslookup_log_file() {
|
|||
}
|
||||
|
||||
nslookup_list() {
|
||||
echo '"nslookup" : { "host": "str", "dns_serevr": "str", "iface": "str", "nbr_of_rep": "str", "timeout": "str", "proto": "str" }'
|
||||
json_add_object "nslookup"
|
||||
json_add_string "host" "str"
|
||||
json_add_string "dns_serevr" "str"
|
||||
json_add_string "iface" "str"
|
||||
json_add_string "nbr_of_rep" "str"
|
||||
json_add_string "timeout" "str"
|
||||
json_add_string "proto" "str"
|
||||
json_close_object
|
||||
}
|
||||
|
||||
nslookup_error() {
|
||||
|
|
|
|||
|
|
@ -3,11 +3,19 @@
|
|||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
. "$(dirname "${0}")/../bbf_api"
|
||||
. /usr/share/bbfdm/bbf_api
|
||||
|
||||
serverselection_list() {
|
||||
echo '"serverselection" : { "hostlist": "str", "port":"str", "iface": "str", "ip_proto": "str", "nbr_of_rep": "str", "timeout": "str", "protocol_used": "str", "proto": "str" }'
|
||||
json_add_object "serverselection"
|
||||
json_add_string "hostlist" "str"
|
||||
json_add_string "port" "str"
|
||||
json_add_string "iface" "str"
|
||||
json_add_string "ip_proto" "str"
|
||||
json_add_string "nbr_of_rep" "str"
|
||||
json_add_string "timeout" "str"
|
||||
json_add_string "protocol_used" "str"
|
||||
json_add_string "proto" "str"
|
||||
json_close_object
|
||||
}
|
||||
|
||||
serverselection_error() {
|
||||
|
|
|
|||
|
|
@ -3,11 +3,21 @@
|
|||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
. "$(dirname "${0}")/../bbf_api"
|
||||
. /usr/share/bbfdm/bbf_api
|
||||
|
||||
udpecho_list() {
|
||||
echo '"udpecho" : { "host": "str", "port":"str", "iface": "str", "ip_proto": "str", "nbr_of_rep": "str", "timeout": "str", "data_size": "str", "dscp": "str", "inter_trans_time":"str", "proto": "str" }'
|
||||
json_add_object "udpecho"
|
||||
json_add_string "host" "str"
|
||||
json_add_string "port" "str"
|
||||
json_add_string "iface" "str"
|
||||
json_add_string "ip_proto" "str"
|
||||
json_add_string "nbr_of_rep" "str"
|
||||
json_add_string "timeout" "str"
|
||||
json_add_string "data_size" "str"
|
||||
json_add_string "dscp" "str"
|
||||
json_add_string "inter_trans_time" "str"
|
||||
json_add_string "proto" "str"
|
||||
json_close_object
|
||||
}
|
||||
|
||||
udpecho_error() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue