adding 1 user with htpasswd in 2 different servers using ssh connection - http

i'm working with apache camel and i want to add one user in two differents servers.And i want to test if ssh.redundancy=true.This is my code :
<simple ${headers.op} == 1</simple>
<doTry id="try-cmd-httpd">
<setBody id="httpd.cmd.htpasswd">
<simple>htpasswd -b /etc/httpd/passwords ${header.login} ${header.passwd} {{httpd.io_redir}}</simple>
</setBody>
**<to id="to_exec_htpaswd" uri="ssh://{{ssh.user}}:{{ssh.passwd}}#{{ssh.host}}:{{ssh.port}}"/>**
<log id="htpasswdResp_log" message="response: ${body}"/>
**<to id="to_exec_htpaswd2" uri="ssh://{{ssh.user}}:{{ssh.passwd}}#{{ssh.host2}}:{{ssh.port}}"/>**
<log id="htpasswdResp_log2" message="response: ${body}"/> ```

I found the solution.Just add a choice for the parametre ssh.redundancy and invoque for the second time.
<when id="redundancytrue">
<simple>{{ssh.redundancy}} == "true"</simple>
<setBody id="httpd.cmd.htpasswd">
<simple>htpasswd -b /etc/httpd/passwords ${header.login} ${header.passwd} {{httpd.io_redir}}</simple>
</setBody>
<to id="to_exec_htpaswd2" uri="ssh://{{ssh.user}}:{{ssh.passwd}}#{{ssh.host2}}:{{ssh.port}}"/>
</when>
</choice>```

Related

How to retrieve Itinerary remarks with GetReservationsRQ Api?

Running the command I¥ command returns:
2 AA1579X 16SEP 5 DFWORD HF1 0625 0846 /DCBA*SDAZXT /E
I have successfully sent a request using GetReservationRQ. Asking for the remarks sections but I am getting the result above which I would expect. (I assumed this is the right section and have tried Itinerary too, see below)
<GetReservationRQ version="1.1.0" xmlns="http://services.sabre.com/sp/updatereservation/v1_1">
<Profile>
<UniqueID id="......."/>
</Profile>
<SubjectAreas>
<SubjectArea>REMARKS</SubjectArea>
</SubjectAreas>
<ReturnOptions>
<ViewName>Default</ViewName>
<ResponseFormat>STL</ResponseFormat>
</ReturnOptions>
</GetReservationRQ>
Which returns 2 remarks as part of the response:
<Remarks>
<Remark id="44" index="1" type="HS">
<RemarkLines>
<RemarkLine>
<Text>POSSIBLE DUPE BOOKING. SEE PNR JZXWEI JBVFYC HUSTLM</Text>
</RemarkLine>
</RemarkLines>
</Remark>
<Remark id="45" index="2" type="HS">
<RemarkLines>
<RemarkLine>
<Text>POSSIBLE DUPE BOOKING. SEE PNR KDCFKD KQLLXF</Text>
</RemarkLine>
</RemarkLines>
</Remark>
</Remarks>
However as you can see they are not the same remark as when I run the command I¥. What am I doing wrong?
Here are links to the sabre documentation:
https://developer.sabre.com/docs/soap_apis/management/itinerary/Retrieve_Itinerary/help_doc?page=get-reservation-request-and-response-structure
Which says:
REMARKS Allows to display remark information (supported types: REG, HD, HS, CLIADR, DELADR, INVOICE, ITINERARY, INTERFACE, CODED_A, PRTONTKT, CORPORATE, FOP, QQ, FILLER, ITINSEGASSOC)

xmlstarlet "does not work" for XMLs with namespaces

