Not able to retrive output of command via shell script/bigfic action script

(imported topic written by Darknight)

Hi All,

i have prepared a shell script and executing it on hp-ux endpoint through task:

#!/sbin/sh
mkdir -p "/var/opt/BESClient/__BESData/actionsite/__HardwareInfo/"
rm /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt
echo "Machine Serial Number:`getconf MACHINE_SERIAL`" >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt
echo "CPU_CHIP_TYPE:`getconf CPU_CHIP_TYPE`" >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt
echo "CPU VERSION:`getconf CPU_VERSION`" >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt
echo "HW_CPU_SUPP_BITS:`getconf HW_CPU_SUPP_BITS`" >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt
echo "logical processor:`print_manifest | perl -nle '/(\d+) logical processors/&&($x=$1);END{print "$x"}'`" >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt
echo "cores:`print_manifest | awk '/([[:digit:]]+[[:space:]])(core|cores)([[:space:]]+$|$|,)/{gsub(/,/,x);print $1}'| tail -1`" >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

if i run the script manually on server its giving below output which is expected out of it :

cat /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

Machine Serial Number:VM01328001

CPU_CHIP_TYPE:553649156

CPU VERSION:768

HW_CPU_SUPP_BITS:64

logical processor:16

cores:1

but whenever i try to include this script in task and run it as shell script it provides output as below :

cat /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

Machine Serial Number:VM01328001

CPU_CHIP_TYPE:553649156

CPU VERSION:768

HW_CPU_SUPP_BITS:64

logical processor:
cores:

Can someone help me in understanding why this is happening . Do i have to make any changes in my script and then run it via IEM.

Also additionally i can see the below highlighted text in pink colour on IEM console whenever i try to inlcude it in action script:

echo “logical processor:print_manifest | perl -nle '/(\d+) logical processors/&&($x=$1);END {print "$x"} '” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

echo “cores:print_manifest | awk '/([[:digit:]]+[[:space:]])(core|cores)([[:space:]]+$|$|,)/ {gsub(/,/,x);print $1} '| tail -1” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

i have also tried to run the above shell script as bigfix action script but results are same,below is the action script :

wait mkdir -p “__HardwareInfo/”

delete __appendfile

appendfile #!/sbin/sh

appendfile mkdir -p “/var/opt/BESClient/__BESData/actionsite/__HardwareInfo/”

appendfile rm /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

appendfile echo “Machine Serial Number:getconf MACHINE_SERIAL” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

appendfile echo “CPU_CHIP_TYPE:getconf CPU_CHIP_TYPE” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

appendfile echo “CPU VERSION:getconf CPU_VERSION” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

appendfile echo “HW_CPU_SUPP_BITS:getconf HW_CPU_SUPP_BITS” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

appendfile echo “logical processor:print_manifest | perl -nle '/(\d+) logical processors/&&($x=$1);END{{print "$x"}'” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

appendfile echo “cores:print_manifest | awk '/([[:digit:]]+[[:space:]])(core|cores)([[:space:]]+$|$|,)/{{gsub(/,/,x);print $1}'| tail -1” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

delete inventory.sh

copy __appendfile inventory.sh

wait chmod 555 inventory.sh

wait sh inventory.sh

(imported comment written by jgstew)

You may not need to actually run something to gather this data. Most of what you are looking for may be available using inspectors. See the following:

http://bigfix.me/analysis/details/2994630

http://bigfix.me/analysis/details/2994601

(imported comment written by Darknight)

thanks jgstew :slight_smile:

Using the relevance which you have created ,i can find out one of the property thats is : number of cores of cpus. I can see that the relevance output is matching with my command output.

But i have not found relevance to find out the number of logical processors of server (hp-ux).Could you please guide me in retriving this property using relevance.

(imported comment written by jgstew)

Number of CPUs
I believe is what you are looking for, but it is unclear from your statement of “number of logical processors”.

All from:
http://bigfix.me/analysis/details/2994630

the property
Number of CPUs
is the number of sockets or the number of physically separate CPUs.

the property
Number of Cores per CPU
is the number of cpu cores per package.

the property
Number of Cores of CPUs
is the equivalent of (
Number of CPUs
)*(
Number of Cores per CPU
) which is the total number of logical processor cores.

the property

of Threads per CPU

is the number of threads that can simultaneously execute per socket (CPU)

the property

of Threads Total

is equivalent to (
Number of CPUs
)*(

of Threads per CPU

) which is the total number of simultaneous threads total for the system.

In a single socket system, some of these values will be the same because the total is the same as the number per socket since there is only one socket.

(imported comment written by jgstew)

You can download the analysis from bigfix.me and import it into your BigFix console. Then see which of the properties seems to be reporting the number that you are looking for.

I think we are having a bit of a confusing of terms from “logical processors” to “number of cores”

To me, the hierarchy goes something like:

Sockets (Physical CPUs) -> Cores -> SimultaneousThreads (HyperThreading)

