Netstat

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

Moderators: Developers, Moderators

Post Reply
pheezy
Cacti User
Posts: 61
Joined: Thu Oct 26, 2006 5:30 pm

Netstat

Post by pheezy »

EDIT: Updated to use snmpnetstat

Here's a netstat graph I made for linux.

Steps to install:
1. Copy netstat.sh to %CACTI_HOME%/scripts/ (for me this is /var/www/cacti), and make sure it is executable.
2. Import template into cacti, and start graphing.

You will need to provide the community string when creating the graph, unless someone can tell me how to automatically pass that to a script-type data input. :)

Unfortunately, I was unable to make it completely SNMP based so I had to wrap snmpnetstat in a shell script; some of my network devices did not have the correct OIDs as described by Howie, but this script input works correctly for Windows, Linux, BSD, and even some network devices!

Enjoy!

This is all released under GPL2 so do what you want with it. :)
Attachments
netstat.sh
This goes in %CACTI_HOME%/scripts. Make sure it is executable with chmod +x or owned by cacti.
(341 Bytes) Downloaded 977 times
cacti_graph_template_ucdnet_-_snmpnetstat.xml
Exported with 0.8.7a
(26.21 KiB) Downloaded 1001 times
Fancy screenshot.
Fancy screenshot.
netstat.png (37.04 KiB) Viewed 11978 times
Last edited by pheezy on Mon Dec 10, 2007 9:57 pm, edited 1 time in total.
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

If you're already running net-snmp snmpd on the remote machines, then you can get most of the same info from snmpnetstat:

Code: Select all

snmpnetstat -v 1 -c public -Cs myserver
which in turn suggests that there are probably real OIDs for it too, which is a whole lot more efficient than an exec. And works on non-linux too, even non-Unix.

Just saying.

Edit: This is the MIB that snmpnetstat uses.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
pheezy
Cacti User
Posts: 61
Joined: Thu Oct 26, 2006 5:30 pm

Post by pheezy »

Hey thanks I didn't know about snmpnetstat; I'll make the changes tonight. :)
artiflo
Cacti User
Posts: 76
Joined: Wed Dec 19, 2007 2:00 pm

Post by artiflo »

I have an error when I try to import the template "Error: XML: Hash version does not exist."

I am in 0.8.6j, How I can import your template 0.8.7a into 0.8.6j ?
pheezy
Cacti User
Posts: 61
Joined: Thu Oct 26, 2006 5:30 pm

Post by pheezy »

I don't think you can, and I only tested it in 0.8.7a, sorry. :(
ericgearhart
Posts: 11
Joined: Wed Feb 11, 2009 12:59 pm
Contact:

Post by ericgearhart »

artiflo wrote:I have an error when I try to import the template "Error: XML: Hash version does not exist."?
Yes, the hash table error is what you get when you try to import a template exported from a newer ver of Cacti than what you're running'


You can only import "up," to a newer version of Cacti, not "down"
ericgearhart
Posts: 11
Joined: Wed Feb 11, 2009 12:59 pm
Contact:

Post by ericgearhart »

Thanks for the netstat template though man... setting it up now ^_^

Just so everyone's aware... make sure you rename "netstat_208.sh" to netstat.sh if you wget it down to your cacti/scripts folder
ericgearhart
Posts: 11
Joined: Wed Feb 11, 2009 12:59 pm
Contact:

Re: Netstat

Post by ericgearhart »

pheezy wrote:EDIT:You will need to provide the community string when creating the graph, unless someone can tell me how to automatically pass that to a script-type data input. :)
Here's a screenshot of my modified Data Input Method, that shows how to pass the snmp community string so you don't have to enter it in for every device added... the "special type code" is what does the trick:
Attachments
snmpnetstat.png
snmpnetstat.png (45.07 KiB) Viewed 9066 times
ericgearhart
Posts: 11
Joined: Wed Feb 11, 2009 12:59 pm
Contact:

Post by ericgearhart »

Here's my modified templates, for those like me who are truly lazy and just want to import templates :)

This was exported from Cacti 0.8.7d
Attachments
cacti_graph_template_ucdnet_-_snmpnetstat.xml
(24.29 KiB) Downloaded 300 times
kido
Posts: 37
Joined: Thu Mar 19, 2009 3:56 am
Location: Bucharest

Post by kido »

Hello,

I am not sure I understood: besides the xml template file, do I need to download something else? Cause I downloaded and imported it, everything looked fine, but the graph displays only nan values.

Then I checked Data sources for the monitored host and discovered that there's only one data source. Is this ok?

Thank you!
Attachments
netstat.png
netstat.png (46.05 KiB) Viewed 9049 times
kido
Posts: 37
Joined: Thu Mar 19, 2009 3:56 am
Location: Bucharest

Post by kido »

Forgot to mention this:

Cacti Version 0.8.7d
Cacti OS unix
SNMP Version NET-SNMP version: 5.3.2.2
RRDTool Version RRDTool 1.2.x
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Since Netstat pulls from the RFC1213 MIB, you all realize a snmp script/templates have already been created for it -- including TCP stats?
kido
Posts: 37
Joined: Thu Mar 19, 2009 3:56 am
Location: Bucharest

Post by kido »

many thanks!
ericgearhart
Posts: 11
Joined: Wed Feb 11, 2009 12:59 pm
Contact:

Post by ericgearhart »

BSOD2600 wrote:Since Netstat pulls from the RFC1213 MIB, you all realize a snmp script/templates have already been created for it -- including TCP stats?
Wow... that's really in-depth. No I'd just been searching the forum for netstat and this was the first thread I'd come across. Thanks.
ericgearhart
Posts: 11
Joined: Wed Feb 11, 2009 12:59 pm
Contact:

Post by ericgearhart »

kido wrote:Hello,

I am not sure I understood: besides the xml template file, do I need to download something else? Cause I downloaded and imported it, everything looked fine, but the graph displays only nan values.
kido: if you're still trying to get this version to work, did you copy the netstat shell script to your cacti/scripts folder?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest