Inspired by a question from John Cook on Twitter, I’ve taken my “Update-RibbonADCache.ps1” script, and through the magic of “Save As” we now have Get-RibbonSbcUptime.ps1.
Get-RibbonSbcUptime.ps1 invokes a REST login to your Sonus/Ribbon SBC 1k/2k/SWe-Lite and reports how long it’s been running: the CpuUptime.
It outputs to the pipeline either a timespan object, or a literal string in the same format the SBC displays on its System/Overview tab.
Usage
The minimum parameters are the SBC FQDN, the REST login name and REST password. An optional parameter is “-AsTimeString”.
PS C:\>.\Get-RibbonSbcUptime.ps1 -SbcFQDN 10.10.16.82 -RestLogin REST -RestPassword MyRestPwD -AsTimeString
If you fail to provide any of the required parameters, the script will prompt you for them.
The default output is a timespan object:
Days : 2 Hours : 20 Minutes : 3 Seconds : 10 Milliseconds : 0 Ticks : 2449900000000 TotalDays : 2.83553240740741 TotalHours : 68.0527777777778 TotalMinutes : 4083.16666666667 TotalSeconds : 244990 TotalMilliseconds : 244990000
With the “-AsTimeString” switch the script will output a literal version of the uptime, in the same format as the SBC shows on its System/Overview tab:
3 days, 20 hrs, 4 mins, 48 secs
Automation
If you’re automating this script, you can capture its output into a variable to work on in a subsequent flow. If you ARE doing this, make sure you add the “-SkipUpdateCheck” switch, otherwise when I post an update it will break the automation:
PS C:\> $SbcUptime = (.\Get-RibbonSbcUptime.ps1 -SbcFQDN 10.10.16.82 -RestLogin REST -RestPassword P@ssw0rd1 -Verbose -SkipUpdateCheck)
Known Issue
SBC firmware versions prior to v8.0.3 have a known bug: the CpuUptime reports zero. This is not a problem with the script. If the script reports zero but System/Overview reports an expected value, you’ll need to update the SBC’s firmware.
Auto Update
I’ve added an update-checking component so it will let you know as updates become available. You can suppress the update check by running it with the “-SkipUpdateCheck” parameter, which you should ALWAYS add if you’re running the script via a scheduled task or some other automated/unattended means.
Download
You’ll find a code-signed version of the script on GitHub. You’re welcome to pinch, adapt or improve upon the code with my blessing. If you encounter any problems with it please create an issue on the repo.
Revision History
6th June 2020: Corrected a typo in the post and updated the Download link to point to GitHub.
1.0 – 16th November 2019.
- This is the initial release.
– G.
Hi Greig,
I tried to test this script on SBC SWe Lite version 9.02, it is failing to retrieve the report. I suspected Ribbon had tighten REST security on version 9 or require a REST license enable.
Are you able to test and confirm if this is the case.
Regards
Ti
Aha, yes I see there’s a problem there. Leave it with me.
Ok Ti, please upgrade to v1.1 and let me know if you’re still having problems (and please send me a screen-scrape if you do).
https://github.com/greiginsydney/Get-RibbonSbcUptime.ps1
– Greig.
Hi Greig,
Thanks, updated version 1.1 fixed, so what was the fix?
Regards,
Ti
Hi Ti,
It looks like Ribbon used to pad the start of their REST responses with blank characters, and my script was blindly chopping the start of the response accordingly. They’ve since changed that, and it broke this and another of my REST scripts.
I’ve updated both to check if the incoming response is deemed valid XML, pass it through, but if it’s a string, perform a “trimstart” to get rid of any white-space at the start before proceeding. That’s a better approach than before, so hopefully it’ll hold.
Ta for bringing it to my attention.
– Greig.