Windows uptime statistics

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

wvr120364
Posts: 16
Joined: Tue May 06, 2003 7:48 am

Windows uptime statistics

Post by wvr120364 »

Hi,

After searching this forum for a Windows uptime script I found this thread that gave me enough information to go on and build a script based on my needs. The solution from Thomas Rupp in message:http://forums.cacti.net/viewtopic.php?t=6998 did the trick.

Here is a preview of the graph that it produces:
Image

Installation instructions:
1.- Download uptime.zip and save it to a local folder.
2.- Extract the file to a subdirectory \uptime.
3.- Copy its contents to, exept the two XML-files, to a new directory \uptime under the <path to cacti>\scripts drectory. The data-template assumes <path to cacti>\scripts\uptime.
4.- Go to this new dir. and edit win_uptime.cmd. Find the three set variables and change them to your needs.

Code: Select all

set htmlfile=d:\<path to cacti>\cacti\log\uptime_%1.html
set htmladdr=http://www.your.domain/cacti/log/uptime_%1.html
set script_path=d:\<path to cacti>\cacti\scripts\uptime\
5.- import the data_template and graph_template trough console -> Import templates.
6.- If you have placed the scripts and programmes in another place you have to edit the Data Input Methods [edit: Windows uptime].

Code: Select all

<path_cacti>/scripts/uptime/win_uptime.cmd <hostname> <sla_avail>
to your needs.
7.- After that you can create a new graph for your device. The hostname is already taken and you will be asked to give the required avalability. Default is 99.9900%.
8. Wait for two or three pollings and the results will show up.

Remarks:
1,- This script counts and evaluate the readings of eventnumber 6005 in the eventlog. If the eventlog is reset, the script starts at zero, but gives you the history.
2.- Maybe there is an easier way to collect the data, please feel free to alter and post your solution here.
3.- This is my first atempt to create a solution in this way. I hope it all works for you. Tested on cacti: 8.6.g.

Wietze Visscher
Attachments
uptime.zip
Uptime scripts and programmes
(213.76 KiB) Downloaded 10633 times
tman
Cacti User
Posts: 97
Joined: Thu Oct 14, 2004 4:14 pm

Post by tman »

Sounds cool. Was this created under 0.8.6g by any chance? I'm still running 0.8.6f at the moment, and get a 'Hash version does not exist' when trying to import the templates.

Cheers
Thomas
Cacti User
Posts: 112
Joined: Thu Dec 09, 2004 1:51 pm
Location: Austria

Post by Thomas »

WOW, I'm really impressed!
Thomas Rupp
wvr120364
Posts: 16
Joined: Tue May 06, 2003 7:48 am

Post by wvr120364 »

tman wrote:Sounds cool. Was this created under 0.8.6g by any chance? I'm still running 0.8.6f at the moment, and get a 'Hash version does not exist' when trying to import the templates.

Cheers
tman,

It is for verion 8.6g. I don't know how to downgrade it to a lower version. Maybe some other can help you.

Wietze
chewy009
Posts: 38
Joined: Wed Jun 15, 2005 1:18 pm
Location: Washington State, USA

Post by chewy009 »

The install went fine but I get the following error in the cacti log everytime it runs.

11/22/2005 10:00:06 AM - CACTID: Poller[0] Host[1] ERROR: Empty result [127.0.0.1]: 'C:/Apache2/htdocs/cacti/scripts/uptime/win_uptime.cmd 127.0.0.1 99.9900'

It is giving me this error on multiple machines. Also, the RRD file is not updating either.
wvr120364
Posts: 16
Joined: Tue May 06, 2003 7:48 am

Post by wvr120364 »

chewy009 wrote:The install went fine but I get the following error in the cacti log everytime it runs.

11/22/2005 10:00:06 AM - CACTID: Poller[0] Host[1] ERROR: Empty result [127.0.0.1]: 'C:/Apache2/htdocs/cacti/scripts/uptime/win_uptime.cmd 127.0.0.1 99.9900'

It is giving me this error on multiple machines. Also, the RRD file is not updating either.
chewy009,

Try a different hostname, like localhost or ip-adress. I will test it also.

I set up a new device 'Test' with Ip 127.0.0.1 and after two cycles I get a nice graph with the first results. I don't have a clue what is going wrong with your configuration. Try also if you can run the script from the command-line, like:

Code: Select all

d:\<path to cacti>\scripts\uptime> win_uptime.cmd 127.0.0.1 99.9900
If you get any readings, maybe the configuration of the set parameters in win_uptime.cmd are not correct. Please post the results.

Wietze
Last edited by wvr120364 on Tue Nov 22, 2005 1:42 pm, edited 1 time in total.
chewy009
Posts: 38
Joined: Wed Jun 15, 2005 1:18 pm
Location: Washington State, USA

Post by chewy009 »

RRD still not updating trying what you suggested.

One other question on the line below

set htmladdr=http://www.your.domain/cacti/log/uptime_%1.html

Does www.your.domain = server name that cacti is installed on??
wvr120364
Posts: 16
Joined: Tue May 06, 2003 7:48 am

Post by wvr120364 »

chewy009 wrote:RRD still not updating trying what you suggested.

One other question on the line below

set htmladdr=http://www.your.domain/cacti/log/uptime_%1.html

Does www.your.domain = server name that cacti is installed on??
chewy009,
I edited my last post. Please read it.
www.your.domain = webadress of your cacti-dir where you can find your cacti from the internet. Like: http://www.microsoft.com/cacti.
Wietze
chewy009
Posts: 38
Joined: Wed Jun 15, 2005 1:18 pm
Location: Washington State, USA

