Cisco DHCP statistics (c3750, c1800, ...)

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

Moderators: Developers, Moderators

Post Reply
l33
Posts: 4
Joined: Thu Dec 16, 2010 8:19 am
Location: Paris. France
Contact:

Cisco DHCP statistics (c3750, c1800, ...)

Post by l33 »

Hello,

The purpose is to get DHCP servers statistics from Cisco routers (and associated IOS) who do not support a few MIBs related to DHCP.
It's my case with a Cisco 3750 who provides 4 DHCP pools, and a c1803 providing one pool.
For persons who are working with c3750, they know this equipment is a piece of sh*t to monitor a bit deeply (no temp env available, ...).
As a workaround, Cisco provides an embedded script in Tcl (tool command language) to convert datas to snmp, but it breaks small routers (100% cpu) - and sometimes erase flash memory :/

There're 3 parts in the perl script :

-> get the dhcp server memory (the only usefull stats for ths command):

Code: Select all

#sh ip dhcp server statistics 
Memory usage         70884
...
-> get the pool stats - you can indicates many pools
. number of excluded IPs
. number of leased IPs
. max number IPs available in the pool, as a legend in the graphs

-> get the IPs conflicts (differenciating gratuitous ARP detection method and ping detection method)


I had only one problem : make the perl script working with Spine, that's just impossible, I searched a solution everywhere in Google and this forum, I just saw there's bugs with some kind of script outputs.
(if Mister TheWitness could listen ... :)

In the attached file, you will find all captures images, the perl script, and all the XML I exported through the cacti web gui, 0.8.7g.
All the infos and the use of the files are in the README inside the compressed attached file, I let the content here :

Code: Select all

# ------------------ #
#  Cisco DHCP stats  #
# ------------------ #

# -- Environment:

- Cacti:

Cacti Version - 0.8.7g
Plugin Architecture - 2.8
Poller Type - CMD.php

- Server:

Server Info - Linux 2.6.32-22-server
Web Server - lighttpd 1.4.26 (ssl)
PHP - 5.3.2-1ubuntu4.5
MySQL - 5.1.41-3ubuntu12.8
RRDTool - 1.3.8
SNMP - 5.4.2.1

 - Plugins:

Host Info (hostinfo - v0.2)
Login Page Mod (loginmod - v1.0)
PHP Network Weathermap (weathermap - v0.97a)
Global Plugin Settings (settings - v0.5)
Syslog Monitoring (syslog - v0.5.2)
Read-only Devices Tab (devices - v0.4)

# -- Installation:

1.      place cisco_dhcp_stats.pl in $cacti_path/scripts directory
2.      create the data input methods as shown in the images (conflicts, memstats, poolstats)
3.      import cisco_dhcp_*_template.xml files to Cacti using web interface
4.      add the graph templates to your device with your values (username, ...)
5.      create graphs
5 bis.  if you have many pools for a server, add new poolstats graph for each one,
        and don't forget to indicate the |pool_name| for data sources and graph.
6.      add graphs to your trees

# -- Data Input Methods command line :

1.  pool statistics :

/usr/bin/perl <path_cacti>/scripts/cisco_dhcp_stats.pl --host <hostname> --port <port> --username <username> --password <password> --enable <enable> --appli poolstats --pool <poolname>

2.  IP conflicts stats :

/usr/bin/perl <path_cacti>/scripts/cisco_dhcp_stats.pl --host <hostname> --port <port> --username <username> --password <password> --enable <enable> --appli conflicts

3.  memory stats :

/usr/bin/perl <path_cacti>/scripts/cisco_dhcp_stats.pl --host <hostname> --port <port> --username <username> --password <password> --enable <enable> --appli memstats

# -- Notes:

the perl script works only with the CMD.php poller, it never wanna work with Spine (0.8.7).
tried too with the compile option "nifty popen" ...

a few infos : http://forums.cacti.net/viewtopic.php?f=2&t=38693&start=15

if you have the solution, please share it !

As an ending of my post, the time to execute the script :

Code: Select all

~/scripts$ time /usr/bin/perl cisco_dhcp_stats.pl --host ... --port 22023 --username ... --password ... --enable ... --appli poolstats --pool DATA-POOL
poolexcl:10 poolleased:120 poolmax:2046 
real	0m0.776s
user	0m0.070s
sys	0m0.000s
'hope my contrib can help someone.
Attachments
cisco_dhcp_stats.tar.gz
cisco dhcp stats
(379.69 KiB) Downloaded 699 times
jkrejci
Posts: 11
Joined: Mon Sep 27, 2010 9:44 am

Re: Cisco DHCP statistics (c3750, c1800, ...)

Post by jkrejci »

I will have to take a look at this.

We have the DHCP lease file get written to a tftp server (ios config does this for us). We then have scripts that parse these files in conjunction with copy of the running config (initiated via SNMP to copy to the same tftp server). We are able to manually parse out the pools, sizes, leases/utilization, interfaces the pools are used on, etc. We can then spit all this data out in a script to SNMP which can then be graphed into cacti or in some cases just spits out an email when utilization gets too high or whatever we want really. This essentially has no load on the cisco (we're using a lot of 3560's for this).
l33
Posts: 4
Joined: Thu Dec 16, 2010 8:19 am
Location: Paris. France
Contact:

Re: Cisco DHCP statistics (c3750, c1800, ...)

Post by l33 »

great method, jkrejci, I would prefer it, but in my case I don't have any local server and can't take out the configs and some stuff (no snmp v3, etc) :(

by the way, this script is for speed monitoring purpose, and sure good enough for most people ?
cksrealm
Cacti User
Posts: 140
Joined: Sun May 08, 2005 5:45 pm
Location: Sydney,Australia
Contact:

Re: Cisco DHCP statistics (c3750, c1800, ...)

Post by cksrealm »

This is awesome well done mate really like it
System - Red Hat Enterprise
Cacti Version - 1.2.23
RRDTool - 1.7.0
Poller - CMD
[u]Plugins Installed[/u]
Monitor 2.5
ReportIT 1.1.3
Thold 1.7
Weathermap 1.0
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests