diff --git a/examples/linux/disk_info.yaml b/examples/linux/disk_info.yaml new file mode 100644 index 0000000..e90cb7f --- /dev/null +++ b/examples/linux/disk_info.yaml @@ -0,0 +1,13 @@ +--- +name: Use DF to get drive information in JSON. +groups: Placeholder +target_os: "Linux" +tasks: + - name: Get disk-info with df returning JSON. + command: > + df -Th -x overlay -x tmpfs -x devtmpfs | \ + awk 'NR==1 || $1 ~ ".+"{print $3, $4, $5, $7, $2}' | \ + awk 'NR>1 {printf "{\"size\":\"%s\",\"used\":\"%s\",\"available\":\"%s\",\"mount_point\":\"%s\",\"type\":\"%s\"},", $1, $2, $3, $4, $5}' | \ + sed '$ s/,$//' | \ + awk 'BEGIN {printf "["} {printf "%s", $0} END {printf "]"}' + exit \ No newline at end of file diff --git a/meshbook.py b/meshbook.py index d91ba20..ccf1c2b 100644 --- a/meshbook.py +++ b/meshbook.py @@ -224,7 +224,6 @@ async def gather_targets(meshbook: dict, group_list: dict[str, list[dict]], os_c if isinstance(pseudo_target, str): matched_devices = await process_device_or_group(pseudo_target, group_list, os_categories, target_os) target_list.extend(matched_devices) - else: console(text_color.yellow + "Please use devices (Notice the 'S') for multiple devices.", True) @@ -241,7 +240,8 @@ async def gather_targets(meshbook: dict, group_list: dict[str, list[dict]], os_c if isinstance(pseudo_target, str) and pseudo_target in group_list: matched_devices = await filter_targets(group_list[pseudo_target], os_categories, target_os) target_list.extend(matched_devices) - + if pseudo_target not in group_list: + console(text_color.yellow + "Targeted group not found on the MeshCentral server.", True) else: console(text_color.yellow + "Please use groups (Notice the 'S') for multiple groups.", True)