How can i add Uptime to the Statistics?

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

Moderators: Developers, Moderators

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

How can i add Uptime to the Statistics?

Post by Ghandi »

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

Post by scavenger67 »

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

Post by Thomas »

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 1936 times
cacti_graph_template_snmp_system_uptime.xml
(8.28 KiB) Downloaded 2426 times
uptime.JPG
uptime.JPG (33.86 KiB) Viewed 24628 times
Thomas Rupp
Ghandi
Cacti User
Posts: 73
Joined: Tue May 04, 2004 5:09 am
Location: Graz / Austria

Post by Ghandi »

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

Post by Thomas »

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

Post by Ghandi »

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

Post by Thomas »

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

Post by scavenger67 »

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

Post by Thomas »

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

Post by Ghandi »

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

Post by Thomas »

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: 16997
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

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 dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Ghandi
Cacti User
Posts: 73
Joined: Tue May 04, 2004 5:09 am
Location: Graz / Austria

Post by Ghandi »

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?

Post by ggarbe »

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

Post by Thomas »

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

Who is online

Users browsing this forum: No registered users and 1 guest