Operating System - HP-UX
1832691 Members
2439 Online
110043 Solutions
New Discussion

Passing environment variable to SWA

 
Raynald Boucher
Super Advisor

Passing environment variable to SWA

Hello all,

I'm new to SWA and trying to setup a process by which we can monitor multiple systems.
I'm currently attempting to pass a hostname to SWA using an environment variable so that the resulting output files can be uniquely identified (ex. _swa_analisys.xml).

Is there a way to do this other than writing a wrapper script that will invoke SWA with comand line options (ex. -x analisyz_file=${1}_swa_analisys.xml) where an environment variable or parameter can be actualized?

Here are my current results:

# grep SWA_HOST /etc/opt/swa/swa.conf
analysis_file = ${user_dir}/cache/${SWA_HOST}_swa_analysis.xml
html_report = ${user_dir}/report/${SWA_HOST}_swa_report.html
# export SWA_HOST=romulus
# echo $SWA_HOST
romulus
# var/opt/swa/cache/swa_inventory_3481069612.xml <

======= 10/17/08 10:32:47 ADT#Canada#Canada BEGIN anada Run "analyze" Step
(user=boucherr) (jobid=romulus)

NOTE: SWA_HOST is not set.
WARNING: Variable SWA_HOST Undefined
* Performing Analysis
NOTE: SWA_HOST is not set.
WARNING: Variable SWA_HOST Undefined

======= 10/17/08 10:33:21 ADT#Canada#Canada END anada Run "analyze" Step
succeeded with 2 warnings. (user=boucherr) (jobid=romulus)

NOTE: More information may be found in the Software Assistant logfile
"/var/opt/swa/swa.log".
[boucherr@romulus] /var/opt/swa/cache $ ll -tr
total 24496
-rw-r--r-- 1 root sys 10375067 Oct 7 16:53 swa_catalog.xml
-rw-r--r-- 1 root sys 675493 Oct 16 11:43 swa_inventory_3481069612.xml
-rw------- 1 root sys 72249 Oct 17 10:33 _swa_analysis.xml
[boucherr@romulus] /var/opt/swa/cache $

Thanks

RayB
2 REPLIES 2
Dennis Handly
Acclaimed Contributor

Re: Passing environment variable to SWA

This may fail if SWA communicates with a demon, one that has already been started and can't possibly see your new environment variables.

Also, if /etc/opt/swa/swa.conf isn't a shell script, it won't do the substitutions.

So your wrapper idea seem like the only solution.
Raynald Boucher
Super Advisor

Re: Passing environment variable to SWA

Yup,

I had thought that it would be permissable from references to ${user_dir} in the swa.conf file but it doesn't work so I developped a little script that works just file so far. Here it is if interested:

#!/usr/bin/ksh
#
# name swa_check.sh
#
# purpose To perform a security check on a given UNIX server
# and download required patches
#
# usage /usr/local/bin/swa_check.sh
#
# configuration See default configuration in /etc/opt/swa/swa.conf
# the -x options below override the configuration file
#
# history Oct 2008 new
#
#######################################################################

swa report -x catalog=/var/opt/swa/cache/swa_catalog.xml \
-x inventory_source=ssh://root@${1} \
-x analysis_file=/var/opt/swa/cache/${1}_swa_analysis.xml \
-x html_report=/var/opt/swa/report/${1}_swa_report.html \
-x download_cmd='/usr/bin/ssh swauser@dell curl'

swa get -t /var/opt/swa/cache/${1}_`date +%y%j`_depot \
-x analysis_file=/var/opt/swa/cache/${1}_swa_analysis.xml \
-x download_cmd='/usr/bin/ssh boucherr@stealthdell curl'
#