%# %# NAVBAR %#
%# %# MAP %# %if ($arg_t eq 'svg' and $enabled{svg}) { % $m->comp("SELF:netmap_svg", f => $exists{svg}); %} elsif ($enabled{$arg_t}) { % $m->comp("SELF:netmap_img", f => $netdisco::CONFIG{"graph_$arg_t"}); %} else {

Network Map not enabled

Please edit netdisco.conf and run netdisco -g. %} %# %# KEY %# <%args> $w => 1024 $a => '16:9' # laptop $t => '' <%shared> my ($arg_w,$arg_a,$arg_t,$arg_h); my @types = qw/map png gif svg jpg jpeg/; my @types_on = (); my %enabled = (); my %exists = (); my $dir; <%init> $arg_w = $w; $arg_a = $a; $arg_t = $t; $dir = $m->current_comp->source_dir; # Width / Height handling (SVG only) my @w_opts = qw/400 600 800 1024 1200 1400/; my @a_opts = qw/4:3 3:2 16:9/; $arg_h = (9/16)*$arg_w; if ($arg_a =~ /^(\d+):(\d+)$/) { $arg_h = ($2/$1)*$arg_w; } # Hack for default graph my $default = $netdisco::CONFIG{graph}; my $def_ext; if (defined $default) { $def_ext = $default; $def_ext =~ s/^.*\.([^\.]+)$/$1/; $netdisco::CONFIG{"graph_$def_ext"} = $netdisco::CONFIG{graph}; } # # Check for each type being enabled and created # foreach my $type (@types) { my $file = $netdisco::CONFIG{"graph_$type"}; $file =~ s,^.*/,,g; # strip path $enabled{$type} = defined $file; push(@types_on,$type) if $enabled{$type} and $type ne 'map'; next unless $enabled{$type}; my $path = "$dir/$file"; $exists{$type} = -r $path ? $file : 0; } # Select one as default if we haven't selected one if ($t eq '' or !grep(/^\Q$t\E$/,@types_on)) { $t = $netdisco::CONFIG{graph_default} || $def_ext || $types_on[0] || 'svg'; $arg_t = $t; } # Key creation my $right_key = [ [ '--------', 'WAN' ], [ '-------', '10Mbps' ], [ '=======', '100Mbps' ], [ '=======', '1.0 Gbps' ] ]; my $left_key = []; foreach my $map (@{$netdisco::CONFIG{node_map}}) { my ($var,$regex,$attr,$val,$name,$label) = split(':',$map); next unless $name && $label; my ($textcolor) = $netdisco::CONFIG{node_fontcolor} || 'white'; my ($bracketcolor) = $netdisco::CONFIG{graph_color} || 'white'; if ($attr eq 'fillcolor') { $textcolor = $bracketcolor = $val; } elsif ($attr eq 'color') { $bracketcolor = $val; } my($txt) = '['; if ($textcolor ne $bracketcolor) { $txt .= ''; } $txt .= $name; if ($textcolor ne $bracketcolor) { $txt .= ''; } $txt .= ']'; push(@{$left_key}, [ $txt, $label ]); } my $problem = $netdisco::CONFIG{node_problem} || 'red'; my $colorname = $problem; $colorname =~ s/^./\U$&/; push(@{$left_key}, [ '[bad-dev]', 'Device Unaccessable' ]); %# %# netmap_map() %# <%method netmap_map> <%perl> return unless $enabled{'map'}; unless ($exists{'map'}) { $m->comp("SELF:no_file", f => $netdisco::CONFIG{graph_map}); return; } my (@map, $map_age, $secs_per_day, $map_days); open (MAP, "< $exists{'map'}"); @map = (); close (MAP); % foreach my $line (@map){ <%$line%> % } %# %# netmap_img() %# <%method netmap_img> <& SELF:netmap_map &> % my $file = $exists{$arg_t}; % unless ($file) { % $m->comp('SELF:no_file', f=>$netdisco::CONFIG{"graph_$arg_t"}); % return; % } Network Map
<%$file%> is <&SELF:file_age_days, f=>"$dir/$file"&> days old. %# %# netmap_svg() %# <%method netmap_svg> <%args> $f => '' <%perl> unless ($exists{'svg'}) { $m->comp("SELF:no_file", f => $netdisco::CONFIG{graph_svg}); return; } %#
Function Mouse Keyboard
Zoom Mouse Wheel / Shift+Click+Vertical Drag + / -
PageUp / PageDown
Pan Click+Drag Arrow Keys
Open Device Double-Click / Middle Click
Tool Pallet Move to Top-Left corner
%# %# no_file( f=>file ) %# <%method no_file> <%args> $f => ''

Error

File <%$f|h%> is not accessable. Please run netdisco -g or use the Admin Panel. %# %# file_age_days(f => file) %# <%method file_age_days> <%args> $f => undef <%perl> return -1 unless -r $f; my $secs_per_day = 60*60*24; my $age = (stat($f))[9]; $age = time - $age; my $days = sprintf("%-2.2f", $age/$secs_per_day); <%$days|h%>\ %# %# Add javascript routines to header %# tl(layer) - Toggles Layer visibility %# tlgo(layer,[anchor]) - Toggles layer and goes to anchor, %# default anchor is same as layer %# <%method html_head> <%method title> - Network Map \ %# $Id$ %# vim:syntax=mason