Shell Script Problem

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
jromariz
Posts: 264
Joined: Wed Apr 03, 2002 6:00 pm
Location: Brasil

Post by jromariz »

Alex,

Just sent you the e-mail.

Regards,


Jromariz.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

File contains non-printable characters because "top -n 1" uses escape secuences.
Also do not use ":%" because "99:%" is not correct reply, it should be "99 %" (space, not colon).

Recommendations:
1) use "-b" option for top command
2) use " %" as suffix, not ":%"
2) do not use CPU variable in the script

E.g. this script works fine on our Linux system

Code: Select all

#!/bin/sh
top -b -n 1 | grep "Cpu(s)" | awk -F" " '{ printf("%s\n",$8) }' | awk -F"%" '{ printf("scriptres:Ok:%d\n",100-$1) }'
Regards
Alex
jromariz
Posts: 264
Joined: Wed Apr 03, 2002 6:00 pm
Location: Brasil

Post by jromariz »

Alex,


It really worked now :D ! Thanks a lot for helping!!


Regards,


Jromariz.
jromariz
Posts: 264
Joined: Wed Apr 03, 2002 6:00 pm
Location: Brasil

Post by jromariz »

Alex,

The script is working but I notice a strange behavior. The values of CPU usage that are logged are different from the ones the script is returning, at least the ones returned by "Let´s try" option of Script Manager. I´ve compared the values from the "Let´s try" to the one´s of top on the machine and looks correct, but the ones been logges are a lot different.

Any idea?

Jromariz.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I have created script for my system, you should check it and accommodate for your system. May be you have different version of top utility that displays result in different format

Regards
Alex
jromariz
Posts: 264
Joined: Wed Apr 03, 2002 6:00 pm
Location: Brasil

Post by jromariz »

Alex,

This problem is solved. Now I´m facing another one. I´m trying to run a perl script using hostmon. The script runs normally and replies are correct if I run it from DOS prompt or from a remote agent. When I run it using hostmon I get "Script started, no results received".

Any ideas?


Regards.
jromariz
Posts: 264
Joined: Wed Apr 03, 2002 6:00 pm
Location: Brasil

Post by jromariz »

Alex,


Just found the problem. I was not using the "cmd /c" before the path to perl interpreter.


Thanks anyway.


Regards,

Jromariz.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Please create new topics for new problems.

Regards
Alex
jromariz
Posts: 264
Joined: Wed Apr 03, 2002 6:00 pm
Location: Brasil

Post by jromariz »

I will.

Jromariz.
Post Reply