Post by chewy009 »

OK, so here is what I've found. Running it from the command line gives me back useful information.

C:\Apache2\htdocs\cacti\scripts\uptime>win_uptime.cmd 10.10.10.40 99.9900
cur_uptime:75909 mean_days:13.44 tot_uptime:45293769 tot_blue:0 tot_downtime:6542 tot_reb:39 avail:99.9856 sla_avail:99.9900

C:\Apache2\htdocs\cacti\scripts\uptime>win_uptime.cmd 10.10.10.40 99.9900
cur_uptime:76368 mean_days:13.44 tot_uptime:45294229 tot_blue:0 tot_downtime:6542 tot_reb:39 avail:99.9856 sla_avail:99.9900

C:\Apache2\htdocs\cacti\scripts\uptime>win_uptime.cmd 10.10.10.24 99.9900
cur_uptime:5762460 mean_days:9.63 tot_uptime:21617767 tot_blue:0 tot_downtime:6870 tot_reb:26 avail:
99.9682 sla_avail:99.9900

C:\Apache2\htdocs\cacti\scripts\uptime>win_uptime.cmd 10.10.10.22 99.9900
cur_uptime:1037248 mean_days:7.01 tot_uptime:1816226 tot_blue:0 tot_downtime:318 tot_reb:3 avail:99.9825 sla_avail:99.9900

C:\Apache2\htdocs\cacti\scripts\uptime>win_uptime.cmd 10.10.10.15 99.9900
cur_uptime:384849 mean_days:22.86 tot_uptime:51343968 tot_blue:0 tot_downtime:3423 tot_reb:26 avail:
99.9933 sla_avail:99.9900

Here is how I configured the set lines in the win_uptime.cmd file

set htmlfile=c:\apache2\htdocs\cacti\log\uptime_%1.html
set htmladdr=http://server.test.net/cacti/log/uptime_%1.html
set script_path=c:\apache2\htdocs\cacti\scripts\uptime\

Is there supposed to be a logfile in the C:\apache2\htdocs\cacti\log directory other than cacti.log?
wvr120364
Posts: 16
Joined: Tue May 06, 2003 7:48 am

Post by wvr120364 »

chewy009,

The readings looking good, it's what it should be doing.
In win_uptime.cmd comment out the last line

Code: Select all

rem erase %htmlfile%
Run win_uptime.cmd from the command-line. Point your browser to

Code: Select all

http://server.test.net/cacti/log/uptime_10.10.10.40.html
and see if you can actualy see a page. If that is the fact, and the page is filled with data everything should be working and I am out of any options.

Wietze
chewy009
Posts: 38
Joined: Wed Jun 15, 2005 1:18 pm
Location: Washington State, USA

Post by chewy009 »

doing what you said, everything shows up properly, including going to that url you indicated in your previous post. However, it still shows nothing in the graph. When I look at the data source and turn on debug mode this is what I get.

Data Source Debug

c:/rrdtool/rrdtool.exe create \
C:/Apache2/htdocs/cacti/rra/netmgr_sla_avail_64.rrd \
--step 300 \
DS:sla_avail:GAUGE:600:0:100 \
DS:mean_days:GAUGE:600:0:U \
DS:avail:GAUGE:600:0:100 \
DS:tot_blue:GAUGE:600:0:U \
DS:tot_reb:GAUGE:600:0:U \
DS:tot_downtime:GAUGE:600:0:U \
DS:tot_uptime:GAUGE:600:0:U \
DS:cur_uptime:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MIN:0.5:1:600 \
RRA:MIN:0.5:6:700 \
RRA:MIN:0.5:24:775 \
RRA:MIN:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797 \
RRA:LAST:0.5:1:600 \
RRA:LAST:0.5:6:700 \
RRA:LAST:0.5:24:775 \
RRA:LAST:0.5:288:797 \

I don't get why it works from the CMD line but not from within Cacti. :(
chewy009
Posts: 38
Joined: Wed Jun 15, 2005 1:18 pm
Location: Washington State, USA

Post by chewy009 »

OK, so i installed this on my "production" cacti box and it seems like it's working. Why is the Required (SLA) showing up as 0.0000%? Will the rest of the graph items fill in over time or should they already be there? I rebooted this box yesterday, hence the 0.98 days of uptime. What do you think?
Attachments
graph.jpg
graph.jpg (55.59 KiB) Viewed 107142 times
User avatar
Pumpi
Cacti User
Posts: 259
Joined: Wed Jan 14, 2004 3:23 am
Location: Germany

Post by Pumpi »

wvr120364,

very interessting script !

I have two questions:

Can I poll with this script Windows Servers from my Cacti Server running on Suse Linux ?

If yes I get following error:

sh: line 1: /srv/www/htdocs/cacti/scripts/uptime/win_uptime.cmd: Permission denied
royce
Cacti User
Posts: 79
Joined: Wed Dec 29, 2004 7:37 am
Location: Sweden

Post by royce »

that's because this script is designed for Windows-cacti boxen.

However, I just finished porting this to Linux +NRPE_NT...
royce
Cacti User
Posts: 79
Joined: Wed Dec 29, 2004 7:37 am
Location: Sweden

Post by royce »

chewy009 wrote:OK, so i installed this on my "production" cacti box and it seems like it's working. Why is the Required (SLA) showing up as 0.0000%? Will the rest of the graph items fill in over time or should they already be there? I rebooted this box yesterday, hence the 0.98 days of uptime. What do you think?
I've got the same problem - debugging cacti tells that cacti only sees some of the output vars...

Do the maintainer use cactid och php?
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests