[CentOS] ssh remote execute awk problem

Thu Mar 17 14:43:46 UTC 2011
m.roth at 5-cent.us <m.roth at 5-cent.us>

Les Mikesell wrote:
> On 3/17/2011 8:31 AM, Nico Kadel-Garcia wrote:
>>
>>> Quote the whole command and backslash the command quotes...
>>> ssh root at localhost "awk '/processor/{count[\"proc\"]++}; END{print
>>> count[\"proc\"] } ' /proc/cpuinfo"
>>
>> Or do the processing locally and stay away from proc nuttiness,
>> without mucking with ssh and awk.
>>
>>       grep ^processor /proc/cpuinfo | wc -l
>>
>> Or:
>>
>>       ssh -l $TARGETUSER $TARGETHOST "[ -e /proc/cpuinfo ] -a grep
>> ^processor | wc -l"
>
> Or, more extremely - if you are doing much of this kind of remote
> inventory checking, you might consider running ocsinventory-ng with
> agents on the nodes.

Yes. We use ocsinventory here. Warning: there are a few systems that
ocsinventory, or at least the version we put on last year, would literally
crash or hang the system.

           mark