Display uptime?

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

chexhcky
Posts: 12
Joined: Wed Jul 16, 2003 9:49 am
Location: Havertown, PA

Display uptime?

Post by chexhcky »

Any way to get an Uptime display for a host, in a graph preferrably? Looking to get similar to what MRTG provides.

Thanks
-----
Its not a penalty unless the ref sees it!
User avatar
NetVicious
Posts: 49
Joined: Mon Oct 13, 2003 1:14 pm
Location: Spain

Post by NetVicious »

Create a script <path_cacti>/scripts/snmpUptime.sh with this:

snmpget -v1 -Cf -c $1 $2 $3 | awk '{ print $5 }'


Create a Data Input Method linking to this script

Input String:
bash <path_cacti>/scripts/snmpUptime.sh <community> <host> <oid>

Output String:
<uptime>


On the Data Template write the OID:
.1.3.6.1.2.1.1.3.0
.. //\/ e t . \/ i c i o u s ..
claytondukes

Geeze

Post by claytondukes »

You guys have to be more descriptive than this...
Please try to assume that other people who aren't familiar with this sytem will be reading it :-)

NetVicious wrote:Create a script <path_cacti>/scripts/snmpUptime.sh with this:

snmpget -v1 -Cf -c $1 $2 $3 | awk '{ print $5 }'


Create a Data Input Method linking to this script

Input String:
bash <path_cacti>/scripts/snmpUptime.sh <community> <host> <oid>

Output String:
<uptime>


On the Data Template write the OID:
.1.3.6.1.2.1.1.3.0
akko81

Post by akko81 »

Is there anyway to print the whole string value as a GPRINT on the graph as opposed to graphing the actual integer value?
Tank

Post by Tank »

You can add a graph with no color. The problem with this is that if the uptime value is larger than the rest of the graphed items, the graph will be wrongly scaled.

Tank
Guest

Post by Guest »

I've made a change here to allow the uptime to be displayed in the graph as a comment. It uses a script to do an snmp get on the target device. After applying the patch you can just use |sys_uptime| in your comment and it will replace it with the uptime.

e.g Uptime: |sys_uptime| will print a comment like Uptime: 195 days, 14:04:22.12 on the graph.

You might need to change the path to your cacti scripts directory in the patch before applying it (sorry I couldn't make it cleaner!).
Attachments
rrd_php_show_uptime.zip
Show uptime in graph patch, shell script to retrieve uptime.
(808 Bytes) Downloaded 951 times
Speedster
Posts: 27
Joined: Wed Feb 11, 2004 7:53 pm
Location: Perth, Australia

Post by Speedster »

Argh! Forgot to login again!

This is what the uptime on the graph looks like.
Attachments
njord.png
njord.png (10.25 KiB) Viewed 13323 times
loop
Posts: 1
Joined: Tue Dec 30, 2003 3:53 am

Post by loop »

Speedster - Your patch applies cleanly to 0.8.4, but for some reason I'm unable to get the uptime onto the graph. I'm using FreeBSD 4.9 and I did check that the OID reported the uptime. I had to edit the patch to get the path to the script correct, and the script is exectutable - so I'm at a loss why it won't work. Any thoughts?
Attachments
graph_image.php.png
graph_image.php.png (4.28 KiB) Viewed 13236 times
I'd give my right arm to be ambidextrous
Guest

Post by Guest »

Not sure, I've generated the patch against 0.8.5. At a guess I'd say it's either not entering the text substitution for some reason.
Speedster
Posts: 27
Joined: Wed Feb 11, 2004 7:53 pm
Location: Perth, Australia

Post by Speedster »

^---------- that was me :oops:
r_chetanjain
Cacti User
Posts: 83
Joined: Fri Aug 22, 2003 4:33 am

how do i pass a comment

Post by r_chetanjain »

i am new to snmp,rrd,mrtg.....how do i pass a comment Uptime

chetan.
karunesh
Posts: 15
Joined: Mon Feb 02, 2004 1:25 pm
Location: India

how to

Post by karunesh »

Speedster.

Can you pls let us know how to apply this patch on linux sys.

Thanks
__Kårunesh__
Speedster
Posts: 27
Joined: Wed Feb 11, 2004 7:53 pm
Location: Perth, Australia

Post by Speedster »

Once you have put the script in the scripts directory and edited the diff file so the paths are correct, run

patch -p0 < /path/to/rrd_php_show_uptime.patch

from your cacti directory
Mika
Cacti User
Posts: 64
Joined: Tue Mar 23, 2004 3:01 am

Post by Mika »

Hi guys,

I've made patch but graphs no longer showing. I get an erro message when I click on "source":

Code: Select all

 
Warning: Undefined variable: current_field in /opt/cacti-0.8.5/lib/rrd.php on line 637

/usr/bin/rrdtool graph - \
--imgformat=GIF \
--start=end-138240 \
--end=1081433361 \
COMMENT:"From 2004-04-07 01:45:21 to 2004-04-08 16:09:21\c" \
COMMENT:"Graph Generated at 2004-04-08 16:09:21\c" \
--title="battery_in_voltage" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
DEF:a="/opt/cacti-0.8.5/rra/t_vilnsav_ups_4_in_voltage_358.rrd":in_voltage:AVERAGE \
AREA:a#FF7D00:""  \
GPRINT:a:LAST:"Current\:%8.2lf %s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" 
script name for uptime is snmp_cisco_uptime.sh under script/ directory

Can anyone help me with this?
Thanks in advance
Speedster
Posts: 27
Joined: Wed Feb 11, 2004 7:53 pm
Location: Perth, Australia

Post by Speedster »

Are you using 0.8.5 or have you upgraded to 0.8.5a? I found when applying the patch to 0.8.5a the text substitution variables had changed since 0.8.5.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests