port status templates with automated port discovery v00.01

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

Moderators: Developers, Moderators

Post Reply
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

port status templates with automated port discovery v00.01

Post by johnrembo »

Hello community,

I did not found any set of scripts/templates to check port(-s) status of a specific device, so had to make my own.

Yes, I know - manage plug-in has this feature, but I've also needed a port scanner in addition.

A data-query uses nmap to scan host and detect services running
Image

And resulting charts (it measures time to establish socket connectivity, which should be in ms at most)
Image

however, due to some strange issues related with php and nmap - a scan might happen much faster in some cases (i.e. it might take 6 seconds for a data query to reload instead of 30), but with reduced amount of info avaiable (can't figure why this happens - please write me if you have some ideas). Anyway - it works.

Image

ps: by default nmap scans for TCP ports. You can adjust it's command-line parameters on your own, but existing version of script checks only for TCP ports - small fix might be necessary if you're interested in UDP as well.

ps: don't forged to edit socket_states.php to change nmap and tmp folder paths.
ps2: not tested on windows
ps3: php-xml extension is required!

tested on: freebsd, debian, centos
nmap: 3.7, 5.x
Attachments
socket_states.tar.gz
v00.01 (tiny error updated at line 184 at socket_states.php)
(5.33 KiB) Downloaded 199 times
socket_states.zip
v00.01 (tiny error updated at line 184 at socket_states.php)
(6.42 KiB) Downloaded 189 times
Last edited by johnrembo on Mon Jul 26, 2010 8:25 am, edited 4 times in total.
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
unnamed
Posts: 1
Joined: Sun Feb 28, 2010 7:33 am

z

Post by unnamed »

hmmmm I'm sorry but where is socket_states.xml .. :(
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

Re: z

Post by johnrembo »

unnamed wrote:hmmmm I'm sorry but where is socket_states.xml .. :(
look above :)

you must download uncompressed .xml file + compressed .php file (.zip or .gzip)
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
shd
Cacti User
Posts: 96
Joined: Mon Apr 09, 2007 1:33 pm
Location: Nizhnevartovsk, Russia

Re: z

Post by shd »

johnrembo wrote:you must download uncompressed .xml file + compressed .php file (.zip or .gzip)

Code: Select all

+ Running data query [34].
+ Found type = '4 '[script query].
+ Could not find data query XML file at '.../resource/script_queries/socket_states.xml'
+ Error parsing XML file into an array.
+ Could not find data query XML file at '.../resource/script_queries/socket_states.xml'
+ Could not find data query XML file at '.../resource/script_queries/socket_states.xml'
+ Could not find data query XML file at '.../resource/script_queries/socket_states.xml'
uncompressed xml file is not enough - it is a template export.
CentOS 64-bit, 20Gb RAM, 8xCPU, some virtual datastore. 600+ hosts, 200k+ datasources, avg polltime 45 sec
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

Re: z

Post by johnrembo »

shd wrote:
johnrembo wrote:you must download uncompressed .xml file + compressed .php file (.zip or .gzip)

Code: Select all

+ Running data query [34].
+ Found type = '4 '[script query].
+ Could not find data query XML file at '.../resource/script_queries/socket_states.xml'
+ Error parsing XML file into an array.
+ Could not find data query XML file at '.../resource/script_queries/socket_states.xml'
+ Could not find data query XML file at '.../resource/script_queries/socket_states.xml'
+ Could not find data query XML file at '.../resource/script_queries/socket_states.xml'
uncompressed xml file is not enough - it is a template export.
oh crap, sorry :)
I've repacked and reattached the files - should be fine now
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
User avatar
gilles
Cacti User
Posts: 250
Joined: Tue Jul 12, 2005 8:16 pm

Post by gilles »

right, manage can't do that
but there is a workaround in the ports template
i don't recommend this (php time limit on scripts if you use this) but you can edit scripts/ports.inc to specifically add any port you want to scan
1 port per line...
then run a Verbose Query
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

Post by johnrembo »

gilles wrote:right, manage can't do that
but there is a workaround in the ports template
i don't recommend this (php time limit on scripts if you use this) but you can edit scripts/ports.inc to specifically add any port you want to scan
1 port per line...
then run a Verbose Query
Oh, I must have missed that...
Well, theoreticaly I had same idea - to build a php-based port-discovery tool, yet, after digging more into nmap's advanced features it became obvious - you can't perform that fast on php side (I'm not even mentioning App./OS Discovery features).

Anyway, Gilles, maybe you've come with some i.e. data_input template that could use you port checking scripts to graph (visualize) historical port availability? That's the major thing I've missed in "Manage".
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests