Difference between revisions of "Netdisco"

From HackerNet
Jump to: navigation, search
Line 86: Line 86:
 
  echo "( sudo su - netdisco -c '/home/netdisco/run-netdisco.sh' ) &" >/etc/rc.local
 
  echo "( sudo su - netdisco -c '/home/netdisco/run-netdisco.sh' ) &" >/etc/rc.local
 
  reboot
 
  reboot
 +
 +
 +
upgrade Netdisco
 +
~/bin/localenv cpanm --notest App::Netdisco
 +
 +
apply database schema updates
 +
~/bin/netdisco-deploy
 +
 +
restart web service
 +
~/bin/netdisco-web restart
 +
 +
restart job daemon
 +
~/bin/netdisco-daemon restart

Revision as of 20:00, 28 December 2014

Netdisco hämtar MAC-tabeller, ARP-tabeller, VLAN-databaser, LLDP/CDP-grannskap, firmwareversioner, m.m från routrar och switchar med hjälp av SNMP. Man schemalägger när data ska samlas in.


Installation Ubuntu 14.04.1 LTS Server x64

Förberedelser

Denna guide är till stor del hämtad från: http://blog.asiantuntijakaveri.fi/2014/08/netdisco2-on-ubuntu-1404.html

sudo su -
apt-get update && apt-get -y dist-upgrade && apt-get -y install open-vm-tools build-essential wget lftp mtr-tiny zip ntp

Databas

apt-get -y install libdbd-pg-perl libsnmp-perl postgresql pgtune 
mv /etc/postgresql/9.3/main/postgresql.conf /etc/postgresql/9.3/main/postgresql.conf.old
pgtune -i /etc/postgresql/9.3/main/postgresql.conf.old -o /etc/postgresql/9.3/main/postgresql.conf

Switch to postgres user and create new SQL user

su - postgres
createuser -DRSP netdiscoUSER
Enter some password here
createdb --owner netdiscoUSER netdiscoDB

Switch back to root

exit

Netdisco

adduser netdisco --shell /bin/bash --disabled-password --gecos netdisco && su - netdisco
curl -L http://cpanmin.us/ | perl - --notest --local-lib ~/perl5 App::Netdisco
mkdir ~/bin
mkdir ~/environments
ln -s ~/perl5/bin/{localenv,netdisco-*} ~/bin/
~/bin/netdisco-daemon status

Här är grunden för deploymenten, lägg till de SNMP-communitys som ska användas. Schemaläggningen är i cron-format. T.ex. discoverall görs 10 över varje timme.

cat <<'__EOF__'>~/environments/deployment.yml
database:
 name: 'netdiscoDB'
 user: 'netdiscoUSER'
 pass: '(PW som sattes tidigare)'
safe_password_store: true
snmp_auth:
 - tag: 'default_1'
   community: 'puplic'
   read: true
   write: false
 - tag: 'default_2'
   community: 'public'
   read: true
   write: false
schedule:
 discoverall:
    when: '10 * * * *'
 macwalk:
    when: '35 * * * *'
 arpwalk:
    when: '45 * * * *'
 nbtwalk:
    when: '55 * * * *'
 expire:
    when: '15 23 * * *'
dns:
 max_outstanding: 50
workers:
 tasks: 'AUTO * 5'
__EOF__
~/bin/netdisco-deploy

Create script to start Netdisco

cat <<'__EOF__' >~/run-netdisco.sh
#!/bin/bash
~/bin/netdisco-web start
sleep 5
~/bin/netdisco-daemon start
__EOF__
chmod a+x ~/run-netdisco.sh
~/run-netdisco.sh

Switch back to root

exit 
echo "( sudo su - netdisco -c '/home/netdisco/run-netdisco.sh' ) &" >/etc/rc.local
reboot


upgrade Netdisco

~/bin/localenv cpanm --notest App::Netdisco

apply database schema updates

~/bin/netdisco-deploy

restart web service

~/bin/netdisco-web restart

restart job daemon

~/bin/netdisco-daemon restart