3 # Parse the object names out of Nagios' xdata/xodtemplate.h, and
4 # convert them to their definition format.
6 # Operates on whatever file you give it, like the other utilities.
10 EXIT_INPUT_FILE_DOESNT_EXIST
=2
13 echo "Usage: $0 <input_file>"
20 if [ ! -f "$INFILE" ]; then
21 echo "Error: input file $INFILE doesn't exist."
22 exit $EXIT_INPUT_FILE_DOESNT_EXIST
25 # Grep grabs all of the "#define XODTEMPLATE_..." lines, except for
26 # XODTEMPLATE_NONE, which ain't real.
28 # Sed removes the "XODTEMPLATE_" prefixes, then tr lowercases everything.
30 # Oh and we sort everything, add "define ", and surround each line with
31 # quotes, because we can get away with it here.
33 grep --only-matching '[[:space:]]XODTEMPLATE_[[:alnum:]_]\{1,\}' "$INFILE" \
34 | grep -v 'XODTEMPLATE_NONE' \
35 | sed 's/ XODTEMPLATE_//g' \
36 | tr '[A-Z]' '[a-z]' \
38 | sed -e 's/^/\"define /g' -e 's/$/\"/g'