source: trunk/push-web @ 329

Last change on this file since 329 was 329, checked in by g7moreau, 6 years ago
  • Add bad-vlan-id web page
  • Property svn:executable set to *
File size: 5.2 KB
Line 
1#!/bin/bash
2#
3# 2007/10/23 gabriel
4# 2010/11/03 gabriel
5# 2011/03/30 gabriel - make it generic
6
7SITE_NAME=''
8REMOTE_SERVER=localhost
9REMOTE_USER=''
10REMOTE_FOLDER=/var/www/klask/
11
12GRAPH_MODULO=9
13GRAPH_SHIFT=1
14
15if [ -f /etc/klask/push-web.conf ]
16then
17   . /etc/klask/push-web.conf
18fi
19
20TMP='/tmp/klask-push-web'
21
22
23# local command
24MKDIR=/bin/mkdir
25DATE=/bin/date
26CAT=/bin/cat
27TAIL=/usr/bin/tail
28HEAD=/usr/bin/head
29SSH=/usr/bin/ssh
30SCP=/usr/bin/scp
31KLASK=/usr/sbin/klask
32RSYNC=/usr/bin/rsync
33
34# remote command
35DOT=/usr/bin/dot
36
37
38$MKDIR -p ${TMP}
39if [ ! -d ${TMP} ]
40then
41   echo "Error: Folder ${TMP} do not exist !"
42   exit 1
43fi
44cd ${TMP}
45
46
47LOCALTIME=$($DATE "+%Y-%m-%d %H:%M")
48
49
50$KLASK exportsw --format dot --modulo ${GRAPH_MODULO} --shift ${GRAPH_SHIFT} > ${TMP}/switch-map.txt
51
52
53$KLASK exportdb > ${TMP}/hostname-db.txt
54$KLASK exportsw > ${TMP}/switch-db.txt
55$KLASK ip-free  > ${TMP}/ipfree-db.txt
56
57
58$CAT <<END > ${TMP}/index.html
59<html>
60<head>
61 <link rel="stylesheet" type="text/css" href="style-klask.css" />
62 <meta http-equiv="refresh" content="1800">
63 <noscript>
64 </noscript>
65 <script src="sorttable-klask.js"></script>
66 <script>
67function delayedRefresh() {
68 setTimeout( "refresh()", 1800*1000 );
69 }
70
71function refresh() {
72 history.go(0);
73 }
74 </script>
75</head>
76<body onload="delayedRefresh">
77<h1>
78<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
79- Un outil pour <a href="switch-map.png">cartographier</a> (<a href="switch-map.svg">svg</a>) le r&eacute;seau [${LOCALTIME}] - site ${SITE_NAME}
80</h1>
81
82<p>
83Ce portail pr&eacute;sente la liste de toutes les IP d&eacute;tect&eacute;es par Klask.
84La liste des <a href="ip-free.html">IP non d&eacute;tect&eacute;es</a> par Klask depuis plus de deux ann&eacute;es est aussi disponible.
85</p>
86
87<p>
88Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
89<a href="hostname-db.txt">Machines</a>,
90<a href="switch-db.txt">Commutateurs</a>,
91<a href="ipfree-db.txt">IP disponibles</a>,
92<a href="switch-map.txt">Carte</a>.
93</p>
94END
95
96$KLASK exportdb --format html >> ${TMP}/index.html
97
98$CAT <<END >> ${TMP}/index.html
99</body>
100</html>
101END
102
103
104$CAT <<END > ${TMP}/ip-free.html
105<html>
106<head>
107 <link rel="stylesheet" type="text/css" href="style-klask.css" />
108 <meta http-equiv="refresh" content="1800">
109 <script src="sorttable-klask.js"></script>
110</head>
111<body>
112<h1>
113<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
114- Un outil pour <a href="switch-map.png">cartographier</a> (<a href="switch-map.svg">svg</a>) le r&eacute;seau [${LOCALTIME}] - site ${SITE_NAME}
115</h1>
116
117<p>
118Cette page pr&eacute;sente la liste des IP non d&eacute;tect&eacute;es par Klask depuis plus de deux ann&eacute;es.
119Le portail contient la liste de toutes les <a href="index.html">IP d&eacute;tect&eacute;es</a> par Klask.
120</p>
121
122<p>
123Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
124<a href="hostname-db.txt">Machines</a>,
125<a href="switch-db.txt">Commutateurs</a>,
126<a href="ipfree-db.txt">IP disponibles</a>,
127<a href="switch-map.txt">Carte</a>.
128</p>
129END
130
131$KLASK ip-free --format html >> ${TMP}/ip-free.html
132
133$CAT <<END >> ${TMP}/ip-free.html
134</body>
135</html>
136END
137
138
139$CAT <<END > ${TMP}/bad-vlan-id.html
140<html>
141<head>
142 <link rel="stylesheet" type="text/css" href="style-klask.css" />
143 <meta http-equiv="refresh" content="1800">
144 <script src="sorttable-klask.js"></script>
145</head>
146<body>
147<h1>
148<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
149- Un outil pour <a href="switch-map.png">cartographier</a> (<a href="switch-map.svg">svg</a>) le r&eacute;seau [${LOCALTIME}] - site ${SITE_NAME}
150</h1>
151
152<p>
153Cette page pr&eacute;sente la liste des machines qui ne sont pas configur&eacute;es sur le bon VLAN.
154Le portail contient la liste de toutes les <a href="index.html">IP d&eacute;tect&eacute;es</a> par Klask.
155</p>
156
157<p>
158Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
159<a href="hostname-db.txt">Machines</a>,
160<a href="switch-db.txt">Commutateurs</a>,
161<a href="ipfree-db.txt">IP disponibles</a>,
162<a href="switch-map.txt">Carte</a>.
163</p>
164END
165
166$KLASK bad-vlan-id --format html >> ${TMP}/bad-vlan-id.html
167
168$CAT <<END >> ${TMP}/bad-vlan-id.html
169</body>
170</html>
171END
172
173
174if [ "${REMOTE_SERVER}" = "localhost" ]
175then
176   $RSYNC \
177      /usr/share/klask/sorttable-klask.js \
178      /usr/share/klask/style-klask.css \
179      ${TMP}/index.html \
180      ${TMP}/ip-free.html \
181      ${TMP}/bad-vlan-id.html \
182      ${TMP}/*-db.txt \
183      ${TMP}/switch-map.txt \
184      ${REMOTE_FOLDER}/
185
186   [ -x ${DOT} ] && (cd ${REMOTE_FOLDER}; ${DOT} -T svg switch-map.txt > switch-map.svg; ${DOT} -T png switch-map.txt > switch-map.png)
187
188else
189   $RSYNC \
190      /usr/share/klask/sorttable-klask.js \
191      /usr/share/klask/style-klask.css \
192      ${TMP}/index.html \
193      ${TMP}/ip-free.html \
194      ${TMP}/bad-vlan-id.html \
195      ${TMP}/*-db.txt \
196      ${TMP}/switch-map.txt \
197      ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_FOLDER}/
198
199
200   $SSH ${REMOTE_USER}@${REMOTE_SERVER} "(cd ${REMOTE_FOLDER}; ${DOT} -T svg switch-map.txt > switch-map.svg; ${DOT} -T png switch-map.txt > switch-map.png)"
201fi
Note: See TracBrowser for help on using the repository browser.