I'm using media info, to get some xml information about movie:
mediainfo --Output=XML Krtek\ a\ buldozer-jdvwqZUEbhc.mkv | xmlstarlet format
which output is:
<?xml version="1.0" encoding="UTF-8"?>
<MediaInfo xmlns="https://mediaarea.net/mediainfo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://mediaarea.net/mediainfo https://mediaarea.net/mediainfo/mediainfo_2_0.xsd" version="2.0">
<creatingLibrary version="18.03" url="https://mediaarea.net/MediaInfo">MediaInfoLib</creatingLibrary>
<media ref="Krtek a buldozer-jdvwqZUEbhc.mkv">
<track type="General">
<UniqueID>101120522676894244607292274887483611459</UniqueID>
<VideoCount>1</VideoCount>
<AudioCount>1</AudioCount>
<FileExtension>mkv</FileExtension>
<Format>Matroska</Format>
<Format_Version>4</Format_Version>
<FileSize>60132643</FileSize>
<Duration>374.101</Duration>
<OverallBitRate>1285912</OverallBitRate>
<FrameRate>25.000</FrameRate>
<FrameCount>9352</FrameCount>
<IsStreamable>Yes</IsStreamable>
<File_Modified_Date>UTC 2018-10-15 07:09:29</File_Modified_Date>
<File_Modified_Date_Local>2018-10-15 09:09:29</File_Modified_Date_Local>
<Encoded_Application>Lavf57.71.100</Encoded_Application>
<Encoded_Library>Lavf57.71.100</Encoded_Library>
<extra>
<ErrorDetectionType>Per level 1</ErrorDetectionType>
</extra>
</track>
<track type="Video">
<StreamOrder>0</StreamOrder>
<ID>1</ID>
<UniqueID>1</UniqueID>
<Format>AVC</Format>
<Format_Profile>High</Format_Profile>
<Format_Level>4</Format_Level>
<Format_Settings_CABAC>Yes</Format_Settings_CABAC>
<Format_Settings_RefFrames>3</Format_Settings_RefFrames>
<CodecID>V_MPEG4/ISO/AVC</CodecID>
<Duration>374.080000000</Duration>
<Width>1920</Width>
<Height>1080</Height>
<Stored_Height>1088</Stored_Height>
<Sampled_Width>1920</Sampled_Width>
<Sampled_Height>1080</Sampled_Height>
<PixelAspectRatio>1.000</PixelAspectRatio>
<DisplayAspectRatio>1.778</DisplayAspectRatio>
<FrameRate_Mode>CFR</FrameRate_Mode>
<FrameRate_Mode_Original>VFR</FrameRate_Mode_Original>
<FrameRate>25.000</FrameRate>
<FrameCount>9352</FrameCount>
<ColorSpace>YUV</ColorSpace>
<ChromaSubsampling>4:2:0</ChromaSubsampling>
<BitDepth>8</BitDepth>
<ScanType>Progressive</ScanType>
<Delay>0.000</Delay>
<Default>Yes</Default>
<Forced>No</Forced>
<colour_range>Limited</colour_range>
<colour_description_present>Yes</colour_description_present>
<colour_primaries>BT.709</colour_primaries>
<transfer_characteristics>BT.709</transfer_characteristics>
<matrix_coefficients>BT.709</matrix_coefficients>
</track>
<track type="Audio">
<StreamOrder>1</StreamOrder>
<ID>2</ID>
<UniqueID>2</UniqueID>
<Format>Opus</Format>
<CodecID>A_OPUS</CodecID>
<Duration>374.101000000</Duration>
<Channels>2</Channels>
<ChannelPositions>Front: L R</ChannelPositions>
<SamplingRate>48000</SamplingRate>
<SamplingCount>17956848</SamplingCount>
<BitDepth>32</BitDepth>
<Compression_Mode>Lossy</Compression_Mode>
<Delay>0.000</Delay>
<Delay_Source>Container</Delay_Source>
<Language>en</Language>
<Default>Yes</Default>
<Forced>No</Forced>
</track>
</media>
</MediaInfo>
now say that I want to get all IDs:
... | xmlstarlet sel -t -v "//ID"
and nothing is printed. What? Why? Well it turned out, that if i remove all parameters from tag on second line, the same selection command will work. Now I undestand, that xmlstarlet (probably) works just fine, I'm just missing some magic flag or syntax, so that it can process xmls with defined namespaces. Can someone advice?
You need to use the namespace with -N option, and use it in the query like <namespace>:<xpath>:
... | xmlstarlet sel -N n="https://mediaarea.net/mediainfo" -t -v "//n:ID"
From the help page:
-N <name>=<value>
- predefine namespaces (name without 'xmlns:')
ex: xsql=urn:oracle-xsql
Multiple -N options are allowed.

