Windows uptime statistics

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

Moderators: Developers, Moderators

arjanv
Posts: 13
Joined: Thu Dec 09, 2004 1:48 pm

Post by arjanv »

I wan't to monitor several Windows 2003 servers from my Centos Cacti server.

Is it possible te use this script on linux to poll Windows Servers?
Does anyone have a quick how-to?
tspec
Posts: 10
Joined: Tue Nov 15, 2005 10:56 pm

Post by tspec »

arjanv wrote:Is it possible te use this script on linux to poll Windows Servers?
Does anyone have a quick how-to?
Also after the same thing, would love to get uptime statics running on my install of cacti which is running on Ubuntu. If anyone can help, that would be fantastic. Running version 0.8.6h.

/edit: On my continued search, Hobbit Monitoring looks like it might be a goer as it plugs into cacti. Anyone had any experience with it.... good / not good ???

http://www.hobbitmon.com/
ABX
Cacti User
Posts: 68
Joined: Thu Mar 01, 2007 5:55 am

Post by ABX »

When I run win_uptime.cmd from command prompt I get an error.

c:\>win_uptime.cmd loclhost 99.95
Couldn't get it! at d:\something\cacti\scripts\uptime\win_uptime.pl line 20.
sla_avail:99.95
frostie
Posts: 1
Joined: Wed Oct 24, 2007 5:30 pm

Linux Port

Post by frostie »

Hi is there a linux version for the uptime script?

The xml files import fine, just the scripts woun't run...

Thanks
Neil
malibumaniac
Posts: 15
Joined: Tue Apr 08, 2008 8:33 am

Post by malibumaniac »

ABX wrote:When I run win_uptime.cmd from command prompt I get an error.

c:\>win_uptime.cmd loclhost 99.95
Couldn't get it! at d:\something\cacti\scripts\uptime\win_uptime.pl line 20.
sla_avail:99.95
same here..

someone got this solved?
i've checked line 20, its

my $content = LWP::Simple::get($httpaddr) or die "Couldn't get it!";

i have serious no clue how to fix..
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

I'm the same on this one. From what I can gather the Perl script is trying access the web address specified in the win_uptime.cmd script.
Dominic Ryan
www.iis-aid.com
royce
Cacti User
Posts: 79
Joined: Wed Dec 29, 2004 7:37 am
Location: Sweden

linux -> Windows WMI

Post by royce »

hi.

You guys running Linux. Be sure to remove any ^M 's in the perl scripts supplied.

Code: Select all

$ dos2unix win_cur_uptime.pl
$ dos2unix win_uptime.pl

Someone asked for my linux-script I use to get info. As I said before I use NRPe to connect to a Windows server and from there, to any windows server within that Active directory.

Please note. You have to configure the NRPE commands on the Windows server in order to do what you like.

Here's my script i use for that.

Code: Select all

!/bin/sh

log="/cacti path/cacti/log/uptime_$1.log"
txt="/cacti path/cacti/log/uptime_$1.txt"
gawk=/usr/bin/gawk

htmlfile=/your cacti path here/cacti/log/uptime_$1.html
htmladdr=http://your cacti server here/cacti/log/uptime_$1.html
script_path=/your cacti path here/scripts/uptime

$gawk -f $script_path/gawk_head.txt $log > $htmlfile
echo "000000 Uptime Report for: \\\\$1" > $log

/your cacti path here/cacti/scripts/check_nrpe -H <NRPE windows server> -c win32_uptime1 -a "$1" > $txt

/your cacti path here/cacti/scripts/check_nrpe -H <NRPE windows server> -c win32_uptime2 -a "$1" | tr '@' '\n' >> $log

gawk -f $script_path/gawk_main.txt $log >> $htmlfile
gawk -f $script_path/gawk_tail.txt $log >> $htmlfile
perl $script_path/win_cur_uptime.pl $txt
perl $script_path/win_uptime.pl $htmladdr
echo sla_avail:$2

rm $log
rm $txt
rm $htmlfile
So. The flow goes like this:

