How can i add Uptime to the Statistics?

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Moderators, Developers

Author
Message
Ghandi
Cacti User
Posts: 73
Joined: Tue May 04, 2004 5:09 am
Location: Graz / Austria

How can i add Uptime to the Statistics?

#1 Post by Ghandi » Mon Oct 18, 2004 8:35 am

hi everybody,

i have search the forum for a post that describes how i can add the uptime of a host to the stats, but i can't find some thread which is helpfull for me.

can somebody help me with this problem? i use win2000 server, cacti is running perfect :) now i will add the uptime of my hosts..

hope somebody can help..

thx a log

scavenger67
Posts: 49
Joined: Fri Mar 18, 2005 7:33 am
Location: France

#2 Post by scavenger67 » Sun Mar 27, 2005 4:36 am

Hi Ghandi, do you find something in order to have the uptime information ? i'm going to leave MRTG for CACTI and the only information that is missing is the system uptime.

Thanks
Scav.

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

#3 Post by Thomas » Tue Mar 29, 2005 2:27 am

Here's how I monitor the system uptime:
* Create the following script (I call it uptime.sh):

Code: Select all

#!/bin/sh
uptime=`snmpget -Ov -c $1 -v 1 $2 system.sysUpTime.0 | awk '{print $3}'`
case $uptime in
*:*) uptime=0 ;;
*) ;;
esac
echo "$uptime";
* Use the following data and graph templates (exported on cacti 0.8.6c). This is my first time adding a template so I hope I got it all. Your uptime graphs should look like:
Attachments
cacti_data_template_snmp_system_uptime.xml
(4 KiB) Downloaded 1797 times
cacti_graph_template_snmp_system_uptime.xml
(8.28 KiB) Downloaded 2282 times
uptime.JPG
uptime.JPG (33.86 KiB) Viewed 22801 times
Thomas Rupp

Ghandi
Cacti User
Posts: 73
Joined: Tue May 04, 2004 5:09 am
Location: Graz / Austria

#4 Post by Ghandi » Tue Mar 29, 2005 3:56 am

hi thomas,

great script, but i need info how i can add the uptime text to my exiting graphs...

can you help me?
like the |date_time| comment in the graph template items.

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

#5 Post by Thomas » Tue Mar 29, 2005 4:07 am

Hi,

I searched the archives and I think this posting should help: http://forums.cacti.net/viewtopic.php?t=2546
Thomas Rupp

Ghandi
Cacti User
Posts: 73
Joined: Tue May 04, 2004 5:09 am
Location: Graz / Austria

#6 Post by Ghandi » Tue Mar 29, 2005 4:12 am

hi,

thanks for the info, but the last message in this thread is for me, i need this under windows :( this patch doesn't run in windows..

is there really no commant?

bad :(

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

#7 Post by Thomas » Tue Mar 29, 2005 4:23 am

Hi Ghandi,

I had a look at the patch. It won't run on Windows because it calls a Skript using the *nix notation.
If you replace the line

Code: Select all

@$uptime = exec("/home/httpd/html/cacti/scripts/snmp_cisco_uptime.sh " . $hostdata["snmp_community"] . " " . $hostdata["hostname"]);
with something like

Code: Select all

@$uptime = exec("C:\...\uptime.bat " . $hostdata["snmp_community"] . " " . $hostdata["hostname"]);
then it should work on Windows as well.
P.S. I don't know anything about PHP and am not running CACTI on Windows so please handle my advice with care ;-)
Thomas Rupp

scavenger67
Posts: 49
Joined: Fri Mar 18, 2005 7:33 am
Location: France

#8 Post by scavenger67 » Tue Mar 29, 2005 6:08 am

that's not so easy because there is no patch method for cacti running on windows. But if you found something i'm interested.
thanks

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

#9 Post by Thomas » Tue Mar 29, 2005 6:18 am

scavenger67 wrote:that's not so easy because there is no patch method for cacti running on windows.
I see ... but in this case you only have to add a few lines. The line numbers can be found in the heading of the patch file - so this should be quite easy to patch manually.
But as I said before, I have no CACTI running on Windows ...
Thomas Rupp

Ghandi
Cacti User
Posts: 73
Joined: Tue May 04, 2004 5:09 am
Location: Graz / Austria

#10 Post by Ghandi » Tue Mar 29, 2005 7:16 am

what i doesn't understand is, uptime is a snmp query, why its so difficult to add the uptime from a host... ?

is there no host or graph variable for this feature?

greetings

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

#11 Post by Thomas » Tue Mar 29, 2005 7:33 am

No, there is no variable for this feature (in this version of CACTI).
I would create a separate graph for uptime (see my above example) - this gives you the needed information with least effort.
BTW: What uptime data do you want to monitor? .iso.org.dod.internet.mgmt.mib-2.system.sysUpTime (.1.3.6.1.2.1.1.3) = "The time since the network management portion of the system was last re-initialized." or .iso.org.dod.internet.mgmt.mib-2.host.hrSystem.hrSystemUptime (.1.3.6.1.2.1.25.1.1) = "The amount of time since this host was last initialized."

P.S. Schöne Grüße vom Bodensee nach Graz
Thomas Rupp

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#12 Post by TheWitness » Tue Mar 29, 2005 8:12 am

We currently keep uptime in one of our tables. It would not be a major hack to provide it as a GPRINT in the next version.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

Ghandi
Cacti User
Posts: 73
Joined: Tue May 04, 2004 5:09 am
Location: Graz / Austria

#13 Post by Ghandi » Tue Mar 29, 2005 8:38 am

ok, than i will wait for the next version... i have enough time to wait.. but not enough to work on scripts *g* :)

thanks..

PS.: jo ebenso schöne grüße zum bodensee aus graz.. :)

ggarbe
Posts: 6
Joined: Fri Apr 01, 2005 8:36 am
Contact:

who?

#14 Post by ggarbe » Fri Apr 01, 2005 8:46 am

Thomas wrote:Here's how I monitor the system uptime:
* Create the following script (I call it uptime.sh):

Code: Select all

#!/bin/sh
uptime=`snmpget -Ov -c $1 -v 1 $2 system.sysUpTime.0 | awk '{print $3}'`
case $uptime in
*:*) uptime=0 ;;
*) ;;
esac
echo "$uptime";
* Use the following data and graph templates (exported on cacti 0.8.6c). This is my first time adding a template so I hope I got it all. Your uptime graphs should look like:
Who I can add this graph (detailed) on my Cacti system using Net-SNMP for Windows?

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

#15 Post by Thomas » Mon Apr 04, 2005 2:26 am

SNMPGET returns the following value:

Code: Select all

Timeticks: (43847204) 5 days, 1:47:52.04
My script takes token 3 (with AWK) and checks if it contains a ":". If yes, then uptime is < 1 day and the script returns 0.
If you can create a script (perl?) then it should be possible for windows as well.
I've found the following skript for an UPS:

Code: Select all

#!/usr/bin/perl
#
# Script to convert runtime MIB variable for UPS into minutes

$a=`snmpget -v1 -c public $ARGV[0] .1.3.6.1.4.1.318.1.1.1.2.2.3.0`;
chomp $a;
@b=split(/ /,$a);
@c=split(/:/,$b[4]);
$z = eval($c[0] * 60 + $c[1]),"\n";
print $z;
Please be careful and test all code! I'm running on Linux so my Windows suggestions are all theoretical!
Thomas Rupp

Post Reply