blib/lib/App/Netdisco.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 17 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package App::Netdisco;
2  
3 use strict;
4 use warnings;
5 use 5.010_000;
6  
7 our $VERSION = '2.119000';
8 use App::Netdisco::Configuration;
9  
10 =head1 NAME
11  
12 App::Netdisco - An open source web-based network management tool.
13  
14 =head1 DESCRIPTION
15  
16 Netdisco is a web-based network management tool designed for network
17 administrators. Data is collected into a PostgreSQL database using SNMP.
18  
19 Some of the things you can do with Netdisco:
20  
21 =over 4
22  
23 =item *
24  
25 B<Locate> a machine on the network by MAC or IP and show the switch port it
26 lives at
27  
28 =item *
29  
30 B<Turn off> a switch port, or change the VLAN or PoE status of a port
31  
32 =item *
33  
34 B<Inventory> your network hardware by model, vendor, software and operating
35 system
36  
37 =item *
38  
39 B<Pretty pictures> of your network
40  
41 =back
42  
43 L<App::Netdisco> provides a web frontend with built-in web server, and a
44 backend daemon to gather information from your network, and handle
45 interactive requests such as changing port or device properties.
46  
47 =over 4
48  
49 =item *
50  
51 See the demo at: L<https://netdisco-demo-jyxhs.ondigitalocean.app/>
52  
53 =item *
54  
55 L<Container images|https://hub.docker.com/r/netdisco/netdisco> are also available
56  
57 =back
58  
59 We have several other pages with tips for
60 L<installation tips|https://github.com/netdisco/netdisco/wiki/Install-Tips>,
61 L<understanding and troubleshooting Netdisco|https://github.com/netdisco/netdisco/wiki/Troubleshooting>,
62 L<notes for specific device vendors|https://github.com/netdisco/netdisco/wiki/Vendor-Tips>,
63 and L<all the configuration options|https://github.com/netdisco/netdisco/wiki/Configuration>.
64  
65 You can also speak to someone in the C<#netdisco@libera> IRC channel, or on
66 the L<community email list|https://lists.sourceforge.net/lists/listinfo/netdisco-users>.
67 Before installing or upgrading please always review the latest
68 L<Release Notes|https://github.com/netdisco/netdisco/wiki/Release-Notes>.
69  
70 =head1 Dependencies
71  
72 Netdisco requires Perl 5.24 or newer and PostgreSQL 9.6 or newer. Some of
73 the libraries a new installation downloads need Perl 5.24.
74  
75 Most other dependencies will be automatically installed, but we require that
76 the following items are installed using your own operating system, to get the
77 most compatible versions. Please run the commands below.
78  
79 On Ubuntu/Debian:
80  
81 root:~# apt-get install libdbd-pg-perl libsnmp-perl libssl-dev libio-socket-ssl-perl python3 python3-venv curl postgresql build-essential
82  
83 On Fedora/Red-Hat:
84  
85 root:~# yum install perl-core perl-DBD-Pg net-snmp-perl net-snmp-devel openssl-devel python3 postgresql-server postgresql-contrib make automake gcc
86 root:~# postgresql-setup initdb
87 root:~# systemctl start postgresql
88 root:~# systemctl enable postgresql
89  
90 On openSUSE:
91  
92 root:~# zypper refresh
93 root:~# zypper install curl automake gcc make postgresql postgresql-server openssh openssl libopenssl-devel python3 net-snmp perl perl-DBD-Pg perl-SNMP
94  
95 On SUSE Linux Enterprise Server 15 and later:
96  
97 root:~# zypper refresh
98 root:~# zypper install postgresql postgresql-devel postgresql-server postgresql-server-devel libdbi-drivers-dbd-pgsql perl-DBI perl-DBD-Pg perl-SNMP perl-HTTP-Parser-XS perl-Module-Install net-snmp net-snmp-devel python3 curl make automake gcc
99  
100 We also have a L<FreeBSD guide|https://github.com/netdisco/netdisco/wiki/FreeBSD-Install>
101 and L<OpenBSD guide|https://github.com/netdisco/netdisco/wiki/OpenBSD-Install>.
102  
103 With those installed, please check that your system's clock is correct. We
104 also recommend that you run Netdisco in UTC (time zone +0) if possible, to
105 avoid issues with Daylight Savings Time changes.
106  
107 Create a user on your system called C<netdisco> if one does not already exist.
108 We'll install Netdisco and its dependencies into this user's home area, which
109 will take about 250MB including MIB files.
110  
111 root:~# useradd -m -p x -s /bin/bash netdisco
112  
113 Netdisco uses the PostgreSQL database server. Install PostgreSQL (at least
114 version 9.6) and then change to the PostgreSQL superuser (usually
115 C<postgres>). Create a new database and PostgreSQL user for the Netdisco
116 application:
117  
118 root:~# su - postgres
119
120 postgres:~$ createuser -DRSP netdisco
121 Enter password for new role:
122 Enter it again:
123
124 postgres:~$ createdb -O netdisco netdisco
125  
126 You may wish to L<amend the PostgreSQL
127 configuration|https://github.com/netdisco/netdisco/wiki/Install-Tips#enable-md5-authentication-to-postgresql>
128 so that local connections are working.
129  
130 The default PostgreSQL configuration isn't tuned for large installations
131 on modern server hardware. We recommend L<https://pgtune.leopard.in.ua/>.
132  
133 =head1 Installation
134  
135 The following is a general guide which works well in most circumstances. It
136 assumes you have a user C<netdisco> on your system, that you want to perform
137 an on-line installation, and have the application run self-contained from
138 within that user's home. There are alternatives: see the
139 L<Deployment|https://github.com/netdisco/netdisco/wiki/Install-Tips>
140 documentation for further details.
141  
142 To avoid muddying your system, use the following script to download and
143 install Netdisco and its dependencies into the C<netdisco> user's home area
144 (C<~/perl5>):
145  
146 su - netdisco
147 curl -L https://cpanmin.us/ | perl - --notest --local-lib ~/perl5 App::Netdisco
148  
149 Link some of the newly installed apps into a handy location:
150  
151 mkdir ~/bin
152 ln -s ~/perl5/bin/{localenv,netdisco-*} ~/bin/
153  
154 If you will authenticate users with TACACS+, also install the
155 Authen::TacacsPlus module, which Netdisco does not install for you:
156  
157 ~/bin/localenv cpanm --notest Authen::TacacsPlus
158  
159 On systems with GCC 15 or newer, such as Ubuntu 26.04, build it in C17 mode:
160  
161 CFLAGS="-std=gnu17" ~/bin/localenv cpanm --notest Authen::TacacsPlus
162  
163 Test the installation by running the following command, which should only
164 produce a status message (it's just a test - you'll start the daemons
165 properly, later on):
166  
167 ~/bin/netdisco-backend status
168  
169 =head1 Configuration
170  
171 Make a directory for your local configuration and copy the configuration
172 template from this distribution:
173  
174 mkdir ~/environments
175 cp ~/perl5/lib/perl5/auto/share/dist/App-Netdisco/environments/deployment.yml ~/environments
176 chmod 600 ~/environments/deployment.yml
177  
178 Edit the file ("C<~/environments/deployment.yml>") and change the database
179 connection parameters to match those for your local system (that is, the
180 C<name>, C<user> and C<pass>).
181  
182 In the same file uncomment and edit the C<domain_suffix> setting to be
183 appropriate for your local site. Change the C<community> string setting if
184 your site has different values.
185  
186 Have a quick read of the other settings to make sure you're happy, then move
187 on. See
188 L<Configuration|https://github.com/netdisco/netdisco/wiki/Configuration> for
189 further details.
190  
191 =head1 Initialisation
192  
193 The database either needs configuring if new, or updating from the current
194 release of Netdisco (1.x). You also need vendor MAC address prefixes (OUI
195 data) and some MIBs if you want to run the backend daemon. The following
196 script will take care of all this for you:
197  
198 ~/bin/netdisco-deploy
199  
200 If this is a new installation of Netdisco 2, answer yes to all questions. If
201 you wish to deploy without Internet access, see the
202 L<Deployment|https://github.com/netdisco/netdisco/wiki/Install-Tips>
203 documentation.
204  
205 =head1 Startup
206  
207 Run the following command to start the web-app server as a background process:
208  
209 ~/bin/netdisco-web start
210  
211 The web app listens on port 5000 (for example C<< http://localhost:5000/ >> or
212 C<< http://yourhost.example.com:5000/ >>).
213  
214 Run the following command to start the job control daemon (device polling,
215 port control, etc):
216  
217 ~/bin/netdisco-backend start
218  
219 =head1 First Run
220  
221 After installing Netdisco for the first time, you must manually discover at
222 least one device on your network. Choose a device which speaks CDP, FDP, or
223 LLDP and knows about its neighbors; Netdisco will then start following this
224 chain of neighbors to discover the rest of your network.
225  
226 Either go to the web interface and enter an IP or fully qualified domain name,
227 OR perform the following step at the command line:
228  
229 ~/bin/netdisco-do discover -d {name or IP address of a switch or router}
230  
231 =head1 Further Reading
232  
233 We have several pages with tips for
234 L<alternate deployment scenarios|https://github.com/netdisco/netdisco/wiki/Install-Tips>,
235 L<understanding and troubleshooting Netdisco|https://github.com/netdisco/netdisco/wiki/Troubleshooting>,
236 L<tips and tricks for specific platforms|https://github.com/netdisco/netdisco/wiki/Vendor-Tips>,
237 and L<all the configuration options|https://github.com/netdisco/netdisco/wiki/Configuration>.
238  
239 You can also speak to someone in the C<#netdisco@libera> IRC channel, or on
240 the L<community email list|https://lists.sourceforge.net/lists/listinfo/netdisco-users>.
241 Before installing or upgrading please always review the latest
242 L<Release Notes|https://github.com/netdisco/netdisco/wiki/Release-Notes>.
243  
244 =head1 Upgrading from 2.x
245  
246 Netdisco requires PostgreSQL 9.6 or newer. An installation on a Perl older
247 than 5.24 can still be upgraded, because the libraries it already has are
248 kept, until a release requires a newer version of one of them. A new
249 installation needs Perl 5.24 or newer.
250  
251 Always review the latest L<Release Notes|https://github.com/netdisco/netdisco/wiki/Release-Notes>.
252 Then the process below should be run for each installation:
253  
254 # upgrade Netdisco
255 ~/bin/localenv cpanm --notest App::Netdisco
256 ln -sf ~/perl5/bin/{localenv,netdisco-*} ~/bin/
257
258 # apply database schema updates, update MIBs and Vendor MACs
259 ~/bin/netdisco-deploy
260
261 # restart web service (if you run it)
262 ~/bin/netdisco-web restart
263
264 # restart the backend workers (wherever you run them)
265 ~/bin/netdisco-backend restart
266  
267 Furthermore, whenever you upgrade your Operating System, you must delete the
268 C<~/perl5> directory and re-run the following command, to update Netdisco's C
269 library bindings (and then run all of the above upgrade commands again):
270  
271 curl -L https://cpanmin.us/ | perl - --notest --local-lib ~/perl5 App::Netdisco
272  
273 =head1 Tips and Tricks
274  
275 =head2 Searching
276  
277 The main black navigation bar has a search box which is smart enough to work
278 out what you're looking for in most cases. For example device names, node IP
279 or MAC addresses, VLAN numbers, and so on.
280  
281 =head2 Command-Line Device and Port Actions
282  
283 Most significant Device jobs and Port actions, as well as several
284 troubleshooting and housekeeping duties, can be performed at the command-line
285 with the L<netdisco-do> program. For example:
286  
287 ~/bin/netdisco-do -D discover -d 192.0.2.1
288  
289 See the L<netdisco-do documentation|netdisco-do> for further details.
290  
291 =head2 Import Topology
292  
293 Netdisco 1.x had support for a topology information file to fill in device
294 port relations which could not be discovered. This is now stored in the
295 database (and edited in the web interface). To import a legacy topology file,
296 run:
297  
298 ~/bin/localenv nd-import-topology /path/to/netdisco-topology.txt
299  
300 =head2 Database API
301  
302 Bundled with this distribution is a L<DBIx::Class> layer for the Netdisco
303 database. This abstracts away all the SQL into an elegant, re-usable OO
304 interface. See the L<Developer|https://github.com/netdisco/netdisco/wiki/Developing>
305 documentation for further information.
306  
307 =head2 Plugins
308  
309 Netdisco includes a Plugin subsystem for customizing the web user interface and backend daemon.
310 See L<Web Plugins|https://github.com/netdisco/netdisco/wiki/Web-Plugins>
311 and L<Backend Plugins|https://github.com/netdisco/netdisco/wiki/Backend-Plugins>
312 for further information.
313  
314 =head2 Extensions
315  
316 Using the Plugins mechanism, it's also easy to write new commands (or actions)
317 for Netdisco. For example, an action has been added to L<generate RANCID
318 configuration|App::Netdisco::Worker::Plugin::MakeRancidConf>.
319  
320 =head2 Developing
321  
322 Lots of information about the architecture of this application is contained
323 within the L<Developer|https://github.com/netdisco/netdisco/wiki/Developing> documentation.
324  
325 =head1 AUTHOR
326  
327 Oliver Gorwits <oliver@co-ding.org>
328  
329 =head1 CONTRIBUTORS
330  
331 Netdisco was created at the University of California, Santa Cruz (UCSC),
332 Networking and Technology Services (NTS) department. UCSC continues to support
333 the development of Netdisco by providing development servers and beer.
334  
335 Original development by Max Baker, with significant contributions from Mark
336 Boolootian and Jim Warner (through whose ideas Netdisco was born and shaped),
337 Bill Fenner, Jeroen van Ingen, Eric Miller, Carlos Vicente, and Brian de Wolf.
338  
339 Other contributions (large and small) by Mike Hunter (UCB), Brian Wilson
340 (NCSU), Bradley Baetz (bbaetz), David Temkin (sig.com), Edson Manners (FSU),
341 Dmitry Sergienko (Trifle Co, .ua), Remo Rickli (PSI, Switzerland),
342 Jean-Philippe Luiggi (sagem.com), A.L.M Buxey (Loughborough University, UK),
343 Kevin Cheek (UMICH), John Bigrow (bnl.gov), George Pavel (llnl.gov), Charles
344 Goldsmith (wokka.org), Douglas M. McKeown (saintmarys.edu), Revital Shvarzman
345 (York U, Ontario), Walter Gould (Auburn U), Lindsay Druet and Colin Palmer (U
346 of Waikato, Hamilton NZ), Dusty Hall (Auburn U), Jon Monroe (center pointe),
347 Alexander Barthel, Bill Anderson, Alexander Hartmaier (t-systems.at), Justin
348 Hunter (Arizona State U), Jethro Binks (U of Strathclyde, Glasgow), Jordi
349 Guijarro (UAB.es), Sam Stickland (spacething.org), Stefan Radman (CTBTO.org),
350 Clint Wise, Max Kosmach, Bernhard Augenstein, Sebastian Roesch and Nick
351 Nauwelaerts (aquafin.be).
352  
353 We probably forgot some names - sorry about that :-(.
354  
355 Deep gratitude also goes
356 to the authors and communities of all the other software that Netdisco is
357 built upon.
358  
359 =head1 COPYRIGHT AND LICENSE
360
361 This software is copyright (c) 2003-2026 by The Netdisco Developer Team.
362
363 Redistribution and use in source and binary forms, with or without
364 modification, are permitted provided that the following conditions are met:
365 * Redistributions of source code must retain the above copyright
366 notice, this list of conditions and the following disclaimer.
367 * Redistributions in binary form must reproduce the above copyright
368 notice, this list of conditions and the following disclaimer in the
369 documentation and/or other materials provided with the distribution.
370 * Neither the name of the Netdisco Project nor the
371 names of its contributors may be used to endorse or promote products
372 derived from this software without specific prior written permission.
373
374 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
375 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
376 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
377 DISCLAIMED. IN NO EVENT SHALL THE NETDISCO DEVELOPER TEAM BE LIABLE FOR ANY
378 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
379 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
380 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
381 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
382 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
383 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
384  
385 =cut
386  
387 1;