andyml73 andyml73 - 4 days ago 4x
Bash Question

Unix shell command for uptime monitoring

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?



Does this work for you?

cat /proc/uptime | gawk '{print ($1>86400)?1:0;}'