Plain directory file based data reporter
-
NOTE: replace
/tmpwith$env:TEMPfor Windows host. -
set up few directories and datafiles
echo 'host1' > /tmp/hosts1
mkdir /tmp/host1
touch /tmp/host1/data.txt
mvn testmvn spring-boot:run- create few host lists
/tmp/hosts1:
host1
host2
host3/tmp/hosts2:
host1
host3
host5/tmp/hosts3:
host6
host7- create data
for H in $(cat /tmp/hosts1) ; do D=/tmp/$H; mkdir $D; touch $D/data.txt; K=datakey; echo -e "$K: value for $H\n" > $D/data.txt ; doneor in Powershell:
cd $env:TEMP
mkdir host1,host2,host3
'host1','host2','host3' | foreach-object { ('dataKey: value for ' + $_) | out-file -literalpath "$_/data.txt" -encoding ascii}
remove-item 'hosts1' -force
'host1','host2','host3','host4' | foreach-object { $_ | out-file -literalpath 'hosts1' -append -encoding ascii}alternartively start with the hosts file that may have some structure:
$server_tag $hostname/$extra_server_info $additional_fields
iterate over items of inerest and mock up the data files:
$F='hosts2'
$K='datakey'
$V='value'
$T='server tag'
get-content $F | where-object {
$_ -match $T -and (-not ($_ -match '^#')) } |
foreach-object {
$fields = convertfrom-string $_;
$H = $fields.P2 -replace '/.*$', '';
write-output $H;
mkdir "${env:TEMP}/$H" -erroraction silentlycontinue;"${K}: ${V}" | out-file -literalpath "${env:TEMP}/$H/data.txt" -encoding ascii }- test
curl 'http://localhost:8080/data?name=hosts1&key=datakey' | jq '.'{
"host1": "value for host1",
"host3": "value for host3",
"host2": "value for host2"
}curl 'http://localhost:8080/data?name=hosts2&key=datakey' | jq '.'{
"host5": null,
"host1": "value for host1",
"host3": "value for host3"
}curl 'http://localhost:8080/data?name=hosts3&key=datakey' | jq '.'{
"host7": null,
"host6": null
}curl http://localhost:8080/data{}curl 'http://localhost:8080/typeddata?name=hosts1&key=dataKey' | jq '.'[
{
"hostname": "host1",
"key": "dataKey",
"value": "value for host1"
},
{
"hostname": "host2",
"key": "dataKey",
"value": "value for host2"
}
]curl 'http://localhost:8080/typeddata_v2?name=hosts1&key=dataKey' | jq '.'{
"host1": {
"key": "dataKey",
"value": "value for host1"
},
"host2": {
"key": "dataKey",
"value": "value for host2"
}
}In the commit cafa2c2deb6ed17a9baaab630b104851d40c48eb introduces the following error
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'example.service.ServerService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
The project copied to basic-dirscan-services, rollback of few latest commits pending.
