Hi all,
I was looking for a script to get uptime statistics and found this: http://forums.cacti.net/viewtopic.php?f=12&t=10514
Unfortunately, this script use uptime.exe from Microsoft and do not work when an unexpected shutdown appears. In this case the lonely way to resolve the issue is to clean up the system eventlog.
I finally decide to write the script uptime.exe in Powershell
As it's wrote in Powershell, we do not need anymore of gawk.exe, grep.exe, nl.exe, sort.exe,uniq.exe, uptime.exe and perl scripts. Powershell 4.0 is now compatible with 2008/+R2, 2012/+R2 so... What else...
The Powershell script is launched by the win_uptime.cmd so the change of the xml files is not necessary.
So the installation of the script is exactly the same as describe in the post of wvr120364 (http://forums.cacti.net/viewtopic.php?f=12&t=10514) just replace the content of the uptime directory by the contents of the zip file. That's it.
Last point, the output of win_uptime.cmd is:
hostname:Gateway.contoso.com sla_avail:99.99 cur_uptime:0000007435 tot_uptime:0002107881 tot_downtime:0000421974 tot_reb:37 mean_days:00.7917 tot_blue:0 avail:0.8332 sla_avail:99.99
And the graph:
The curves are not good but it's due to tests.
The tot_uptime must be in seconds and mean_days in days so when the xml wait for days and you fill seconds, the curves' scale explode.
Update of Windows Uptime Statistics
Moderators: Developers, Moderators
-
- Posts: 8
- Joined: Tue Feb 24, 2015 9:45 am
Update of Windows Uptime Statistics
- Attachments
-
- UptimeStats.zip
- This zip file contains XML and PS1/CMD.
See installation instruction in the below post. - (10.38 KiB) Downloaded 68 times
-
- uptime.zip
- Contains:
OS-UptimeForCacti.ps1
win_uptime.cmd
Just replace all files in Cacti\Scripts\uptime with these 2 files. - (2.51 KiB) Downloaded 78 times
Last edited by SwitchNikky on Mon May 04, 2015 2:52 am, edited 2 times in total.
Re: Update of Windows Uptime Statistics
If you get a chance, please post this to the templates site:
http://docs.cacti.net/templates
http://docs.cacti.net/templates.guidelines
http://docs.cacti.net/templates
http://docs.cacti.net/templates.guidelines
--
Live fast, die young
You're sucking up my bandwidth.
J.P. Pasnak,CD
CCNA, LPIC-1
http://www.warpedsystems.sk.ca
Live fast, die young
You're sucking up my bandwidth.
J.P. Pasnak,CD
CCNA, LPIC-1
http://www.warpedsystems.sk.ca
-
- Posts: 8
- Joined: Tue Feb 24, 2015 9:45 am
Re: Update of Windows Uptime Statistics
I am not able to login on Documentation site. My username/password does not work... Special rights are needed to create a script? I have tried to create this:Linegod wrote:If you get a chance, please post this to the templates site
http://docs.cacti.net/userscript:uptimestats
The text:
This script produces this graph: Installation instructions:
1.- Download UptimeStats.zip and save it to temporary local folder.
2.- Extract the files in this temporary folder.
3.- Move the .ps1 and .cmd files into a subdirectory of Cacti. ex: C:\inetpub\cacti\scripts\uptime. The data-template assumes <CactiInstallationPath>\scripts\uptime
4.- Go to this new dir. and edit win_uptime.cmd. Find and set the parameters following your environment:
Code: Select all
set txt=<CactiInstallationPath>\log\uptime_%1.txt
set script_path=<CactiInstallationPath>\scripts\uptime\
<CactiInstallationPath> is your installation path of Cacti ex: C:\inetpub\cacti
5.- import the data_template and graph_template trough console -> Import templates.
6.- If you have placed the scripts in another place you have to edit the Data Input Methods
Code: Select all
<path_cacti>/scripts/uptime/win_uptime.cmd <hostname> <sla_avail>
8.- Wait for two or three polling and the results will show up.
The script will scan 30 days in the event logs. You can change this time span by modifying this command line in win_uptime.cmd:
Code: Select all
PowerShell.exe -Command "%script_path%OS-UptimeForCacti.ps1 %1 30 %2" > %txt%
%1 is the hostname (do not change this value)
30 is the default time span of 30 days
%2 is the default SLA target.
Special thanks to Thomas Rupp and Wietze Visscher for the original script (http://forums.cacti.net/viewtopic.php?f=12&t=10514 and http://forums.cacti.net/viewtopic.php?t=6998)
Requirements:
Powershell 4.0 http://social.technet.microsoft.com/wik ... l-4-0.aspx
All forks for this script can be find here: https://poweruptime.codeplex.com/
The scripts will be updated there.
- Attachments
-
- UptimeStats.zip
- (10.38 KiB) Downloaded 64 times
Who is online
Users browsing this forum: No registered users and 1 guest