How to send custom metric from collectd (stackdriver agent) to stackdriver

I can't send data to strackdriver. It's simple example.
I'm using syntax what I found in example for collectd.
Stackdriver documentation don't have info about how to send custom data from exec module.
What am I doing wrong?
This is collectd.conf
LoadPlugin exec
<Plugin "exec">
Exec "apache" "/etc/stackdriver/collectd.d/dir.sh"
</Plugin>
This is dir.sh
#!/bin/bash
FOLDER="/var/www/"
while true; do
DU=$(du -shm ${FOLDER} | awk '{print $1}')
echo "PUTVAL \"projects/project_name/custom.googleapis.com/folder/completesolar\" interval=60 N:${DU}"
sleep 60
done
Script output
$/etc/stackdriver/collectd.d/dir.sh
PUTVAL "projects/project_name/custom.googleapis.com/folder/completesolar" interval:60 N:1155
I enabled debug mode and found this error:
[2018-09-21 00:45:55] utils_cmd_putval: handle_putval (fh = 0x3e71d8f040, buffer = PUTVAL "projects/project_name/custom.googleapis.com/folder/completesolar" interval=60 N:1155);
[2018-09-21 00:45:55] No such dataset registered: custom.googleapis.com/folder/completesolar
I created this metric and found it in stackdriver console:
http://joxi.ru/a2XlPGvi1VzJL2
This is json for creating my metric:
{
"name": "projects/project_name/metricDescriptors/custom.googleapis.com/folder/completesolar",
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"unit": "By",
"description": "Folder bytes used",
"displayName": "Folder usage",
"type": "custom.googleapis.com/folder/completesolar",
"metadata": {
"launchStage": "GA",
"samplePeriod": "60s",
"ingestDelay": "0s"
}
}
This should be work.
/etc/stackdriver/collectd.d/dir.conf
LoadPlugin exec
<Plugin "exec">
Exec "apache" "/path/to/dir.sh"
</Plugin>
LoadPlugin target_set
PreCacheChain "PreCache"
<Chain "PreCache">
<Rule "dir">
<Match regex>
Plugin "^exec$"
PluginInstance "^dir$"
</Match>
<Target "set">
MetaData "stackdriver_metric_type" "custom.googleapis.com/folder/completesolar"
# MetaData "stackdriver_metric_type" "custom.googleapis.com/%{plugin_instance}/%{type_instance}"
# MetaData "label:name" "dir usage"
</Target>
</Rule>
</Chain>
/path/to/dir.sh
#!/bin/bash
INTERVAL="$COLLECTD_INTERVAL"
HOSTNAME="$COLLECTD_HOSTNAME"
FOLDER="/var/www/"
while true; do
DU=$(du -sm ${FOLDER} | awk '{print $1}')
# https://collectd.org/documentation/manpages/collectd-exec.5.shtml
# PUTVAL Identifier [OptionList] Valuelist
# Identifier: <host>/<plugin>-<plugin_instance>/<type>-<type_instance>
# Type: See /opt/stackdriver/collectd/share/collectd/types.db
echo "PUTVAL ${HOSTNAME}/exec-dir/gauge-usage/ interval=${INTERVAL} N:${DU}"
sleep "${INTERVAL}"
done
See below if you want to (pre) create or delete a metric.
https://cloud.google.com/monitoring/custom-metrics/creating-metrics
Looks like you are following this guide to ingest exec metrics. I think the rewrite rules did not work so the metric ends up being ingested though a regular agent metrics path, which rejects unrecognized metrics. You might need to modify the metadata for your metric by using filter chain . I would suggest you to revisit the troubleshooting guide.

