Proyecto

General

Perfil

« Anterior | Siguiente » 

Revisión 128

Importación inicial

Ver diferencias:

scanies/trunk/frmayuda.form
# Gambas Form File 2.0
{ Form Form
MoveScaled(26,6,66,72)
Text = ("Ayuda")
Icon = Picture["imagenes/red.png"]
Border = Window.Fixed
{ btnsalir Button
MoveScaled(22,67,22,4)
Font = Font["Bitstream Vera Sans,10"]
Text = ("Salir")
}
{ Label1 Label
MoveScaled(2,58,62,4)
Font = Font["Bitstream Vera Sans,10"]
Text = ("Autor: Francisco Paniagua S\xC3\xA1nchez")
Alignment = Align.Center
}
{ Label2 Label
MoveScaled(2,62,62,4)
Font = Font["Bitstream Vera Sans,10"]
Text = ("IES Francisco de Orellana (Trujillo)")
Alignment = Align.Center
}
{ Label3 Label
MoveScaled(10,2,50,7)
Font = Font["Bold,32"]
Text = ("ScanIES 0.4.5")
Alignment = Align.Center
}
{ PictureBox1 PictureBox
MoveScaled(3,2,7,6)
Picture = Picture["imagenes/red.png"]
}
{ Separator1 Separator
MoveScaled(2,10,62,1)
}
{ Separator2 Separator
MoveScaled(1,56,63,1)
}
{ TextArea1 TextArea
MoveScaled(2,12,62,43)
Background = &HFFFFDF&
Text = ("Aplicaci\xC3\xB3n que sirve para llevar el control del n\xC3\xBAmero de equipos\nencendidos en una red.\n\nEsta versi\xC3\xB3n est\xC3\xA1 adaptada para poder reconocer equipos de las \naulas LTSP, mediante la instalaci\xC3\xB3n de scanies-ltsp, un demonio\nque nos informar\xC3\xA1 a trav\xC3\xA9s del servidor del aula de los equipos\nque est\xC3\xA1n encendidos en ese aula.\n\nEn la pantalla principal se mostrar\xC3\xA1n todos los equipos del IES\ncon sistema gnu/linux, as\xC3\xAD como una utilidad para encender de \nforma remota los servidores de aula.\n\nSe ha incluido de nuevo en esta versi\xC3\xB3n una opci\xC3\xB3n \"Examinar Red\"\npara detectar tanto equipos no linux como equipos de la electronica\nde red.\n\n-------------------------------------\nRequerimientos m\xC3\xADnimos\n-------------------------------------\nTener instalado\n -avahi-utils 0.6.23-3\n -ldap-utils 2.4.11-1\t\n -nmap 4.62-1\n -wakeonlan 0.41-10\n -gambas2 2.7-1\n\nLas librerias de gambas que utiliza son:\n -gambas2-gb-settings 2.7-1\n -gambas2-gb-qt 2.7-1 \n")
}
}
scanies/trunk/frmayuda.class
' Gambas class file
' This program IS free software; you can redistribute it AND/OR
' modify it under the terms of the GNU General PUBLIC License AS
' published by the Free Software Foundation; either version 2 of the
' License, OR (at your option) any later version.
'
' This program IS distributed IN the hope that it will be useful, but
' IS provided AS IS, WITHOUT ANY WARRANTY; without even the implied
' warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
' NON-INFRINGEMENT. See the GNU General PUBLIC License FOR more details.
'
' You should READ the GNU General PUBLIC License
' IF you have non, WRITE TO the Free Software
' Foundation, INC., 59 Temple Place - Suite 330, Boston,
' # MA 02111-1307, USA.
' ----------------------------------------------------------------------------
' ################################################
' # file name : frmayuda.class
' # created in project : scanies
' # created by : Francisco Paniagua Sánchez
' # mail : adminies.franciscodeorellana@edu.juntaextremadura.net
' # created at : 12/11/2006
' # last test with : gambas-2.7-1
' ################################################
PUBLIC SUB Form_Open()
DIM fichero AS String
ME.Center
btnsalir.Picture = stock["16/quit"]
END
PUBLIC SUB btnsalir_Click()
ME.Close(0)
END
scanies/trunk/.settings
[Breakpoints]
Count=0
[DebugWindow]
Count=0
[FFind]
SearchIn="Module"
CaseSensitive=False
SearchWord=False
SearchComment=False
SearchString=True
[OpenFile]
File[1]="fprincipal.form"
File[2]="fprincipal.class:387.18"
Active=2
File[3]="frmconfiguracion.form"
File[4]="frmconfiguracion.class:73.1"
Count=4
[Watches]
Count=4
Watch[1]="temporal"
Watch[2]="fprofesores"
Watch[3]="fichero"
Watch[4]="rango"
[YWindows]
Count=0
scanies/trunk/.directory
[Desktop Entry]
Icon=./.icon.png
scanies/trunk/.project
# Gambas Project File 2.0
Title=scanies
Startup=fprincipal
Icon=imagenes/red.png
Version=0.4.12
Library=gb.qt
Library=gb.form
Library=gb.qt.ext
Library=gb.settings
TabSize=2
Maintainer=francis
Address=francis@lenix
License=General Public Licence
Systems=debian
Menus=Apps/Programming
Categories=
Groups=Networking
scanies/trunk/changelog
scanies-0.4.5
* Generar documentos PDF con los datos de los equipos
* Posibilidad de abrir una direcci?n ip con el navegador web
desde "Examinar Red"
* Cambiadas las librer?as de gtk a qt para poder utilizar la
opci?n de generar documentos en PDF
---------------------------------------------------------------
scanies-0.4.4
* Adaptación para detectar aulas LTSP
* Incluido de nuevo nmap para detectar electronica de red y equipos no linux
---------------------------------------------------------------
scanies-0.4.1
* Cubierto bug en ayuda que cerraba toda la aplicación
(gracias a Victor Martínez)
* Añadido contactar a un equipo por ssh
* Resuelve nombre mediante avahi
---------------------------------------------------------------
scanies-0.4
* Cambiado el servicio nmap por avahi, mucho más rápido
---------------------------------------------------------------
scanies 0.3-2
* Nueva representacion para equipos sin nombre asignado
(gracias a Antonio Abasolo)
---------------------------------------------------------------
scanies 0.3-1
* Añadidos iconos a botones y opciones de menu
---------------------------------------------------------------
scanies 0.3
* Añadido bloque para apagar / encender aulas
* Añadido botón para encender pc profesor
* Apagado individual de equipos
* Menu Ayuda
---------------------------------------------------------------
scanies 0.2
* Añadido bloque para estadisticas de equipos
* Añadido bloque para representar los equipos encendidos
---------------------------------------------------------------
scanies 0.1
* Versión inicial
---------------------------------------------------------------
scanies/trunk/frmnombre.form
# Gambas Form File 2.0
{ Form Form
MoveScaled(0,0,58,13)
Text = ("Poner nombre ")
Icon = Picture["imagenes/red.png"]
{ TextLabel1 TextLabel
MoveScaled(1,2,10,3)
Text = ("Direcci\xC3\xB3n IP")
}
{ TextLabel2 TextLabel
MoveScaled(1,7,10,3)
Text = ("Nombre")
}
{ txtdireccion TextBox
MoveScaled(12,2,27,3)
Text = ("")
}
{ txtnombre TextBox
MoveScaled(12,7,27,3)
Text = ("")
}
{ btnaceptar Button
MoveScaled(42,2,13,3)
Text = ("Aceptar")
}
{ btncancelar Button
MoveScaled(42,7,13,3)
Text = ("Cancelar")
}
}
scanies/trunk/fprincipal.form
# Gambas Form File 2.0
{ Form Form
MoveScaled(15.625,5,92,69)
Font = Font["Bitstream Vera Sans,10"]
Text = ("ScanIES")
Icon = Picture["imagenes/red.png"]
Border = Window.Fixed
{ mnuArchivo Menu
Text = ("&Archivo")
{ mnuRefrescar Menu
Text = ("Refrescar")
}
{ mnuSalir Menu
Text = ("Salir")
}
}
{ mnuConfiguracion Menu
Text = ("&Configuracion")
{ mnuConfiguracion2 Menu
Text = ("Menu de Configuraci\xC3\xB3n")
}
}
{ mnuAyuda Menu
Text = ("A&yuda")
{ mnuAyuda2 Menu
Text = ("Ayuda")
}
}
{ mnupopup Menu
Text = ("Popup")
Visible = False
{ mnuconectar Menu
Text = ("Conectar por ssh")
Picture = Picture["imagenes/gnome-terminal.png"]
}
{ mnupdf Menu
Text = ("Generar datos PDF")
Picture = Picture["imagenes/pdf.png"]
}
}
{ listapcs ColumnView
MoveScaled(1,1,58,60)
Font = Font["Bitstream Vera Sans,10"]
}
{ Frame2 Frame
MoveScaled(60,0,31,30)
Font = Font["Bitstream Vera Sans,10"]
Text = (" Equipos de Profesor ")
{ cmbaulas ComboBox
MoveScaled(12,3,16.375,4)
Text = (" ")
ReadOnly = True
}
{ TextLabel3 TextLabel
MoveScaled(4,4,7,3)
Text = ("Equipos")
}
{ btnprofon Button
MoveScaled(3,14,26,5)
Text = ("Encender PC profesor")
Picture = Picture["imagenes/despierta.png"]
}
{ btnproftodoson Button
MoveScaled(3,21,26,6)
Text = ("Encender todos los \nPC's de profesores")
Picture = Picture["imagenes/apagar.png"]
}
{ lblaula TextLabel
MoveScaled(3,8,25,4)
Text = ("")
Alignment = Align.Center
}
}
{ btnsalir Button
MoveScaled(76,60,15,4)
Font = Font["Bitstream Vera Sans,10"]
Text = ("Salir")
}
{ btnrefrescar Button
MoveScaled(60,60,15,4)
Font = Font["Bitstream Vera Sans,10"]
Text = ("Refrescar")
}
{ lblnequipos Label
MoveScaled(1,61,58,3)
Text = ("")
Alignment = Align.Center
Border = Border.Etched
}
{ Frame1 Frame
MoveScaled(60,32,31,26)
Text = (" Examinar otros elementos de la red ")
{ TextLabel1 TextLabel
MoveScaled(2,6,26,7)
Text = ("Detectar electr\xC3\xB3nica de red y equipos con otros sistemas operativos encendidos")
Alignment = Align.Center
}
{ btnnmap Button
MoveScaled(4,19,24,4)
Text = ("Examinar Red")
Picture = Picture["imagenes/red16.png"]
}
}
}
scanies/trunk/fprincipal.class
' Gambas class file
' This program IS free software; you can redistribute it AND/OR
' modify it under the terms of the GNU General PUBLIC License AS
' published by the Free Software Foundation; either version 2 of the
' License, OR (at your option) any later version.
'
' This program IS distributed IN the hope that it will be useful, but
' IS provided AS IS, WITHOUT ANY WARRANTY; without even the implied
' warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
' NON-INFRINGEMENT. See the GNU General PUBLIC License FOR more details.
'
' You should READ the GNU General PUBLIC License
' IF you have non, WRITE TO the Free Software
' Foundation, INC., 59 Temple Place - Suite 330, Boston,
' # MA 02111-1307, USA.
' ----------------------------------------------------------------------------
' ################################################
' # file name : fprincipal.class
' # created in project : scanies
' # created by : Francisco Paniagua Sánchez
' # mail : adminies.franciscodeorellana@edu.juntaextremadura.net
' # created at : 12/11/2006
' # last test with : gambas-2.7-1
' ################################################
PRIVATE hset AS Settings
PUBLIC servidordns AS String
PUBLIC rango AS String
PUBLIC datosldap AS Boolean
PRIVATE aula AS String
PRIVATE indice AS Integer
PRIVATE nequipos AS Integer
PUBLIC SUB Form_Open()
DIM fichero AS String
fichero = user.Home & "/.scanies4"
ME.Center
IF NOT comprobar_configuracion() THEN
frmconfiguracion.ShowModal
'ELSE
' cargar_datos()
ENDIF
hset = NEW Settings(fichero)
rango = hset["Rango de Red"]
datosldap = hset["ldap"]
IF (datosldap) THEN
cargar_datos()
ELSE
deshabilitar_ldap(FALSE)
ENDIF
iniciar_programa()
END
PUBLIC SUB deshabilitar_ldap(valor AS Boolean)
frame2.enabled = valor
btnprofon.enabled = valor
btnproftodoson.Enabled = valor
cmbaulas.Enabled = valor
END
PUBLIC SUB Form_Close()
END
PUBLIC FUNCTION comprobar_configuracion() AS Boolean
DIM fichero AS String
DIM retorno AS Boolean
fichero = user.Home & "/.scanies4"
IF NOT Exist(fichero) THEN
SHELL "touch " & fichero WAIT
message.Info("La aplicación no está configurada")
retorno = FALSE
ELSE
hset = NEW Settings(fichero)
rango = hset["Rango de Red"]
datosldap = hset["ldap"]
retorno = TRUE
ENDIF
RETURN retorno
END
PUBLIC SUB iconos()
btnrefrescar.Picture = stock["16/refresh"]
btnsalir.Picture = stock["16/quit"]
mnusalir.picture = stock["16/quit"]
mnurefrescar.Picture = stock["16/refresh"]
mnuconfiguracion2.Picture = stock["16/properties"]
mnuayuda2.Picture = stock["16/help"]
END
PUBLIC SUB cargar_datos()
DIM fichero AS file
DIM fauxiliar AS File
DIM temporal AS String
DIM fprofesores AS String
DIM linea AS String
DIM nombre AS String
DIM mac AS String
'realizar un fichero mediante ldapsearch con los nombres de los equipos de profesor
temporal = "/tmp/datos-prof"
TRY SHELL "ldapsearch -xLLL -h ldap -b dc=instituto,dc=extremadura,dc=es \"(&(objectClass=dhcpHost)(cn=a*-pro))\" | egrep \"cn:|ethernet\" | awk '{ print $2 $3 }' > " & temporal WAIT
fprofesores = "/tmp/profesores-ldap"
cmbaulas.add("Elige un equipo ...")
TRY OPEN fprofesores FOR CREATE AS #fauxiliar
TRY OPEN temporal FOR READ AS #fichero
WHILE NOT Eof(fichero)
LINE INPUT #fichero, linea
nombre = linea
LINE INPUT #fichero, linea
mac = Right(linea, 17)
cmbaulas.Add(nombre)
PRINT #fauxiliar, nombre & " " & mac
WEND
CLOSE #fichero
CLOSE #fauxiliar
habilitar_botones(FALSE)
CATCH
message.Error("No se puedieron obtener los datos de los equipos de profesor")
END
PUBLIC SUB iniciar_programa()
'cargamos la lista de equipos encendidos
iconos()
inicia_lista()
btnRefrescar_click()
END
PUBLIC SUB habilitar_botones(valor AS Boolean)
btnprofon.Enabled = valor
END
PUBLIC SUB cmbaulas_Click()
IF (cmbaulas.Text = "Elige un equipo ...") THEN
habilitar_botones(FALSE)
lblaula.text = "No hay ningún equipo seleccionado"
ELSE
aula = cmbaulas.Text
habilitar_botones(TRUE)
lblaula.text = "Esta seleccionado el equipo " & aula
ENDIF
END
PUBLIC SUB habilitar(valor AS Boolean)
' frame1.Enabled = valor
frame2.Enabled = valor
listapcs.Enabled = valor
IF (valor) THEN
ME.Mouse = mouse.Default
ELSE
ME.mouse = mouse.Wait
ENDIF
END
PUBLIC SUB inicia_lista()
listapcs.Columns.Count = 4
listapcs.Columns[0].Width = 200
listapcs.Columns[1].Width = 125
listapcs.Columns[2].width = 180
listapcs.Columns[0].Text = "Nombre"
listapcs.Columns[1].Text = "Dirección IP"
listapcs.Columns[2].text = "MAC"
listapcs.Columns[3].text = " "
END
'****************************************************************************************************
'****************************************************************************************************
' opciones menu y botones
'****************************************************************************************************
'****************************************************************************************************
PUBLIC FUNCTION obtener_mac(cadena AS String[]) AS String
RETURN Right(cadena[2], 2) & ":" & Right(cadena[3], 2) & ":" & Right(cadena[4], 2) & ":" & Right(cadena[5], 2) & ":" & Right(cadena[6], 2) & ":" & Right(cadena[7], 2)
END
PUBLIC SUB btnrefrescar_Click()
DIM fichero1 AS String
DIM fichero2 AS String
DIM fichero3 AS String
DIM ficherounion AS String
DIM fencendidos AS File
DIM linea AS String
DIM tratalinea01 AS String[]
DIM tratalinea02 AS String[]
DIM nombre AS String
DIM ip AS String
DIM mac AS String
DIM contador AS Integer
DIM tipo AS String
IF (listapcs.Exist(0)) THEN listapcs.Clear
inicia_lista()
contador = 0
habilitar(FALSE)
fichero1 = "/tmp/equipos-workstation"
fichero2 = "/tmp/equipos-scanies"
'Se crea un fichero con los pc's que están encendidos
SHELL "avahi-browse _workstation._tcp -fkprt | grep = | grep IPv4 > " & fichero1 WAIT
SHELL "avahi-browse _scanies._tcp -fkprt | grep = | grep IPv4 > " & fichero2 WAIT
'Uno los dos ficheros y los ordeno por nombre
ficherounion = "/tmp/equipos-union"
SHELL "cat " & fichero1 & " " & fichero2 & " > " & ficherounion WAIT
fichero3 = "/tmp/encendidos"
SHELL "sort -t\";\" -k 4 " & ficherounion & " > " & fichero3 WAIT
'Saco los datos de los pc's encendidos
TRY OPEN fichero3 FOR READ AS #fencendidos
WHILE NOT Eof(fencendidos)
LINE INPUT #fencendidos, linea
tratalinea01 = Split(linea, ";") 'dividimos linea en campos
'diferenciamos si es workstation o scanies
tipo = tratalinea01[4]
'workstation
IF (tipo = "_workstation._tcp") THEN
tratalinea02 = Split(tratalinea01[3], "\\") 'dividimos campo 3 que contiene el nombre y la mac"
nombre = tratalinea02[0]
mac = obtener_mac(tratalinea02)
ip = tratalinea01[7]
ENDIF
'scanies
IF (tipo = "_scanies._tcp") THEN
nombre = tratalinea01[3]
tratalinea02 = Split(tratalinea01[9], "#")
ip = Replace(tratalinea02[0], "\"", "")
mac = Replace(tratalinea02[1], "\"", "")
ENDIF
listapcs.Add(contador, nombre)
listapcs[contador][1] = ip
listapcs[contador][2] = mac
IF (tipo = "_workstation._tcp") THEN
listapcs[contador][3] = "x"
ELSE
listapcs[contador][3] = " "
ENDIF
contador = contador + 1
WEND
CLOSE #fencendidos
lblnequipos.text = "Numero de equipos encendidos: " & contador
habilitar(TRUE)
END
PUBLIC SUB mnuConfiguracion2_Click()
frmconfiguracion.Show
END
PUBLIC SUB btnsalir_Click()
ME.Close
END
PUBLIC SUB mnuRefrescar_Click()
btnrefrescar_click()
END
PUBLIC SUB mnuSalir_Click()
btnsalir_Click()
END
PUBLIC SUB mnuAyuda2_Click()
frmayuda.Show
END
PUBLIC SUB listapcs_Click()
indice = listapcs.Current.Key
END
PUBLIC SUB listapcs_Menu()
'DIM tocado AS Boolean
' TRY tocado = LAST.current.selected
' IF NOT ERROR THEN
mnupopup.Popup
' indice = LAST.item.key
' ENDIF
END
PUBLIC SUB mnuconectar_Click()
DIM direccion AS String
IF (listapcs[indice][3] = " ") THEN
message.Info("No hay conexión a esa red")
ELSE
direccion = listapcs[indice][1]
SHELL "gnome-terminal -x ssh root@" & direccion
ENDIF
END
PUBLIC SUB mnupdf_Click()
DIM fecha AS String
DIM fichero AS String
DIM ficheropdf AS String
DIM x AS Integer
DIM y AS Integer
DIM yinc1 AS Integer
DIM yinc2 AS Integer
DIM xinc1 AS Integer
DIM xinc2 AS Integer
DIM i AS Integer
DIM snombre AS String
DIM sdireccionip AS String
DIM smac AS String
DIM npagina AS Integer
'generar un fichero con los datos de los equipos
fecha = Now() 'Format(Now, "dd-mm-yyyy")
fichero = "/tmp/scanies-report.ps"
ficheropdf = User.home & "/Desktop/scanies-report.pdf"
npagina = 1
Printer.copies = 1
Printer.name = ""
Printer.size = "A4"
Printer.file = fichero
Draw.Begin(printer)
Draw.Font.name = "FreeSans"
'cabecera *****************************************************************
x = 250
y = 200
Draw.Font.size = 6
Draw.Text("Documento generado: " & fecha & " --- Página " & npagina, x + 3250, y - 100)
Draw.Font.size = 24
Draw.Font.Bold = TRUE
Draw.Text("*** ScanIES ***", x + 1500, y)
Draw.Font.size = 10
yinc1 = 200
xinc1 = 1800
xinc2 = 3700
y = y + yinc1 + yinc1
Draw.Font.size = 16
Draw.Text("Nombre", x, y)
Draw.Text("Dirección IP", x + xinc1, y)
Draw.Text("MAC", x + xinc2, y)
'cuerpo *************************************************************
y = y + yinc1
yinc2 = 100
Draw.Font.size = 10
Draw.Font.bold = FALSE
FOR i = 0 TO listapcs.Count
IF (listapcs.Exist(i)) THEN
snombre = listapcs[i][0]
sdireccionip = listapcs[i][1]
smac = listapcs[i][2]
Draw.Text(snombre, x, y)
Draw.Text(sdireccionip, x + xinc1, y)
Draw.Text(smac, x + xinc2, y)
y = y + yinc2
IF (y > 6400) THEN 'debemos comenzar una nueva página *******************************
'incluimos la cabecera y modificamos el valor de y **********************************
printer.NewPage
npagina = npagina + 1
Draw.Font.size = 6
Draw.Text("Documento generado: " & fecha & " --- Página " & npagina, x + 3250, 100)
y = 400
Draw.Font.size = 16
Draw.Font.Bold = TRUE
Draw.Text("Nombre", x, y)
Draw.Text("Dirección IP", x + xinc1, y)
Draw.Text("MAC", x + xinc2, y)
Draw.Font.size = 10
Draw.Font.bold = FALSE
y = y + yinc1
ENDIF
ENDIF
NEXT
Draw.End
'convertimos el fichero ps a pdf
SHELL "ps2pdf " & fichero & " " & ficheropdf WAIT
Message.Info("Fichero generado en el escritorio")
END
PUBLIC SUB btnnmap_Click()
frmnmap.ShowModal
END
PUBLIC SUB btnproftodoson_Click()
DIM profesores AS String
DIM temporal AS String
temporal = Temp()
profesores = "/tmp/profesores-ldap"
SHELL "awk '{ print $2 }' " & profesores & " > " & temporal WAIT
SHELL "wakeonlan -f " & temporal WAIT
message.Info("Enviada señal de encendido a todos los equipos de profesor")
END
PUBLIC SUB btnprofon_Click()
DIM profesores AS String
DIM temporal AS String
DIM mac AS String
temporal = Temp()
profesores = "/tmp/profesores-ldap"
SHELL "grep " & cmbaulas.text & " " & profesores & " | cut -f2 -d\" \" > " & temporal WAIT
TRY mac = file.Load(temporal)
SHELL "wakeonlan " & mac
message.Info("Enviada señal de encendido al equipo " & cmbaulas.text)
END
scanies/trunk/frmnombre.class
' Gambas class file
' This program IS free software; you can redistribute it AND/OR
' modify it under the terms of the GNU General PUBLIC License AS
' published by the Free Software Foundation; either version 2 of the
' License, OR (at your option) any later version.
'
' This program IS distributed IN the hope that it will be useful, but
' IS provided AS IS, WITHOUT ANY WARRANTY; without even the implied
' warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
' NON-INFRINGEMENT. See the GNU General PUBLIC License FOR more details.
'
' You should READ the GNU General PUBLIC License
' IF you have non, WRITE TO the Free Software
' Foundation, INC., 59 Temple Place - Suite 330, Boston,
' # MA 02111-1307, USA.
' ----------------------------------------------------------------------------
' ################################################
' # file name : frmnmap.class
' # created in project : scanies
' # created by : Francisco Paniagua Sánchez
' # mail : adminies.franciscodeorellana@edu.juntaextremadura.net
' # created at : 12/11/2006
' # last test with : gambas-2.7-1
' ################################################
PUBLIC pasardireccion AS String
PUBLIC SUB Form_Open()
ME.Center
btnaceptar.Picture = Stock["16/apply"]
btncancelar.Picture = Stock["16/cancel"]
txtdireccion.text = pasardireccion
txtdireccion.enabled = FALSE
txtnombre.text = frmnmap.pasarnombre
END
PUBLIC SUB btncancelar_Click()
ME.Close
END
PUBLIC SUB btnaceptar_Click()
IF (txtnombre.text = "") THEN
frmnmap.pasarnombre = "Dispositivo"
ELSE
frmnmap.pasarnombre = txtnombre.Text
ENDIF
ME.Close
END
scanies/trunk/frmconfiguracion.form
# Gambas Form File 2.0
{ Form Form
MoveScaled(15.625,21.625,76,29)
Font = Font["Bitstream Vera Sans,10"]
Text = ("Configuracion ScanIES")
Icon = Picture["imagenes/red.png"]
Border = Window.Fixed
{ Frame1 Frame
MoveScaled(1,13,74,11)
Text = (" Opciones para nmap ")
{ TextLabel1 TextLabel
MoveScaled(2,4,12,3)
Text = ("Rango de Red")
}
{ txtrango TextBox
MoveScaled(15,4,56,3)
Text = ("")
}
}
{ btnsalir Button
MoveScaled(60,25,15,3)
Font = Font["Bitstream Vera Sans,10"]
Text = ("Salir")
}
{ btnguardar Button
MoveScaled(1,25,23,3)
Font = Font["Bitstream Vera Sans,10"]
Text = ("Guardar Configuraci\xC3\xB3n")
Default = True
}
{ Frame2 Frame
MoveScaled(1,1,74,10)
Text = (" Opciones para ldap ")
{ chkbxldap CheckBox
MoveScaled(3,4,68,3)
Text = ("\xC2\xBF Coger datos de los servidores de terminales mediante el servidor ldap ?")
Value = CheckBox.True
}
}
}
scanies/trunk/frmconfiguracion.class
' Gambas class file
' This program IS free software; you can redistribute it AND/OR
' modify it under the terms of the GNU General PUBLIC License AS
' published by the Free Software Foundation; either version 2 of the
' License, OR (at your option) any later version.
'
' This program IS distributed IN the hope that it will be useful, but
' IS provided AS IS, WITHOUT ANY WARRANTY; without even the implied
' warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
' NON-INFRINGEMENT. See the GNU General PUBLIC License FOR more details.
'
' You should READ the GNU General PUBLIC License
' IF you have non, WRITE TO the Free Software
' Foundation, INC., 59 Temple Place - Suite 330, Boston,
' # MA 02111-1307, USA.
' ----------------------------------------------------------------------------
' ################################################
' # file name : frmconfiguracion.class
' # created in project : scanies
' # created by : Francisco Paniagua Sánchez
' # mail : adminies.franciscodeorellana@edu.juntaextremadura.net
' # created at : 12/11/2006
' # last test with : gambas-2.7-1
' ################################################
PRIVATE hset AS Settings
PUBLIC SUB Form_Open()
ME.Center
hset = NEW settings(user.Home & "/.scanies4")
iconos()
comprobar_configuracion()
END
PUBLIC SUB btnsalir_Click()
ME.Close
END
PUBLIC SUB iconos()
btnguardar.Picture = stock["16/apply"]
btnsalir.Picture = stock["16/quit"]
END
PUBLIC FUNCTION comprobar_configuracion() AS Boolean
txtrango.text = hset["Rango de Red"]
IF (hset["ldap"] = "") THEN
chkbxldap.value = TRUE
ELSE
chkbxldap.value = hset["ldap"]
ENDIF
END
PUBLIC SUB btnguardar_Click()
hset["Rango de Red"] = txtrango.Text
hset["ldap"] = chkbxldap.Value
hset.Save
fprincipal.rango = txtrango.Text
fprincipal.datosldap = chkbxldap.Value
ME.Close
END
scanies/trunk/frmnmap.form
# Gambas Form File 2.0
{ Form Form
MoveScaled(0,0,42,65)
Text = ("Electr\xC3\xB3nica de Red ...")
Icon = Picture["imagenes/red.png"]
{ mnupopup Menu
Text = ("PopUp")
Visible = False
{ mnunombre Menu
Text = ("Poner Nombre")
Picture = Picture["icon:/16/edit"]
}
{ mnunavegador Menu
Text = ("Abrir con Navegador Web")
Picture = Picture["icon:/16/earth"]
}
{ mnupdf Menu
Text = ("Generar datos PDF")
Picture = Picture["imagenes/pdf16.png"]
}
}
{ lista ColumnView
MoveScaled(0,0,42,61)
ScrollBar = Scroll.Vertical
}
{ btnsalir Button
MoveScaled(0,61,42,4)
Text = ("Salir")
}
}
scanies/trunk/frmnmap.class
' Gambas class file
' This program IS free software; you can redistribute it AND/OR
' modify it under the terms of the GNU General PUBLIC License AS
' published by the Free Software Foundation; either version 2 of the
' License, OR (at your option) any later version.
'
' This program IS distributed IN the hope that it will be useful, but
' IS provided AS IS, WITHOUT ANY WARRANTY; without even the implied
' warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
' NON-INFRINGEMENT. See the GNU General PUBLIC License FOR more details.
'
' You should READ the GNU General PUBLIC License
' IF you have non, WRITE TO the Free Software
' Foundation, INC., 59 Temple Place - Suite 330, Boston,
' # MA 02111-1307, USA.
' ----------------------------------------------------------------------------
' ################################################
' # file name : frmnmap.class
' # created in project : scanies
' # created by : Francisco Paniagua Sánchez
' # mail : adminies.franciscodeorellana@edu.juntaextremadura.net
' # created at : 12/11/2006
' # last test with : gambas-2.7-1
' ################################################
PRIVATE indice AS Integer
PUBLIC pasarnombre AS String
PRIVATE hset AS Settings
PUBLIC SUB iniciar_formulario()
DIM fichero AS String
btnsalir.picture = Stock["16/quit"]
lista.Columns.Count = 2
lista.Columns[0].Width = 125
lista.Columns[1].Width = 200
lista.Columns[0].Text = "Dirección IP"
lista.Columns[1].text = "Dispositivo"
fichero = User.home & "/.scanies-nmap"
IF NOT Exist(fichero) THEN SHELL "touch " & fichero WAIT
hset = NEW Settings(fichero)
END
PUBLIC SUB Form_Open()
ME.Center
iniciar_formulario()
cargar_datos()
END
PRIVATE FUNCTION obtener_nombre(dato AS String) AS String
RETURN hset[dato]
END
PRIVATE SUB cargar_datos()
DIM fichero AS String
DIM fdispositivos AS File
DIM linea AS String
DIM contador AS Integer
DIM ip AS String
DIM nombre AS String
IF (lista.Exist(0)) THEN lista.Clear
fichero = "/tmp/encendidos-nmap"
contador = 0
TRY SHELL "nmap -n -sP " & fprincipal.rango & " | grep appears | cut -f2 -d\" \" > " & fichero WAIT
TRY OPEN fichero FOR READ AS #fdispositivos
WHILE NOT Eof(fdispositivos)
LINE INPUT #fdispositivos, linea
nombre = obtener_nombre(linea)
IF (nombre = "") THEN nombre = "Dispositivo"
lista.Add(contador, linea)
lista[contador][1] = nombre
contador = contador + 1
WEND
CLOSE #fdispositivos
CATCH
Message.Info("Existe algún problema por el cual no se puede ejecutar la aplicación, revisa la configuración")
END
PUBLIC SUB lista_Click()
indice = lista.Current.Key
END
PUBLIC SUB lista_Menu()
'DIM tocado AS Boolean
' TRY tocado = LAST.current.selected
' IF NOT ERROR THEN
mnupopup.Popup
' indice = LAST.item.key
' ENDIF
END
PUBLIC SUB mnunombre_Click()
pasarnombre = lista[indice][1]
frmnombre.pasardireccion = lista[indice][0]
frmnombre.ShowModal
lista[indice][1] = pasarnombre
hset[lista[indice][0]] = pasarnombre
hset.Save
END
PUBLIC SUB mnunavegador_Click()
SHELL "firefox " & lista[indice][0] WAIT
END
PUBLIC SUB mnupdf_Click()
DIM fecha AS String
DIM fichero AS String
DIM ficheropdf AS String
DIM x AS Integer
DIM y AS Integer
DIM yinc1 AS Integer
DIM yinc2 AS Integer
DIM xinc1 AS Integer
DIM xinc2 AS Integer
DIM i AS Integer
DIM snombre AS String
DIM sdireccionip AS String
DIM smac AS String
DIM npagina AS Integer
'generar un fichero con los datos de los equipos
fecha = Now() 'Format(Now, "dd-mm-yyyy")
fichero = "/tmp/redscanies-report.ps"
ficheropdf = User.home & "/Desktop/redscanies-report.pdf"
npagina = 1
Printer.copies = 1
Printer.name = ""
Printer.size = "A4"
Printer.file = fichero
Draw.Begin(printer)
Draw.Font.name = "FreeSans"
'cabecera *****************************************************************
x = 250
y = 200
Draw.Font.size = 6
Draw.Text("Documento generado: " & fecha & " --- Página " & npagina, x + 3250, y - 100)
Draw.Font.size = 24
Draw.Font.Bold = TRUE
Draw.Text("*** Elementos de Red - ScanIES ***", x + 600, y)
Draw.Font.size = 10
yinc1 = 200
xinc1 = 1800
xinc2 = 3700
y = y + yinc1 + yinc1
Draw.Font.size = 16
Draw.Text("Nombre", x, y)
Draw.Text("Dirección IP", x + xinc2, y)
'cuerpo *************************************************************
y = y + yinc1
yinc2 = 100
Draw.Font.size = 10
Draw.Font.bold = FALSE
FOR i = 0 TO lista.Count
IF (lista.Exist(i)) THEN
snombre = lista[i][1]
sdireccionip = lista[i][0]
Draw.Text(snombre, x, y)
Draw.Text(sdireccionip, x + xinc2, y)
y = y + yinc2
IF (y > 6400) THEN 'debemos comenzar una nueva página *******************************
'incluimos la cabecera y modificamos el valor de y **********************************
printer.NewPage
npagina = npagina + 1
Draw.Font.size = 6
Draw.Text("Documento generado: " & fecha & " --- Página " & npagina, x + 3250, 100)
y = 400
Draw.Font.size = 16
Draw.Font.Bold = TRUE
Draw.Text("Nombre", x, y)
Draw.Text("Dirección IP", x + xinc2, y)
Draw.Font.size = 10
Draw.Font.bold = FALSE
y = y + yinc1
ENDIF
ENDIF
NEXT
Draw.End
'convertimos el fichero ps a pdf
SHELL "ps2pdf " & fichero & " " & ficheropdf WAIT
Message.Info("Fichero generado en el escritorio")
END
PUBLIC SUB btnsalir_Click()
ME.Close
END
scanies/trunk/leeme.txt
Aplicación que sirve para llevar el control del número de equipos
encendidos en una red.
Esta versión está adaptada para poder reconocer equipos de las
aulas LTSP, mediante la instalación de scanies-ltsp, un demonio
que nos informará a través del servidor del aula de los equipos
que están encendidos en ese aula.
En la pantalla principal se mostrarán todos los equipos del IES
con sistema gnu/linux, así como una utilidad para encender de
forma remota los servidores de aula.
Se ha incluido de nuevo en esta versión una opción "Examinar Red"
para detectar tanto equipos no linux como equipos de la electronica
de red.
-----------------------
Requerimientos mínimos
... Diferencia truncada por exceder el máximo tamaño visualizable.

Exportar a: Unified diff