(imported comment written by jgstew)

Now that I think about it. I think you want

of Threads Total

(imported comment written by Darknight)

thanks jgstew…i got your point.

I have little confusion about the terms

of Threads Total

and logical processor

my requirement is to cpature the number of logical processor particular hp-ux server has and by command its posiible as hsown below :

print_manifest | more

System Hardware

Model:              ia64 hp Integrity Virtual Partition


Main Memory:        16377 MB


Processors:         1


    Intel(R)  Itanium(R)  Processor 9560 (2.53 GHz, 32 MB)


    8 cores, 16 logical processors per socket


    6.38 GT/s QPI, CPU version D0


           Active processor count:


           1 socket


           1 core


  
     1 logical processor (1 per socket)

i am able to get this using the command mentioned in my original post .

Could you please let me know whether

of Threads Total

and logicalk processors are one and the same…i am bit confused about it.

Also can you let me know why the below two commands are not giving output whenever i try to run it as shellscript in actionscript:

echo “logical processor:print_manifest | perl -nle '/(\d+) logical processors/&&($x=$1);END {print "$x"} '” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

echo “cores:print_manifest | awk '/([[:digit:]]+[[:space:]])(core|cores)([[:space:]]+$|$|,)/ {gsub(/,/,x);print $1} '| tail -1” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

this will help me to understand where i am going wrong while extracting the desired output through command :slight_smile:

(imported comment written by jgstew)

There is definitely some terminology confusion it looks like.

From here:

http://ark.intel.com/products/71699/Intel-Itanium-Processor-9560-32M-Cache-2_53-GHz

This processor from intel has 8 CPU cores per socket and 16 threads per socket. It seems your particular server of interest has 1 socket (1 physical CPU installed )

If what you expect to get is 16 for logical processors, then I think that you are looking for the same as

of Threads

If what you want for cores is 1, then you are looking for
Number of CPUs

The reason this is not working:

echo “logical processor:print_manifest | perl -nle '/(\d+) logical processors/&&($x=$1);END{print "$x"}'” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

echo “cores:print_manifest | awk '/([[:digit:]]+[[:space:]])(core|cores)([[:space:]]+$|$|,)/{gsub(/,/,x);print $1}'| tail -1” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

is due to the {} which in actionscript are interpreted as relevance substitution, which causes problems and need to be escaped.

The following should work properly:

echo “logical processor:print_manifest | perl -nle '/(\d+) logical processors/&&($x=$1);END{{print "$x"}'” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

echo “cores:print_manifest | awk '/([[:digit:]]+[[:space:]])(core|cores)([[:space:]]+$|$|,)/{{gsub(/,/,x);print $1}'| tail -1” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

I still think you can get this same information using inspectors without having to run this code to get this information. If you have not already imported the “Hardware Information (Universal) - CPU” analysis, I would recommend doing so to see what it gives you for all of your systems.

http://bigfix.me/analysis/details/2994630

(imported comment written by jgstew)

what version of the bigfix client is installed on this server?

The analysis requires version 8.2 or higher. I have updated the analysis to reflect this:
http://bigfix.me/analysis/details/2994635

(imported comment written by Darknight)

i am uinsg 9.0.649.0 version. i forgot to mention you that u have tried to use escape character using additional open brace {. But result is same.while writing a script on endpoint , IEM is writing the action script on server as expected that is pure unix format :

echo “logical processor:print_manifest | perl -nle '/(\d+) logical processors/&&($x=$1);END {print "$x"} '” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

echo “cores:print_manifest | awk '/([[:digit:]]+[[:space:]])(core|cores)([[:space:]]+$|$|,)/ {gsub(/,/,x);print $1} '| tail -1” >> /var/opt/BESClient/__BESData/actionsite/__HardwareInfo/inventory.txt

and if i execute the same script manually on the server using command line (sh ),everything is working fine.but via IEM there is no output against

logical processor:

cores:

(imported comment written by jgstew)

I’m not sure where the issue is, but I still feel that you should be able to get this same information from the CPUPACKAGE inspector, and it should work given your client version.

Have you tried this for “logical processors” ?

((thread
of
it*count
of

it
)
of
cpupackage)

(imported comment written by martinc)

One thing confusing here is that I see jgstew attempting to use an analysis to work on this issue and the omkar is using fixlets to output locally,but does not seem to be trying the analysis as suggested. Is there an issue with using just the analysis? If not, they I would strongly recommend you try out what jgstew is trying to recommend as it avoids 2 steps for collecting the data.

Omkar, when you run the script, are you running it as root (assuming that is what the bes daemon is running as). The reason I ask is I am wondering if it has the same environment as when you run it. Does it have access to perl and awk?

Have you tried executing with the following:

wait sh -c inventory.sh

or maybe to see if there is some output you could get

wait sh inventory.sh > /tmp/inventory.log 2>&1

But if you can try what jgstew recommends, that would still be the best for getting the data into IEM.

Martin