Clean up migration scripts by doing a chown on destination folders and files to the LibreNMS user and group, remove leftover XML files from source directories, and allow user to specify the SNMP version string in the 'settings' section of . (#4792)

This commit is contained in:
Scott Armitage
2016-10-14 16:48:04 -07:00
committed by Neil Lathwood
parent 5b96c67ec5
commit 075c94d2eb
3 changed files with 30 additions and 16 deletions

View File

@@ -19,10 +19,16 @@
ADDHOST=/opt/librenms/addhost.php
# Enter your unique SNMP String
SNMPSTRING=cisconetwork
# Enter SNMP version of all clients in nodelist text file
SNMPVERSION=v2c
# Enter path to nodelist text file
NODELIST=/tmp/nodelist.txt
# Enter user and group of LibreNMS installation
L_USRGRP=librenms
while read line
# Change ownership to LibreNMS user and group
chown -R $L_USRGRP:$L_USRGRP .;
# Add each host from the node list file to LibreNMS
do php $ADDHOST "${line%/*}" $SNMPSTRING v2c;
do php $ADDHOST "${line%/*}" $SNMPSTRING $SNMPVERSION;
done < $NODELIST

View File

@@ -46,6 +46,8 @@ while read line;
for f in *.rrd; do rrdtool dump ${f} > ${f}.xml; done
# Transfer XML file to LibreNMS Server
scp *.xml root@$DEST:$L_RRDPATH"${line%/*}"/
# Remove leftover XML files
rm *.xml
# Exit to parent dir
cd ..
done < $NODELIST

View File

@@ -23,8 +23,12 @@ L_RRDPATH=/opt/librenms/rrd/
ADDHOST=/opt/librenms/addhost.php
# Enter your unique SNMP String
SNMPSTRING=cisconetwork
# Enter SNMP version of all clients in nodelist text file
SNMPVERSION=v2c
# Enter path to nodelist text file
NODELIST=/tmp/nodelist.txt
# Enter user and group of LibreNMS installation
L_USRGRP=librenms
# Loop enters RRD directory and then each folder based on contents of node list text file
while read line
@@ -34,8 +38,10 @@ while read line
for f in *.xml; do rrdtool restore ${f} `echo ${f} | cut -f1 -d .`.rrd; done;
# Remove leftover XML files
rm *.xml;
# Change ownership to LibreNMS user and group
chown -R $L_USRGRP:$L_USRGRP .;
# Add the host to LibreNMS
php $ADDHOST "${line%/*}" $SNMPSTRING v2c;
php $ADDHOST "${line%/*}" $SNMPSTRING $SNMPVERSION;
# Change back to parent directory
cd ..;
done < $NODELIST