Cacti server (Linux)
Windows NRPE (Windows)
Other Windows servers (AD)


Linux runs the script configured (above) wich runs check_nrpe. Check_nrpe sends "win32_uptime1" to my Windows server, it also includes the IP address of the AD server cacti wants to poll. Then check_nrpe runs the windows script at the windows server and collects the WMI data from the AD server, and returns the output to Cacti.

Next, I use a quick and dirty solution to fix the buffered-output problem. I run the win_update.sh through a script that just echo's all output up front. (Because cactid/php want it that way..) anyway. Dirty dirty.

Code: Select all

#!/bin/sh
E=`/usr/share/cacti/scripts/uptime/win_uptime.sh $1 $2`

echo $E
Hope this helps someone.
Hyperion.Jiang
Posts: 1
Joined: Tue Nov 11, 2008 1:53 am

Re: Windows uptime statistics

Post by Hyperion.Jiang »

hello !
thanks for you supporting the Templates for windows uptime , but I can't catch the data , when I import it sucessfully , so I want to make sure weather it's suitable for cacti from linux or not ?

PS : my cacti set on linux , not windows platform , tks !
royce
Cacti User
Posts: 79
Joined: Wed Dec 29, 2004 7:37 am
Location: Sweden

Re: Windows uptime statistics

Post by royce »

Hyperion.Jiang wrote:hello !
thanks for you supporting the Templates for windows uptime , but I can't catch the data , when I import it sucessfully , so I want to make sure weather it's suitable for cacti from linux or not ?

PS : my cacti set on linux , not windows platform , tks !
Hi.
If you are used to Linux, you are used to find ways to get your stuff running. Linux is like UNIX, and UNIX teaches one to read and understand.

My previous post was written to folks that runs linux and knows how to read and understand a simple shell script and instructions. What you do with it is up to you. If you feel this is to less plug and play, don't bother.

Thanks :)
Chris
ryaner
Posts: 4
Joined: Tue Mar 03, 2009 4:25 am

Post by ryaner »

Brashquido wrote:I'm the same on this one. From what I can gather the Perl script is trying access the web address specified in the win_uptime.cmd script.
It is a permissions error. You need to put a chmod 644 if you are using linux, or a setattrib on windows.
glowe
Posts: 7
Joined: Wed Mar 18, 2009 7:43 am

Post by glowe »

malibumaniac wrote:someone got this solved?
i've checked line 20, its

my $content = LWP::Simple::get($httpaddr) or die "Couldn't get it!";

i have serious no clue how to fix..
Yes, when you edit win_uptime.cmd make sure the following line is the intranet URL to your Cacti. I am using SSL so I had edit accordingly.

Code: Select all

set htmladdr=https://servername/log/uptime_%1.html
For those people who are not getting any values in their graphs, the solution is to make sure that the user account running the cacti poller scheduled task is recognised by each machine you are gathering the uptime stats for (I added the same local user to each machine, but a domain account may work).
bigturk
Posts: 37
Joined: Wed Sep 02, 2009 4:45 pm

Help got graph but now data

Post by bigturk »

I get no data can someone help?

@echo off
set log=.\uptime_%1.log
set txt=.\uptime_%1.txt

set htmlfile=d:C:\Cacti_Install\Apache2\htdocs\cacti\log\uptime_%1.html
set htmladdr=http://my_ip_address_4_cacti/cacti/log/uptime_%1.html
set script_path=d:\C:\Cacti_Install\Apache2\htdocs\cacti\scripts\uptime\

