diff --git a/agent/network-scripts/collected-data/agent-version.tree b/agent/network-scripts/collected-data/agent-version.tree deleted file mode 100755 index e93fd3ce859264f16dc7044574f40d4bb7d82418..0000000000000000000000000000000000000000 --- a/agent/network-scripts/collected-data/agent-version.tree +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR -# -# This file is part of datasid -# -# 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 WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. - -# set PREFIX -export PREFIX="$(readlink -f "$(dirname $0)/../../")" - -# run datasid-common.sh -source "$(readlink -f "$(dirname $0)/../..")/bin/datasid-common.sh" || exit 1 - -if test -z "${PREFIX}"; then - exit 2 -fi - -echo "${VERSION}" diff --git a/agent/network-scripts/collected-data/interfaces.tree b/agent/network-scripts/collected-data/interfaces.tree deleted file mode 100755 index 64f81a414c605b10df9c52e0bfcb3b64040557f9..0000000000000000000000000000000000000000 --- a/agent/network-scripts/collected-data/interfaces.tree +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR -# -# This file is part of collect-agent -# -# collect-agent 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 WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. - -for interface in $(/sbin/ifconfig -s 2>/dev/null | awk '!/Iface/ {print $1}' | sort -u); do - if test "$interface" != "lo"; then - mac=$(/sbin/ifconfig "$interface" 2>/dev/null | awk '/HW/ {print $NF}; /ether/ {print $2}') - - newTag="<interface name=\"$interface\" mac-address=\"$mac\"/>" - tags="$tags$newTag" - fi -done - -printf "${tags}\n" diff --git a/agent/network-scripts/collected-data/telecentro-id.tree b/agent/network-scripts/collected-data/telecentro-id.tree deleted file mode 100755 index 00d548926ac347d572582177fdc74330c17ae507..0000000000000000000000000000000000000000 --- a/agent/network-scripts/collected-data/telecentro-id.tree +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR -# -# This file is part of collect-agent -# -# collect-agent 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 WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. - -# set PREFIX -export PREFIX="$(readlink -f "$(dirname $0)/../../")" - -# run datasid-common.sh -bash "$(readlink -f "$(dirname $0)/../../")/bin/datasid-common.sh" || exit 1 - -if test -z "${PREFIX}"; then - exit 2 -fi - -# Check if telecentroInfo exists -test -f ${CONFDIR}/telecentroInfo || exit 3 - -# Collect telecentro id -grep "datasid" ${CONFDIR}/telecentroInfo | awk -F'=' '{print $2}' diff --git a/agent/network-scripts/collected-data/use/bandwidth-usage.tree b/agent/network-scripts/collected-data/use/bandwidth-usage.tree deleted file mode 100755 index 8a7fbc38672c0f4a1d4651d47fc3a7af4d309a27..0000000000000000000000000000000000000000 --- a/agent/network-scripts/collected-data/use/bandwidth-usage.tree +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -# Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR -# -# This file is part of collect-agent -# -# collect-agent 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 WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. - -#------------------------------------------------------------------------------ -# Function: increment_time -# Increment the time counter by 5 minutes -function increment_time() -{ - TRAFFIC_MINUTE=$((TRAFFIC_MINUTE + 5)) - - if test $TRAFFIC_MINUTE -ge 60; then - TRAFFIC_HOUR=$((TRAFFIC_HOUR + 1)) - TRAFFIC_MINUTE=2 - fi -} - -# Function: xml_print -# Function that prints the contents of XML when there are collected -# data. Print the statistics according to the collection. -function xml_print() -{ - local TRAFFIC_TIME=$(printf "%02d:%02d:30" $TRAFFIC_HOUR $TRAFFIC_MINUTE) - - printf "<netuse id=\"$((COUNT+1))\">" - printf "<date value=\"$TRAFFIC_DATE\" type=\"string\"/>" - printf "<time value=\"$TRAFFIC_TIME\" type=\"string\"/>" - printf "<rx>" - printf "<packets value=\"$(awk '{ print $2 }' <<< $line)\" type=\"int\"/>" - printf "<bytes value=\"$(awk '{ print $3 }' <<< $line)\" type=\"int\"/>" - printf "</rx>" - printf "<tx>" - printf "<packets value=\"$(awk '{ print $4 }' <<< $line)\" type=\"int\"/>" - printf "<bytes value=\"$(awk '{ print $5 }' <<< $line)\" type=\"int\"/>" - printf "</tx>" - printf "</netuse>" -} - - -# Function: xml_data_generator -# This function compares the file date of the last day of collection -# data with the current date and, if they are equal, generates the -# data to the XML file. -function xml_data_generator() -{ - local CURRENT_TIMESTAMP=$(date -d"$(date +%F)" +%s) - local TRAFFIC_TIMESTAMP=$(date -d"$(head -n1 $TRAFFIC)" +%s) - - # Check if date in TRAFFIC file aint older than 15 days - if test $TRAFFIC_TIMESTAMP -ge $(($CURRENT_TIMESTAMP - 1296000)); then - - # Since we want the mean time between the five minutes intervals, - # the minute counter starts at 2 and gets 5 minutes increments. - # Also the "seconds counter" is fixed at 30. So we always get - # something like HH:2:30 or HH:7:30 (mean times). - # - # Example: if interval = 10:15~10:20 => mean = 10:17:30 - - TRAFFIC_HOUR=0 - TRAFFIC_MINUTE=2 - COUNT=-1 - - while read line; do - # Check if its the first line (containing the date) - if test $COUNT -eq -1; then - TRAFFIC_DATE=$(head -1 $TRAFFIC) - COUNT=$((${COUNT} + 1)) - else - INTERVALID=$(cut -d" " -f1 <<< $line) - - if test $COUNT -eq $INTERVALID -a $COUNT -lt 288; then - xml_print - COUNT=$((${COUNT} + 1)) - increment_time - fi - fi - done < $TRAFFIC - else - # If date in TRAFFIC file is older than 15 days then remove the file. - rm -f $TRAFFIC - fi - - printf "\n" -} - -# ------------------------------------------------------------------------------ - -# set PREFIX -export PREFIX="$(readlink -f "$(dirname $0)/../")" - -# run datasid-common.sh -source "$(readlink -f "$(dirname $0)")/datasid-common.sh" || exit 1 - -if test -z "${PREFIX}"; then - date +"%F %T - ERROR: Prefix not set." - exit 2 -fi - -# If it's the first execution, do not collect network data and exit -if test "${FIRST_EXECUTION}"; then - exit 0 -fi - -TRAFFICS="${DATADIR}/previous" - -test -d ${TRAFFICS} || exit 0 - -# Call the function xml_data_generator to generate the data to XML -for TRAFFIC in $(ls -r ${TRAFFICS}) -do - if test -s $TRAFFIC; then - xml_data_generator - fi -done diff --git a/webservice/DataSID.java b/webservice/DataSID.java index a26084cef0c5e1e4c4332b7703ca4c487e25050f..312cc7bc3e0dd272642881a4e375fb23a51dc4ab 100644 --- a/webservice/DataSID.java +++ b/webservice/DataSID.java @@ -42,9 +42,11 @@ import javax.xml.validation.SchemaFactory; public class DataSID { private static final String SA_INVENTORY = "sidtb00_sa_inventory"; - - private static final File XML_SCHEMA = new File("/home/datasid/apache-tomcat/webapps/axis2/WEB-INF/collected-data.xsd"); - + private static final String SA_NET_USAGE = "sidtb00_sa_net_usage"; + + private static final File XML_INVENTORY_SCHEMA = new File("/home/datasid/apache-tomcat/webapps/axis2/WEB-INF/collected-data.xsd"); + private static final File XML_NET_USAGE_SCHEMA = new File("/home/datasid/apache-tomcat/webapps/axis2/WEB-INF/net-collected-data.xsd"); + private static final String AGENT_VERSION = "1.0.0"; private static final String AGENT_UPDATE_LINK = "http://bisid.c3sl.ufpr.br/download/datasid-1.0.0-update.run"; @@ -136,7 +138,7 @@ public class DataSID { throw new Exception("Failed to get a database connection!"); SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); - Schema schema = factory.newSchema(XML_SCHEMA); + Schema schema = factory.newSchema(XML_INVENTORY_SCHEMA); JAXBContext context = JAXBContext.newInstance("br.ufpr.c3sl.datasid"); Unmarshaller unmarshaller = context.createUnmarshaller(); @@ -188,14 +190,73 @@ public class DataSID { } + /** + * Receive an XML string which has the inventory data to be parsed and + * inserted into database. Return "Success" string if insertion operation + * is successful. Any other errors will throw exceptions. + * + * @author Eduardo Luis Buratti + * @param xmlData XML string of inventory + * @return String + */ + public static String setNetUsage(String xmlData) + { + try { + InitialContext cxt = new InitialContext(); + DataSource ds = (DataSource) cxt.lookup("java:/comp/env/jdbc/datasid"); + if (ds == null) + throw new Exception("Data source not found!"); + + Connection con = ds.getConnection(); + if (con == null) + throw new Exception("Failed to get a database connection!"); + + SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + Schema schema = factory.newSchema(XML_NET_USAGE_SCHEMA); + + JAXBContext context = JAXBContext.newInstance("br.ufpr.c3sl.datasid"); + Unmarshaller unmarshaller = context.createUnmarshaller(); + unmarshaller.setSchema(schema); + + // Strip spaces in the beginning of the xml + xmlData = xmlData.replaceAll("^\\s+", ""); + + // transform the xml string into a InputStream + InputStream is = new ByteArrayInputStream(xmlData.getBytes()); + + // Decode the XML into a Java Object + JAXBElement<NetCollectedData> element = (JAXBElement<NetCollectedData>) unmarshaller.unmarshal(is); + NetCollectedData collected = element.getValue(); + + PreparedStatement st = createNetUsageStatement(con, collected); + st.executeUpdate(); + + con.close(); + + return "Success"; + } catch (Exception e) { + log(ERROR, e.getMessage() + " " + xmlData); + e.printStackTrace(); + return "ERROR: " + e.getMessage(); + } + } + private static PreparedStatement createInventoryStatement(Connection con, CollectedData collectedData) throws SQLException { final String query = "INSERT INTO " + SA_INVENTORY + " " + - "(sa_contact_date, sa_gesacid, sa_machine, sa_versao, " + + "(sa_contact_date, sa_telecentro_id, sa_versao, sa_machine, sa_machine_type, " + + "sa_admin_name, sa_admin_phone, sa_tl_name, " + + "sa_tl_phone, sa_state, sa_city, " + + "sa_tl_street, sa_tl_number, sa_zipcode, " + + "sa_tl_neighborhood, sa_geolocation, sa_mirrors_timestamp, " + "sa_hd_model, sa_hd_size, sa_hd_used, " + "sa_hd2_model, sa_hd2_size, sa_hd2_used, " + "sa_extra_hds, sa_memory_size, sa_processor, " + "sa_os_type, sa_os_distro, sa_kernel) VALUES " + - "(?, ?, ?, ?, " + + "(?, ?, ?, ?, ?, " + + "?, ?, ?, " + + "?, ?, ?, " + + "?, ?, ?, " + + "?, ?, ?, " + "?, ?, ?, " + "?, ?, ?, " + "?, ?, ?, " + @@ -207,71 +268,144 @@ public class DataSID { Inventory inventory = collectedData.getInventory(); List<Disk> disks = inventory.getDisks().getDisk(); - + TeleCentroInfo teleCentroInfo = collectedData.getTelecentroInfo(); + // sa_contact_date = current date Calendar cal = Calendar.getInstance(); st.setDate(1, new java.sql.Date(cal.getTimeInMillis())); - // sa_gesacid - st.setInt(2, collectedData.getGesacid().intValue()); + // sa_telecentro_id + st.setString(2, teleCentroInfo.getDatasid()); // sa_machine org.postgresql.util.PGobject macaddr = new org.postgresql.util.PGobject(); macaddr.setType("macaddr"); macaddr.setValue(interfaces.get(0).getMacAddress()); st.setObject(3, macaddr); - - // sa_versao + + // sa_versao st.setString(4, collectedData.getAgentVersion()); - + + // sa_machine_type + if(collectedData.getMachineType().compareTo("client") == 0) + st.setInt(5, 0); + else + st.setInt(5, 1); + + // sa_admin_name + st.setString(6, teleCentroInfo.getAdminName()); + + // sa_admin_phone + st.setString(7, teleCentroInfo.getAdminPhone()); + + // sa_tl_name + st.setString(8, teleCentroInfo.getTlName()); + + // sa_tl_phone + st.setString(9, teleCentroInfo.getTlPhone()); + + // sa_state + st.setString(10, teleCentroInfo.getState()); + + // sa_city + st.setString(11, teleCentroInfo.getCity()); + + // sa_tl_street + st.setString(12, teleCentroInfo.getTlStreet()); + + // sa_tl_number + st.setString(13, teleCentroInfo.getTlNumber()); + + // sa_tl_zipcode + st.setString(14, teleCentroInfo.getTlZipcode()); + + // sa_tl_neighborhood + st.setString(15, teleCentroInfo.getTlNeighborhood()); + + // sa_geolocation + st.setString(16, teleCentroInfo.getGeolocation()); + + // sa_mirrors_timestamp + st.setString(17, collectedData.getMirrorsTimestamp()); + // sa_hd_model - st.setString(5, disks.get(0).getModel()); - + st.setString(18, disks.get(0).getModel()); + // sa_hd_size - st.setInt(6, disks.get(0).getSize().intValue()); + st.setInt(19, disks.get(0).getSize().intValue()); // sa_hd_used - st.setInt(7, disks.get(0).getUsed().intValue()); + st.setInt(20, disks.get(0).getUsed().intValue()); if (disks.size() > 1) { // sa_hd2_model - st.setString(8, disks.get(1).getModel()); + st.setString(18, disks.get(1).getModel()); // sa_hd2_size - st.setInt(9, disks.get(1).getSize().intValue()); + st.setInt(19, disks.get(1).getSize().intValue()); // sa_hd2_used - st.setInt(10, disks.get(1).getUsed().intValue()); + st.setInt(20, disks.get(1).getUsed().intValue()); } else { // sa_hd2_model - st.setNull(8, Types.VARCHAR); + st.setNull(18, Types.VARCHAR); // sa_hd2_size - st.setNull(9, Types.INTEGER); + st.setNull(19, Types.INTEGER); // sa_hd2_used - st.setNull(10, Types.INTEGER); + st.setNull(20, Types.INTEGER); } // sa_extra_hds - st.setInt(11, (disks.size() > 2) ? (disks.size() - 2) : 0); + st.setInt(21, (disks.size() > 2) ? (disks.size() - 2) : 0); // sa_memory_size - st.setInt(12, inventory.getMemory().intValue()); + st.setInt(22, inventory.getMemory().intValue()); // sa_processor - st.setString(13, inventory.getProcessor()); + st.setString(23, inventory.getProcessor()); // sa_os_type - st.setString(14, inventory.getOs()); + st.setString(24, inventory.getOs()); // sa_os_distro - st.setString(15, inventory.getDistro()); + st.setString(25, inventory.getDistro()); // sa_kernel - st.setString(16, inventory.getKernel()); + st.setString(26, inventory.getKernel()); return st; } + + + private static PreparedStatement createNetUsageStatement(Connection con, NetCollectedData netCollectedData) throws SQLException { + final String query = "INSERT INTO " + SA_NET_USAGE + " " + + "(sa_contact_date, sa_telecentro_id, sa_versao, sa_machine) VALUES " + + "(?, ?, ?, ?);"; + + PreparedStatement st = con.prepareStatement(query); + + List<Interface> interfaces = netCollectedData.getInterfaces().getInterface(); + + + // sa_contact_date = current date + Calendar cal = Calendar.getInstance(); + st.setDate(1, new java.sql.Date(cal.getTimeInMillis())); + + // sa_telecentro_id + st.setString(2, netCollectedData.getTelecentroId()); + + // sa_machine + org.postgresql.util.PGobject macaddr = new org.postgresql.util.PGobject(); + macaddr.setType("macaddr"); + macaddr.setValue(interfaces.get(0).getMacAddress()); + st.setObject(3, macaddr); + + // sa_versao + st.setString(4, netCollectedData.getAgentVersion()); + + return st; + } } diff --git a/webservice/Makefile b/webservice/Makefile index ae3e9c28d0a1d967e9c57172c5ef20ec8bbcfb80..b9f825a5c0370a47c047db1b764c29214b737a85 100644 --- a/webservice/Makefile +++ b/webservice/Makefile @@ -1,15 +1,16 @@ all: DataSID.aar -DataSID.aar: classes/br/ufpr/c3sl/datasid/DataSID.class collected-data.xsd services.xml +DataSID.aar: classes/br/ufpr/c3sl/datasid/DataSID.class collected-data.xsd net-collected-data.xsd services.xml @mkdir -p pkg/META-INF cp collected-data.xsd services.xml pkg/META-INF/ + cp net-collected-data.xsd services.xml pkg/META-INF/ cp -r classes/* pkg/ jar cvf $@ -C pkg . -classes/br/ufpr/c3sl/datasid/DataSID.class: DataSID.java classes/br/ufpr/c3sl/datasid/CollectedData.class +classes/br/ufpr/c3sl/datasid/DataSID.class: DataSID.java classes/br/ufpr/c3sl/datasid/CollectedData.class javac -source 6 -target 6 -classpath postgresql-9.2-1002.jdbc4.jar:classes -d classes $< -classes/br/ufpr/c3sl/datasid/CollectedData.class: generated/br/ufpr/c3sl/datasid/CollectedData.java +classes/br/ufpr/c3sl/datasid/CollectedData.class: generated/br/ufpr/c3sl/datasid/CollectedData.java generated/br/ufpr/c3sl/datasid/NetCollectedData.java @mkdir -p classes javac -source 6 -target 6 -sourcepath generated -d classes generated/br/ufpr/c3sl/datasid/*.java @@ -17,6 +18,10 @@ generated/br/ufpr/c3sl/datasid/CollectedData.java: collected-data.xsd @mkdir -p generated xjc -d generated -p br.ufpr.c3sl.datasid $< +generated/br/ufpr/c3sl/datasid/NetCollectedData.java: net-collected-data.xsd + @mkdir -p generated + xjc -d generated -p br.ufpr.c3sl.datasid $< + clean: rm -rf generated rm -rf classes diff --git a/webservice/collected-data.xsd b/webservice/collected-data.xsd index d13856d6be28045bd4434dd4085705a54eda7de8..6134989ace1eb0f9446874c80587ac03f28b3936 100644 --- a/webservice/collected-data.xsd +++ b/webservice/collected-data.xsd @@ -5,17 +5,18 @@ <xsd:complexType name="CollectedData"> <xsd:all> <xsd:element name="agent-version" type="xsd:string" minOccurs="1" /> - <xsd:element name="gesacid" type="xsd:integer" minOccurs="1" /> + <xsd:element name="telecentro-info" type="TeleCentroInfo" minOccurs="1" /> <xsd:element name="interfaces" type="Interfaces" minOccurs="1" /> <xsd:element name="machine-type" minOccurs="1"> <xsd:simpleType> <xsd:restriction base="xsd:string"> - <xsd:pattern value="client|server|neither"/> + <xsd:pattern value="client|server"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="inventory" type="Inventory" minOccurs="1" /> <xsd:element name="user-history" type="UserHistory" minOccurs="1" /> + <xsd:element name="mirrors-timestamp" type="xsd:string" minOccurs="1" /> </xsd:all> </xsd:complexType> @@ -70,4 +71,21 @@ <xsd:element name="logout" type="xsd:string" /> </xsd:all> </xsd:complexType> + + <xsd:complexType name="TeleCentroInfo"> + <xsd:all> + <xsd:element name="admin_name" type="xsd:string" /> + <xsd:element name="admin_phone" type="xsd:string" /> + <xsd:element name="tl_name" type="xsd:string" /> + <xsd:element name="tl_phone" type="xsd:string" /> + <xsd:element name="state" type="xsd:string" /> + <xsd:element name="city" type="xsd:string" /> + <xsd:element name="tl_street" type="xsd:string" /> + <xsd:element name="tl_number" type="xsd:string" /> + <xsd:element name="tl_zipcode" type="xsd:string" /> + <xsd:element name="tl_neighborhood" type="xsd:string" /> + <xsd:element name="geolocation" type="xsd:string" /> + <xsd:element name="datasid" type="xsd:string" /> + </xsd:all> + </xsd:complexType> </xsd:schema> diff --git a/webservice/net-collected-data.xsd b/webservice/net-collected-data.xsd new file mode 100644 index 0000000000000000000000000000000000000000..f1996812fed778f5ebcec147bc3d4770880e78a6 --- /dev/null +++ b/webservice/net-collected-data.xsd @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <xsd:element name="net-collected-data" type="NetCollectedData" /> + + <xsd:complexType name="NetCollectedData"> + <xsd:all> + <xsd:element name="agent-version" type="xsd:string" minOccurs="1" /> + <xsd:element name="telecentro-id" type="xsd:string" minOccurs="1" /> + <xsd:element name="interfaces" type="Interfaces" minOccurs="1" /> + <xsd:element name="bandwidth-usage" type="BandwidthUsage" minOccurs="1" /> + </xsd:all> + </xsd:complexType> + + <xsd:complexType name="Interfaces"> + <xsd:sequence> + <xsd:element name="interface" type="Interface" minOccurs="1" maxOccurs="unbounded" /> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="Interface"> + <xsd:attribute name="name" type="xsd:string" use="required" /> + <xsd:attribute name="mac-address" type="xsd:string" use="required" /> + </xsd:complexType> + + <xsd:complexType name="BandwidthUsage"> + <xsd:sequence> + <xsd:element name="netuse" type="NetUse" minOccurs="1" maxOccurs="unbounded" /> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="NetUse"> + <xsd:all> + <xsd:element name="rx" type="Rx" /> + <xsd:element name="tx" type="Tx" /> + </xsd:all> + <xsd:attribute name="date" type="xsd:string" /> + <xsd:attribute name="time" type="xsd:string" /> + </xsd:complexType> + + <xsd:complexType name="Rx"> + <xsd:attribute name="packets" type="xsd:integer" use="required" /> + <xsd:attribute name="bytes" type="xsd:integer" use="required" /> + </xsd:complexType> + + <xsd:complexType name="Tx"> + <xsd:attribute name="packets" type="xsd:integer" use="required" /> + <xsd:attribute name="bytes" type="xsd:integer" use="required" /> + </xsd:complexType> + +</xsd:schema> diff --git a/webservice/services.xml b/webservice/services.xml index 0691f514c98659189a3efbb52078d79ac817287e..0704ca676d3acf3351b7f57d489227eafd120b73 100644 --- a/webservice/services.xml +++ b/webservice/services.xml @@ -9,4 +9,7 @@ <operation name="getUpdateLink"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> </operation> + <operation name="setNetUsage"> + <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> + </operation> </service>