Tsung how to get the controller id

I know that it is possible to set a id to the controller in tsung using the flag -i, i.e, tsung start -i ID. My question is It is possible retrieve that id in the tsung.xml?
e.g.
<setdynvars sourcetype="eval"
code='fun({Pid,DynVars})->
case string:tokens(atom_to_list(node()),"#") of
["tsung_controller_"++ID,_] -> list_to_integer(ID);
_ -> 0 end end.'>
<var name="controller_id" />
</setdynvars>

Spring Webflow - How to Get List of FLOW IDs

What is the best way to get the full list of FLOW IDs generated by Spring Webflow?
Here is my configuration:
<webflow:flow-registry id="flowRegistry"
flow-builder-services="flowBuilderServices"
base-path="/WEB-INF/pageFlows">
<webflow:flow-location-pattern value="/**/*-flow.xml"/>
</webflow:flow-registry>
[UPDATE 1] I should clarify that I want to do this in Java code, not by inspecting my configuration.
[UPDATE 2] answer: requestContext.getActiveFlow().getApplicationContext()
List of flow ids can be identified by the way they are defined in flow-registry. By default, flows will be assigned registry identifiers equal to their filenames minus the file extension, unless a registry base path is defined.
Let me explain this with examples:
Scenario 1:
flow-location and base-path is not specified:
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location path="/WEB-INF/pageFlows/example.xml" />
</webflow:flow-registry>
Flow id: example
Scenario 2:
flow-location-pattern and base-path is not specified :
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location-pattern value="/WEB-INF/pageFlows/**/*-flow.xml"/>
</webflow:flow-registry>
If you have flows like /WEB-INF/pageFlows/example1-flow.xml, /WEB-INF/pageFlows/example2-flow.xml, flow ids are: example1-flow, example2-flow respectively.
Scenario 3:
Your own id is specified:
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location path="/WEB-INF/pageFlows/example.xml" id="myExampleId" />
</webflow:flow-registry>
Flow id: myExampleId
Scenario 4:
base-path is specified:
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
<webflow:flow-location path="/pageFlows/example.xml" />
</webflow:flow-registry>
Flows will now be assigned registry identifiers equal to the the path segment between their base path and file name.
Flow id: pageFlows
Scenario 5:
flow-location-pattern and base-path is specified:
<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
<webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>
Flows will now be assigned registry identifiers equal to the the path segment between their base path and file name.
So if you have flows located in /pageFlows1/example1, /pageFlows2/example2 directories within WEB-INF, flow ids are: pageFlows1, pageFlows2 respectively.
EDIT :
To get flow ids programmatically:
Assuming your flow controller and flowexecutor definitions as below in webflow-config xml file:
<bean name="flowController" class="org.springframework.webflow.executor.mvc.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
//flowRegistry is alredy mentioned in your question
<flow:executor id="flowExecutor" registry-ref="flowRegistry">
<flow:repository type="continuation" max-conversations="1" max-continuations="30" />
</flow:executor>
You can retrieve flow definition ids registered as below:
(I am calling this from a Controller which extends AbstractController, thats why you see getServletContext() method)
ApplicationContext context =
(ApplicationContext)getServletContext().getAttribute(
DispatcherServlet.SERVLET_CONTEXT_PREFIX + "yourWebContextName");
FlowController controller = (FlowController)context.getBean("flowController");
FlowExecutorImpl flowExecutorImpl = (FlowExecutorImpl)controller.getFlowExecutor();
FlowDefinitionRegistryImpl flowDefinitionRegistryImpl = (FlowDefinitionRegistryImpl)flowExecutorImpl.getDefinitionLocator();
//Assuming you have log configured
log.info("Registered Flow Ids are:"+flowDefinitionRegistryImpl.getFlowDefinitionIds());
FlowController has access to FlowExecutor(initial point of entry for webflow). FlowExecutor has access to flowDefinitionRegistry where all flows are registered before being served to requests.
Hope this helps.

Resources