0

apologies, I'm not a Unix guy, Windows and Powershell is more my area. I need to check the uptime on Linux servers using a shell command that can be invoked from SCOM.

I have been able to get the uptime in seconds back into SCOM using...

cat /proc/uptime | gawk -f ' ' '{print $1}'

However, SCOM does not pick this up as numerical, I think it's treating the returned output as a string.

I'd like a shell command that returns a 0 or 1 if the number of seconds is less than one day (86400).

I've been experimenting with [test -gt] but can't seem to get it working?

thanks

andyml73
  • 77
  • 1
  • 5
  • 1
    Possible duplicate of [Comparing numbers in bash](http://stackoverflow.com/questions/18668556/comparing-numbers-in-bash) – Julien Lopez Oct 17 '16 at 09:19

1 Answers1

1

Does this work for you?

cat /proc/uptime | gawk '{print ($1>86400)?1:0;}'
blackpen
  • 2,339
  • 13
  • 15
  • 1
    And if you really want "a shell command that _returns_ a 0 or 1" as an return value and not just prints it out, replace the `print` with `exit`. – James Brown Oct 17 '16 at 12:02