diff --git a/.gitignore b/.gitignore index fcf02863bb44b23a0b1577904265b91ca5d32712..9d59b80841ba823b3359ed05ba0bd541d63ba898 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ build/* bin/* +test/docker/*/agent/* +test/docker/*/*.sh +log/* +styleguide/* +Documentation/* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..7435b66350f3c60efc3bdfd3d6f45301d6adc815 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,87 @@ +stages: + - lint + - build + - test + +pattern: + stage: lint + tags: + - regular + - debian + script: + - shopt -s extglob + - apt-get update && apt-get install -y git python + - git clone https://github.com/google/styleguide + - cd styleguide/cpplint + - ./cpplint.py --filter=-whitespace/blank_line,-build/include_what_you_use ../../src/agent/!(jsoncpp).cpp + +compile: + stage: build + artifacts: + paths: + - bin/ + tags: + - regular + - debian + script: + - echo "Estágio 'build'" + - apt-get update && apt-get install -y build-essential cmake git makeself + libudev-dev + - git submodule init + - git submodule update --init --recursive + - mkdir build + - cd build + - cmake -DCURL_STATICLIB=ON .. + - make + - cd .. + - makeself --notemp --noprogress bin/ agent.run "" ./agent-v0.0 --once --print + - chmod +x agent.run + - mv agent.run bin/ + +testDebian: + stage: test + tags: + - regular + - debian + script: + - apt-get update && apt-get install -y git jq faketime expect + - git clone https://github.com/sstephenson/bats.git + - cd bats + - ./install.sh /usr + - cd ../test + - ./create_users.sh + - last -F + - ./returnTest.bats + dependencies: + - compile + +testUbuntu: + stage: test + tags: + - ubuntu + - regular + script: + - apt-get update && apt-get install -y bats jq faketime expect + - cd test + - ./create_users.sh + - last -F + - ./returnTest.bats + dependencies: + - compile + +testOpensuse: + stage: test + tags: + - opensuse + script: + - zypper -n update + - zypper -n install bats jq libfaketime expect tar + - touch /var/log/wtmp + - chown root.tty /var/log/wtmp + - chmod 664 /var/log/wtmp + - cd test + - ./create_users.sh + - last -F + - ./returnTest.bats + dependencies: + - compile diff --git a/.gitmodules b/.gitmodules index 1734582b8083d50a15503211caa0c0f93a464ac9..ac5d4705e50046d2c042cde7e12778a8e4f22b9b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "lib/cpr"] path = lib/cpr url = https://github.com/whoshuu/cpr.git +[submodule "lib/jsoncpp"] + path = lib/jsoncpp + url = https://github.com/open-source-parsers/jsoncpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 130fd6d2252116db9cf5f64f8065f998ad0fbeb5..9ace5392999da26a32b2ea61249b94400a6054f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 2.6 ) +cmake_minimum_required( VERSION 2.8.7 ) project( simmc-agent ) @@ -9,18 +9,10 @@ set ( VERSION_MINOR 0 ) # cpr requires c++11 set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" ) +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") -# src : main + jsoncpp library -file ( GLOB SOURCES src/*.cpp ) - - -# src : collect functions - depend on OS -if ( WIN32 ) - file ( GLOB SOURCES ${SOURCES} src/windows/*.cpp ) -else () # if( UNIX ) - file ( GLOB SOURCES ${SOURCES} src/linux/*.cpp ) -endif () - +# src : main, collect functions + jsoncpp library +file ( GLOB SOURCES src/agent/*.cpp ) # src : curl requests @@ -32,38 +24,39 @@ option( BUILD_CPR_TESTS "Set to ON to build cpr tests." OFF ) # options for curl # avoid building tests -option( BUILD_CURL_TESTS "Set to ON to build cURL tests." ON ) +option( BUILD_CURL_TESTS "Set to ON to build cURL tests." OFF ) # avoid running tests - set ON again in download version or if errors occur -option( RUN_CURL_TESTS "Set to ON to run cURL tests." ON ) +option( RUN_CURL_TESTS "Set to ON to run cURL tests." OFF ) +option( CURL_STATICLIB "Set to ON to generated curl statically." ON ) add_subdirectory ( lib/cpr ) include_directories ( ${CPR_INCLUDE_DIRS} ) - +include_directories ( ${CURL_INCLUDE_DIRS} ) # src : DtWinVer - Windows Version/Edition class if ( WIN32 ) - add_subdirectory ( lib/dtwinver ) + add_subdirectory ( lib/dtwinver ) endif () - # headers include_directories ( "include" ) +# include headers from boost lib +include_directories ( "${CMAKE_BINARY_DIR}/include" ) -# test -option( PRINT_JSON "Set to ON to print json objects before sending" OFF ) -message(STATUS "${PRINT_JSON}: ${${PRINT_JSON}}") -if ( PRINT_JSON ) - add_definitions ( -DPRINT_JSON ) -endif () - +# scr = libboost +include ( "modules/boost.cmake" ) # compile set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "../bin" ) add_executable ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${SOURCES} ) +target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${CPR_LIBRARIES} ${CURL_LIBRARIES} ${FILESYSTEM_LIB} ${SYSTEM_LIB} ${REGEX_LIB} ${PROGRAM_OPTIONS_LIB}) -target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${CPR_LIBRARIES} ) +add_dependencies ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} Boost) if ( WIN32 ) - target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} dtwinver ) -endif() + target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} dtwinver ) +else () + # libudev + target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} udev ) +endif () diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000000000000000000000000000000000000..f8e7c4139e53cbeeaafa402b037d58d27a80afcf --- /dev/null +++ b/Doxyfile @@ -0,0 +1,2584 @@ +# Doxyfile 1.8.14 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "Simmc-agent" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = "0.0.1" + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +JAVADOC_AUTOBRIEF = YES +======= +JAVADOC_AUTOBRIEF = NO +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +JAVADOC_AUTOBRIEF = YES +>>>>>>> 7b3a2fe... SCRUM$30 - Starting the documentation from simmc-agent using doxygen +======= +JAVADOC_AUTOBRIEF = NO +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +JAVADOC_AUTOBRIEF = YES +>>>>>>> ca8ed79... SCRUM#30 - Documentation from agent e conf file's + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 0. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 0 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = YES + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = NO + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if <section_label> ... \endif and \cond <section_label> +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +INPUT = src/agent/ src/agent/linux/ src/agent/windows/ include/agent/ include/agent/linux/ include/agent/windows/ +======= +INPUT = src/agent/ src/agent/linux/ src/agent/windows/ + include/agent/ include/agent/linux/ include/agent/windows/ +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +INPUT = src/agent/ src/agent/linux/ src/agent/windows/ include/agent/ include/agent/linux/ include/agent/windows/ +>>>>>>> 7b3a2fe... SCRUM$30 - Starting the documentation from simmc-agent using doxygen +======= +INPUT = src/agent/ src/agent/linux/ src/agent/windows/ + include/agent/ include/agent/linux/ include/agent/windows/ +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +INPUT = src/agent/ src/agent/linux/ src/agent/windows/ include/agent/ include/agent/linux/ include/agent/windows/ +>>>>>>> ca8ed79... SCRUM#30 - Documentation from agent e conf file's + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +FILE_PATTERNS = *.c \ *.cpp \ *.h \ +======= +FILE_PATTERNS = *.c \ + *.cpp \ + *.h \ +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +FILE_PATTERNS = *.c \ *.cpp \ *.h \ +>>>>>>> 7b3a2fe... SCRUM$30 - Starting the documentation from simmc-agent using doxygen +======= +FILE_PATTERNS = *.c \ + *.cpp \ + *.h \ +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +FILE_PATTERNS = *.c \ *.cpp \ *.h \ +>>>>>>> ca8ed79... SCRUM#30 - Documentation from agent e conf file's + + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +EXCLUDE = src/agent/jsoncpp.cpp +======= +EXCLUDE = +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +EXCLUDE = src/agent/jsoncpp.cpp +>>>>>>> 1717824... SCRUM#30 - Documentation from get, rotate_log_file, curl, common, post, open_files, get_date, get_time sources files +======= +EXCLUDE = src/agent/jsoncpp.cpp +>>>>>>> 7b3a2fe... SCRUM$30 - Starting the documentation from simmc-agent using doxygen +======= +EXCLUDE = +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +EXCLUDE = src/agent/jsoncpp.cpp +>>>>>>> 1717824... SCRUM#30 - Documentation from get, rotate_log_file, curl, common, post, open_files, get_date, get_time sources files + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# <filter> <input-file> +# +# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +SOURCE_BROWSER = YES +======= +SOURCE_BROWSER = NO +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +SOURCE_BROWSER = YES +>>>>>>> 1717824... SCRUM#30 - Documentation from get, rotate_log_file, curl, common, post, open_files, get_date, get_time sources files +======= +SOURCE_BROWSER = YES +>>>>>>> 7b3a2fe... SCRUM$30 - Starting the documentation from simmc-agent using doxygen +======= +SOURCE_BROWSER = NO +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +SOURCE_BROWSER = YES +>>>>>>> 1717824... SCRUM#30 - Documentation from get, rotate_log_file, curl, common, post, open_files, get_date, get_time sources files + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +HTML_OUTPUT = Documentation +======= +HTML_OUTPUT = html +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +HTML_OUTPUT = Documentation +>>>>>>> 7b3a2fe... SCRUM$30 - Starting the documentation from simmc-agent using doxygen +======= +HTML_OUTPUT = html +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +HTML_OUTPUT = Documentation +>>>>>>> ca8ed79... SCRUM#30 - Documentation from agent e conf file's + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via Javascript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have Javascript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use <access key> + S +# (what the <access key> is depends on the OS and browser, but it is typically +# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down +# key> to jump into the search results window, the results can be navigated +# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel +# the search. The filter options can be selected when the cursor is inside the +# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys> +# to select a filter and <Enter> or <escape> to activate or cancel the filter +# option. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a web server instead of a web client using Javascript. There +# are two flavors of web server based searching depending on the EXTERNAL_SEARCH +# setting. When disabled, doxygen will generate a PHP script for searching and +# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing +# and searching needs to be provided by external tools. See the section +# "External Indexing and Searching" for details. +# The default value is: NO. +# This tag requires that the tag SEARCHENGINE is set to YES. + +SERVER_BASED_SEARCH = NO + +# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP +# script for searching. Instead the search results are written to an XML file +# which needs to be processed by an external indexer. Doxygen will invoke an +# external search engine pointed to by the SEARCHENGINE_URL option to obtain the +# search results. +# +# Doxygen ships with an example indexer (doxyindexer) and search engine +# (doxysearch.cgi) which are based on the open source search engine library +# Xapian (see: http://xapian.org/). +# +# See the section "External Indexing and Searching" for details. +# The default value is: NO. +# This tag requires that the tag SEARCHENGINE is set to YES. + +EXTERNAL_SEARCH = NO + +# The SEARCHENGINE_URL should point to a search engine hosted by a web server +# which will return the search results when EXTERNAL_SEARCH is enabled. +# +# Doxygen ships with an example indexer (doxyindexer) and search engine +# (doxysearch.cgi) which are based on the open source search engine library +# Xapian (see: http://xapian.org/). See the section "External Indexing and +# Searching" for details. +# This tag requires that the tag SEARCHENGINE is set to YES. + +SEARCHENGINE_URL = + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed +# search data is written to a file for indexing by an external tool. With the +# SEARCHDATA_FILE tag the name of this file can be specified. +# The default file is: searchdata.xml. +# This tag requires that the tag SEARCHENGINE is set to YES. + +SEARCHDATA_FILE = searchdata.xml + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the +# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is +# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple +# projects and redirect the results back to the right project. +# This tag requires that the tag SEARCHENGINE is set to YES. + +EXTERNAL_SEARCH_ID = + +# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen +# projects other than the one defined by this configuration file, but that are +# all added to the same external search index. Each project needs to have a +# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of +# to a relative location where the documentation can be found. The format is: +# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... +# This tag requires that the tag SEARCHENGINE is set to YES. + +EXTRA_SEARCH_MAPPINGS = + +#--------------------------------------------------------------------------- +# Configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output. +# The default value is: YES. + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +GENERATE_LATEX = NO +======= +GENERATE_LATEX = YES +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +GENERATE_LATEX = NO +>>>>>>> 7b3a2fe... SCRUM$30 - Starting the documentation from simmc-agent using doxygen +======= +GENERATE_LATEX = YES +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +GENERATE_LATEX = NO +>>>>>>> ca8ed79... SCRUM#30 - Documentation from agent e conf file's + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: latex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. +# +# Note that when enabling USE_PDFLATEX this option is only used for generating +# bitmaps for formulas in the HTML output, but not in the Makefile that is +# written to the output directory. +# The default file is: latex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate +# index for LaTeX. +# The default file is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX +# documents. This may be useful for small projects and may help to save some +# trees in general. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used by the +# printer. +# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x +# 14 inches) and executive (7.25 x 10.5 inches). +# The default value is: a4. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names +# that should be included in the LaTeX output. The package can be specified just +# by its name or with the correct syntax as to be used with the LaTeX +# \usepackage command. To get the times font for instance you can specify : +# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times} +# To use the option intlimits with the amsmath package you can specify: +# EXTRA_PACKAGES=[intlimits]{amsmath} +# If left blank no extra packages will be included. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the +# generated LaTeX document. The header should contain everything until the first +# chapter. If it is left blank doxygen will generate a standard header. See +# section "Doxygen usage" for information on how to let doxygen write the +# default header to a separate file. +# +# Note: Only use a user-defined header if you know what you are doing! The +# following commands have a special meaning inside the header: $title, +# $datetime, $date, $doxygenversion, $projectname, $projectnumber, +# $projectbrief, $projectlogo. Doxygen will replace $title with the empty +# string, for the replacement values of the other commands the user is referred +# to HTML_HEADER. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the +# generated LaTeX document. The footer should contain everything after the last +# chapter. If it is left blank doxygen will generate a standard footer. See +# LATEX_HEADER for more information on how to generate a default footer and what +# special commands can be used inside the footer. +# +# Note: Only use a user-defined footer if you know what you are doing! +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_FOOTER = + +# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# LaTeX style sheets that are included after the standard style sheets created +# by doxygen. Using this option one can overrule certain style aspects. Doxygen +# will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EXTRA_STYLESHEET = + +# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the LATEX_OUTPUT output +# directory. Note that the files will be copied as-is; there are no commands or +# markers available. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EXTRA_FILES = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is +# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will +# contain links (just like the HTML output) instead of page references. This +# makes the output suitable for online browsing using a PDF viewer. +# The default value is: YES. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate +# the PDF file directly from the LaTeX files. Set this option to YES, to get a +# higher quality PDF documentation. +# The default value is: YES. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode +# command to the generated LaTeX files. This will instruct LaTeX to keep running +# if errors occur, instead of asking the user for help. This option is also used +# when generating formulas in HTML. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_BATCHMODE = NO + +# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the +# index chapters (such as File Index, Compound Index, etc.) in the output. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_HIDE_INDICES = NO + +# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source +# code with syntax highlighting in the LaTeX output. +# +# Note that which sources are shown also depends on other settings such as +# SOURCE_BROWSER. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. See +# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# The default value is: plain. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_BIB_STYLE = plain + +# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_TIMESTAMP = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The +# RTF output is optimized for Word 97 and may not look too pretty with other RTF +# readers/editors. +# The default value is: NO. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: rtf. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF +# documents. This may be useful for small projects and may help to save some +# trees in general. +# The default value is: NO. +# This tag requires that the tag GENERATE_RTF is set to YES. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will +# contain hyperlink fields. The RTF file will contain links (just like the HTML +# output) instead of page references. This makes the output suitable for online +# browsing using Word or some other Word compatible readers that support those +# fields. +# +# Note: WordPad (write) and others do not support links. +# The default value is: NO. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's config +# file, i.e. a series of assignments. You only have to provide replacements, +# missing definitions are set to their default value. +# +# See also section "Doxygen usage" for information on how to generate the +# default style sheet that doxygen normally uses. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an RTF document. Syntax is +# similar to doxygen's config file. A template extensions file can be generated +# using doxygen -e rtf extensionFile. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_EXTENSIONS_FILE = + +# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code +# with syntax highlighting in the RTF output. +# +# Note that which sources are shown also depends on other settings such as +# SOURCE_BROWSER. +# The default value is: NO. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for +# classes and files. +# The default value is: NO. + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. A directory man3 will be created inside the directory specified by +# MAN_OUTPUT. +# The default directory is: man. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to the generated +# man pages. In case the manual section does not start with a number, the number +# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is +# optional. +# The default value is: .3. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_EXTENSION = .3 + +# The MAN_SUBDIR tag determines the name of the directory created within +# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by +# MAN_EXTENSION with the initial . removed. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_SUBDIR = + +# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it +# will generate one additional man file for each entity documented in the real +# man page(s). These additional files only source the real man page, but without +# them the man command would be unable to find the correct page. +# The default value is: NO. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that +# captures the structure of the code including all documentation. +# The default value is: NO. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: xml. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_OUTPUT = xml + +# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program +# listings (including syntax highlighting and cross-referencing information) to +# the XML output. Note that enabling this will significantly increase the size +# of the XML output. +# The default value is: YES. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- + +# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files +# that can be used to generate PDF. +# The default value is: NO. + +GENERATE_DOCBOOK = NO + +# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in +# front of it. +# The default directory is: docbook. +# This tag requires that the tag GENERATE_DOCBOOK is set to YES. + +DOCBOOK_OUTPUT = docbook + +# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the +# program listings (including syntax highlighting and cross-referencing +# information) to the DOCBOOK output. Note that enabling this will significantly +# increase the size of the DOCBOOK output. +# The default value is: NO. +# This tag requires that the tag GENERATE_DOCBOOK is set to YES. + +DOCBOOK_PROGRAMLISTING = NO + +#--------------------------------------------------------------------------- +# Configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an +# AutoGen Definitions (see http://autogen.sf.net) file that captures the +# structure of the code including all documentation. Note that this feature is +# still experimental and incomplete at the moment. +# The default value is: NO. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module +# file that captures the structure of the code including all documentation. +# +# Note that this feature is still experimental and incomplete at the moment. +# The default value is: NO. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary +# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI +# output from the Perl module output. +# The default value is: NO. +# This tag requires that the tag GENERATE_PERLMOD is set to YES. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely +# formatted so it can be parsed by a human reader. This is useful if you want to +# understand what is going on. On the other hand, if this tag is set to NO, the +# size of the Perl module output will be much smaller and Perl will parse it +# just the same. +# The default value is: YES. +# This tag requires that the tag GENERATE_PERLMOD is set to YES. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file are +# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful +# so different doxyrules.make files included by the same Makefile don't +# overwrite each other's variables. +# This tag requires that the tag GENERATE_PERLMOD is set to YES. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all +# C-preprocessor directives found in the sources and include files. +# The default value is: YES. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names +# in the source code. If set to NO, only conditional compilation will be +# performed. Macro expansion can be done in a controlled way by setting +# EXPAND_ONLY_PREDEF to YES. +# The default value is: NO. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +MACRO_EXPANSION = YES +======= +MACRO_EXPANSION = NO +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +MACRO_EXPANSION = YES +>>>>>>> 7b3a2fe... SCRUM$30 - Starting the documentation from simmc-agent using doxygen +======= +MACRO_EXPANSION = NO +>>>>>>> a9cf478... Starting the documentation from simmc-agent using doxygen +======= +MACRO_EXPANSION = YES +>>>>>>> ca8ed79... SCRUM#30 - Documentation from agent e conf file's + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then +# the macro expansion is limited to the macros specified with the PREDEFINED and +# EXPAND_AS_DEFINED tags. +# The default value is: NO. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES, the include files in the +# INCLUDE_PATH will be searched if a #include is found. +# The default value is: YES. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by the +# preprocessor. +# This tag requires that the tag SEARCH_INCLUDES is set to YES. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will be +# used. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that are +# defined before the preprocessor is started (similar to the -D option of e.g. +# gcc). The argument of the tag is a list of macros of the form: name or +# name=definition (no spaces). If the definition and the "=" are omitted, "=1" +# is assumed. To prevent a macro definition from being undefined via #undef or +# recursively expanded use the := operator instead of the = operator. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this +# tag can be used to specify a list of macro names that should be expanded. The +# macro definition that is found in the sources will be used. Use the PREDEFINED +# tag if you want to use a different macro definition that overrules the +# definition found in the source code. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will +# remove all references to function-like macros that are alone on a line, have +# an all uppercase name, and do not end with a semicolon. Such function macros +# are typically used for boiler-plate code, and will confuse the parser if not +# removed. +# The default value is: YES. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES tag can be used to specify one or more tag files. For each tag +# file the location of the external documentation should be added. The format of +# a tag file without this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where loc1 and loc2 can be relative or absolute paths or URLs. See the +# section "Linking to external documentation" for more information about the use +# of tag files. +# Note: Each tag file must have a unique name (where the name does NOT include +# the path). If a tag file is not located in the directory in which doxygen is +# run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create a +# tag file that is based on the input files it reads. See section "Linking to +# external documentation" for more information about the usage of tag files. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES, all external class will be listed in +# the class index. If set to NO, only the inherited external classes will be +# listed. +# The default value is: NO. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will be +# listed. +# The default value is: YES. + +EXTERNAL_GROUPS = YES + +# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in +# the related pages index. If set to NO, only the current project's pages will +# be listed. +# The default value is: YES. + +EXTERNAL_PAGES = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of 'which perl'). +# The default file (with absolute path) is: /usr/bin/perl. + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram +# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to +# NO turns the diagrams off. Note that this option also works with HAVE_DOT +# disabled, but it is recommended to install and use dot, since it yields more +# powerful graphs. +# The default value is: YES. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see: +# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# You can include diagrams made with dia in doxygen documentation. Doxygen will +# then run dia to produce the diagram and insert it in the documentation. The +# DIA_PATH tag allows you to specify the directory where the dia binary resides. +# If left empty dia is assumed to be found in the default search path. + +DIA_PATH = + +# If set to YES the inheritance and collaboration graphs will hide inheritance +# and usage relations if the target is undocumented or is not a class. +# The default value is: YES. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz (see: +# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent +# Bell Labs. The other options in this section have no effect if this option is +# set to NO +# The default value is: NO. + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed +# to run in parallel. When set to 0 doxygen will base this on the number of +# processors available in the system. You can set it explicitly to a value +# larger than 0 to get control over the balance between CPU load and processing +# speed. +# Minimum value: 0, maximum value: 32, default value: 0. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_NUM_THREADS = 0 + +# When you want a differently looking font in the dot files that doxygen +# generates you can specify the font name using DOT_FONTNAME. You need to make +# sure dot is able to find the font, which can be done by putting it in a +# standard location or by setting the DOTFONTPATH environment variable or by +# setting DOT_FONTPATH to the directory containing the font. +# The default value is: Helvetica. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of +# dot graphs. +# Minimum value: 4, maximum value: 24, default value: 10. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the default font as specified with +# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set +# the path where dot can find it using this tag. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_FONTPATH = + +# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for +# each documented class showing the direct and indirect inheritance relations. +# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a +# graph for each documented class showing the direct and indirect implementation +# dependencies (inheritance, containment, and class references variables) of the +# class with other documented classes. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for +# groups, showing the direct groups dependencies. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside the +# class node. If there are many fields or methods and many nodes the graph may +# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the +# number of items for each type to make the size more manageable. Set this to 0 +# for no limit. Note that the threshold may be exceeded by 50% before the limit +# is enforced. So when you set the threshold to 10, up to 15 fields may appear, +# but if the number exceeds 15, the total amount of fields shown is limited to +# 10. +# Minimum value: 0, maximum value: 100, default value: 10. +# This tag requires that the tag HAVE_DOT is set to YES. + +UML_LIMIT_NUM_FIELDS = 10 + +# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and +# collaboration graphs will show the relations between templates and their +# instances. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +TEMPLATE_RELATIONS = NO + +# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to +# YES then doxygen will generate a graph for each documented file showing the +# direct and indirect include dependencies of the file with other documented +# files. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +INCLUDE_GRAPH = YES + +# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are +# set to YES then doxygen will generate a graph for each documented file showing +# the direct and indirect include dependencies of the file with other documented +# files. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH tag is set to YES then doxygen will generate a call +# dependency graph for every global function or class method. +# +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. Disabling a call graph can be +# accomplished by means of the command \hidecallgraph. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller +# dependency graph for every global function or class method. +# +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. Disabling a caller graph can be +# accomplished by means of the command \hidecallergraph. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical +# hierarchy of all classes instead of a textual one. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the +# dependencies a directory has on other directories in a graphical way. The +# dependency relations are determined by the #include relations between the +# files in the directories. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. For an explanation of the image formats see the section +# output formats in the documentation of the dot tool (Graphviz (see: +# http://www.graphviz.org/)). +# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order +# to make the SVG files visible in IE 9+ (other browsers do not have this +# requirement). +# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo, +# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and +# png:gdiplus:gdiplus. +# The default value is: png. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# +# Note that this requires a modern browser other than Internet Explorer. Tested +# and working are Firefox, Chrome, Safari, and Opera. +# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make +# the SVG files visible. Older versions of IE do not have SVG support. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +INTERACTIVE_SVG = NO + +# The DOT_PATH tag can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the \dotfile +# command). +# This tag requires that the tag HAVE_DOT is set to YES. + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the \mscfile +# command). + +MSCFILE_DIRS = + +# The DIAFILE_DIRS tag can be used to specify one or more directories that +# contain dia files that are included in the documentation (see the \diafile +# command). + +DIAFILE_DIRS = + +# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the +# path where java can find the plantuml.jar file. If left blank, it is assumed +# PlantUML is not used or called during a preprocessing step. Doxygen will +# generate a warning when it encounters a \startuml command in this case and +# will not generate output for the diagram. + +PLANTUML_JAR_PATH = + +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + +# When using plantuml, the specified paths are searched for files specified by +# the !include statement in a plantuml block. + +PLANTUML_INCLUDE_PATH = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes +# that will be shown in the graph. If the number of nodes in a graph becomes +# larger than this value, doxygen will truncate the graph, which is visualized +# by representing a node as a red box. Note that doxygen if the number of direct +# children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that +# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. +# Minimum value: 0, maximum value: 10000, default value: 50. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs +# generated by dot. A depth value of 3 means that only nodes reachable from the +# root by following a path via at most 3 edges will be shown. Nodes that lay +# further from the root node will be omitted. Note that setting this option to 1 +# or 2 may greatly reduce the computation time needed for large code bases. Also +# note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. +# Minimum value: 0, maximum value: 1000, default value: 0. +# This tag requires that the tag HAVE_DOT is set to YES. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not seem +# to support this out of the box. +# +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) support +# this, this feature is disabled by default. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page +# explaining the meaning of the various boxes and arrows in the dot generated +# graphs. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# files that are used to generate the various graphs. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_CLEANUP = YES diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..36ab0a13c3b57085e584fe77f253f939ed7946ef --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/} + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + 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 3 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, see {http://www.gnu.org/licenses/}. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + solace-test Copyright (C) 2013 Eduardo Luis Buratti + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +{http://www.gnu.org/licenses/}. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +{http://www.gnu.org/philosophy/why-not-lgpl.html}. diff --git a/README.md b/README.md index c0f18021bb094081c1f19ef5ff7b81a0e67f8097..6918f51eae5a4ef05d49fe4449bc026c3a89f987 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ The agent for the SIMMC - Sistema de Monitoramento do Ministério das Comunicaç requirements ------------ +c++ compiler cmake +libudev building and compiling ---------------------- @@ -18,7 +20,7 @@ to generate a `Makefile`, library objects and misterious CMake files, then $ make -to compile. The resulting executable `agent-vx.x` 'will be in `agent/bin`. +to compile. The resulting executable `agent-vx.x` will be in `agent/bin`. Run it with $ ./agent-vx.x @@ -57,6 +59,41 @@ at something that was already corrected, run inside the `build` directory and cmake again. ### building and compiling ### -As above. +When compiling and executing the agent locally, in order to see the resulting +JSON objects, run cmake with the option `PRINT_JSON` + + $ cmake -DPRINT_JSON=ON .. + +You may also set the `Debug` flag if using gdb + + $ cmake -DCMAKE_BUILD_TYPE=Debug -DPRINT_JSON=ON .. + +documentation +------------- + +Clone doxygen project from github + + $ git clone https://github.com/doxygen/doxygen + +requirements - flex lib +----------------------- + + $ apt-get install flex + +Building and compiling +---------------------- + + $ cd doxygen + $ mkdir build + $ cmake -G "Unix Makefiles" .. + $ make + +Testing +------- + +Execute doxygen to generate the simmc-agent documentation + + $ doxygen Doxyfile + +Will be generated a Documentation directory that contains HTML pages for each file from agent -TODO: add DEBUG or DEV option. diff --git a/conf/datasid-conf.json b/conf/datasid-conf.json new file mode 100644 index 0000000000000000000000000000000000000000..ce0589b4583694db3f9c99b47ce87fcea2b47a0d --- /dev/null +++ b/conf/datasid-conf.json @@ -0,0 +1,6 @@ +{ +"idPoint" : "1", +"proxyConf" : "/conf/proxy.json", +"webService": "http://simmc.c3sl.ufpr.br/axis2/services/DataSID" +} + diff --git a/include/agent/agent.h b/include/agent/agent.h new file mode 100644 index 0000000000000000000000000000000000000000..a5ca6402e956a94dc3da1256e89e5b48684e2255 --- /dev/null +++ b/include/agent/agent.h @@ -0,0 +1,58 @@ +#pragma once +#include <iostream> +#include <fstream> +#include <boost/filesystem.hpp> +#include <boost/filesystem/path.hpp> +#include <json/json.h> + +/** + * @file agent.h + * @brief This file has the Agent class and in it is saved info about the current agent, + * like absolute path, current versio and so on. + * The Agent class has 8 attributes: + * - confDir - Absolute path from conf directory (/opt/agentc3sl/conf) + * - configFileName - Absolute path from config file (/opt/agentc3sl/conf/datasid-conf.json) + * - dirInstall - Absolute path from local to install agent (/opt/agentc3sl) + * - logFile - Absolute path from log file (/opt/agentc3sl/log/datasid-agent.log) + * - message - Success, warning and error messages to be setted in logfile + * - prefix - Absolute path from agent - get current local (path) of agent + * - version - Current agent version + * - runName Name of agent .run file + * <br><br> +*/ + +class Agent{ + private: + std::string confDir; /*!< Absolute path from conf directory */ + std::string configFile; /*!< Absolute path from config file */ + std::string dirInstall; /*!< Absolute path from local to install agent */ + std::string logDir; /*!< Absolute path from log directory */ + std::string logFile; /*!< Absolute path from log file */ + std::string message; /*!< Success, warning and error messages to be setted in logfile */ + std::string prefix; /*!< Absolute path from agent */ + std::string version; /*!< Current agent version */ + std::string runName; /*!< Name of agent .run file */ + + public: + void setConfDir(std::string); + void setConfigFile(std::string); + void setDirInstall(std::string); + void setLogDir(std::string); + void setLogFile(std::string); + void setMessage(std::string); + void setPrefix(std::string, int); + void setVersion(std::string); + void setRunName(std::string); + + std::string getConfDir() const; + std::string getConfigFile() const; + std::string getDirInstall() const; + std::string getLogDir() const; + std::string getLogFile() const; + std::string getMessage() const; + std::string getPrefix() const; + std::string getVersion() const; + std::string getRunName() const; + + void prefixISet(); + }; \ No newline at end of file diff --git a/include/agent/common.h b/include/agent/common.h new file mode 100644 index 0000000000000000000000000000000000000000..323137a58c35bb8aa14ad68e63c9697e352085fa --- /dev/null +++ b/include/agent/common.h @@ -0,0 +1,30 @@ +#pragma once +#include <fstream> +#include <sys/stat.h> +#include <agent/agent.h> +#include <agent/parse_config_file.h> +#include <agent/parse_proxy_file.h> +#include <boost/filesystem.hpp> +#include <json/json.h> + +/** @file common.h + * @brief This file has a purpose to make parse from config and proxy file. + * Config file is required + * Proxy file is optional + */ + +/** + * Check if version file exist and set currrent version to agent object. + * Otherwise, setted 0.0.0. + */ +bool check_version_file_exist(Agent*); + +/** + * To make parsing from config and proxy file. + */ +bool common(std::fstream*, Agent*, Conf*, Proxy*); + +/** + * Check if a file exist. + */ +bool file_exist(const char*); diff --git a/include/agent/curl.h b/include/agent/curl.h new file mode 100644 index 0000000000000000000000000000000000000000..7fbce8551a44b04a17a5758e9e8b3b10a5c1ed50 --- /dev/null +++ b/include/agent/curl.h @@ -0,0 +1,50 @@ +#pragma once +#include <cstring> +#include <iostream> +#include <fstream> +#include <stdlib.h> +#include <agent/agent.h> +#include <agent/parse_config_file.h> +#include <boost/filesystem.hpp> +#include <curl/curl.h> +#include <agent/get.h> +#include <json/json.h> + +/** + * @file curl.h + * @brief This file has Curl class and the purpose is to make a get request to web service and download the agent zip file + * - Obs + * - Using libcurl to make a get request (curl/curl.h) + */ + +class Curl{ + private: + CURL *curl; /*!< Curl object */ + CURLcode response; /*!< Response from webService */ + long httpCode = 0; /*!< Code return from webSerice (200, 404, 502 and so on) */ + + public: + bool downloadAgent (std::string, std::fstream*, Agent*); + + /** Default callback function that is necessary to make a curl request. + * @brief Obs: + * - Parameters from this method is define by curl lib (curl/curl.h); + */ + static size_t callBackDownload(void *ptr, size_t size, size_t nmemb,void* userdata) { + FILE* stream = (FILE*)userdata; + + if (!stream) + return 0; + + size_t written = fwrite((FILE*)ptr, size, nmemb, stream); + return written; + } +}; + +/*--------------------------------------------------------------------- + * Function: mkdtemp + * Summary: Create a new and unique temporary directory in /tmp + */ + +template<class T> +char *mkdtemp(T *tmpDir); diff --git a/include/agent/get.h b/include/agent/get.h new file mode 100644 index 0000000000000000000000000000000000000000..c59e7959dc1bc4da8179e76fe630d44afde8412a --- /dev/null +++ b/include/agent/get.h @@ -0,0 +1,25 @@ +#pragma once +#include <iostream> +#include <sys/utsname.h> +#include <fstream> +#include <cpr/cpr.h> +#include <json/json.h> +#include <agent/agent.h> +#include <agent/common.h> +#include <agent/curl.h> +#include <agent/parse_config_file.h> +#include <agent/parse_proxy_file.h> +#include <agent/rotate_log_file.h> + +const std::string url = "http://localhost:3001"; + +/** + * @file get.h + * @brief Check case if has a new agent version available + */ + +int check_update(); +void create_directories(Agent); +bool compare_version(Agent*, std::string, std::fstream*); +bool copy_bin_file_to_destiny_directory(std::fstream*, Agent*, boost::filesystem::path); +bool download(Conf, Agent*, std::fstream*); \ No newline at end of file diff --git a/include/agent/get_date.h b/include/agent/get_date.h new file mode 100644 index 0000000000000000000000000000000000000000..f3530cc72fff9a7f90331ba4fb880b1158686d2e --- /dev/null +++ b/include/agent/get_date.h @@ -0,0 +1,10 @@ +#pragma once +#include <time.h> +#include <string> + +/** + * @file get_date.h + * @brief Get current date from system (YYYY-MM-DD) + */ + +std::string get_date(); diff --git a/include/agent/get_disks_info.h b/include/agent/get_disks_info.h new file mode 100644 index 0000000000000000000000000000000000000000..0cc4de3dd028d9a910020360096985bf49b9afda --- /dev/null +++ b/include/agent/get_disks_info.h @@ -0,0 +1,22 @@ +#pragma once +#include <libudev.h> +#include <iostream> +#include <fstream> +#include <list> +#include <string> + +/** + * @file get_disks_info.h + * @brief Get 2 disks info (Model and size for each one) + */ + +/** struct disk contain model and size from a disk */ +struct disk { + std::string model; + long long size; +}; + +typedef struct disk disk_t; + +void get_scsi_disks(std::list<disk_t>&); +void get_disks_info(std::list<disk_t>&); \ No newline at end of file diff --git a/include/agent/get_distro.h b/include/agent/get_distro.h new file mode 100644 index 0000000000000000000000000000000000000000..20b11b84266a1fbe01b18e52b90012326a86ebb5 --- /dev/null +++ b/include/agent/get_distro.h @@ -0,0 +1,10 @@ +#pragma once +#include <sys/utsname.h> +#include <agent/open_file.h> + +/** + * @file get_distro.h + * @brief Get info from Ubuntu, debian, Linux Comunicações, Linux Educacional, fedora and OpenSUSE distro; windows use dtwinver + */ + +std::string get_distro(); \ No newline at end of file diff --git a/include/agent/get_macaddr.h b/include/agent/get_macaddr.h new file mode 100644 index 0000000000000000000000000000000000000000..9403ba178b2a0d1c254b2b902858ad8e406b2de3 --- /dev/null +++ b/include/agent/get_macaddr.h @@ -0,0 +1,18 @@ +#pragma once +#include <stdio.h> +#include <fstream> +#include <iostream> +#include <cstring> +#ifdef WIN32 + #include <Windows.h> + #include <Iphlpapi.h> + #include <Assert.h> + #pragma comment(lib, "iphlpapi.lib") +#endif + +/** + * @file get_macaddr.h + * @brief Case if linux OS, get macaddress info from /proc/net/rout file + */ + +std::string get_macaddr(); diff --git a/include/agent/get_machine_type.h b/include/agent/get_machine_type.h new file mode 100644 index 0000000000000000000000000000000000000000..8c69134067553017b59e8ea9c4594accc352f54f --- /dev/null +++ b/include/agent/get_machine_type.h @@ -0,0 +1,23 @@ +#pragma once +#include <stdlib.h> +#include <cstring> +#include <iostream> +#include <stdio.h> +#ifdef WIN32 + #define _WIN32_WINNT 0x0500 + #include <tchar.h> + #include <windows.h> +#else + #include <arpa/inet.h> + #include <netdb.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <unistd.h> +#endif + +/** + * @file get_machine_type.h + * @brief Get machine type - return Server or Client + */ + +std::string get_machine_type(); \ No newline at end of file diff --git a/include/agent/get_memory_size.h b/include/agent/get_memory_size.h new file mode 100644 index 0000000000000000000000000000000000000000..9d3c8c724c1db95d2c3e5546011c1f0113de2b29 --- /dev/null +++ b/include/agent/get_memory_size.h @@ -0,0 +1,12 @@ +#pragma once +#include <fstream> +#include <string> +#include <agent/open_file.h> +#include <algorithm> + +/** + * @file get_memory_size.h + * @brief Get memory size info + */ + +int get_memory_size(); \ No newline at end of file diff --git a/include/agent/get_processor_model.h b/include/agent/get_processor_model.h new file mode 100644 index 0000000000000000000000000000000000000000..2f8d3bfa440734bdee6d6455ba5ef69e0351fd21 --- /dev/null +++ b/include/agent/get_processor_model.h @@ -0,0 +1,11 @@ +#pragma once +#include <fstream> +#include <string> +#include <agent/open_file.h> + +/** + * @file get_processor_model.h + * @brief Get processor model info + */ + +std::string get_processor_model(); \ No newline at end of file diff --git a/include/agent/get_time.h b/include/agent/get_time.h new file mode 100644 index 0000000000000000000000000000000000000000..2cb7d25c834157d91b8b3a7ff99e52deefcdb1cc --- /dev/null +++ b/include/agent/get_time.h @@ -0,0 +1,10 @@ +#pragma once +#include <time.h> +#include <string> + +/** + * @file get_time.h + * @brief Get current time from system (HH:MM:SS) + */ + +std::string get_time(); diff --git a/include/agent/get_user_count.h b/include/agent/get_user_count.h new file mode 100644 index 0000000000000000000000000000000000000000..5466b82f47efe786cb30d9c7b77ba4a26ed74be1 --- /dev/null +++ b/include/agent/get_user_count.h @@ -0,0 +1,121 @@ +#pragma once +#include <arpa/inet.h> +#include <ctype.h> +#include <errno.h> +#include <getopt.h> +#include <malloc.h> +#include <netdb.h> +#include <netinet/in.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <pwd.h> +#include <grp.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/fcntl.h> +#include <time.h> +#include <unistd.h> +#include <utmp.h> +#include <iostream> +#include <fstream> +#include <set> + +/** + * @file get_user_count.h + * @brief Get info about who was using the system in the previous day. + * Reading the utmp file (thats allows one to discover information about who is currently using the system) and check case if + * user was logged in, is still logged or also made logout in the previous day. + * <br><br> + * Example (Today is 06/07): + * - User logged in 06/05 and is still logged in; + * - User looged in 06/06; + * - User logout in 06/06; + * . + * All of above examples are valid and all of them will be set in the list. In the list has only the username and doesn't repeat. + * In the end, the get_user_count() function return the size of the list. + */ + +#ifndef OLD_UTMP_H +#define OLD_UTMP_H + +#define OLD_LINESIZE 12 +#define OLD_NAMESIZE 8 +#define OLD_HOSTSIZE 16 + +/** oldutmp struct - Old utmp entry to check for duplicates */ +struct oldutmp { + short ut_type; /*!< Type of record */ + int ut_pid; /*!< PID of login process */ + char ut_line[OLD_LINESIZE]; /*!< Device name of tty - "/dev/" */ + char ut_id[4]; /*!< Terminal name suffix or inittab(5) ID */ + long ut_oldtime; /*!< */ + char ut_user[OLD_NAMESIZE]; /*!< Username */ + char ut_host[OLD_HOSTSIZE]; /*!< Hostname for remote login, or kernel version for run-level messages */ + long ut_oldaddr; +}; + +#endif + +#ifndef SHUTDOWN_TIME +# define SHUTDOWN_TIME 254 +#endif + +#define UCHUNKSIZE 16384 /*!< How much we read at once. */ + +/** utmplist struct - Current utmp entry + * - The utmp file allows one to discover information about who is currently using the system + * - The struct has: + * - utmp struct + * - Address to next node + * - Address to previous node + */ +struct utmplist { + struct utmp ut; + struct utmplist *next; + struct utmplist *prev; +}; + +/** user_log strcut (type of a list) - has info from a user + * - user login name + * - login time + * - logout time + * - address to next node + */ +struct user_log { + char user[8]; + char login[7]; + char logout[7]; + struct user_log *next; +}; + +/* Types of listing */ +#define R_CRASH 1 /*!< No logout record, system boot in between */ +#define R_DOWN 2 /*!< System brought down in decent way */ +#define R_NORMAL 3 /*!< Normal */ +#define R_NOW 4 /*!< Still logged in */ +#define R_REBOOT 5 /*!< Reboot record. */ +#define R_PHANTOM 6 /*!< No logout record but session is stale. */ +#define R_TIMECHANGE 7 /*!< NEW_TIME or OLD_TIME */ + +using namespace std; + +/** + * Read one utmp entry, return in new format. + * Automatically reposition file pointer. + */ +static int uread(FILE*, struct utmp*, int*); + +/** Check each user from utmp file: + * - User logged in the previous day. + * - User logout in the the previous day. + * - User is still logged. + * . + * Case one of above options, saved in a list + */ +static void list(struct utmp *p, time_t t, int what); +/** Check each line from utmp file that is opened by uread function */ +static struct user_log * last_modified(); +/** Get number of users that logged/used the current computer in previous day */ +int get_user_count(); \ No newline at end of file diff --git a/include/agent/inventory.h b/include/agent/inventory.h new file mode 100644 index 0000000000000000000000000000000000000000..40cb3eabfba158bb396a9402613dc60e6704349b --- /dev/null +++ b/include/agent/inventory.h @@ -0,0 +1,34 @@ +#pragma once +#include <sys/utsname.h> +#include <time.h> +#include <iostream> +#include <agent/get_date.h> +#include <agent/get_disks_info.h> +#include <agent/get_distro.h> +#include <agent/get_macaddr.h> +#include <agent/get_machine_type.h> +#include <agent/get_memory_size.h> +#include <agent/get_processor_model.h> +#include <agent/get_time.h> +#include <agent/get_user_count.h> +#include <json/json.h> + +/** + * @file inventory.h + * @brief Collect all info from hardware, like processor, memory, mac adress, disks, machine type, os distro and so on. + * - The data collected are saved in a json object: + * - OS Type + * - OS Distro + * - OS Kernel + * - Processor + * - Memory + * - Disk (Get 2 disk info): + * - Model + * - Size + * - Extra hds (more than 2 disks) + * - Machine type (if not Linux Comunicações) + * - Amount users (Get number of users that logged/used the current computer in previous day) + * - Mac address + */ + +Json::Value get_inventory(); \ No newline at end of file diff --git a/include/agent/linux/get_date.h b/include/agent/linux/get_date.h deleted file mode 100644 index d1a1107f15f88e84aef64b4f6a0d8c9259a3b140..0000000000000000000000000000000000000000 --- a/include/agent/linux/get_date.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include <time.h> -#include <string> - -std::string get_date(); diff --git a/include/agent/linux/get_distro.h b/include/agent/linux/get_distro.h deleted file mode 100644 index ab8d1d25a0579421d810ec316876603046537042..0000000000000000000000000000000000000000 --- a/include/agent/linux/get_distro.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include <sys/utsname.h> -#include <fstream> - -int open_file(std::string name, std::ifstream& fstream); -std::string get_distro(); diff --git a/include/agent/linux/get_macaddr.h b/include/agent/linux/get_macaddr.h deleted file mode 100644 index 08a31a60f2dcb89221ddb11dfbce986246320919..0000000000000000000000000000000000000000 --- a/include/agent/linux/get_macaddr.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include <fstream> -#include <string.h> -#include <iostream> - -std::string get_macaddr(); diff --git a/include/agent/linux/get_machine_type.h b/include/agent/linux/get_machine_type.h deleted file mode 100644 index 338cc47ab6174022c98429b8e6c79aaf98a33b53..0000000000000000000000000000000000000000 --- a/include/agent/linux/get_machine_type.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <netdb.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <iostream> - -std::string get_machine_type(); diff --git a/include/agent/linux/get_time.h b/include/agent/linux/get_time.h deleted file mode 100644 index ad4ee9fd5f1748da64b53b1b8cd3838bcaedd664..0000000000000000000000000000000000000000 --- a/include/agent/linux/get_time.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include <time.h> -#include <string> - -std::string get_time(); diff --git a/include/agent/linux/get_user_count.h b/include/agent/linux/get_user_count.h deleted file mode 100644 index 33e917f5e4379385abe25e9e5397aca11a98f2bb..0000000000000000000000000000000000000000 --- a/include/agent/linux/get_user_count.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/fcntl.h> -#include <time.h> -#include <stdio.h> -#include <ctype.h> -#include <utmp.h> -#include <errno.h> -#include <malloc.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <signal.h> -#include <getopt.h> -#include <netinet/in.h> -#include <netdb.h> -#include <arpa/inet.h> -#include <iostream> -#include <set> - - -#ifndef OLD_UTMP_H -#define OLD_UTMP_H - -#define OLD_LINESIZE 12 -#define OLD_NAMESIZE 8 -#define OLD_HOSTSIZE 16 - -struct oldutmp { - short ut_type; - int ut_pid; - char ut_line[OLD_LINESIZE]; - char ut_id[4]; - long ut_oldtime; - char ut_user[OLD_NAMESIZE]; - char ut_host[OLD_HOSTSIZE]; - long ut_oldaddr; -}; - -#endif - -#ifndef SHUTDOWN_TIME -# define SHUTDOWN_TIME 254 -#endif - -#define UCHUNKSIZE 16384 /* How much we read at once. */ - -/* Double linked list of struct utmp's */ -struct utmplist { - struct utmp ut; - struct utmplist *next; - struct utmplist *prev; -}; - -struct user_log { - char user[8]; - char login[7]; - char logout[7]; - struct user_log *next; -}; - -/* Types of listing */ -#define R_CRASH 1 /* No logout record, system boot in between */ -#define R_DOWN 2 /* System brought down in decent way */ -#define R_NORMAL 3 /* Normal */ -#define R_NOW 4 /* Still logged in */ -#define R_REBOOT 5 /* Reboot record. */ -#define R_PHANTOM 6 /* No logout record but session is stale. */ -#define R_TIMECHANGE 7 /* NEW_TIME or OLD_TIME */ - -using namespace std; -int get_user_count (); diff --git a/include/agent/linux/inventory.h b/include/agent/linux/inventory.h deleted file mode 100644 index 367e431f6d36606d9f1f14a8e3c45d33fbee3115..0000000000000000000000000000000000000000 --- a/include/agent/linux/inventory.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include <iostream> -#include "json/json.h" -#include <sys/utsname.h> -#include <time.h> -#include <string.h> -#include "agent/linux/get_date.h" -#include "agent/linux/get_machine_type.h" -#include "agent/linux/get_macaddr.h" -#include "agent/linux/get_time.h" -#include "agent/linux/get_user_count.h" - -int open_file(std::string name, std::ifstream& fstream); - -std::string get_distro(); -std::string get_processor_model(); - -Json::Value get_inventory(); diff --git a/include/agent/main.h b/include/agent/main.h new file mode 100644 index 0000000000000000000000000000000000000000..4ab3884db7b1ba9e753e439d775f38c0670b0d07 --- /dev/null +++ b/include/agent/main.h @@ -0,0 +1,47 @@ +#pragma once +#include <cstring> +#include <fstream> +#include <iostream> +#include <string> +#include <boost/asio.hpp> +#include <boost/bind.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/program_options/parsers.hpp> +#include <boost/program_options/variables_map.hpp> +#include <boost/filesystem/fstream.hpp> +#include <sys/utsname.h> +#include <cpr/cpr.h> + +namespace pt = boost::posix_time; +namespace po = boost::program_options; +namespace asio = boost::asio; +namespace pholders = boost::asio::placeholders; +namespace sys = boost::system; +namespace fs = boost::filesystem; + +/** + * @file main.h + * @brief Run agent to collect inventory, network bandwidth and user history to send c3sl web service; Also check case if has a new agent version available + */ + +/** Run agent only one time per day. + * - Check case if needed to update agent + * - Send inventory to web service + * - Send network bandwidth to web service + */ +int main(int, char**); + +/** Parse command line + * - Options: + * - Help - help message + * - once - run agent only once + * - print - set print JSON to true - show inventory + * - uninstall - uninstall agent and all associated files + */ +int parse_command_line(int, char*, int*, int*, bool*); + +/** Run agent */ +int run_agent(const sys::error_code& /*e*/, pt::ptime, bool); + +/** Set the first date and time when agent was run */ +int set_begin(pt::ptime&, bool); \ No newline at end of file diff --git a/include/agent/network_bandwidth.h b/include/agent/network_bandwidth.h index 8b137891791fe96927ad78e64b0aad7bded08bdc..4d7a108eaeda16187a9bbb025b991ff514d75682 100644 --- a/include/agent/network_bandwidth.h +++ b/include/agent/network_bandwidth.h @@ -1 +1,26 @@ +#pragma once +#include <iostream> +#include <fstream> +#include <string> +#include <stdlib.h> +#include <json/json.h> +#include <boost/date_time/posix_time/posix_time.hpp> + +/** + * @file network_bandwidth.h + * @brief Collect data from networkork bandwidth. + * - Data collected: + * - Bytes recived + * - Packets recived + * - Bytes transmited + * - Packets transmited + * . + * Linux has a file (/proc/net/dev) that contain info about network bandwidth + * <br> + * The data is collected and set in a json object and net_band.json file. + * When this file (net_band.json) exists, before set in json object, the data from file + * is got and is calculated the difference between the current data and the last data saved in the file + */ + +Json::Value get_net_bandwidth(); \ No newline at end of file diff --git a/include/agent/open_file.h b/include/agent/open_file.h new file mode 100644 index 0000000000000000000000000000000000000000..25f9afd34d389c7e090672d4cf91612520c71999 --- /dev/null +++ b/include/agent/open_file.h @@ -0,0 +1,10 @@ +#pragma once +#include <fstream> +#include <string> + +/** + * @file open_file.h + * @brief Open a file and return 1 case if file was opened - Otherwise, return 0 + */ + +int open_file(std::string, std::ifstream&); diff --git a/include/agent/parse.h b/include/agent/parse.h new file mode 100644 index 0000000000000000000000000000000000000000..15d7ca8f36aee83c139d728f2c6377299f9cdcc8 --- /dev/null +++ b/include/agent/parse.h @@ -0,0 +1,19 @@ +#pragma once +#include <boost/regex.hpp> +#include <cstring> +#include <cstdlib> +#include <fstream> +#include <iostream> +#include <locale> + +/** + * @file parse.h + * @brief Get proxy or config file, read it and parse into a map varaible + */ + +bool is_valid(std::string*); +void normalize(std::string*); +void parse(std::string*, std::map<std::string, std::string>*); +bool read_file(const std::string, std::map<std::string, std::string>*); +bool space_only(const std::string*); +void trim(std::string&); \ No newline at end of file diff --git a/include/agent/parse_config_file.h b/include/agent/parse_config_file.h new file mode 100644 index 0000000000000000000000000000000000000000..faea9dfe9597d94341d93e3b6bcf68030bdb16c6 --- /dev/null +++ b/include/agent/parse_config_file.h @@ -0,0 +1,35 @@ +#pragma once +#include <map> +#include <agent/agent.h> +#include <agent/parse.h> +#include <json/json.h> + +/** + * @file parse_config_file.h + * @brief This file has a Conf class - The main purpose is get config file content and make parse to set in a conf object + */ + +class Conf{ + private: + int idPoint; + std::string proxyConf; /*!< Absolute path from proxy file. */ + std::string webService; /*!< url from web service. */ + + public: + void setIdPoint(int); + void setProxyConf(std::string); + void setWebService(std::string); + + int getIdPoint() const; + std::string getProxyConf() const; + std::string getWebService() const; + + }; + +bool parse_config_file(Agent*, Conf*, std::fstream*); + +/** + * @file parse_config_file.h + * @brief This file has a Conf class - The main purpose is get config file content and make parse to set in a conf object + */ +bool set_conf_object(Conf*, Agent*, std::map<std::string, std::string>*); diff --git a/include/agent/parse_proxy_file.h b/include/agent/parse_proxy_file.h new file mode 100644 index 0000000000000000000000000000000000000000..9dc0992d5952ed603115894f5c40080d66b4ca13 --- /dev/null +++ b/include/agent/parse_proxy_file.h @@ -0,0 +1,44 @@ +#pragma once +#include <map> +#include <agent/agent.h> +#include <agent/parse_config_file.h> +#include <agent/parse.h> +#include <json/json.h> + +/** + * @file parse_proxy_file.h + * @brief This file has the Proxy class - The main purpose is get proxy file content and + * make parse to set in a proxy object + */ + +class Proxy{ + private: + std::string host; + std::string port; + std::string user; + std::string password; + bool proxyFile = false; + + public: + void setHost(std::string); + void setPort(std::string); + void setUser(std::string); + void setPassword(std::string); + void setProxyFile(bool); + + std::string getHost() const; + std::string getPort() const; + std::string getUser() const; + std::string getPassword() const; + + bool proxyFileIsSet() const; + }; + +bool parse_proxy_file(Conf*, Proxy*, std::fstream*, Agent*); + +/** + * @file parse_proxy_file.h + * @brief This file has the Proxy class - The main purpose is get proxy file content and + * make parse to set in a proxy object + */ +bool set_proxy_object(Proxy*, std::map<std::string, std::string>*); diff --git a/include/agent/post.h b/include/agent/post.h index 66e8934a01422476bd0531730ce529fcae8f493c..96ba60ac0813b877d8f2de1d03a215693ec855b4 100644 --- a/include/agent/post.h +++ b/include/agent/post.h @@ -2,19 +2,18 @@ #include <iostream> #include <sys/utsname.h> #include <cpr/cpr.h> -#include "json/json.h" - -#ifdef _UNIX_ - #include "agent/linux/inventory.h" -#else - #include "agent/windows/inventory.h" -#endif - -#include "agent/user_history.h" -#include "agent/network_bandwidth.h" +#include <json/json.h> +#include <agent/inventory.h> +#include <agent/user_history.h> +#include <agent/network_bandwidth.h> const std::string base_url = "http://localhost:3001"; -int send_inventory(); -int send_net_bandwidth(); -int send_user_history(); +/** + * @file post.h + * @brief Collect data from hardware and send to c3sl web service + */ + +int send_inventory(bool); +int send_net_bandwidth(bool); +int send_user_history(bool); \ No newline at end of file diff --git a/include/agent/rotate_log_file.h b/include/agent/rotate_log_file.h new file mode 100644 index 0000000000000000000000000000000000000000..2c4558eae58320b87bfeed8bd41451a10ea2bb20 --- /dev/null +++ b/include/agent/rotate_log_file.h @@ -0,0 +1,38 @@ +#pragma once +#include <iostream> +#include <fstream> +#include <agent/agent.h> +#include <boost/filesystem.hpp> +#include <json/json.h> + +/** + * @file rotate_log_file.h + * @brief Case if log file size greater or equal to 5MB, create a new one; Also, case if has more than 11 log files, remove the oldest one + */ + +namespace bf = boost::filesystem; + +class Rotate{ + private: + bf::path logDir; /*!< Absolute path from log directory */ + int numberOfFiles; /*!< Total of files inside log directory */ + long sizeOfLogfile; /*!< Size from current logfile */ + std::string logfileName; /*!< Name from current logfile */ + public: + void setLogDir(bf::path); + void setNumberOfFiles(); + void setSizeOfLogfile(Agent*); + void setLogfileName(std::string); + + bf::path getLogDir() const; + int getNumberOfFiles() const; + long getSizeOfLogfile() const; + std::string getLogfileName() const; + + void renameFile(Agent*); + void createLogfile(Agent*); + + bool logDirIsSet(); +}; + +void rotate_log_file(Agent*); \ No newline at end of file diff --git a/include/agent/windows/get_date.h b/include/agent/windows/get_date.h deleted file mode 100644 index 525cf97ff774cffb20c32ff2b68f71d300b5ce06..0000000000000000000000000000000000000000 --- a/include/agent/windows/get_date.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include <time.h> -#include <string.h> - -std::string get_date(); diff --git a/include/agent/windows/get_macaddr.h b/include/agent/windows/get_macaddr.h deleted file mode 100644 index 64ffc47f89264541d5b06ca8de11a6832615b915..0000000000000000000000000000000000000000 --- a/include/agent/windows/get_macaddr.h +++ /dev/null @@ -1,7 +0,0 @@ -#include <stdio.h> -#include <Windows.h> -#include <Iphlpapi.h> -#include <Assert.h> -#pragma comment(lib, "iphlpapi.lib") - -string get_macaddr(); diff --git a/include/agent/windows/get_machine_type.h b/include/agent/windows/get_machine_type.h deleted file mode 100644 index c5793ca0d7dd3b78d6d1f2561de2979b0457d7d5..0000000000000000000000000000000000000000 --- a/include/agent/windows/get_machine_type.h +++ /dev/null @@ -1,8 +0,0 @@ -#define _WIN32_WINNT 0x0500 -#include <windows.h> -#include <stdio.h> -#include <tchar.h> - -using namespace std; - -string get_machine_type(void); diff --git a/include/agent/windows/get_time.h b/include/agent/windows/get_time.h deleted file mode 100644 index 94e12d885c9a4e88bc77b931d7b49448b8e06d30..0000000000000000000000000000000000000000 --- a/include/agent/windows/get_time.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include <time.h> -#include <string.h> - -std::string get_time(); diff --git a/include/agent/windows/inventory.h b/include/agent/windows/inventory.h deleted file mode 100644 index 0608637c5ff1996075f9f92ee2adcf12aab942a3..0000000000000000000000000000000000000000 --- a/include/agent/windows/inventory.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include <iostream> -#include "json/json.h" -#include <time.h> -#include <string.h> -#include <fstream> - -int open_file(std::string name, std::ifstream& fstream); - -std::string get_distro(); -std::string get_processor_model(); - -Json::Value get_inventory(); diff --git a/modules/boost.cmake b/modules/boost.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e2183f3fa15cc852dbdaeb00b820cecf5851c68d --- /dev/null +++ b/modules/boost.cmake @@ -0,0 +1,40 @@ +cmake_minimum_required ( VERSION 2.8.7 ) + +# Download boost from git + +include(ExternalProject) + +if ( UNIX ) + + if (NOT Boost) + + SET (Boost_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include/boost/) + SET (Boost_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/lib ) + SET (BOOST_URL https://github.com/boostorg/boost.git ) + SET (BOOST_BUILD ${CMAKE_CURRENT_BINARY_DIR}) + SET (FILESYSTEM_LIB ${BOOST_BUILD}/lib/libboost_filesystem.a) + SET (SYSTEM_LIB ${BOOST_BUILD}/lib/libboost_system.a) + SET (REGEX_LIB ${BOOST_BUILD}/lib/libboost_regex.a) + SET (PROGRAM_OPTIONS_LIB ${BOOST_BUILD}/lib/libboost_program_options.a) + + ExternalProject_Add( Boost + PREFIX Boost + GIT_REPOSITORY ${BOOST_URL} + + GIT_SUBMODULES libs/asio libs/date_time libs/config libs/core libs/detail libs/io libs/iterator libs/predef libs/preprocessor libs/smart_ptr libs/throw_exception libs/system libs/filesystem libs/integer tools/build tools/bcp libs/serialization libs/interprocess libs/tokenizer libs/algorithm libs/program_options libs/regex libs/static_assert libs/thread libs/utility libs/numeric libs/range libs/array libs/bind libs/concept_check libs/lexical_cast libs/math libs/functional libs/assert libs/type_traits libs/mpl libs/move libs/container libs/any libs/type_index libs/function + + UPDATE_COMMAND ./bootstrap.sh --with-libraries=filesystem,system,regex,program_options --includedir=${CMAKE_BINARY_DIR}/include/ + CONFIGURE_COMMAND ./b2 headers + BUILD_COMMAND ./b2 link=static install --libdir=${CMAKE_BINARY_DIR}/lib + BUILD_IN_SOURCE 1 + INSTALL_COMMAND "" + ) + + ADD_LIBRARY (Boost_LIB STATIC IMPORTED DEPENDS Boost) + SET_TARGET_PROPERTIES (Boost_LIB PROPERTIES IMPORTED_LOCATION ${FILESYSTEM_LIB}) + SET_TARGET_PROPERTIES (Boost_LIB PROPERTIES IMPORTED_LOCATION ${SYSTEM_LIB}) + SET_TARGET_PROPERTIES (Boost_LIB PROPERTIES IMPORTED_LOCATION ${REGEX_LIB}) + SET_TARGET_PROPERTIES (Boost_LIB PROPERTIES IMPORTED_LOCATION ${PROGRAM_OPTIONS_LIB}) + + endif() +endif() diff --git a/src/agent/agent.cpp b/src/agent/agent.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4ddbb56cf855ceb8d7b67d6d19e5a5864853967 --- /dev/null +++ b/src/agent/agent.cpp @@ -0,0 +1,149 @@ +/* Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/agent.h> +#include <string> + +/** Set the absolute path from conf directory */ +void Agent::setConfDir(std::string dir) { + this->confDir = this->prefix + dir; +} + + +/** Set the absolute path of config filename */ +void Agent::setConfigFile(std::string filename) { + this->configFile = this->prefix + filename; +} + +/** Set the absolute path from local where install agent */ +void Agent::setDirInstall(std::string d) { + this->dirInstall = d; +} + +/** Set the absolute path of log directory */ +void Agent::setLogDir(std::string logDir) { + this->logDir = this->prefix + logDir; +} + +/** Set the absolute path of log file + * @param logDir absolute path from log directory + * @param file name of logfile +*/ +void Agent::setLogFile(std::string file) { + this->logFile = this->logDir + file; +} + +/** Set the log message + * @brief We have a: + * * logfile + * . + * that are used to saved the success, error and warning messages +*/ +void Agent::setMessage(std::string m) { + this->message = m; +} + +/** Set the absolute path from agent */ +void Agent::setPrefix(std::string p, int tot) { + int i = p.size(), count = 0; + while (i-->-1) + if (p[i] == '/') + if (++count == tot) + break; + this->prefix = p.substr(0, i); +} + +/** Get the agent version from version file, at conf directory, + * and setted the version attribute. */ +void Agent::setVersion(std::string v) { + this->version = v; +} + +/** Set the name to agent .run file */ +void Agent::setRunName(std::string r) { + this->runName = r; +} + +/** Return the absolute path from conf directory */ +std::string Agent::getConfDir() const { + return this->confDir; +} + +/** Return the absolute path from default config filename */ +std::string Agent::getConfigFile() const { + return this->configFile; +} + +/** Return the absolute path from where to uncompress and install agent */ +std::string Agent::getDirInstall() const { + return this->dirInstall; +} + +/** Return the absolute path from logfile */ +std::string Agent::getLogDir() const { + return this->logDir; +} + +/** Return the absolute path from logfile */ +std::string Agent::getLogFile() const { + return this->logFile; +} + +/** Return the success, error or warning message */ +std::string Agent::getMessage() const { + return this->message; +} + +/** Return the absolute path from agent */ +std::string Agent::getPrefix() const { + return this->prefix; +} + +/** Return the current agent version */ +std::string Agent::getVersion() const { + return this->version; +} + +/** Return .run filename downloaded from webService when update is needed */ +std::string Agent::getRunName() const { + return this->runName; +} + +/** Check if the absolute path of agent was setted */ +void Agent::prefixISet() { + if (this->prefix.size() == 0) + throw " ERROR: Prefix not set. "; +} + +/** + * @file agent.cpp + * @brief This file has the implementation from Agent's method and in it is saved info about the current agent, + * like absolute path, current version and so on. + * The Agent class has 8 attributes: + * - confDir - Absolute path from conf directory (/opt/agentc3sl/conf) + * - configFileName - Absolute path from config file (/opt/agentc3sl/conf/datasid-conf.json) + * - dirInstall - Absolute path from local to install agent (/opt/agentc3sl) + * - logFile - Absolute path from log file (/opt/agentc3sl/log/datasid-agent.log) + * - message - Success, warning and error messages to be setted in logfile + * - prefix - Absolute path from agent - get current local (path) of agent + * - version - Current agent version + * - binName Name of agent .run file + * <br><br> +*/ diff --git a/src/agent/common.cpp b/src/agent/common.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b7c69d9fdefa5b771a0345d69c136c8c28ae3825 --- /dev/null +++ b/src/agent/common.cpp @@ -0,0 +1,116 @@ +/* Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/common.h> +#include <string> + + /** @file common.cpp + * @brief This file has a purpose to make parse from config and proxy file. + * Config file is required + * Proxy file is optional + */ + +/** + * Check if a file exist. + */ +bool file_exist(const std::string& file) { + std::ifstream myFile(file.c_str(), std::ifstream::in); + if (myFile.is_open()) { + myFile.close(); + return true; + } + myFile.close(); + return false; +} + +/** + * Check if version file exist and set currrent version to agent object. + * Otherwise, setted 0.0.0. + */ +bool check_version_file_exist(Agent* agent) { + std::string versionFile = agent->getConfDir() + "/version.json"; + std::ifstream myFile(versionFile.c_str(), std::ifstream::in); + + if (myFile.is_open()) { + std::string version; + myFile >> version; + agent->setVersion(version); + myFile.close(); + return true; + } + return false; +} + +/** + * To make parsing from config and proxy file. + */ +bool common(std::fstream* logFile, Agent* agent, Conf* conf, + Proxy* proxy) { + try { + agent->prefixISet(); + } catch (const char* error) { + agent->setMessage(__DATE__ + *error); + *logFile << agent->getMessage() << std::endl; + return false; + } + + /* Read config file and declare only valid variables */ + + if (!file_exist(agent->getConfigFile())) { + agent->setMessage(__DATE__ + + std::string(" - ERROR: Config file not found.")); + *logFile << agent->getMessage() << std::endl; + return false; + } else { + if (!parse_config_file(agent, conf, logFile)) { + return false; + } + } + + /* Read proxy file and declare only valid variables */ + + if (!file_exist(conf->getProxyConf())) { + agent->setMessage(__DATE__ + + std::string(" - WARNING: Proxy file not found.")); + *logFile << agent->getMessage() << std::endl; + } else { + if (!parse_proxy_file(conf, proxy, logFile, agent)) { + return false; + } + } + + if (!check_version_file_exist(agent)) + agent->setVersion("0.0.0"); + + if (conf->getWebService().size() == 0) { + agent->setMessage(__DATE__ + + std::string(" - ERROR: Web service url not configured.")); + *logFile << agent->getMessage() << std::endl; + return false; + } + + return true; +} + +/** @file common.cpp + * @brief This file has a purpose to make parse from config and proxy file. + * Config file is required + * Proxy file is optional + */ diff --git a/src/agent/curl.cpp b/src/agent/curl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bb58e16f352ca4432b05017cefd1bcb9647b158e --- /dev/null +++ b/src/agent/curl.cpp @@ -0,0 +1,128 @@ +/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/curl.h> +#include <string> + +/** Contact webservice server to update the agent. +* @brief Obs: +* - Not using proxy connection; +* - Not downloading file from https protocol; +* - Is a get request. +* +* @param url references to webService +* @param agent object agent +* @param data json object to save success, error and warning messages +* @param logFile references from logfile to save success, error and warning messages +*/ +bool Curl::downloadAgent(std::string url, std::fstream* logFile, + Agent* agent) { + curl = curl_easy_init(); + if (!curl) { + agent->setMessage(__DATE__ + std::string(" - ERROR: Curl ") + + std::string(" did not initialize!")); + *logFile << agent->getMessage() << std::endl; + return false; + } + + boost::system::error_code ec; + /** + * Create a tmp directory on linux (I don't think it's the same on windows) + * /tmp/Agent%%%% .... + */ + boost::filesystem::path test_root(boost::filesystem::unique_path( + boost::filesystem::temp_directory_path(ec) / "Agent%%%%-%%%%-%%%%")); + + if (!boost::filesystem::create_directory(test_root, ec) || ec) { + agent->setMessage(__DATE__ + std::string(" - ERROR: Failed to create ") + + std::string("a temporary directory.")); + *logFile << agent->getMessage() << std::endl; + return false; + } + + /* Create the agent tmp .run file into test_root */ + agent->setRunName("agent.run"); + boost::filesystem::path test_file(test_root / agent->getRunName()); + + FILE* fp = fopen(test_file.c_str(), "wb"); + + if (!fp) { + agent->setMessage(__DATE__ + std::string(" - ERROR: Failed to ") + + std::string("create file on the disk.")); + *logFile << agent->getMessage() << std::endl; + return false; + } + + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Curl::callBackDownload); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); + response = curl_easy_perform(curl); + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); + curl_easy_cleanup(curl); + + if (httpCode == 302) { + agent->setMessage(__DATE__ + std::string(" - ERROR: Protocol HTTPS ") + + std::string("not supported or disabled in libcurl.")); + *logFile << agent->getMessage() << std::endl; + return false; + } + + if (httpCode == 504) { + agent->setMessage(__DATE__ + + std::string(" - ERROR: Time out.")); + *logFile << agent->getMessage() << std::endl; + return false; + } + + fclose(fp); + bool err = copy_bin_file_to_destiny_directory(logFile, agent, test_root); + + // remove agent tmp directory + boost::uintmax_t res = boost::filesystem::remove_all(test_root); + if (res < 2) { + agent->setMessage(__DATE__ + std::string(" - WARNING: Failed ") + + std::string("to remove the agent tmp directory.")); + *logFile << agent->getMessage() << std::endl; + } + + // case error to move agent zip file from tmp to agent home + if (!err) + return false; + + if (response) { + agent->setMessage(__DATE__ + std::string(" - ERROR: Failed ") + + std::string("to download the agent.")); + *logFile << agent->getMessage() << std::endl; + return false; + } + + return true; +} + +/** + * @file curl.cpp + * @brief This file has implementation from Curl's method and the purpose is to make a get request to web + * service and download the agent zip file + * - Obs + * - Using libcurl to make a get request (curl/curl.h) + */ diff --git a/src/agent/get.cpp b/src/agent/get.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ca531f1b1ed7cbc88f135e38077f2e9b5f4489fc --- /dev/null +++ b/src/agent/get.cpp @@ -0,0 +1,195 @@ +/* Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/get.h> +#include <string> + + /** Get agent version from client and webService to check case if needed update agent. + * @brief Obs: + * - Cpr library used to make webservice request - method get; + * + * Get agent agent version from webService. Compare to cliente version; + * <br> + * Case if needed, making download from agent zipfile. + */ + +int check_update() { + Agent agent; + Conf conf; + Proxy proxy; + Rotate rotate; + std::string version; + + /* Set agent prefix */ + agent.setPrefix(__FILE__, 3); + + /* Set conf's file */ + agent.setConfDir("/conf"); + agent.setConfigFile("/conf/datasid-conf.json"); + agent.setLogDir("/log/"); + create_directories(agent); + agent.setLogFile("datasid-agent.log"); + agent.setDirInstall("/opt/agentc3sl"); + std::fstream logFile(agent.getLogFile().c_str(), std::fstream::app); + + /* run common.cpp to make parse from config and proxy file */ + if (common(&logFile, &agent, &conf, &proxy)) { + rotate_log_file(&agent); + logFile << __DATE__ << " - Agent started." << std::endl; + logFile << __DATE__ << " - Start of update process execution." + << std::endl; + /* If proxy is setted */ + if (proxy.proxyFileIsSet()) { + auto p = cpr::Get(cpr::Url{conf.getWebService() + "/api/v1/get"}, + cpr::Proxies{{"http", proxy.getHost()}}, + cpr::Parameters{{"agent", "version"}}, + cpr::Header{{"content-type", "application/json"}}); + + /* Check error with connection */ + if (p.status_code == 502) { + agent.setMessage(__DATE__ + + std::string(" - ERROR: The proxy server received an") + + std::string(" invalid response from server.")); + logFile << agent.getMessage() << std::endl; + } + + version = p.header["version"]; + + } else { + /* Contact webservice server to get client version. */ + auto p = cpr::Get(cpr::Url{conf.getWebService() + "/api/v1/get"}, + cpr::Parameters{{"agent", "version"}}, + cpr::Header{{"content-type", "application/json"}}); + + /* Check error with connection */ + if (p.status_code == 502) { + agent.setMessage(__DATE__ + + std::string(" - ERROR: The proxy server received an") + + std::string(" invalid response from server.")); + logFile << agent.getMessage() << std::endl; + } + + version = p.header["version"]; + } + + /* Case version are different, then make the download */ + if (compare_version(&agent, version, &logFile)) { + /* Case not download, return false */ + if (download(conf, &agent, &logFile)) { + agent.setMessage(__DATE__ + + std::string(" - SUCCESS: Update process terminated ") + + std::string("successfully.")); + logFile << agent.getMessage() << std::endl; + } else { + agent.setMessage(__DATE__ + + std::string(" - ERROR: Failed to update agent.")); + logFile << agent.getMessage() << std::endl; + } + } else { + agent.setMessage(__DATE__ + + std::string(" - ERROR: Failed to update agent.")); + logFile << agent.getMessage() << std::endl; + } + logFile.close(); + } + return(0); +} + + /** + * Compare client agent version with web service version. + * Case if are different and web service version not a empty string, return true; + * <br> + * Otherwise, return false. + */ +bool compare_version(Agent *agent, std::string version, + std::fstream* logFile) { + if (!strcmp(version.c_str(), "")) { + agent->setMessage(__DATE__ + + std::string(" - ERROR: Server returned an empty version string.")); + *logFile << agent->getMessage() << std::endl; + return false; + } else if (strcmp(version.c_str(), agent->getVersion().c_str())) { + agent->setMessage(__DATE__ + + std::string(" - WARNING: Client version out-of-date.") + + std::string(" Update client.")); + *logFile << agent->getMessage() << std::endl; + return true; + } else { + agent->setMessage(__DATE__ + + std::string(" - WARNING: Client is already updated.")); + *logFile << agent->getMessage() << std::endl; + return false; + } +} + +/** + * Copy the agent .run file from tmp directory to opt directory. + * Agent .run file is downloaded in a tmp directory. + */ +bool copy_bin_file_to_destiny_directory(std::fstream* + logFile, Agent* agent, boost::filesystem::path source) { + boost::filesystem::path destination = agent->getDirInstall(); + boost::filesystem::create_directory(destination); + + try { + for (boost::filesystem::directory_iterator file(source); + file != boost::filesystem::directory_iterator(); ++file) { + boost::filesystem::path current(file->path()); + if (!boost::filesystem::is_directory(current)) { + // Found file: Copy + boost::filesystem::copy_file(current, + destination / current.filename()); + } + } + } catch (const boost::filesystem::filesystem_error& e) { + std::string message = __DATE__ + std::string(" - ERROR: Failed to ") + + std::string("copy the agent .run from tmp directory") + + std::string(" to destiny directory."); + *logFile << message << std::endl; + return false; + } + return true; +} + + /** + * To make agent download. + * Curl library is used to make a webService request to get agent zipfile. + */ +bool download(Conf conf, Agent* agent, std::fstream* logFile) { + Curl curl; + if (curl.downloadAgent(conf.getWebService(), + logFile, agent)) + return true; + return false; +} + +/** + * Create "log" directories if needed. + */ +void create_directories(Agent agent) { + boost::system::error_code ec; + boost::filesystem::create_directory(agent.getLogDir().c_str(), ec); + // mkdir(agent->getLogDir().c_str(), 0700); +} + +/** + * @file get.cpp + * @brief Check case if has a new agent version available + */ diff --git a/src/agent/get_date.cpp b/src/agent/get_date.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3758cfd1907245ce9b800ba715aab75de18a021d --- /dev/null +++ b/src/agent/get_date.cpp @@ -0,0 +1,45 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ + +#include <agent/get_date.h> + +/** Get current date from system (YYYY-MM-DD) */ +std::string get_date() { + std::string res = ""; + + time_t rawtime; + struct tm * timeinfo; + char buffer[20]; + + time(&rawtime); + localtime_r(&rawtime, timeinfo); + + // YYYY-MM-DD + strftime(buffer, 20, "%Y-%m-%d", timeinfo); + + res = buffer; + return res; +} + +/** + * @file get_date.cpp + * @brief Get current date from system (YYYY-MM-DD) + */ diff --git a/src/agent/get_disks_info.cpp b/src/agent/get_disks_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e216c549381b2e02aabc0a3de01fe9c05554d187 --- /dev/null +++ b/src/agent/get_disks_info.cpp @@ -0,0 +1,117 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/get_disks_info.h> + +/** We use here udev lib to get info about disks */ +void get_scsi_disks(std::list<disk_t>& disks) { // NOLINT(runtime/references) + + struct udev *udev; + struct udev_enumerate *enumerate; + struct udev_list_entry *devices, *dev_list_entry, *links_list_entry; + struct udev_device *dev; + + udev = udev_new(); + if (!udev) { + throw "Could not creat udev\n"; + } + + /* SCSI disk devices MAJOR = {8, 65-71, 128-135} + see https://www.kernel.org/doc/Documentation/devices.txt */ + const char* scsi_majors[] = {"8", "65", "66", "67", "68", "69", "70", "71", + "128", "129", "130", "131", "132", "133", + "134", "135"}; + int i; + + for (i=0; i < 16; i++) { + + /* create a list of the disk devices in the 'block' subsystem and with + MAJOR == one of the possible scsi major numbers. */ + enumerate = udev_enumerate_new(udev); + udev_enumerate_add_match_property(enumerate, "MAJOR", scsi_majors[i]); + udev_enumerate_add_match_subsystem(enumerate, "block"); + udev_enumerate_scan_devices(enumerate); + devices = udev_enumerate_get_list_entry(enumerate); + + udev_list_entry_foreach(dev_list_entry, devices) { + /* potential new item */ + disk_t curr = {.model = "", .size = -1}; + + /* get the filename of the /sys entry for the device + and create udev_device object representing it */ + const char *path; + path = udev_list_entry_get_name(dev_list_entry); + dev = udev_device_new_from_syspath(udev, path); + + /* MINOR = (16 * drive_number) + partition_number + partition_number is 0 for the whole drive, which is the one we want + therefore, if mod 16 != 0, skip device */ + const char* minor = udev_device_get_property_value(dev, "MINOR"); + if ((atoi(minor) % 16) != 0) { + udev_device_unref(dev); + continue; + } + + + const char* serial = udev_device_get_property_value(dev, + "ID_SERIAL"); + const char* size = udev_device_get_sysattr_value(dev, "size"); + + if (serial) { + curr.model.assign(std::string(serial)); + } + + /* size in Bytes = size * 512 + size in GB = (size * 2^9)/2^30 = size/2^21 */ + if (size) { + curr.size = atoll(size) >> 21; + } + + /* do not push some anomalous device whose model and size we + couldn't obtain */ + if (size && serial) { + disks.push_front(curr); + } + + udev_device_unref(dev); + } + + /* free the enumerator object */ + udev_enumerate_unref(enumerate); + + } + + udev_unref(udev); +} + +/** Get disks info (Model and size) */ +void get_disks_info(std::list<disk_t>& disks) { // NOLINT(runtime/references) + get_scsi_disks(disks); + + if (disks.empty()) { + throw std::string("No disk info found"); + } +} + +/** + * @file get_disks_info.cpp + * @brief Get 2 disks info (Model and size for each one) + */ + diff --git a/src/agent/get_distro.cpp b/src/agent/get_distro.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d05266af6a08516daaf01a5ea0ea5648b8f01901 --- /dev/null +++ b/src/agent/get_distro.cpp @@ -0,0 +1,153 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/get_distro.h> +#include <agent/open_file.h> + +/** + * - lsb-release file has distro info from + * - Ubuntu + * - Debian + * - Linux Comunicações + * - Linux Educacional + * - Get distro info also from + * - Fedora info at /etc/os-release file + * - OpenSUSE info at /etc/redhat-release file; + */ +std::string get_distro() { + /* currently recorded distros are + * Ubuntu + * Debian + * Linux Comunicações + * Linux Educacional + all of which should have the lsb-release file, but I added a couple more + common distros just in case */ + + std::ifstream release_file; + std::string line; + + // lsb compliant + if (open_file("/etc/lsb-release", release_file)) { + const std::string key = "DISTRIB_DESCRIPTION="; + std::size_t found; + + while (getline(release_file, line)) { + found = line.find(key); + if (found != std::string::npos) { + return (line.substr(found+key.length()+1, + // remove key and quotes at the beginning + line.length()-(found+key.length()+1)-1)); + // remove quotes at the end + } + } + + throw std::string("Release file empty or incomplete."); + + // openSuSE + } else if (open_file("/etc/os-release", release_file)) { + const std::string name_key = "NAME="; + const std::string version_key = "VERSION="; + + std::string name; + std::string version; + + std::size_t found_name; + std::size_t found_version; + + while (getline(release_file, line)) { + found_name = line.find(name_key); + found_version = line.find(version_key); + if (found_name < line.length()) { + name = line.substr(found_name+name_key.length()+1, + // remove key and quotes at the beginning + line.length()-(found_name+name_key.length()+1)-1); + // remove quotes at the end + } + + if (found_version < line.length()) { + version = line.substr(found_version+version_key.length()+1, + // remove key and quotes at the beginning + line.length()- + (found_version+version_key.length()+1)-1); + // remove quotes at the end + } + + if (name.length() && version.length()) { + return name + version; + } + } + + if (name.length()) + return name; + + throw std::string("Release file empty or incomplete."); + + } else if (open_file("/etc/novell-release", release_file)) { + getline(release_file, line); + + if (line.length()) + return line; + + throw std::string("Release file empty."); + + } else if (open_file("/etc/sles-release", release_file)) { + getline(release_file, line); + + if (line.length()) + return line; + + throw std::string("Release file empty."); + + // fedora + } else if (open_file("/etc/redhat-release", release_file)) { + getline(release_file, line); + + if (line.length()) + return line; + + throw std::string("Release file empty."); + + // debian -- leave this at the end, otherwise debian-based distros + // will find the debian_version file instead of the actual + // distro name + } else if (open_file("/etc/debian-release", release_file)) { + getline(release_file, line); + + if (line.length()) + return line; + + throw std::string("Release file empty."); + + } else if (open_file("/etc/debian-version", release_file)) { + getline(release_file, line); + + if (line.length()) + return line; + + throw std::string("Release file empty."); + } + + throw std::string("No release file found."); +} + +/** + * @file get_distro.cpp + * @brief Get distro info + */ diff --git a/src/agent/get_macaddr.cpp b/src/agent/get_macaddr.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0f6ce9b9ffa8b1162fec3c3ecd88d0586f56c067 --- /dev/null +++ b/src/agent/get_macaddr.cpp @@ -0,0 +1,115 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/get_macaddr.h> + +/** Case if linux os, get mac address info from /proc/net/route file */ +std::string get_macaddr() { + #ifdef WIN32 + PIP_ADAPTER_INFO AdapterInfo; + DWORD dwBufLen = sizeof(AdapterInfo); + char *mac_addr = reinterpret_cast<char*>malloc(17); + + AdapterInfo = (reinterpret_cast<char*>IP_ADAPTER_INFO *) + malloc(sizeof(IP_ADAPTER_INFO)); + if (AdapterInfo == NULL) { + throw std::string("Error allocating memory needed to call ") + + std::string("GetAdaptersinfo\n"); + } + + // Initial call to GetAdaptersInfo to get the necessary size into + // the dwBufLen variable + if (GetAdaptersInfo(AdapterInfo, &dwBufLen) == ERROR_BUFFER_OVERFLOW) { + + AdapterInfo = (reinterpret_cast<char*>IP_ADAPTER_INFO *) + malloc(dwBufLen); + if (AdapterInfo == NULL) { + throw std::string("Error allocating memory needed to call ") + + std::string(" GetAdaptersinfo\n"); + } + } + + if (GetAdaptersInfo(AdapterInfo, &dwBufLen) == NO_ERROR) { + + // Contains pointer to current adapter info + PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; + + snprintf(mac_addr, "%02X:%02X:%02X:%02X:%02X:%02X", + pAdapterInfo->Address[0], pAdapterInfo->Address[1], + pAdapterInfo->Address[2], pAdapterInfo->Address[3], + pAdapterInfo->Address[4], pAdapterInfo->Address[5]); + free(AdapterInfo); + return mac_addr; + } + free(AdapterInfo); + return ""; + + #else + std::fstream file; + std::string macaddr; + + /* #FIXME The way we are breaking the getline to get the network + * interface is not very efficient, because we create a char + * array and a string to the same thing. + */ + + char line[40]; + char iface[20]; + char dest[20]; + std::string Iface; + std::string Destination; + std::string file_path; + + FILE *fp = fopen("/proc/net/route", "r"); + + // Skip the first line (column headers). + fgets (line, sizeof(line), fp); + + /* Loop to found the default network interface*/ + while (fgets(line, sizeof(line), fp)) { + + /* Found the interface name and check that it is default*/ + sscanf(line, "%s %s\n", iface, dest); + + Iface = iface; + Destination = dest; + + // found default network interface + if (Destination == "00000000") { + /* found macaddr with the default network interface*/ + file_path = "/sys/class/net/"+Iface+"/address"; + file.open(file_path, std::ifstream::in); + if (!file.is_open()) { + throw std::string("No address file found."); + } + getline(file, macaddr); // get macaddr + file.close(); + } + } + fclose(fp); + + return macaddr; + #endif +} + +/** + * @file get_macaddr.cpp + * @brief Get mac address info; Case if linux OS, get info from /proc/net/rout file + */ diff --git a/src/agent/get_machine_type.cpp b/src/agent/get_machine_type.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc74e7de344bfbde2af273f05afde44722d2841f --- /dev/null +++ b/src/agent/get_machine_type.cpp @@ -0,0 +1,84 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/get_machine_type.h> + +/** Get machine type - return server or client */ +std::string get_machine_type() { + #ifdef WIN32 + TCHAR buffer[1024] = TEXT(""); + int cnf = 3; + DWORD dwSize = sizeof(buffer); + + if (!GetComputerNameEx((COMPUTER_NAME_FORMAT)cnf, buffer, &dwSize)) { + _tprintf(TEXT("GetComputerNameEx failed (%d)\n"), GetLastError()); + return "unknow"; + } + + if (!strcmp(buffer, "server.telecentro.net")) { + dwSize = _countof(buffer); + ZeroMemory(buffer, dwSize); + return "server"; + } + + dwSize = _countof(buffer); + ZeroMemory(buffer, dwSize); + return "client"; + #else + struct addrinfo hints, *info, *p; + int gai_result; + + char hostname[1024]; + hostname[1023] = '\0'; + gethostname(hostname, 1023); + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; /*either IPV4 or IPV6*/ + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_CANONNAME; + + gai_result = getaddrinfo(hostname, "http", &hints, &info); + + if (gai_result) { + std::string key("getaddrinfo: "); + std::string error(gai_strerror(gai_result)); + throw key + error; + } + + for (p = info; p; p = p->ai_next) { + if (!p->ai_canonname) { + continue; + } + if (!strcmp(p->ai_canonname, "server.telecentro.net")) {; + freeaddrinfo(info); + return "server"; + } + } + + freeaddrinfo(info); + + return "client"; + #endif +} + +/** + * @file get_machine_type.h + * @brief Get machine type - return Server or Client + */ diff --git a/src/agent/get_memory_size.cpp b/src/agent/get_memory_size.cpp new file mode 100644 index 0000000000000000000000000000000000000000..61fb2177ca2fabbfb8371b6af682fa4cd4683c90 --- /dev/null +++ b/src/agent/get_memory_size.cpp @@ -0,0 +1,68 @@ +/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/get_memory_size.h> + +/** Get memory size info from /proc/meminfo file + */ +int get_memory_size() { + + std::ifstream meminfo_file; + std::string line; + std::string memsize; + + if (open_file("/proc/meminfo", meminfo_file)) { + + const std::string key = "MemTotal:"; + std::size_t found; + + while (getline(meminfo_file, line)) { + + found = line.find(key); + + if (found != std::string::npos) { + // remove key and 'kB' at the end + std::string value = line.substr(found + key.length(), + line.length() - + (found+key.length()+3)); + // remove whitespaces + remove_copy(value.begin(), value.end(), + std::back_inserter(memsize), ' '); + // convert to integer before returning + return std::stoi(memsize); + } + } + // If EOF and no info returned + std::string err = "MemTotal not found in /proc/meminfo."; + throw err; + + } else { + + std::string err = "Failed to open /proc/meminfo."; + throw err; + + } + +} + +/** + * @file get_memory_size.cpp + * @brief Get memory size info from /proc/meminfo file + */ diff --git a/src/agent/get_processor_model.cpp b/src/agent/get_processor_model.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b61825bc9bc141e499b3943e3a6be450cdc6ef72 --- /dev/null +++ b/src/agent/get_processor_model.cpp @@ -0,0 +1,48 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/get_processor_model.h> + +/** Get processor model info from /proc/cpuinfo file */ +std::string get_processor_model() { + + std::ifstream cpuinfo_file; + std::string line; + if (open_file("/proc/cpuinfo", cpuinfo_file)) { + const std::string key = "model name"; + std::size_t found; + + while (getline(cpuinfo_file, line)) { + found = line.find(key); + if (found != std::string::npos) { + // remove ':' and space at the beginning + found = line.find(":"); + return (line.substr(found+2)); + } + } + throw std::string("Coudn't find model name in /proc/cpuinfo"); + } + + throw std::string("Coudn't open /proc/cpuinfo"); +} + +/** @file get_processor_model.cpp + * @brief Case if linux OS, get processor model info from /proc/cpuinfo file + */ diff --git a/src/agent/get_time.cpp b/src/agent/get_time.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9805dd84a7cbb786367f1fe0d1460cdedee27008 --- /dev/null +++ b/src/agent/get_time.cpp @@ -0,0 +1,45 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/get_time.h> + +/** Get current time from system (HH:MM:SS) */ +std::string get_time() { + std::string res = ""; + + time_t rawtime; + struct tm * timeinfo; + char buffer[20]; + + time(&rawtime); + localtime_r(&rawtime, timeinfo); + + // HH:MM:SS + strftime(buffer, 20, "%H:%M:%S", timeinfo); + + res = buffer; + return res; +} + +/** + * @file get_time.cpp + * @brief Get current time from system (HH:MM:SS) + * + */ diff --git a/src/linux/get_user_count.cpp b/src/agent/get_user_count.cpp similarity index 64% rename from src/linux/get_user_count.cpp rename to src/agent/get_user_count.cpp index daca143abe8bd8f17861f417751d30e53fca610d..93ac90a0998860af782821f44dc274bf8025ea3e 100644 --- a/src/linux/get_user_count.cpp +++ b/src/agent/get_user_count.cpp @@ -1,54 +1,73 @@ -/* - * last.c Re-implementation of the 'last' command, this time - * for Linux. Yes I know there is BSD last, but I - * just felt like writing this. No thanks :-). - * Also, this version gives lots more info (especially with -x) +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR * - * Author: Miquel van Smoorenburg, miquels@cistron.nl + * This file is part of simmc-agent * - * Version: @(#)last 2.85 30-Jul-2004 miquels@cistron.nl + * last.c Re-implementation of the 'last' command, this time + * for Linux. Yes I know there is BSD last, but I + * just felt like writing this. No thanks :-). + * Also, this version gives lots more info (especially with -x) * - * This file is part of the sysvinit suite, - * Copyright (C) 1991-2004 Miquel van Smoorenburg. + * Author: Miquel van Smoorenburg, miquels@cistron.nl * - * 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. + * Version: @(#)last 2.85 30-Jul-2004 miquels@cistron.nl * - * 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. + * This file is part of the sysvinit suite, + * Copyright (C) 1991-2004 Miquel van Smoorenburg. * - * 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 + * 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 + */ +#include <agent/get_user_count.h> +#include <string> +#include <set> + + /** + * @file get_user_count.cpp + * @brief Get info about who was using the system in the previous day. + * - Obs: + * - last.c: Re-implementation of the 'last' command. + * . + * Reading the utmp file (that's allows one to discover information about who is currently using the system) and check case if + * user was logged in, is still logged or also made logout in the previous day. + * <br><br> + * Example (Today is 06/07): + * - User logged in 06/05 and is still logged in; + * - User looged in 06/06; + * - User logout in 06/06; + * . + * All of above examples are valid and all of them will be set in the list. In the list has only the username and doesn't repeat. + * In the end, the get_user_count() function return the size of the list. */ - -#include "agent/linux/get_user_count.h" - -struct utmplist *utmplist = NULL; /* Global variables */ -int recsdone = 0; /* Number of records listed */ -int fulltime = 0; /* Print full dates and times */ -int name_len = 8; /* Default print 8 characters of name */ -int domain_len = 16; /* Default print 16 characters of domain */ +struct utmplist *utmplist = NULL; char *ufile; /* Filename of this file */ time_t lastdate; /* Last date we've seen */ +struct tm * timeinfo; +set<string> users; +char yesterday[7], today[7]; - -/* +/** * Read one utmp entry, return in new format. * Automatically reposition file pointer. */ -static int uread (FILE *fp, struct utmp *u, int *quit) { - static int utsize; +static int uread(FILE *fp, struct utmp *u, int *quit) { + static int utsize, bpos; static char buf[UCHUNKSIZE]; char tmp[1024]; static off_t fpos; - static int bpos; off_t o; if (quit == NULL && u != NULL) { @@ -72,7 +91,7 @@ static int uread (FILE *fp, struct utmp *u, int *quit) { fprintf(stderr, "ERROR: seek failed!\n"); return 0; } - bpos = (int)(fpos - o); + bpos = static_cast<int>(fpos - o); if (fread(buf, bpos, 1, fp) != 1) { fprintf(stderr, "ERROR: read failed!\n"); return 0; @@ -127,137 +146,73 @@ static int uread (FILE *fp, struct utmp *u, int *quit) { return 1; } -/* - * Get the basename of a filename +/** Check each user from utmp file: + * - User logged in the previous day. + * - User logout in the the previous day. + * - User is still logged. + * . + * Case one of above options, saved in a list */ -static char *mybasename (char *s) { - char *p; - - if ((p = strrchr(s, '/')) != NULL) - p++; - else - p = s; - return p; -} - - -static void month_number (char *orig,char*dest){ - char mon[] = {orig[4],orig[5],orig[6],'\0'}; - - if(!strcmp(mon,"Jan")){ - dest[2] = '0'; - dest[3] = '1'; - return; - } - if(!strcmp(mon,"Feb")){ - dest[2] = '0'; - dest[3] = '2'; - return; - } - if(!strcmp(mon,"Mar")){ - dest[2] = '0'; - dest[3] = '3'; - return; - } - if(!strcmp(mon,"Apr")){ - dest[2] = '0'; - dest[3] = '4'; - return; - } - if(!strcmp(mon,"May")){ - dest[2] = '0'; - dest[3] = '5'; - return; - } - if(!strcmp(mon,"Jun")){ - dest[2] = '0'; - dest[3] = '6'; - return; - } - if(!strcmp(mon,"Jul")){ - dest[2] = '0'; - dest[3] = '7'; - return; - } - if(!strcmp(mon,"Aug")){ - dest[2] = '0'; - dest[3] = '8'; - return; - } - if(!strcmp(mon,"Sep")){ - dest[2] = '0'; - dest[3] = '9'; - return; - } - if(!strcmp(mon,"Oct")){ - dest[2] = '1'; - dest[3] = '0'; - return; - } - if(!strcmp(mon,"Nov")){ - dest[2] = '1'; - dest[3] = '1'; - return; - } - if(!strcmp(mon,"Dec")){ - dest[2] = '1'; - dest[3] = '2'; - return; - } - -} -/* - * Show one line of information on screen - */ -static struct user_log *list (struct utmp *p, time_t t, int what) { +static void list(struct utmp *p, time_t t, int what) { time_t tmp; struct user_log * u = (struct user_log *)malloc(sizeof(struct user_log)); - char login[25],logout[25]; + char login[25], logout[25], month[3]; - /* - * Calculate times - */ tmp = (time_t)p->ut_time; + timeinfo = gmtime(&tmp); // NOLINT(runtime/threadsafe_fn) + strftime(month, 3, "%m", timeinfo); + month[3]='\0'; - strcpy(u->user,p->ut_name); - strcpy(login,ctime(&tmp)); - month_number(login,u->login); + snprintf(u->user, sizeof(u->user), p->ut_name, 0); + snprintf(login, sizeof(login), ctime(&tmp), 0); u->login[0] = login[22]; u->login[1] = login[23]; + u->login[2] = month[0]; + u->login[3] = month[1]; u->login[4] = login[8] == ' '?'0':login[8]; u->login[5] = login[9]; u->login[6] = '\0'; - switch(what) { + switch (what) { case R_NOW: - sprintf(u->logout, "999999"); + snprintf(u->logout, sizeof(u->logout), "999999"); break; case R_PHANTOM: - sprintf(u->logout, "000000"); + snprintf(u->logout, sizeof(u->logout), "000000"); break; case R_NORMAL: - strcpy(logout, ctime(&t)); - month_number(logout,u->logout); + timeinfo = gmtime(&t); // NOLINT(runtime/threadsafe_fn) + strftime(month, 3, "%m", timeinfo); + month[3]='\0'; + snprintf(logout, sizeof(logout), ctime(&t), 0); u->logout[0] = logout[22]; u->logout[1] = logout[23]; + u->logout[2] = month[0]; + u->logout[3] = month[1]; u->logout[4] = logout[8] == ' '?'0':logout[8]; u->logout[5] = logout[9]; u->logout[6] = '\0'; break; } - recsdone++; - - return u; + if (!strcmp(u->logout, yesterday)) { + users.insert(u->user); + } else if (!strcmp(u->login, yesterday)) { + users.insert(u->user); + } else if (( strcmp(u->login, yesterday) && + strcmp(u->login, today)) && (!strcmp(u->logout, today) || + !strcmp(u->logout, "999999"))) { + users.insert(u->user); + } } -static struct user_log * last_modified () { +/** Check each line from utmp file that is opened by uread function */ +static struct user_log * last_modified() { FILE *fp; /* Filepointer of wtmp file */ struct utmp ut; /* Current utmp entry */ struct utmp oldut; /* Old utmp entry to check for duplicates */ - struct utmplist *p; /* Pointer into utmplist */ - struct utmplist *next;/* Pointer into utmplist */ + struct utmplist *p, *next; /* Pointer into utmplist */ time_t lastboot = 0; /* Last boottime */ time_t lastdown; /* Last downtime */ @@ -272,12 +227,11 @@ static struct user_log * last_modified () { struct user_log * v = NULL; struct user_log * w = NULL; - fulltime++; - /* * Which file do we want to read? */ - ufile = (char *)WTMP_FILE; + char *auxar = WTMP_FILE; + ufile = auxar; time(&lastdown); /* @@ -290,11 +244,11 @@ static struct user_log * last_modified () { */ if ((fp = fopen(ufile, "r")) == NULL) { x = errno; - fprintf(stderr, "ERROR: %s: %s\n", ufile, strerror(errno)); if (x == ENOENT) - fprintf(stderr, "Perhaps this file was removed by the " - "operator to prevent logging info.\n"); - exit(1); + // file not found + throw std::string(ufile) + std::string(": ") + + std::string(strerror(errno)); + throw strerror(errno); } /* @@ -305,9 +259,9 @@ static struct user_log * last_modified () { /* * Read first structure to capture the time field */ - if (uread(fp, &ut, NULL) == 1) + if (uread(fp, &ut, NULL) == 1) { begintime = ut.ut_time; - else { + } else { fstat(fileno(fp), &st); begintime = st.st_ctime; quit = 1; @@ -324,7 +278,6 @@ static struct user_log * last_modified () { */ while (!quit && skip) { - if (uread(fp, &ut, &quit) != 1) break; @@ -342,13 +295,12 @@ static struct user_log * last_modified () { ut.ut_type = BOOT_TIME; else if (strncmp(ut.ut_user, "runlevel", 8) == 0) ut.ut_type = RUN_LVL; - } /*def COMPAT*/ /* * For stupid old applications that don't fill in * ut_type correctly. */ - else { + } else { if (ut.ut_type != DEAD_PROCESS && ut.ut_name[0] && ut.ut_line[0] && strcmp(ut.ut_name, "LOGIN") != 0) @@ -385,9 +337,7 @@ static struct user_log * last_modified () { /* Show it */ if (c == 0) { quit = 0; - u = list(&ut, p->ut.ut_time, R_NORMAL); - v = u; - v->next = NULL; + list(&ut, p->ut.ut_time, R_NORMAL); c = 1; } if (p->next) p->next->prev = p->prev; @@ -404,17 +354,17 @@ static struct user_log * last_modified () { */ if (c == 0) { c = R_NOW; + /* Is process still alive? */ if (ut.ut_pid > 0 && kill(ut.ut_pid, 0) != 0 && errno == ESRCH) c = R_PHANTOM; - quit = 0; - u = list(&ut, lastboot, c); - v = u; - v->next = NULL; - } - /* FALLTHRU */ + + quit = 0; + list(&ut, lastboot, c); + } + /* FALLTHRU */ case DEAD_PROCESS: /* @@ -423,22 +373,22 @@ static struct user_log * last_modified () { */ if (ut.ut_line[0] == 0) break; - if ((p = (struct utmplist *)malloc(sizeof(struct utmplist))) == NULL) { - fprintf(stderr, "ERROR: out of memory\n"); - exit(1); + + p = (struct utmplist *)malloc(sizeof(struct utmplist)); + if (p == NULL) { + throw std::string("ERROR: out of memory"); } + memcpy(&p->ut, &ut, sizeof(struct utmp)); p->next = utmplist; p->prev = NULL; if (utmplist) utmplist->prev = p; utmplist = p; break; - } } - while(!quit) { - + while (!quit) { if (uread(fp, &ut, &quit) != 1) break; @@ -456,13 +406,12 @@ static struct user_log * last_modified () { ut.ut_type = BOOT_TIME; else if (strncmp(ut.ut_user, "runlevel", 8) == 0) ut.ut_type = RUN_LVL; - } /*def COMPAT*/ /* * For stupid old applications that don't fill in * ut_type correctly. */ - else { + } else { if (ut.ut_type != DEAD_PROCESS && ut.ut_name[0] && ut.ut_line[0] && strcmp(ut.ut_name, "LOGIN") != 0) @@ -499,11 +448,7 @@ static struct user_log * last_modified () { /* Show it */ if (c == 0) { quit = 0; - w = list(&ut, p->ut.ut_time, R_NORMAL); - c = 1; - v->next = w; - w->next = NULL; - v = w; + list(&ut, p->ut.ut_time, R_NORMAL); } if (p->next) p->next->prev = p->prev; if (p->prev) @@ -519,6 +464,7 @@ static struct user_log * last_modified () { */ if (c == 0) { c = R_NOW; + /* Is process still alive? */ if (ut.ut_pid > 0 && kill(ut.ut_pid, 0) != 0 && @@ -526,10 +472,7 @@ static struct user_log * last_modified () { c = R_PHANTOM; quit = 0; - w = list(&ut, lastboot, c); - v->next = w; - w->next = NULL; - v = w; + list(&ut, lastboot, c); } /* FALLTHRU */ @@ -540,9 +483,9 @@ static struct user_log * last_modified () { */ if (ut.ut_line[0] == 0) break; - if ((p = (struct utmplist *)malloc(sizeof(struct utmplist))) == NULL) { - fprintf(stderr, "ERROR: out of memory\n"); - exit(1); + p = (struct utmplist *)malloc(sizeof(struct utmplist)); + if (p == NULL) { + throw std::string("ERROR: out of memory"); } memcpy(&p->ut, &ut, sizeof(struct utmp)); p->next = utmplist; @@ -550,50 +493,44 @@ static struct user_log * last_modified () { if (utmplist) utmplist->prev = p; utmplist = p; break; - } } fclose(fp); - return u; } -int get_user_count () { - struct user_log * u = last_modified(); - struct user_log * i; - int count; +/** Get number of users that logged/used the current computer in previous day */ +int get_user_count() { + + /* The agent execution depends on the file '/var/log/wtmp', which is not + * present on some distros, such as OpenSUSE docker image. When this happens, + * this file is created and it's permissions setted. + */ + + std::string wtmp_path = "/var/log/wtmp"; + struct stat buffer; + if (stat(wtmp_path.c_str(), &buffer) != 0) { // file not exists + ofstream wtmp_file; + wtmp_file.open(wtmp_path.c_str()); + wtmp_file.close(); + chown(wtmp_path.c_str(), getpwnam("root")->pw_uid, + getgrnam("tty")->gr_gid); + chmod(wtmp_path.c_str(), 664); + } time_t rawtime; - struct tm * timeinfo; - char yesterday[7]; - set<string> users; - time (&rawtime); - timeinfo = localtime (&rawtime); + time(&rawtime); + timeinfo = localtime(&rawtime); // NOLINT(runtime/threadsafe_fn) + strftime(today, 7, "%y%m%d", timeinfo); + today[6]='\0'; timeinfo->tm_mday--; mktime(timeinfo); - strftime (yesterday,7,"%y%m%d",timeinfo); + strftime(yesterday, 7, "%y%m%d", timeinfo); yesterday[6] = '\0'; - for(i = u; i; i = u){ - if(!strcmp(i->logout,"999999")){ - if(strcmp(i->login,yesterday) <= 0){ - users.insert(i->user); - } - }else{ - if(!strcmp(i->login,yesterday)){ - users.insert(i->user); - }else - if(strcmp(i->login,yesterday) < 0 && strcmp(i->logout,yesterday) >= 0){ - users.insert(i->user); - } - } - u = i->next; - free(i); - } - - count = users.size(); + last_modified(); - return count; + return users.size(); } diff --git a/src/agent/inventory.cpp b/src/agent/inventory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f37d4ede134ddd9df1e95edd0c2f98638ab83bc3 --- /dev/null +++ b/src/agent/inventory.cpp @@ -0,0 +1,240 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/inventory.h> +#include <list> + +/** Collect all info about hardware and set it in a json object to send to c3sl web service + * - Data collected: + * - OS Type + * - OS Distro + * - OS Kernel + * - Processor + * - Memory + * - Disk (Get 2 disk info): + * - Model + * - Size + * - Extra hds (more than 2 disks) + * - Machine type (if not Linux Comunicações) + * - Amount users (Get number of users that logged/used the current computer in previous day) + * - Mac address + */ + +Json::Value get_inventory() { + Json::Value inv; + + // os info + + #ifdef __linux__ + struct utsname sysinfo; + uname(&sysinfo); + #endif + + // OS type + #ifdef WIN32 + inv["data_inventory"]["os_type"] = "Windows"; + #else + inv["data_inventory"]["os_type"] = "Linux"; + #endif + + + // OS distro + try { + #ifdef WIN32 + // use dtwinver + inv["data_inventory"]["os_distro"] = "unknown"; + #else + inv["data_inventory"]["os_distro"] = get_distro(); + #endif + } + catch ( std::string err ) { + inv["data_inventory"]["os_distro"] = Json::nullValue; + inv["error_inventory"]["os_distro"] = err; + } + + // OS kernel + #ifdef WIN32 + inv["data_inventory"]["os_kernel"] = "Windows"; + #else + inv["data_inventory"]["os_kernel"] = sysinfo.release; + #endif + + + // mirror timestamp + #ifdef WIN32 + inv["data_inventory"]["mirror_timestamp"] = "Windows"; + #else + inv["data_inventory"]["mirror_timestamp"] = sysinfo.version; + #endif + + + // processor model + try { + #ifdef WIN32 + inv["data_inventory"]["processor"] = "unknown"; + #else + inv["data_inventory"]["processor"] = get_processor_model(); + #endif + } + catch ( std::string err ) { + inv["data_inventory"]["processor"] = Json::nullValue; + inv["error_inventory"]["processor"] = err; + } + + // memory + try { + #ifdef WIN32 + inv["data_inventory"]["memory"] = "unknown"; + #else + inv["data_inventory"]["memory"] = get_memory_size(); + #endif + } + catch ( std::string err ) { + inv["data_inventory"]["memory"] = Json::nullValue; + inv["error_inventory"]["memory"] = err; + } + + // disk + try { + #ifdef WIN32 + inv["data_inventory"]["disk1_model"] = "unknown"; + inv["data_inventory"]["disk1_size"] = "unknown"; + inv["data_inventory"]["disk2_model"] = "unknown"; + inv["data_inventory"]["disk2_size"] = "unknown"; + inv["data_inventory"]["extra_hds"] = "unknown"; + #else + std::list<disk_t> disks; + get_disks_info(disks); + disk_t curr = disks.front(); + inv["data_inventory"]["disk1_model"] = curr.model; + inv["data_inventory"]["disk1_size"] = curr.size; + disks.pop_front(); + + if (disks.empty()) { + inv["data_inventory"]["disk2_model"] = Json::nullValue; + inv["data_inventory"]["disk2_size"] = Json::nullValue; + } else { + curr = disks.front(); + inv["data_inventory"]["disk2_model"] = curr.model; + inv["data_inventory"]["disk2_size"] = curr.size; + disks.pop_front(); + } + + Json::UInt64 disks_size = disks.size(); + inv["data_inventory"]["extra_hds"] = disks_size; + #endif + } + catch ( std::string err ) { + inv["data_inventory"]["disk1_model"] = Json::nullValue; + inv["data_inventory"]["disk1_size"] = Json::nullValue; + inv["data_inventory"]["disk2_model"] = Json::nullValue; + inv["data_inventory"]["disk2_size"] = Json::nullValue; + inv["data_inventory"]["extra_hds"] = Json::nullValue; + + inv["error_inventory"]["disk1_model"] = err; + inv["error_inventory"]["disk1_size"] = err; + inv["error_inventory"]["disk2_model"] = err; + inv["error_inventory"]["disk2_size"] = err; + inv["error_inventory"]["extra_hds"] = err; + } + + // hw info + /* + inv["disk1_used"] = + inv["disk2_used"] = + */ + + // other + /* + inv["agent_version"] = + inv["contact_date"] = + */ + + + // machine type + #ifdef WIN32 + try { + inv["data_inventory"]["machine_type"] = "unknown"; + } + catch ( std::string err ) { + inv["data_inventory"]["machine_type"] = Json::nullValue; + inv["error_inventory"]["machine_type"] = err; + } + #else + if (inv["data_inventory"]["os_distro"].asString().find("Linux Comunicações") // NOLINT [whitespace/line_length] + != std::string::npos) { + try { + inv["data_inventory"]["machine_type"] = get_machine_type(); + } + catch ( std::string err ) { + inv["data_inventory"]["machine_type"] = Json::nullValue; + inv["error_inventory"]["machine_type"] = err; + } + } else { + inv["data_inventory"]["machine_type"] = Json::nullValue; + } + #endif + + // amount users + try { + #ifdef WIN32 + inv["data_inventory"]["amount_users"] = "unknown"; + #else + inv["data_inventory"]["amount_users"] = get_user_count(); + #endif + } + catch ( std::string err ) { + inv["data_inventory"]["amount_users"] = Json::nullValue; + inv["error_inventory"]["amount_users"] = err; + } + + // mac address + try { + #ifdef WIN32 + inv["data_inventory"]["mac_address"] = "unknown"; + #else + inv["data_inventory"]["mac_address"] = get_macaddr(); + #endif + } + catch ( std::string err ) { + inv["data_inventory"]["mac_address"] = Json::nullValue; + inv["error_inventory"]["mac_address"] = err; + } + + return inv; +} + +/** + * @file inventory.cpp + * @brief This file has a purpose to collect all info from hardware, like processor, memory, mac adress, disks, machine type, os distro and so on. + * - The data collected are saved in a json object: + * - OS Type + * - OS Distro + * - OS Kernel + * - Processor + * - Memory + * - Disk (Get 2 disk info): + * - Model + * - Size + * - Extra hds (more than 2 disks) + * - Machine type (if not Linux Comunicações) + * - Amount users (Get number of users that logged/used the current computer in previous day) + * - Mac address + */ diff --git a/src/jsoncpp.cpp b/src/agent/jsoncpp.cpp similarity index 100% rename from src/jsoncpp.cpp rename to src/agent/jsoncpp.cpp diff --git a/src/agent/main.cpp b/src/agent/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5f6b2f58df7b647294fbd63ab500c786b038c086 --- /dev/null +++ b/src/agent/main.cpp @@ -0,0 +1,147 @@ +/* Copyright (C) 2016-2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/main.h> +#include <agent/get.h> +#include <agent/post.h> +#include <string> + +/** Run agent */ +int run_agent(const sys::error_code& /*e*/, pt::ptime begin, bool print ) { + pt::ptime now; + now = pt::second_clock::local_time(); + pt::time_duration t3 = now - begin; + if ((t3.minutes() % 5 == 0 )) { + send_net_bandwidth(print); + } + if ((t3.hours() % 24 == 0) && (t3.minutes() %60 == 0 )) { + check_update(); + send_inventory(print); + send_user_history(print); + } + return(0); +} + +/** Set the first date and time when agent was run */ +int set_begin(pt::ptime& begin, bool print) { // NOLINT (runtime/reference) + std::string t; + std::stringstream t2; + std::fstream myfile("../build/time.txt", + std::fstream::app | std::fstream::in | std::fstream::out); + getline(myfile, t); + if (t.size() == 0) { + begin = pt::second_clock::local_time(); + myfile << begin; + myfile << "\n"; + + check_update(); + send_inventory(print); + send_net_bandwidth(print); + send_user_history(print); + + myfile.close(); + return(0); + } else { + t2 << t; + t2 >> begin; + + myfile.close(); + return(1); + } +} + +/** Parse command line + * - Options: + * - Help - help message + * - once - run agent only once + * - print - set print JSON to true - show inventory + * - uninstall - uninstall agent and all associated files + */ +int parse_command_line(int ac, char* av[], int *increment, int *lim, + bool *print) { + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "produce help message") + ("once", "run agent only once") + ("print", "set print JSON to true"); + ("uninstall", "uninstall agent and all associated files"); + + po::variables_map vm; + po::store(po::parse_command_line(ac, av, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return(1); + } + if (vm.count("once")) { + *lim = 0; + } + if (vm.count("print")) { + *print = true; + } else { + *print = false; + } + return (0); + + if (vm.count("uninstall")) { + fs::remove_all("../../agent"); + return (1); + } + return(0); +} + +/** Run agent only one time per day. + * - Check case if needed to update agent + * - Send inventory to web service + * - Send network bandwidth to web service + */ +int main(int argc, char* argv[]) { + int increment = 0; + int lim = 1; + bool print; + if (parse_command_line(argc, argv, &increment, &lim, &print)) { + return (1); + } + pt::ptime begin; + + if (set_begin(begin, print) && lim == 0) { + check_update(); + send_inventory(print); + send_net_bandwidth(print); + send_user_history(print); + return (0); + } + int i = 0; + while (i < lim) { + asio::io_service io; + asio::deadline_timer t(io, pt::seconds(60)); + t.async_wait(boost::bind(run_agent, pholders::error, begin, print)); + io.run(); + i += increment; + } + + return(0); +} + +/** + * @file main.cpp + * @brief Run agent to collect inventory, network bandwidth and user history to send c3sl web service; Also check case if has a new agent version available + */ diff --git a/src/agent/network_bandwidth.cpp b/src/agent/network_bandwidth.cpp new file mode 100644 index 0000000000000000000000000000000000000000..917833622391f7977a91d416599972d33a9cda05 --- /dev/null +++ b/src/agent/network_bandwidth.cpp @@ -0,0 +1,227 @@ +/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include "agent/network_bandwidth.h" +#include <string> + +/** + * @file network_bandwidth.cpp + * @brief Collect data from networkork bandwidth. + * - Data collected: + * - Bytes recived + * - Packets recived + * - Bytes transmited + * - Packets transmited + * . + * Linux has a file (/proc/net/dev) that contain info about network bandwidth + * <br> + * The data is collected and set in a json object and net_band.json file. + * When this file (net_band.json) exists, before set in json object, the data from file + * is got and is calculated the difference between the current data and the last data saved in the file + */ + +namespace pt = boost::posix_time; + +/** Get network bandwidth */ +Json::Value get_net_bandwidth() { + Json::Value net_band; + Json::Value net_band_all_time; + Json::Reader reader; + std::ofstream ofs; + std::ifstream net_band_file("net_band.json", std::ifstream::binary); + pt::ptime time; + std::string str; + std::fstream time_file("time_now.txt", std::ios::out|std::ios::trunc); + + #ifdef __linux__ + // net_band_file >> net_band_all_time; + reader.parse(net_band_file, net_band_all_time , false); + net_band_file.close(); + unsigned long long b_rec, pack_rec, b_tr, pack_tr; // NOLINT (runtime/int) + unsigned long long b_rec_allt, pack_rec_allt, b_tr_allt, pack_tr_allt; // NOLINT (runtime/int) + + if (net_band_all_time.isNull()) { + b_rec_allt = 0; + pack_rec_allt = 0; + b_tr_allt = 0; + pack_tr_allt = 0; + } else { + b_rec_allt = + net_band_all_time["data_net"]["bytes_received"].asLargestUInt(); + pack_rec_allt = + net_band_all_time["data_net"]["packets_received"].asLargestUInt(); // NOLINT [whitespace/line_length] + b_tr_allt = + net_band_all_time["data_net"]["bytes_transmitted"].asLargestUInt(); // NOLINT [whitespace/line_length] + pack_tr_allt = + net_band_all_time["data_net"]["packets_tranmitted"].asLargestUInt(); // NOLINT [whitespace/line_length] + } + + + std::string t; + std::ifstream myfile("/proc/net/dev"); + getline(myfile, t); + getline(myfile, t); + getline(myfile, t); + + getline(myfile, t); + int i = 0; + int j = 0; + int len = 0; + char tmp[20]; + std::string stmp; + + while (t[i] == ' ') { + ++i; + } + while (t[i] != ' ') { + tmp[j] = t[i]; + tmp[j+1] = '\0'; + stmp = tmp; + ++i; + ++j; + } // skips " eth0:" + + if (stmp != "eth0:") { + i = 0; + getline(myfile, t); + while (t[i] == ' ') { + ++i; + } + while (t[i] != ' ') { + ++i; + } + } + + while (t[i] == ' ') { + ++i; + } + + + j = i; + + while (t[i] != ' ') { + ++i; + ++len; + } + + b_rec = atoll(t.substr(j, len).c_str()); + while (t[i] == ' ')++i; + + j = i; + len = 0; + while (t[i] != ' ') { + ++i; + ++len; + } + + pack_rec = atoll(t.substr(j, len).c_str()); + + + while (t[i] == ' ') { + ++i; + } + while (t[i] != ' ') { + ++i; + } // skips "errs" + + while (t[i] == ' ') { + ++i; + } + while (t[i] != ' ') { + ++i; + } // skips drop + + while (t[i] == ' ') { + ++i; + } + while (t[i] != ' ') { + ++i; + } // skips fifo + + while (t[i] == ' ') { + ++i; + } + while (t[i] != ' ') { + ++i; + } // skips frame + + while (t[i] == ' ') { + ++i; + } + while (t[i] != ' ') { + ++i; + } // skips compresed + + while (t[i] == ' ') { + ++i; + } + while (t[i] != ' ') { + ++i; + } // skips multicast + + + + while (t[i] == ' ')++i; + + j = i; + len = 0; + + while (t[i] != ' ') { + ++i; + ++len; + } + b_tr = atoll(t.substr(j, len).c_str()); + + + while (t[i] == ' ')++i; + j = i; + len = 0; + + while (t[i] != ' ') { + ++i; + ++len; + } + + pack_tr = atoll(t.substr(j, len).c_str()); + + ofs.open("net_band.json", std::ios::trunc); + net_band_all_time["data_net"]["bytes_received"] = b_rec; + net_band_all_time["data_net"]["packets_received"] = pack_rec; + net_band_all_time["data_net"]["bytes_transmitted"] = b_tr; + net_band_all_time["data_net"]["packets_tranmitted"] = pack_tr; + ofs << net_band_all_time; + ofs.close(); + //////////////////////////////////////////////////// + time = pt::second_clock::local_time(); + time_file << time; + time_file.close(); + time_file.open("time_now.txt", std::ios::in); + getline(time_file, str); + time_file.close(); + ////////////////////////////////////////////////////////////// + net_band["data_net"]["bytes_received"] = b_rec - b_rec_allt; + net_band["data_net"]["packets_received"] = pack_rec - pack_rec_allt; + net_band["data_net"]["bytes_transmitted"] = b_tr - b_tr_allt; + net_band["data_net"]["packets_tranmitted"] = pack_tr - pack_tr_allt; + net_band["data_net"]["collect_time"] = str; + myfile.close(); + return (net_band); + #endif +} diff --git a/src/agent/open_file.cpp b/src/agent/open_file.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4840f1e421f52b87d45f1ce9325a18f99ba7d3a --- /dev/null +++ b/src/agent/open_file.cpp @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ + +#include <agent/open_file.h> + +/** + * @file open_file.cpp + * @brief Open a file and return 1 case if file was opened - Otherwise, return 0 + */ + +/** Open a file. Case file opened, return 1. Otherwise, return 0 */ +int open_file(std::string name, std::ifstream& fstream) { + fstream.open(name); + if (fstream.is_open()) + return 1; + return 0; +} diff --git a/src/agent/parse.cpp b/src/agent/parse.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fa884387138604c04abdad66cc4a0e04fcc8b6fb --- /dev/null +++ b/src/agent/parse.cpp @@ -0,0 +1,186 @@ +/* Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/parse.h> +#include <map> +#include <string> + +/** Erases leading tabs, leading spaces; trailing tabs, trailing spaces */ +void trim(std::string* str) { + int i = 0; + + while (i < static_cast<int>(str->length()) && ((*str)[i] == ' ' + || (*str)[i] == '\t')) + ++i; + + if (i > 0) + str->erase(0, i); + + int j = i = str->length(); + + while (i > 0 && ((*str)[i - 1] == ' ' || (*str)[i - 1] == '\t')) + --i; + + if (i < j) + str->erase(i, j); +} + +/** Erases tabs and spaces between the variable's name and its value */ +void normalize(std::string* str) { + size_t i, j; + i = j = 0; + + trim(str); + + while (i < str->length()) { + if ((*str)[i] == ' ' || (*str)[i] == '\t') { + j = i + 1; + + while (j < str->length() && ((*str)[j] == ' ' || (*str)[j] == '\t')) + ++j; + + if (j == i) + str->erase(i, 1); + else + str->erase(i, j - i); + } else { + ++i; + } + } +} + +/** Check if a line consists only of spaces and tabs*/ +bool space_only(const std::string* line) { + for (int i = 0, j = line->length(); i < j; ++i) + if ((*line)[i] != ' ' && (*line)[i] != '\t') + return false; + return true; +} + +/** Check if a line is valid - the line is valid when has "key":"value"; */ +bool is_valid(std::string* line) { + std::string s = *line; + int i = 0; + + normalize(line); + + /* if the line is a comment */ + + boost::regex expr{"((\\/\\/)|(\\/\\*)|(\\#))(.*)"}; + + if (boost::regex_match(s, expr)) + return false; + + expr ="(\")(.*)"; + + /* if the line start with a different character than quote */ + + if (!boost::regex_match(s, expr)) + return false; + /* + * if the line start with quote, + * but is not a pattern : "key":"value" + */ + + + if ((*line)[i] = '"') { + int n = std::count((*line).begin(), (*line).end(), '"'); + + /* if the line doesn't has four quotes */ + if (n < 4) + return false; + + /* if the second character is quote. */ + + if ((*line)[i+1] == '"') + return false; + + n = line->find_last_of('"'); + + /* if the second to last character is quote. */ + + if ((*line)[n-1] == '"') + return false; + + n = line->find_last_of(':'); + + /* if the line doesn't has the colon character. */ + + if (n == -1) + return false; + + /* if the position of the colon character is string ends. */ + + if (n == (line->length())-1) + return false; + } + + return true; +} + +/** After check if the line is valid, than parse the "key":"value" to a map.*/ +void parse(std::string* line, std::map<std::string, std::string>* content) { + std::locale loc; + + /* if the line is a "key":"value" */ + + if ((*line)[0] == '"') { + std::string name = line->substr(1, line->find(':')-2); + + for (int i = 0; i < name.length(); i++) + name[i] = toupper(name[i], loc); + + std::string value = line->substr(line->find(':')+2); + value = value.substr(0, value.find('"')); + + (*content)[name] = value; + } +} + +/** + * - Read a file (config or proxy file), then check if the line is valid; + * - Case is valid, parse the "key":"value" to a map; + * - After all, get de value by key and "initialize" a conf or proxy object. + */ +bool read_file(const std::string file, std::map<std::string, + std::string>* content) { + + content->clear(); + + std::ifstream config(file.c_str(), std::ifstream::in); + + if (!config.is_open()) + return false; + + std::string buffer; + + while (getline(config, buffer, '\n')) { + if (!space_only(&buffer)) + if (is_valid(&buffer)) + parse(&buffer, content); + } + + return true; +} + +/** + * @file parse.cpp + * @brief Get proxy or config file, read it and parse into a map varaible + */ diff --git a/src/agent/parse_config_file.cpp b/src/agent/parse_config_file.cpp new file mode 100644 index 0000000000000000000000000000000000000000..56651a998bb7e8ddc4336b6f8ec962aa09acae33 --- /dev/null +++ b/src/agent/parse_config_file.cpp @@ -0,0 +1,106 @@ +/* Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/parse_config_file.h> +#include <cstdlib> +#include <cstring> +#include <iostream> +#include <locale> +#include <map> +#include <sstream> +#include <string> + + +/** Set id Point */ +void Conf::setIdPoint(int i) { + this->idPoint = i; +} + +/** Set absolute path from proxyfile */ +void Conf::setProxyConf(std::string p) { + this->proxyConf = p; +} + +/** Set web service url */ +void Conf::setWebService(std::string web) { + this->webService = web; +} + +/** Return id Point */ +int Conf::getIdPoint() const { + return this->idPoint; +} + +/** Return absolute path from proxyfile */ +std::string Conf::getProxyConf() const { + return this->proxyConf; +} + +/** Return url from web service */ +std::string Conf::getWebService() const { + return this->webService; +} + + +/** + * After parse the config file, get the values from map variable and set at conf object + */ +bool set_conf_object(Conf* conf, Agent* agent, std::map<std::string, + std::string>* content) { + if (content->count("PROXYCONF") == 0 || + content->count("WEBSERVICE") == 0|| + content->count("IDPOINT") == 0 ) + return false; + + /* + * agent.getPrefix() contains the absolute path from agent + */ + std::string proxyConf = agent->getPrefix() + (*content)["PROXYCONF"]; + std::string webService = (*content)["WEBSERVICE"]; + int idPoint = atoi((*content)["IDPOINT"].c_str()); + + conf->setProxyConf(proxyConf); + conf->setWebService(webService); + conf->setIdPoint(idPoint); + + return true; +} + +/** Read config file and make the parse to conf object */ +bool parse_config_file(Agent* agent, Conf* conf, std::fstream* logFile) { + std::map<std::string, std::string> content; + + if (read_file(agent->getConfigFile(), &content)) { + if (!set_conf_object(conf, agent, &content)) { + agent->setMessage(__DATE__ + + std::string(" - ERROR: to parse variables from config file.")); + *logFile << agent->getMessage() << std::endl; + return false; + } + } + + return true; +} + +/** + * @file parse_config_file.cpp + * @brief This file contain the implementation from Conf's method - The main purpose is get config file content and + * make parse to set in a conf object + */ diff --git a/src/agent/parse_proxy_file.cpp b/src/agent/parse_proxy_file.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fb0f3d9ff1f33ffa33111f748e93255416b91803 --- /dev/null +++ b/src/agent/parse_proxy_file.cpp @@ -0,0 +1,117 @@ +/* Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/parse_proxy_file.h> +#include <iostream> +#include <map> +#include <string> + +/** Set host */ +void Proxy::setHost(std::string h) { + this->host = h; +} + +/** Set port */ +void Proxy::setPort(std::string p) { + this->port = p; +} + +/** Set user name */ +void Proxy::setUser(std::string u) { + this->user = u; +} + +/** Set user password */ +void Proxy::setPassword(std::string p) { + this->password = p; +} + +/** Set true case if proxy file exist */ +void Proxy::setProxyFile(bool opt) { + this->proxyFile = opt; +} + +/** Return host */ +std::string Proxy::getHost() const { + return this->host; +} + +/** Return port */ +std::string Proxy::getPort() const { + return this->port; +} + +/** Return user name */ +std::string Proxy::getUser() const { + return this->user; +} + +/** Return password user */ +std::string Proxy::getPassword() const { + return this->password; +} + +/** Return true case if proxy file exist. Otherwise, return false */ +bool Proxy::proxyFileIsSet() const { + return this->proxyFile; +} + +/** Get map variable and set the values at proxy object + * After parse the proxy file, get the values from map variable and set at proxy object + */ +bool set_proxy_object(Proxy* proxy, std::map<std::string, + std::string>* content) { + if (content->count("PROXYHOST") == 0 || + content->count("PROXYPORT") == 0 || + content->count("PROXYUSER") == 0 || + content->count("PROXYPASSWORD") == 0) + return false; + + proxy->setHost((*content)["PROXYHOST"]); + proxy->setPort((*content)["PROXYPORT"]); + proxy->setUser((*content)["PROXYUSER"]); + proxy->setPassword((*content)["PROXYPASSWORD"]); + + return true; +} + +/** Read proxy file and make the parse to proxy object */ +bool parse_proxy_file(Conf* conf, Proxy* proxy, std::fstream* logFile, + Agent* agent) { + std::map<std::string, std::string> content; + + if (read_file(conf->getProxyConf(), &content)) { + if (!set_proxy_object(proxy, &content)) { + agent->setMessage(__DATE__ + + std::string(" - ERROR: to parse variables from proxy file.")); + *logFile << agent->getMessage() << std::endl; + return false; + } + } + + proxy->setProxyFile(true); + return true; +} + +/** + * @file parse_proxy_file.cpp + * @brief This file contain the implementation from Proxy's method - The main purpose is get proxy file content and + * make parse to set in a proxy object + */ diff --git a/src/agent/post.cpp b/src/agent/post.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ed5ad9e886c137abb9aa52ef9257c6e8b1879b96 --- /dev/null +++ b/src/agent/post.cpp @@ -0,0 +1,123 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ + +#include <agent/post.h> + +/******************************* + * INVENTORY * + *******************************/ + +/** Send inventory to simmc agent webService + * - Send inventory json object; + * - Cpr wrapper library - to make request to webService; + */ +int send_inventory(bool print) { + Json::Value inventory = get_inventory(); + Json::FastWriter fastWriter; + + if (print == true) { + Json::StyledWriter styledWriter; + if (!inventory.isNull()) + std::cout << styledWriter.write(inventory); + else + std::cout << "Empty inventory object" << std::endl; + } + + auto p = cpr::Post(cpr::Url{base_url + "/api/v1/collect"}, + cpr::Parameters{{"type", "inventory"}}, + cpr::Body{fastWriter.write(inventory)}, + cpr::Header{{"content-type", "application/json"}}); + + if (p.status_code == 200) { + return 1; + } + + return 0; +} + +/*************************************** + * NETWORK BANDWIDTH * + ***************************************/ + +/** Send network bandwidth to simmc agent webService + * - Send net json object; + * - Cpr wrapper library - to make request to webService; + */ +int send_net_bandwidth(bool print) { + Json::Value net = get_net_bandwidth(); + Json::FastWriter fastWriter; + + if (print == true) { + Json::StyledWriter styledWriter; + if (!net.isNull()) + std::cout << styledWriter.write(net); + else + std::cout << "Empty network_bandwidth object" << std::endl; + } + + auto p = cpr::Post(cpr::Url{base_url + "/api/v1/collect"}, + cpr::Parameters{{"type", "network_bandwidth"}}, + cpr::Body{fastWriter.write(net)}, + cpr::Header{{"content-type", "application/json"}}); + + if (p.status_code == 200) { + return 1; + } + + return 0; +} + +/********************************** + * USER HISTORY * + **********************************/ + +/** Send user history to simmc webService + * - Send u_h json object; + * - Cpr wrapper library - to make request to webService; + */ +int send_user_history(bool print) { + Json::Value u_h; + Json::FastWriter fastWriter; + + if (print == true) { + Json::StyledWriter styledWriter; + if (!u_h.isNull()) + std::cout << styledWriter.write(u_h); + else + std::cout << "Empty user_history object" << std::endl; + } + + auto p = cpr::Post(cpr::Url{base_url + "/api/v1/collect"}, + cpr::Parameters{{"type", "user_history"}}, + cpr::Body{fastWriter.write(u_h)}, + cpr::Header{{"content-type", "application/json"}}); + + if (p.status_code == 200) { + return 1; + } + + return 0; +} + +/** + * @file post.cpp + * @brief Collect data from hardware and send to c3sl web service + */ diff --git a/src/agent/rotate_log_file.cpp b/src/agent/rotate_log_file.cpp new file mode 100644 index 0000000000000000000000000000000000000000..618189f318445de510e04b6dfb26a4c8bcf237a7 --- /dev/null +++ b/src/agent/rotate_log_file.cpp @@ -0,0 +1,165 @@ +/* Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ +#include <agent/rotate_log_file.h> +#include <string> + +/** Set the absolute path from log dir */ +void Rotate::setLogDir(bf::path d) { + this->logDir = d; +} + +/** Count the total of files that are in a specific directory */ +void Rotate::setNumberOfFiles() { + int count = 0; + for (bf::directory_iterator it(this->logDir); it != bf::directory_iterator(); ++it) // NOLINT [whitespace/line_length] + count++; + this->numberOfFiles = count; +} + + +/** Get the size of a logfile and set the attribute sizeOfLogfile */ +void Rotate::setSizeOfLogfile(Agent* agent) { + std::fstream file((agent->getLogFile()).c_str(), std::fstream::app); + this->sizeOfLogfile = file.tellg(); // NOLINT [runtime/int] + file.close(); +} + +/** Set the name from logfile */ +void Rotate::setLogfileName(std::string n) { + this->logfileName = n; +} + +/** Return the absolute path from log directory */ +bf::path Rotate::getLogDir() const { + return this->logDir; +} + +/** Return the total of files that are in log directory */ +int Rotate::getNumberOfFiles() const { + return this->numberOfFiles; +} + +/** Return logfile name */ +std::string Rotate::getLogfileName() const { + return this->logfileName; +} + +/** Return size from logfile */ +long Rotate::getSizeOfLogfile() const { // NOLINT [runtime/int] + return this->sizeOfLogfile; +} + +/** Check case if the absolute path from logfile was setted */ +bool Rotate::logDirIsSet() { + if (this->logDir.size() != 0) + return true; + return false; +} + +/** Case rotated logfile (the oldest logfile was removed - datasid-agent.1.log), is needed create a new logfile // NOLINT [whitespace/line_length] + */ +void Rotate::createLogfile(Agent* agent) { + std::fstream file(this->getLogfileName().c_str(), std::fstream::app); + if (file.is_open()) { + agent->setMessage(__DATE__ + std::string(" - SUCCESS: ") + + std::string(" Rotate logfile.")); + file << agent->getMessage() << std::endl; + file.close(); + } else { + agent->setMessage(__DATE__ + std::string(" - ERROR: ") + + std::string(" Logfile cannot be created.")); + } +} + +/** Case the oldest logfile (datasid-agent.1.log) was removed, than is necessary to rename logfiles + * @brief Example + * - Files inside log directory + * - datasid-agent.2.log, datasid-agent.3.log, datasid-agent.4.log, datasid-agent.log + * - Rename + * - datasid-agent.2.log renamed to datasid-agent.1.log + * - datasid-agent.3.log renamed to datasid-agent.2.log + * - datasid-agent.4.log renamed to datasid-agent.3.log + */ +void Rotate::renameFile(Agent* agent) { + this->setNumberOfFiles(); + int count = 1, number = this->getNumberOfFiles(); + for (int i = count; i < number; i++) + bf::rename((agent->getPrefix() + + std::string("/log/datasid-agent.") + + std::string(std::to_string(i+1)) + std::string(".log")), + (agent->getPrefix() + + std::string("/log/datasid-agent.") + + std::string(std::to_string(count++)) + std::string(".log"))); +} + +/** Rotate logfile + * - Check the number of logfiles that are in log directory. + * - Case if the number more than 12 files, remove datasid-agent.1.log + * - After that, rename the files name in log directory. + * - Check also the size of datasid-agent.log file. + * - Case if size more than 5.000.000 bytes (5MB), than create a new logfile. + */ +void rotate_log_file(Agent* agent) { + Rotate rotate; + rotate.setLogfileName(agent->getLogFile()); + rotate.setSizeOfLogfile(agent); + rotate.setLogDir(agent->getPrefix() + std::string("/log")); + rotate.setNumberOfFiles(); + rotate.getNumberOfFiles(); + + if (rotate.logDirIsSet()) { + if (rotate.getNumberOfFiles() < 5) { + // Size - size of logfile in bytes. + if (rotate.getSizeOfLogfile() > 5000000) { + bf::rename(rotate.getLogfileName().c_str(), agent->getPrefix() + // NOLINT [whitespace/line_length] + std::string("/log/datasid-agent.") + + std::string(std::to_string(rotate.getNumberOfFiles())) + + std::string(".log")); + rotate.createLogfile(agent); + } + } else { + /* + * Case if are more than 11 files inside log dir, + * remove datasid-agent.1.log file. + */ + std::fstream logFile(rotate.getLogfileName().c_str(), std::fstream::app); // NOLINT [whitespace/line_length] + if (logFile.is_open()) { + if (remove((agent->getPrefix() + + std::string("/log/datasid-agent.1.log")).c_str()) != 0) { + agent->setMessage(__DATE__ + std::string(" - ERROR: ") + + std::string("Failed to remove logFile at rotate") + + std::string(" logfile function.")); + logFile << agent->getMessage() << std::endl; + } else { + agent->setMessage(__DATE__ + std::string(" - SUCCESS: ") + + std::string("Logfile removed.")); + logFile << agent->getMessage() << std::endl; + + agent->setMessage(__DATE__ + std::string(" - SUCCESS: ") + + std::string(" Rotate logfile.")); + logFile << agent->getMessage() << std::endl; + rotate.renameFile(agent); + } + logFile.close(); + } + } + } +} diff --git a/src/agent/user_history.cpp b/src/agent/user_history.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5cb063fc713b67d2ff4fad0c364426db4ce7e7c9 --- /dev/null +++ b/src/agent/user_history.cpp @@ -0,0 +1,22 @@ +/* Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * 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. + */ + +#include <agent/user_history.h> diff --git a/src/linux/get_date.cpp b/src/linux/get_date.cpp deleted file mode 100644 index ab435517b7ef61a2eef11acfa8da2a0f2be9a1a9..0000000000000000000000000000000000000000 --- a/src/linux/get_date.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include <agent/linux/get_date.h> - -std::string get_date() { - std::string res = ""; - - time_t rawtime; - struct tm * timeinfo; - char buffer [20]; - - time (&rawtime); - timeinfo = localtime (&rawtime); - - // YYYY-MM-DD - strftime (buffer,20,"%Y-%m-%d",timeinfo); - - res = buffer; - return res; -} diff --git a/src/linux/get_distro.cpp b/src/linux/get_distro.cpp deleted file mode 100644 index 9597ce2924432ad6696cd2b0f359702da30b36a6..0000000000000000000000000000000000000000 --- a/src/linux/get_distro.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "agent/linux/get_distro.h" - -int open_file(std::string name, std::ifstream& fstream){ - fstream.open(name); - if (fstream.is_open()) - return 1; - else - return 0; -} - -std::string get_distro(){ - /* in Linux: distro name + version + release - the year is 2016 and we have 2 "unified" ways to identify distros - and a couple regex to find the distro name files - update: I used to complain about Linux, then I tried coding for - Windows... */ - - /* current recorded distros are - * Ubuntu - * Debian - * Linux Comunicações - * Linux Educacional - all of which should have the lsb-release file, but I added a couple more - common distros just in case */ - - std::ifstream release_file; - std::string line; - - // lsb compliant - if (open_file("/etc/lsb-release", release_file)) { - const std::string key = "DISTRIB_DESCRIPTION="; - std::size_t found; - - while (getline(release_file, line)) { - found = line.find(key); - if (found!=std::string::npos) { - return (line.substr(found+key.length()+1, - // remove key and quotes at the beginning - line.length()-(found+key.length()+1)-1)); - // remove quotes at the end - } - } - } - - // openSuSE - else if (open_file("/etc/os-release", release_file)){ - const std::string name_key = "NAME="; - const std::string version_key = "VERSION="; - - std::string name; - std::string version; - - std::size_t found_name; - std::size_t found_version; - - while (getline(release_file, line)) { - found_name = line.find(name_key); - found_version = line.find(version_key); - if (found_name < line.length()) { - name = line.substr(found_name+name_key.length()+1, - // remove key and quotes at the beginning - line.length()-(found_name+name_key.length()+1)-1); - // remove quotes at the end - } - - if (found_version < line.length()) { - version = line.substr(found_version+version_key.length()+1, - // remove key and quotes at the beginning - line.length()-(found_version+version_key.length()+1)-1); - // remove quotes at the end - } - - if (name.length() && version.length()) { - return name + version; - } - } - - if (name.length()) { - return name; - } - else { - return "unknown"; - } - } - - else if (open_file("/etc/novell-release", release_file)){ - getline(release_file, line); - return line; - } - - else if (open_file("/etc/sles-release", release_file)){ - getline(release_file, line); - return line; - } - - // fedora - else if (open_file("/etc/redhat-release", release_file)){ - getline(release_file, line); - return line; - } - - // debian -- leave this at the end, otherwise debian-based distros - // will find the debian_version file instead of the actual - // distro name - else if (open_file("/etc/debian-release", release_file)){ - getline(release_file, line); - return line; - } - - else if (open_file("/etc/debian-version", release_file)){ - getline(release_file, line); - return line; - } - - return "unknown"; -} diff --git a/src/linux/get_macaddr.cpp b/src/linux/get_macaddr.cpp deleted file mode 100644 index a1fbcef762f1c80bc9221847e1b65797e8995254..0000000000000000000000000000000000000000 --- a/src/linux/get_macaddr.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include <agent/linux/get_macaddr.h> - -std::string get_macaddr(){ - std::fstream file; - std::string macaddr; - - file.open("/sys/class/net/eth0/address", std::ifstream::in); - - if (!file.is_open()) { - file.open("/sys/class/net/eth1/address", std::ifstream::in); - if (!file.is_open()) { - return "unknown"; - } - } - - getline(file, macaddr); - file.close(); - - return macaddr; -} diff --git a/src/linux/get_machine_type.cpp b/src/linux/get_machine_type.cpp deleted file mode 100644 index 9f4ba3cdf381fbe4c73778553bb35974876bbb08..0000000000000000000000000000000000000000 --- a/src/linux/get_machine_type.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include <agent/linux/get_machine_type.h> - -std::string get_machine_type () { - struct addrinfo hints, *info, *p; - int gai_result; - - char hostname[1024]; - hostname[1023] = '\0'; - gethostname(hostname, 1023); - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; /*either IPV4 or IPV6*/ - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_CANONNAME; - - gai_result = getaddrinfo(hostname, "http", &hints, &info); - - if (gai_result) { - fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(gai_result)); - return "unknown"; - } - - for(p = info; p; p = p->ai_next) { - if (!p->ai_canonname) { - continue; - } - if (!strcmp(p->ai_canonname,"server.telecentro.net")) {; - freeaddrinfo(info); - return "server"; - } - } - - freeaddrinfo(info); - - return "client"; -} diff --git a/src/linux/get_time.cpp b/src/linux/get_time.cpp deleted file mode 100644 index b3e6472a25dc9267cf5564d0b54e9ffa8905487b..0000000000000000000000000000000000000000 --- a/src/linux/get_time.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "agent/linux/get_time.h" - -// get current time -std::string get_time() { - std::string res = ""; - - time_t rawtime; - struct tm * timeinfo; - char buffer [20]; - - time (&rawtime); - timeinfo = localtime (&rawtime); - - // HH:MM:SS - strftime (buffer,20,"%H:%M:%S",timeinfo); - - res = buffer; - return res; -} diff --git a/src/linux/inventory.cpp b/src/linux/inventory.cpp deleted file mode 100644 index deb719c6c46110978d52c9a801e71b1a17f8489f..0000000000000000000000000000000000000000 --- a/src/linux/inventory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "agent/linux/inventory.h" - -/******************************* - * INVENTORY * - *******************************/ - -std::string get_processor_model(){ - return "unknown"; -} - -Json::Value get_inventory(){ - - Json::Value inv; - - // os info - - struct utsname sysinfo; - uname(&sysinfo); - - inv["os_type"] = "Linux"; - inv["os_distro"] = get_distro(); - inv["os_kernel"] = sysinfo.release; - inv["mirror_timestamp"] = sysinfo.version; - - // hw info - /* - inv["processor"] = - inv["memory"] = - inv["disk1_model"] = - inv["disk1_size"] = - inv["disk1_used"] = - inv["disk2_model"] = - inv["disk2_size"] = - inv["disk2_used"] = - inv["extra_hds"] = - */ - - // other - /* - inv["agent_version"] = - inv["contact_date"] = - */ - - inv["machine_type"] = get_machine_type(); - inv["amount_users"] = get_user_count(); - inv["mac_address"] = get_macaddr(); - - return inv; -} diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 973956b177e395510d029c15eb44faa69d82486f..0000000000000000000000000000000000000000 --- a/src/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include <iostream> -#include <sys/utsname.h> -#include <cpr/cpr.h> -#include <fstream> -#include "agent/post.h" - -int main(){ - - send_inventory(); - send_net_bandwidth(); - send_user_history(); - - return 0; -} diff --git a/src/network_bandwidth.cpp b/src/network_bandwidth.cpp deleted file mode 100644 index 9ff07d5397340f1fe6c9138adde724e7ff6c6f83..0000000000000000000000000000000000000000 --- a/src/network_bandwidth.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "agent/network_bandwidth.h" diff --git a/src/post.cpp b/src/post.cpp deleted file mode 100644 index dac86f2207c1edb843355d96f19fb0d03f769ebb..0000000000000000000000000000000000000000 --- a/src/post.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "agent/post.h" - -/******************************* - * INVENTORY * - *******************************/ - -int send_inventory(){ - Json::Value inventory = get_inventory(); - Json::FastWriter fastWriter; - -#ifdef PRINT_JSON - Json::StyledWriter styledWriter; - if (!inventory.isNull()) - std::cout << styledWriter.write(inventory); - else - std::cout << "Empty inventory object" << std::endl; -#endif - - auto p = cpr::Post(cpr::Url{base_url + "/api/v1/collect"}, - cpr::Parameters{{"type", "inventory"}}, - cpr::Body{fastWriter.write(inventory)}, - cpr::Header{{"content-type", "application/json"}}); - - if (p.status_code == 200) { - return 1; - } - - return 0; - -} - -/*************************************** - * NETWORK BANDWIDTH * - ***************************************/ - -int send_net_bandwidth(){ - Json::Value net; - Json::FastWriter fastWriter; - -#ifdef PRINT_JSON - Json::StyledWriter styledWriter; - if (!net.isNull()) - std::cout << styledWriter.write(net); - else - std::cout << "Empty network_bandwidth object" << std::endl; -#endif - - auto p = cpr::Post(cpr::Url{base_url + "/api/v1/collect"}, - cpr::Parameters{{"type", "network_bandwidth"}}, - cpr::Body{fastWriter.write(net)}, - cpr::Header{{"content-type", "application/json"}}); - - if (p.status_code == 200) { - return 1; - } - - return 0; - -} - -/********************************** - * USER HISTORY * - **********************************/ - -int send_user_history(){ - Json::Value u_h; - Json::FastWriter fastWriter; - -#ifdef PRINT_JSON - Json::StyledWriter styledWriter; - if (!u_h.isNull()) - std::cout << styledWriter.write(u_h); - else - std::cout << "Empty user_history object" << std::endl; -#endif - - auto p = cpr::Post(cpr::Url{base_url + "/api/v1/collect"}, - cpr::Parameters{{"type", "user_history"}}, - cpr::Body{fastWriter.write(u_h)}, - cpr::Header{{"content-type", "application/json"}}); - - if (p.status_code == 200) { - return 1; - } - - return 0; - -} diff --git a/src/user_history.cpp b/src/user_history.cpp deleted file mode 100644 index c42b72f1e471e208b22108b42c8617116c416294..0000000000000000000000000000000000000000 --- a/src/user_history.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "agent/user_history.h" diff --git a/src/windows/get_date.cpp b/src/windows/get_date.cpp deleted file mode 100644 index ee6d0ce36658f49f3807fa742b99de6cb14aa113..0000000000000000000000000000000000000000 --- a/src/windows/get_date.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include <agent/windows/get_date.h> - -std::string get_date() { - std::string res = ""; - - time_t rawtime; - struct tm * timeinfo; - char buffer [20]; - - time (&rawtime); - timeinfo = localtime (&rawtime); - - // YYYY-MM-DD - strftime (buffer,20,"%Y-%m-%d",timeinfo); - - res = buffer; - return res; -} diff --git a/src/windows/get_macaddr.cpp b/src/windows/get_macaddr.cpp deleted file mode 100644 index bce36442ea87e19d7da72b58a0d7c24167a338b0..0000000000000000000000000000000000000000 --- a/src/windows/get_macaddr.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include <agent/windows/get_macaddr.h> - -string get_macaddr(){ - PIP_ADAPTER_INFO AdapterInfo; - DWORD dwBufLen = sizeof(AdapterInfo); - char *mac_addr = (char*)malloc(17); - - AdapterInfo = (IP_ADAPTER_INFO *) malloc(sizeof(IP_ADAPTER_INFO)); - if (AdapterInfo == NULL) { - printf("Error allocating memory needed to call GetAdaptersinfo\n"); - } - - // Make an initial call to GetAdaptersInfo to get the necessary size into the dwBufLen variable - if (GetAdaptersInfo(AdapterInfo, &dwBufLen) == ERROR_BUFFER_OVERFLOW) { - - AdapterInfo = (IP_ADAPTER_INFO *) malloc(dwBufLen); - if (AdapterInfo == NULL) { - printf("Error allocating memory needed to call GetAdaptersinfo\n"); - } - } - - if (GetAdaptersInfo(AdapterInfo, &dwBufLen) == NO_ERROR) { - PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;// Contains pointer to current adapter info - - sprintf(mac_addr, "%02X:%02X:%02X:%02X:%02X:%02X", - pAdapterInfo->Address[0], pAdapterInfo->Address[1], - pAdapterInfo->Address[2], pAdapterInfo->Address[3], - pAdapterInfo->Address[4], pAdapterInfo->Address[5]); - free(AdapterInfo); - return mac_addr; - } - free(AdapterInfo); - return ""; -} diff --git a/src/windows/get_machine_type.cpp b/src/windows/get_machine_type.cpp deleted file mode 100644 index c8734a065dc5e99c3ebb5fcda4e1216a8b128931..0000000000000000000000000000000000000000 --- a/src/windows/get_machine_type.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include <agent/windows/get_machine_type.h> - -string get_machine_type(void) { - TCHAR buffer[1024] = TEXT(""); - int cnf = 3; - DWORD dwSize = sizeof(buffer); - - if (!GetComputerNameEx((COMPUTER_NAME_FORMAT)cnf, buffer, &dwSize)) { - _tprintf(TEXT("GetComputerNameEx failed (%d)\n"), GetLastError()); - return "unknow"; - } - - if (!strcmp(buffer,"server.telecentro.net")) { - dwSize = _countof(buffer); - ZeroMemory(buffer, dwSize); - return "server"; - } - - dwSize = _countof(buffer); - ZeroMemory(buffer, dwSize); - return "client"; -} diff --git a/src/windows/get_time.cpp b/src/windows/get_time.cpp deleted file mode 100644 index 2e405288f3c4cb4fc75938fbb7b8b4b9b82535bd..0000000000000000000000000000000000000000 --- a/src/windows/get_time.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include <time.h> -#include <string.h> - -// get current time -std::string get_time() { - std::string res = ""; - - time_t rawtime; - struct tm * timeinfo; - char buffer [20]; - - time (&rawtime); - timeinfo = localtime (&rawtime); - - // HH:MM:SS - strftime (buffer,20,"%H:%M:%S",timeinfo); - - res = buffer; - return res; diff --git a/src/windows/inventory.cpp b/src/windows/inventory.cpp deleted file mode 100644 index 3fe31119e265374f3962250e1ec029e073a8721f..0000000000000000000000000000000000000000 --- a/src/windows/inventory.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "agent/windows/inventory.h" - -/******************************* - * INVENTORY * - *******************************/ - -std::string get_distro(){ - // use dtwinver - - return "unknown"; -} - -std::string get_processor_model(){ - return "unknown"; -} - -Json::Value get_inventory(){ - - Json::Value inv; - - // os info - - inv["os_type"] = "Windows"; - inv["os_distro"] = "Windows"; //TODO: replace with dtwinver thing - inv["os_kernel"] = "Windows"; - inv["mirror_timestamp"] = "Windows"; - - // hw info - /* - inv["processor"] = - inv["memory"] = - inv["disk1_model"] = - inv["disk1_size"] = - inv["disk1_used"] = - inv["disk2_model"] = - inv["disk2_size"] = - inv["disk2_used"] = - inv["extra_hds"] = - */ - - // other - /* - inv["agent_version"] = - inv["contact_date"] = - inv["amount_users"] = - */ - - inv["machine_type"] = get_machine_type(); - inv["mac_address"] = get_macaddr(); - - return inv; -} diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7c917774c3d18c77ffefa5a282b94d9dc0b7f60f --- /dev/null +++ b/test/README.md @@ -0,0 +1,62 @@ +Requirements +------------ + +* docker + +Docker +------ + +Docker supplies images of main Linux distributions from which one can build +their own with a single configuration file `Dockerfile`. It looks like a +virtual machine, but uses the kernel of the hosting OS. + +Running +------- + + ./test.sh [-c] [-b [IMAGE_NAME]] [-r [IMAGE_NAME]] + +The `test.sh` script, run without arguments, executes these three steps: + +* copy the agent directories and files, plus other needed scripts, to a +directory inside each distribution directory - observation: this must be done +because docker does not allow inclusion of directories by relative paths. +* build/update all docker images - install requirements, build and compile the +agent, and run other needed scripts +* run all docker images - run the agent inside the images, print the JSON +generated in execution + +Building the images and the agent may take some time and throw a lot of output, +so you can use the options + +* `-c` to copy (rsync) the agent into the distribution directories +* `-b [IMAGE_NAME]` to build the docker image specified by IMAGE_NAME or all + of them if none specified +* `-r [IMAGE_NAME]` to run the docker image specified by IMAGE_NAME or all + of them if none specified +* `-q` to run in quiet mode: redirect stdout to log.txt during + steps "copy" and "build" + +to execute only part of the flow. Of course, running will not work if the images +have not been built once previously. + +Images +------ + +Currently tested images are + +* ubuntu +* debian +* opensuse + +Dockerfiles +------------------- + +* Make use of Docker cache when trying stuff: avoid adding instructions +before long-standing ones if possible. (For example: once docker executes `RUN +apt-get update && apt-get install ...`, the resulting image is cached and +subsequent builds with no changes before that instruction will not execute it +again.) + +* Refer to best practices + * https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/ + * http://crosbymichael.com/dockerfile-best-practices-take-2.html diff --git a/test/create_users.sh b/test/create_users.sh new file mode 100755 index 0000000000000000000000000000000000000000..9ec3a629fa2b63a694c8334831e427f9fb67946b --- /dev/null +++ b/test/create_users.sh @@ -0,0 +1,34 @@ +#!/bin/bash +declare -a ft_users=( user1 user2 user3 user4 ) +declare -a ft_dates=( -2d -1d -1d -0d ) + +for i in $(seq 0 $(( ${#ft_users[@]} -1 ))) +do + + ft_user=${ft_users[$i]} + ft_date=${ft_dates[$i]} + + password="" + pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) + + useradd -m -p $pass $ft_user + if [ $? -ne 0 ] + then + echo "Failed to add $ft_user!" + fi + + faketime -f "${ft_date}" ./login.exp $ft_user &>/dev/null + + if grep -q "openSUSE" /etc/os-release + then + userdel -r $ft_user >/dev/null + else + deluser --remove-home $ft_user >/dev/null + fi + + if [ $? -ne 0 ] + then + echo "Failed to delete $ft_user!" + fi + +done \ No newline at end of file diff --git a/test/docker/debian/Dockerfile b/test/docker/debian/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4eaff3908c689790ddc182d7d661f53ded616401 --- /dev/null +++ b/test/docker/debian/Dockerfile @@ -0,0 +1,24 @@ +FROM debian:latest + +# install requirements +RUN apt-get update && apt-get install -y cmake \ + expect \ + faketime \ + git \ + g++ + +# copy agent directory +COPY agent home/agent/ + +# cmake +RUN /bin/bash -c 'cd home/agent/build ;\ + cmake -DPRINT_JSON=ON ..' + +# make +RUN /bin/bash -c 'cd home/agent/build ;\ + make' + +# create, login as and delete users +COPY create_users.sh home/create_users.sh +RUN /bin/bash -c "cd home ; \ + faketime 'yesterday' ./create_users.sh" diff --git a/test/docker/opensuse/Dockerfile b/test/docker/opensuse/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1bc1c2c2aec59048c32d5476310f333cdd1d2956 --- /dev/null +++ b/test/docker/opensuse/Dockerfile @@ -0,0 +1,30 @@ +FROM opensuse:latest + +# install requirements +COPY faketime-0.9.6-4.mga6.x86_64.rpm home/faketime-0.9.6-4.mga6.x86_64.rpm +RUN zypper --non-interactive --no-gpg-checks install cmake \ + expect \ + /home/faketime-0.9.6-4.mga6.x86_64.rpm \ + gcc-c++ + +# copy agent directory +COPY agent home/agent/ + +# cmake +RUN /bin/bash -c 'cd home/agent/build ; \ + cmake -DPRINT_JSON=ON ..' + +# make +RUN /bin/bash -c 'cd home/agent/build ; \ + make' + +# create /var/log/wtmp +RUN touch /var/log/wtmp +RUN chown root.tty /var/log/wtmp +RUN chmod 664 /var/log/wtmp + + +# create, login as and delete users +COPY create_users.sh home/create_users.sh +RUN /bin/bash -c "cd home ; \ + faketime 'yesterday' ./create_users.sh" diff --git a/test/docker/opensuse/faketime-0.9.6-4.mga6.x86_64.rpm b/test/docker/opensuse/faketime-0.9.6-4.mga6.x86_64.rpm new file mode 100644 index 0000000000000000000000000000000000000000..a2a55a90195b156b6bb17bc96f10a018d38a96d7 Binary files /dev/null and b/test/docker/opensuse/faketime-0.9.6-4.mga6.x86_64.rpm differ diff --git a/test/docker/ubuntu/Dockerfile b/test/docker/ubuntu/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a559fbcc85f1ce14141d16cc826f89bf962a927d --- /dev/null +++ b/test/docker/ubuntu/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:latest + +# install requirements +RUN apt-get update && apt-get install -y \ + cmake \ + expect \ + faketime \ + g++ + +# copy agent directory +COPY agent home/agent/ + +# cmake +RUN /bin/bash -c 'cd home/agent/build ; \ + cmake -DPRINT_JSON=ON ..' + +# make +RUN /bin/bash -c 'cd home/agent/build ; \ + make' + +# create, login as and delete users +COPY create_users.sh home/create_users.sh +RUN /bin/bash -c "cd home ; \ + faketime 'yesterday' ./create_users.sh" diff --git a/test/login.exp b/test/login.exp new file mode 100755 index 0000000000000000000000000000000000000000..6813a6f26faca21482c21eff43249863cce99a30 --- /dev/null +++ b/test/login.exp @@ -0,0 +1,10 @@ +#!/usr/bin/expect + +set user [lindex $argv 0] + +spawn login -f $user +sleep 2 +expect "\$ " +send -- "logout\r" + +exit \ No newline at end of file diff --git a/test/returnTest.bats b/test/returnTest.bats new file mode 100755 index 0000000000000000000000000000000000000000..fdef68b174038eef9ca4e419d3e1b9a20613ff28 --- /dev/null +++ b/test/returnTest.bats @@ -0,0 +1,142 @@ +#!/usr/bin/env bats + +function amount_users() { + expected_number_of_users=3 + obj=$(cat inventory.json | jq -r '.data_inventory.amount_users') + [[ "$obj" -eq "$expected_number_of_users" ]] && [[ "$obj" != "null" ]] +} + +function mac_address() { + obj=$(cat inventory.json | jq -r '.data_inventory.mac_address') + [[ "$obj" =~ ^(..:){5}..$ ]] && [[ "$obj" != "null" ]] +} + +function machine_type() { + os=$(cat inventory.json | jq -r '.data_inventory.os_distro') + obj=$(cat inventory.json | jq -r '.data_inventory.machine_type') + ! [[ "$os" =~ .*Linux\ Comunicações.* ]] || ( [[ "$os" =~ .*Linux\ Comunicações.* ]] && [[ "$obj" != "null" ]] ) + +} + +function memory() { + obj=$(cat inventory.json | jq -r '.data_inventory.memory') + [[ "$obj" -eq "$obj" ]] && [[ "$obj" != "null" ]] +} + +function os_distro() { + obj=$(cat inventory.json | jq -r '.data_inventory.os_distro') + [[ "$obj" != "null" ]] +} + +function os_kernel() { + obj=$(cat inventory.json | jq -r '.data_inventory.os_kernel') + [[ "$obj" != "null" ]] +} + +function os_type() { + obj=$(cat inventory.json | jq -r '.data_inventory.os_type') + [[ "$obj" != "null" ]] +} + +function processor() { + obj=$(cat inventory.json | jq -r '.data_inventory.processor') + [[ "$obj" != "null" ]] +} + +function bytes_received() { + obj=$(cat net.json | jq -r '.data_net.bytes_received') + [[ "$obj" -ge 0 ]] +} + +function bytes_transmitted() { + obj=$(cat net.json | jq -r '.data_net.bytes_transmitted') + [[ "$obj" -ge 0 ]] +} + +function packets_received() { + obj=$(cat net.json | jq -r '.data_net.packets_received') + [[ "$obj" -ge 0 ]] +} + +function packets_transmitted() { + obj=$(cat net.json | jq -r '.data_net.packets_transmitted') + [[ "$obj" -ge 0 ]] +} + +setup() { + ./../bin/agent.run --quiet | head -n -1 > export.json + pt1=$(cat export.json | head -n -9) + echo $pt1 > inventory.json + pt2=$(cat export.json | tail -n 9) + echo $pt2 > net.json + [ -s export.json ] + [ -s inventory.json ] + [ -s net.json ] + cat export.json +} + +teardown() { + rm -f export.json + rm -f inventory.json + rm -f net.json +} + +@test "Bytes Received" { + run bytes_received + [ "$status" -eq 0 ] +} + +@test "Bytes Transmitted" { + run bytes_transmitted + [ "$status" -eq 0 ] +} + +@test "Packets Received" { + run packets_received + [ "$status" -eq 0 ] +} + +@test "Packets Trasmitted" { + run packets_transmitted + [ "$status" -eq 0 ] +} + +@test "Amount Users" { + run amount_users + [ "$status" -eq 0 ] +} + +@test "MAC" { + run mac_address + [ "$status" -eq 0 ] +} + +@test "Machine Type" { + run machine_type + [ "$status" -eq 0 ] +} + +@test "Memory" { + run memory + [ "$status" -eq 0 ] +} + +@test "OS Distro" { + run os_distro + [ "$status" -eq 0 ] +} + +@test "OS Kernel" { + run os_kernel + [ "$status" -eq 0 ] +} + +@test "OS Type" { + run os_type + [ "$status" -eq 0 ] +} + +@test "Processor" { + run processor + [ "$status" -eq 0 ] +} diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..00d822e79303538c0937c138c9b79716d019f012 --- /dev/null +++ b/test/test.sh @@ -0,0 +1,189 @@ +#!/bin/bash + +# allow for improved pattern recognition +shopt -s extglob + +# is docker installed? +command -v docker >/dev/null 2>&1 || { echo >&2 "It seems docker is not installed. Aborting."; exit 1; } + + +# Check options +# -c - rsync agent directory into image directory +# -b - build only specified image / all images if no argument is provided +# -r - run only specified image / all images if no argument is provided +# -q - redirect stdout of rsync and docker build to specified file / log.txt if +# no argument is provided + +LINT=true +EXECUTE_ALL=true +RSYNC=false +BUILD_DOCKER_IMAGES=false +RUN=false +QUIET_MODE=false + +# current tested images +declare -A IMAGES_LIST=([ubuntu]=1 [debian]=1 [opensuse]=1) + +while (($#)) +do + case "$1" in + -c) + RSYNC=true + EXECUTE_ALL=false + shift 1 + ;; + + -b) + BUILD_DOCKER_IMAGES=true + EXECUTE_ALL=false + if [[ "$2" = -* ]] || [[ "$2" = "" ]] + then + # no arguments + shift 1 + else + if [[ -n "${IMAGES_LIST[$2]}" ]] + then + B_IMAGE_NAME=$2 + else + echo "Invalid image name: $2" >&2 + fi + shift 2 + fi + ;; + + -r) + RUN=true + EXECUTE_ALL=false + if [[ "$2" = -* ]] || [[ "$2" = "" ]] + then + # no arguments + shift 1 + else + if [[ -n "${IMAGES_LIST[$2]}" ]] + then + R_IMAGE_NAME=$2 + else + echo "Invalid image name: $2" >&2 + fi + shift 2 + fi + ;; + + -q) + QUIET_MODE=true + if [[ "$2" = -* ]] || [[ "$2" = "" ]] + then + # no arguments + shift 1 + else + LOG_FILE_NAME=$2 + shift 2 + fi + ;; + + \?) + echo "Invalid option: $2" >&2 + shift + ;; + esac +done + + +# If no options were used, run everything +if ($EXECUTE_ALL) +then + + RSYNC=true + BUILD_DOCKER_IMAGES=true + RUN=true + +fi + +# If quiet mode was selected, redirect stdout to log.txt file +if ($QUIET_MODE) +then + # save stdout + exec 5<&1 + # redirect + if [ -z "${LOG_FILE_NAME}" ] + then + exec 1> log.txt + else + exec 1> "${LOG_FILE_NAME}" + fi +fi + +# rsync +if ($RSYNC) +then + printf "******************\n* LINT and COPY *\n******************\n\n" + + printf "Applying linter to /agent/src/*.cpp\n" + cpplint.py --filter=-whitespace/blank_line,-build/include_what_you_use ../src/!(jsoncpp).cpp ../src/linux/*.cpp ../src/windows/*.cpp + shopt -u extglob + + for i in "${!IMAGES_LIST[@]}" + do + printf "Copying to docker/%s/agent\n" "$i" + rsync -au ../* docker/"$i"/agent --delete --exclude test --exclude build/* + printf "Copying to docker/%s/create_users.sh\n\n" "$i" + rsync -u create_users.sh docker/"$i"/create_users.sh + + done + + printf "\n" + +fi + + +# build images +if ($BUILD_DOCKER_IMAGES) +then + printf "***********\n* BUILD *\n***********\n\n" + + if [ -z "${B_IMAGE_NAME}" ] + then + for i in "${!IMAGES_LIST[@]}" + do + printf "Building %s:agent\n\n" "$i" + docker build -t "$i":agent docker/"$i" + printf "\n" + done + else + printf "Building %s:agent\n\n" "${B_IMAGE_NAME}" + docker build -t "${B_IMAGE_NAME}":agent docker/"${B_IMAGE_NAME}" + printf "\n" + fi + + printf "\n" + +fi + +# If quiet mode was selected, restore stdout before running +if ($QUIET_MODE) +then + exec 1<&5 +fi + +# run agent into images +if ($RUN) +then + printf "*********\n* RUN *\n*********\n" + + if [ -z "${R_IMAGE_NAME}" ] + then + for i in "${!IMAGES_LIST[@]}" + do + printf "\nRunning %s:agent\n" "$i" + printf "******************************************************\n" + docker run -it "$i":agent ./home/agent/bin/agent-v0.0 + printf "******************************************************\n\n" + done + else + printf "\nRunning %s:agent\n\n" "${R_IMAGE_NAME}" + printf "******************************************************\n" + docker run -it "${R_IMAGE_NAME}":agent ./home/agent/bin/agent-v0.0 + printf "******************************************************\n" + fi + +fi