SlightlyLoony
Tera Contributor
Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
07-06-2009
01:25 PM
Have you noticed that some probes have commands with odd-looking "words" in them? For example, the MySQL - Configuration probe has a command cat ${filename}, and the Linux - Disk probe has a command sh ${file:hd.sh}. What's up with those dollar signs and squiggly braces?
Well, those are called replaceable parameters, and they're actually quite useful. Read on if you'd like to know more about them...
Probes support two kinds of replaceable parameters:
- Simple replaceable parameters: These are used to create the actual command that will be executed from a command pattern plus one or more values. In our example, the command pattern is cat ${filename}. The ${filename} part of this command pattern means "replace this with the value of the parameter named filename. For example, suppose the paramter filename had a value of /tmp/oranges.txt. In that case, the actual command executed by the MID server would be cat /tmp/oranges.txt. Any number of simple replaceable parameters may appear in a single command.
- Script replaceable parameters: These are slightly more complicated but very powerful feature. In our example (sh ${file:hd.sh}), note the file: that appears as the first thing inside the squiggly braces — this is what makes it a script replaceable parameter. The MID server takes the value of the named parameter (hd.sh in this case) and copies it to the /tmp directory on the target computer. Then it substitutes the complete path of this script (/tmp/hd.sh in our case) for the entire replaceable parameter to form the complete command (sh /tmp/hd.sh) that will execute on the target computer. After running this command, the MID server then deletes the script from the target computer. If you look at any probe that uses script replaceable parameters, you'll see that it has parameters defined to match the scripts named in thecommand. If you look at these parameters, you'll see that they are ordinary shell scripts. Generally these scripts are used when the commands that must be executed would be awkward or too lengthy on a single line.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.