%script_path%gawk -f %script_path%gawk_head.txt %log% > %htmlfile%
echo 000000 Uptime Report for: \\%1 > %log%
%script_path%uptime.exe %1 > %txt%
%script_path%Uptime.exe /s %1 | %script_path%nl -nrz | %script_path%grep "Uptime Report for:\|Since \|System Availability:\|Total Uptime:\|Total Downtime:\|Total Reboots:\|Mean Time Between Reboots:\|Total Bluescreens:" | %script_path%gawk "{gsub(/Since/,\" Since:\"); print}" | %script_path%sort -k 2,2 -k 1,1r | %script_path%uniq --skip-chars=8 --check-chars=30 | %script_path%sort >> %log%
%script_path%gawk -f %script_path%gawk_main.txt %log% >> %htmlfile%
%script_path%gawk -f %script_path%gawk_tail.txt %log% >> %htmlfile%
perl.exe %script_path%win_cur_uptime.pl %txt%
perl.exe %script_path%win_uptime.pl %htmladdr%
echo sla_avail:%2

rem erase temp files
erase %log%
erase %txt%
erase %htmlfile%

i get the graph but no data.
debug
RRDTool Command:

C:/Cacti_Install/rrdtool/rrdtool.exe graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="WDoffice54-2 -Uz - Windows Uptime Statistics" \
--base=1000 \
--height=175 \
--width=650 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Percentage (%) or days" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="C\:/Cacti_Install/Apache2/htdocs/cacti/rra/wdoffice54-2_-uz_sla_avail_850.rrd":sla_avail:AVERAGE \
DEF:b="C\:/Cacti_Install/Apache2/htdocs/cacti/rra/wdoffice54-2_-uz_sla_avail_850.rrd":avail:AVERAGE \
DEF:c="C\:/Cacti_Install/Apache2/htdocs/cacti/rra/wdoffice54-2_-uz_sla_avail_850.rrd":tot_uptime:AVERAGE \
DEF:d="C\:/Cacti_Install/Apache2/htdocs/cacti/rra/wdoffice54-2_-uz_sla_avail_850.rrd":cur_uptime:AVERAGE \
DEF:e="C\:/Cacti_Install/Apache2/htdocs/cacti/rra/wdoffice54-2_-uz_sla_avail_850.rrd":tot_downtime:AVERAGE \
DEF:f="C\:/Cacti_Install/Apache2/htdocs/cacti/rra/wdoffice54-2_-uz_sla_avail_850.rrd":tot_reb:AVERAGE \
DEF:g="C\:/Cacti_Install/Apache2/htdocs/cacti/rra/wdoffice54-2_-uz_sla_avail_850.rrd":mean_days:AVERAGE \
DEF:h="C\:/Cacti_Install/Apache2/htdocs/cacti/rra/wdoffice54-2_-uz_sla_avail_850.rrd":tot_blue:AVERAGE \
CDEF:cdeff=c,e,-,60,/,60,/,24,/ \
CDEF:cdefba=c,60,/,60,/,24,/ \
CDEF:cdefbc=c,c,/,100,* \
CDEF:cdefbf=d,60,/,60,/,24,/ \
CDEF:cdefbh=d,c,/,100,* \
CDEF:cdefca=e,60,/,60,/,24,/ \
CDEF:cdefcc=e,c,/,100,* \
CDEF:cdefdb=g,24,*,60,*,60,*,c,/,100,* \
CDEF:cdefdi=100,a,-,100,/,c,*,60,/,60,/,24,/ \
CDEF:cdefdj=100,a,- \
CDEF:cdefea=e,100,a,-,100,/,/,c,-,60,/,60,/,24,/ \
COMMENT:"Availability\:\n" \
LINE1:a#F51D30FF:"Required (SLA)\:" \
GPRINT:a:LAST:" %6.4lf%%\n" \
LINE1:b#00CF00FF:"Current as of eventlog\:" \
GPRINT:b:LAST:" %6.4lf%%" \
GPRINT:cdeff:LAST:"(%8.2lf day(s))" \
GPRINT:b:AVERAGE:"Avg\:%6.4lf%%" \
GPRINT:b:MAX:" Max\:%6.4lf%%\n" \
COMMENT:" \n" \
COMMENT:"Uptime and downtime\:\n" \
LINE1:cdefba#A150AAFF:"Total uptime (eventlog)\:" \
GPRINT:cdefba:LAST:" %8.2lf day(s)" \
GPRINT:cdefbc:LAST:"(%6.2lf%%)" \
GPRINT:cdefba:AVERAGE:" Avg\:%8.2lf day(s)" \
GPRINT:cdefba:MAX:"Max\:%8.2lf day(s)\n" \
AREA:cdefbf#FF7D00FF:"Uptime since last reboot\:" \
GPRINT:cdefbf:LAST:" %8.2lf day(s)" \
GPRINT:cdefbh:LAST:"(%6.4lf%%)" \
GPRINT:cdefbf:AVERAGE:" Avg\:%8.2lf day(s)" \
GPRINT:cdefbf:MAX:"Max\:%8.2lf day(s)\n" \
LINE1:cdefca#FAFD9EFF:"Total downtime (eventlog)\:" \
GPRINT:cdefca:LAST:"%8.4lf day(s)" \
GPRINT:cdefcc:LAST:"(%6.4lf%%)" \
GPRINT:cdefca:AVERAGE:" Avg\:%8.4lf day(s)" \
GPRINT:cdefca:MAX:"Max\:%8.4lf day(s)\n" \
COMMENT:" \n" \
COMMENT:"Reboot information\:\n" \
LINE1:f#837C04FF:"Total reboots (eventlog)\:" \
GPRINT:f:LAST:" %8.0lf\n" \
LINE1:g#00004DFF:"Mean time between reboots\:" \
GPRINT:g:LAST:"%8.2lf day(s)" \
GPRINT:cdefdb:LAST:"(%6.4lf%%)" \
GPRINT:g:AVERAGE:" Avg\:%8.2lf day(s)" \
GPRINT:g:MAX:"Max\:%8.2lf day(s)\n" \
LINE1:h#002A97FF:"Total blue screens\:" \
GPRINT:h:LAST:" %8.0lf\n" \
COMMENT:" \n" \
COMMENT:"Summary\:\n" \
GPRINT:cdefdi:LAST:" Allowed current downtime (SLA)\:%8.4lf day(s)" \
GPRINT:cdefdj:LAST:"(%6.4lf%%)\n" \
GPRINT:cdefea:LAST:"Days to reach required SLA availability\:%8.2lf day(s)\n"

