#!/bin/bash # # 2007/10/23 Gabriel Moreau # 2010/11/03 Gabriel Moreau # 2011/03/30 Gabriel Moreau - make it generic # 2017/11/04 Gabriel Moreau - all reworks - use tab export PATH=/bin:/sbin:/usr/bin:/usr/sbin export LANG=C SITE_NAME='' REMOTE_SERVER=localhost REMOTE_USER='' REMOTE_FOLDER=/var/www/klask/ GRAPH_MODULO=9 GRAPH_SHIFT=1 if [ -f /etc/klask/push-web.conf ] then . /etc/klask/push-web.conf fi TMP='/tmp/klask-push-web' # remote command DOT=/usr/bin/dot mkdir -p ${TMP} if [ ! -d ${TMP} ] then echo "Error: Folder ${TMP} do not exist !" exit 1 fi cd ${TMP} LOCALTIME=$(date "+%Y-%m-%d %H:%M") klask exportsw --format dot --modulo ${GRAPH_MODULO} --shift ${GRAPH_SHIFT} > ${TMP}/switch-map.txt.new klask exportdb > ${TMP}/hostname-db.txt klask exportsw > ${TMP}/switch-db.txt klask ip-free > ${TMP}/ipfree-db.txt klask bad-vlan-id > ${TMP}/badvlan-db.txt cat < ${TMP}/index.html Klask mapping net-tools

Klask Tool for mapping the local network - site ${SITE_NAME} ${LOCALTIME}

List of all IP addresses detected on the local network (on all VLANs) since the origin of the database (except those that have been deleted manually and voluntarily).

END klask exportdb --format html >> ${TMP}/index.html cat <> ${TMP}/index.html
END cmp --silent ${TMP}/switch-map.txt.new ${TMP}/switch-map.txt || mv -f ${TMP}/switch-map.txt.new ${TMP}/switch-map.txt if [ "${REMOTE_SERVER}" = "localhost" ] then rsync --times \ /usr/share/klask/sorttable-klask.js \ /usr/share/klask/style-klask.css \ ${TMP}/index.html \ ${TMP}/*-db.txt \ ${TMP}/switch-map.txt \ ${REMOTE_FOLDER}/ [ -x ${DOT} ] && (cd ${REMOTE_FOLDER}; [ switch-map.txt -nt switch-map.svg ] && ${DOT} -T svg switch-map.txt > switch-map.svg; [ switch-map.txt -nt switch-map.png ] && ${DOT} -T png switch-map.txt > switch-map.png) else rsync --times \ /usr/share/klask/sorttable-klask.js \ /usr/share/klask/style-klask.css \ ${TMP}/index.html \ ${TMP}/*-db.txt \ ${TMP}/switch-map.txt \ ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_FOLDER}/ ssh ${REMOTE_USER}@${REMOTE_SERVER} "(cd ${REMOTE_FOLDER}; [ switch-map.txt -nt switch-map.svg ] && ${DOT} -T svg switch-map.txt > switch-map.svg; [ switch-map.txt -nt switch-map.png ] && ${DOT} -T png switch-map.txt > switch-map.png)" fi