RRDTool Says:

OK
Attachments
graph_image.jpg
graph_image.jpg (62.49 KiB) Viewed 7964 times
bigturk
Posts: 37
Joined: Wed Sep 02, 2009 4:45 pm

Post by bigturk »

good news with some reading and posting i finally got it 80% working. im getting the graph, the html file, log file, and SLA line in the graph but thats it.
when i click on the html file i get all the info i wish to see on the graph.
Attachments
graph_image.jpg
graph_image.jpg (74.52 KiB) Viewed 7899 times
wasted247
Posts: 5
Joined: Thu Mar 25, 2010 8:27 am

Post by wasted247 »

Hi All,

Script wouldn't run on my w2003sR2 x64 box (locally), turned out that the perl executable couldn't be found. Not mentioned in the starting post, but pretty obvious that its needed when reading win_uptime.cmd.

Added a var to win_uptime.cmd (after "set script_path="):

set perl_path=C:\strawberry\perl\bin\

and changed the perl.exe lines to:

%perl_path%perl.exe %script_path%win_cur_uptime.pl %txt%
%perl_path%perl.exe %script_path%win_uptime.pl %htmladdr%
zeroy
Posts: 25
Joined: Wed Jan 25, 2006 8:27 am

Re: linux -> Windows WMI

Post by zeroy »

royce wrote:Please note. You have to configure the NRPE commands on the Windows server in order to do what you like.
Ok i have NRPE running now on a AD server but using the following command on my CentOS install:

Code: Select all

[root@localhost uptime]# /usr/lib/nagios/plugins/check_nrpe -H 192.168.1.235 -c win32_uptime1 -a "192.168.253.236"
I get this:

Code: Select all

NRPE: Command 'win32_uptime1' not defined
I see i have to setup the win32_uptime1 command in the nrpe.cfg but how?

Thanks!
¬¬ZeRoY¬¬
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests