├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── aclocal.m4 ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── install-sh ├── ltmain.sh ├── m4 └── m4-ax_compare_version.m4 ├── missing ├── scripts ├── Makefile.am ├── Makefile.in ├── hpeilo_nagios_config.in ├── hpeilo_snmp_service_set_tool.in ├── nagios_hpeilo_cfg_generator.in └── nagios_hpeilo_traps.in └── src ├── credit_save ├── Makefile.am ├── Makefile.in └── credit_save.c ├── ilo_credit ├── Makefile.am ├── Makefile.in ├── base64.c ├── ilo-credit-store.cpp └── ilo_credit.in ├── include ├── base64.h ├── cJSON.h ├── credit_save.h ├── ilo-credit-store.h ├── nagios_hpilo_common.h ├── nagios_hpilo_engine.h └── nagios_hpilo_restful_engine.h └── restful ├── Makefile.am ├── Makefile.in ├── base64.c ├── cJSON.c └── nagios_hpilo_restful_engine.c /AUTHORS: -------------------------------------------------------------------------------- 1 | MAINTAINERS 2 | 3 | Linux_SWdeliverables Linux_SWdeliverables@groups.ext.hpe.com 4 | 5 | PATCHES 6 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | (C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P. 2 | 3 | This program is free software; you can redistribute it and/or modify it under the terms 4 | of version 2 of the GNU General Public License as published by the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 7 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 8 | 9 | See the GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License along with this program; 12 | if not, write to: 13 | Free Software Foundation, Inc. 14 | 51 Franklin Street, Fifth Floor 15 | Boston, MA 02110-1301, USA. 16 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HewlettPackard/nagios-hpeilo-restful-extension/97f96dc4b57a83f71b608f58043e37058fb4b86e/ChangeLog -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, 5 | Inc. 6 | 7 | Copying and distribution of this file, with or without modification, 8 | are permitted in any medium without royalty provided the copyright 9 | notice and this notice are preserved. This file is offered as-is, 10 | without warranty of any kind. 11 | 12 | Quick Installation 13 | ****************** 14 | 15 | After executing the following commands: 16 | $ ./configure && make && sudo make install 17 | Six files (credit_save, nagios_hpeilo_engine, nagios_hpeilo_cfg_generator, 18 | nagios_hpeilo_traps and hpeilo_nagios_config, hpeilo_snmp_service_set_tool) 19 | will be copied to the default folder "/usr/local/nagios/libexec". 20 | 21 | HPE iLO Management configuration 22 | =============================== 23 | In order to make iLO respond the SNMP requests, you should add "public" to 24 | "Read Community" and "Trap Community" fields under 25 | Administration->Management->SNMP setting in iLO web page. 26 | In order for the monitoring server (Nagios server) to get the health 27 | status of the HPE ProLiant servers in real-time, the SNMP Alert Destination(s) 28 | field under Administration->Management->SNMP setting in iLO web page has to 29 | been configured with the IP address of the monitoring server. 30 | 31 | Firewall 32 | ======== 33 | Open httpd and SNMP port on the firewall with root account. 34 | # iptables -I INPUT -p udp -m udp --dport 161 -j ACCEPT 35 | # iptables -I INPUT -p udp -m udp --dport 162 -j ACCEPT 36 | # iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT 37 | # iptables-save > /etc/sysconfig/iptables 38 | 39 | Basic Installation 40 | ****************** 41 | 42 | Briefly, the shell commands `./configure; make; make install' should 43 | configure, build, and install this package. The following 44 | more-detailed instructions are generic; see the `README' file for 45 | instructions specific to this package. Some packages provide this 46 | `INSTALL' file but do not implement all of the features documented 47 | below. The lack of an optional feature in a given package is not 48 | necessarily a bug. More recommendations for GNU packages can be found 49 | in *note Makefile Conventions: (standards)Makefile Conventions. 50 | 51 | The `configure' shell script attempts to guess correct values for 52 | various system-dependent variables used during compilation. It uses 53 | those values to create a `Makefile' in each directory of the package. 54 | It may also create one or more `.h' files containing system-dependent 55 | definitions. Finally, it creates a shell script `config.status' that 56 | you can run in the future to recreate the current configuration, and a 57 | file `config.log' containing compiler output (useful mainly for 58 | debugging `configure'). 59 | 60 | It can also use an optional file (typically called `config.cache' 61 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 62 | the results of its tests to speed up reconfiguring. Caching is 63 | disabled by default to prevent problems with accidental use of stale 64 | cache files. 65 | 66 | If you need to do unusual things to compile the package, please try 67 | to figure out how `configure' could check whether to do them, and mail 68 | diffs or instructions to the address given in the `README' so they can 69 | be considered for the next release. If you are using the cache, and at 70 | some point `config.cache' contains results you don't want to keep, you 71 | may remove or edit it. 72 | 73 | The file `configure.ac' (or `configure.in') is used to create 74 | `configure' by a program called `autoconf'. You need `configure.ac' if 75 | you want to change it or regenerate `configure' using a newer version 76 | of `autoconf'. 77 | 78 | The simplest way to compile this package is: 79 | 80 | 1. `cd' to the directory containing the package's source code and type 81 | `./configure' to configure the package for your system. 82 | 83 | Running `configure' might take a while. While running, it prints 84 | some messages telling which features it is checking for. 85 | 86 | 2. Type `make' to compile the package. 87 | 88 | 3. Optionally, type `make check' to run any self-tests that come with 89 | the package, generally using the just-built uninstalled binaries. 90 | 91 | 4. Type `make install' to install the programs and any data files and 92 | documentation. When installing into a prefix owned by root, it is 93 | recommended that the package be configured and built as a regular 94 | user, and only the `make install' phase executed with root 95 | privileges. 96 | 97 | 5. Optionally, type `make installcheck' to repeat any self-tests, but 98 | this time using the binaries in their final installed location. 99 | This target does not install anything. Running this target as a 100 | regular user, particularly if the prior `make install' required 101 | root privileges, verifies that the installation completed 102 | correctly. 103 | 104 | 6. You can remove the program binaries and object files from the 105 | source code directory by typing `make clean'. To also remove the 106 | files that `configure' created (so you can compile the package for 107 | a different kind of computer), type `make distclean'. There is 108 | also a `make maintainer-clean' target, but that is intended mainly 109 | for the package's developers. If you use it, you may have to get 110 | all sorts of other programs in order to regenerate files that came 111 | with the distribution. 112 | 113 | 7. Often, you can also type `make uninstall' to remove the installed 114 | files again. In practice, not all packages have tested that 115 | uninstallation works correctly, even though it is required by the 116 | GNU Coding Standards. 117 | 118 | 8. Some packages, particularly those that use Automake, provide `make 119 | distcheck', which can by used by developers to test that all other 120 | targets like `make install' and `make uninstall' work correctly. 121 | This target is generally not run by end users. 122 | 123 | Compilers and Options 124 | ===================== 125 | 126 | Some systems require unusual options for compilation or linking that 127 | the `configure' script does not know about. Run `./configure --help' 128 | for details on some of the pertinent environment variables. 129 | 130 | You can give `configure' initial values for configuration parameters 131 | by setting variables in the command line or in the environment. Here 132 | is an example: 133 | 134 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 135 | 136 | *Note Defining Variables::, for more details. 137 | 138 | Compiling For Multiple Architectures 139 | ==================================== 140 | 141 | You can compile the package for more than one kind of computer at the 142 | same time, by placing the object files for each architecture in their 143 | own directory. To do this, you can use GNU `make'. `cd' to the 144 | directory where you want the object files and executables to go and run 145 | the `configure' script. `configure' automatically checks for the 146 | source code in the directory that `configure' is in and in `..'. This 147 | is known as a "VPATH" build. 148 | 149 | With a non-GNU `make', it is safer to compile the package for one 150 | architecture at a time in the source code directory. After you have 151 | installed the package for one architecture, use `make distclean' before 152 | reconfiguring for another architecture. 153 | 154 | On MacOS X 10.5 and later systems, you can create libraries and 155 | executables that work on multiple system types--known as "fat" or 156 | "universal" binaries--by specifying multiple `-arch' options to the 157 | compiler but only a single `-arch' option to the preprocessor. Like 158 | this: 159 | 160 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 161 | CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 162 | CPP="gcc -E" CXXCPP="g++ -E" 163 | 164 | This is not guaranteed to produce working output in all cases, you 165 | may have to build one architecture at a time and combine the results 166 | using the `lipo' tool if you have problems. 167 | 168 | Installation Names 169 | ================== 170 | 171 | By default, `make install' installs the package's commands under 172 | `/usr/local/bin', include files under `/usr/local/include', etc. You 173 | can specify an installation prefix other than `/usr/local' by giving 174 | `configure' the option `--prefix=PREFIX', where PREFIX must be an 175 | absolute file name. 176 | 177 | You can specify separate installation prefixes for 178 | architecture-specific files and architecture-independent files. If you 179 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses 180 | PREFIX as the prefix for installing programs and libraries. 181 | Documentation and other data files still use the regular prefix. 182 | 183 | In addition, if you use an unusual directory layout you can give 184 | options like `--bindir=DIR' to specify different values for particular 185 | kinds of files. Run `configure --help' for a list of the directories 186 | you can set and what kinds of files go in them. In general, the 187 | default for these options is expressed in terms of `${prefix}', so that 188 | specifying just `--prefix' will affect all of the other directory 189 | specifications that were not explicitly provided. 190 | 191 | The most portable way to affect installation locations is to pass the 192 | correct locations to `configure'; however, many packages provide one or 193 | both of the following shortcuts of passing variable assignments to the 194 | `make install' command line to change installation locations without 195 | having to reconfigure or recompile. 196 | 197 | The first method involves providing an override variable for each 198 | affected directory. For example, `make install 199 | prefix=/alternate/directory' will choose an alternate location for all 200 | directory configuration variables that were expressed in terms of 201 | `${prefix}'. Any directories that were specified during `configure', 202 | but not in terms of `${prefix}', must each be overridden at install 203 | time for the entire installation to be relocated. The approach of 204 | makefile variable overrides for each directory variable is required by 205 | the GNU Coding Standards, and ideally causes no recompilation. 206 | However, some platforms have known limitations with the semantics of 207 | shared libraries that end up requiring recompilation when using this 208 | method, particularly noticeable in packages that use GNU Libtool. 209 | 210 | The second method involves providing the `DESTDIR' variable. For 211 | example, `make install DESTDIR=/alternate/directory' will prepend 212 | `/alternate/directory' before all installation names. The approach of 213 | `DESTDIR' overrides is not required by the GNU Coding Standards, and 214 | does not work on platforms that have drive letters. On the other hand, 215 | it does better at avoiding recompilation issues, and works well even 216 | when some directory options were not specified in terms of `${prefix}' 217 | at `configure' time. 218 | 219 | Optional Features 220 | ================= 221 | 222 | If the package supports it, you can cause programs to be installed 223 | with an extra prefix or suffix on their names by giving `configure' the 224 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 225 | 226 | Some packages pay attention to `--enable-FEATURE' options to 227 | `configure', where FEATURE indicates an optional part of the package. 228 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 229 | is something like `gnu-as' or `x' (for the X Window System). The 230 | `README' should mention any `--enable-' and `--with-' options that the 231 | package recognizes. 232 | 233 | For packages that use the X Window System, `configure' can usually 234 | find the X include and library files automatically, but if it doesn't, 235 | you can use the `configure' options `--x-includes=DIR' and 236 | `--x-libraries=DIR' to specify their locations. 237 | 238 | Some packages offer the ability to configure how verbose the 239 | execution of `make' will be. For these packages, running `./configure 240 | --enable-silent-rules' sets the default to minimal output, which can be 241 | overridden with `make V=1'; while running `./configure 242 | --disable-silent-rules' sets the default to verbose, which can be 243 | overridden with `make V=0'. 244 | 245 | Particular systems 246 | ================== 247 | 248 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU 249 | CC is not installed, it is recommended to use the following options in 250 | order to use an ANSI C compiler: 251 | 252 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" 253 | 254 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. 255 | 256 | HP-UX `make' updates targets which have the same time stamps as 257 | their prerequisites, which makes it generally unusable when shipped 258 | generated files such as `configure' are involved. Use GNU `make' 259 | instead. 260 | 261 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot 262 | parse its `' header file. The option `-nodtk' can be used as 263 | a workaround. If GNU CC is not installed, it is therefore recommended 264 | to try 265 | 266 | ./configure CC="cc" 267 | 268 | and if that doesn't work, try 269 | 270 | ./configure CC="cc -nodtk" 271 | 272 | On Solaris, don't put `/usr/ucb' early in your `PATH'. This 273 | directory contains several dysfunctional programs; working variants of 274 | these programs are available in `/usr/bin'. So, if you need `/usr/ucb' 275 | in your `PATH', put it _after_ `/usr/bin'. 276 | 277 | On Haiku, software installed for all users goes in `/boot/common', 278 | not `/usr/local'. It is recommended to use the following options: 279 | 280 | ./configure --prefix=/boot/common 281 | 282 | Specifying the System Type 283 | ========================== 284 | 285 | There may be some features `configure' cannot figure out 286 | automatically, but needs to determine by the type of machine the package 287 | will run on. Usually, assuming the package is built to be run on the 288 | _same_ architectures, `configure' can figure that out, but if it prints 289 | a message saying it cannot guess the machine type, give it the 290 | `--build=TYPE' option. TYPE can either be a short name for the system 291 | type, such as `sun4', or a canonical name which has the form: 292 | 293 | CPU-COMPANY-SYSTEM 294 | 295 | where SYSTEM can have one of these forms: 296 | 297 | OS 298 | KERNEL-OS 299 | 300 | See the file `config.sub' for the possible values of each field. If 301 | `config.sub' isn't included in this package, then this package doesn't 302 | need to know the machine type. 303 | 304 | If you are _building_ compiler tools for cross-compiling, you should 305 | use the option `--target=TYPE' to select the type of system they will 306 | produce code for. 307 | 308 | If you want to _use_ a cross compiler, that generates code for a 309 | platform different from the build platform, you should specify the 310 | "host" platform (i.e., that on which the generated programs will 311 | eventually be run) with `--host=TYPE'. 312 | 313 | Sharing Defaults 314 | ================ 315 | 316 | If you want to set default values for `configure' scripts to share, 317 | you can create a site shell script called `config.site' that gives 318 | default values for variables like `CC', `cache_file', and `prefix'. 319 | `configure' looks for `PREFIX/share/config.site' if it exists, then 320 | `PREFIX/etc/config.site' if it exists. Or, you can set the 321 | `CONFIG_SITE' environment variable to the location of the site script. 322 | A warning: not all `configure' scripts look for a site script. 323 | 324 | Defining Variables 325 | ================== 326 | 327 | Variables not defined in a site shell script can be set in the 328 | environment passed to `configure'. However, some packages may run 329 | configure again during the build, and the customized values of these 330 | variables may be lost. In order to avoid this problem, you should set 331 | them in the `configure' command line, using `VAR=value'. For example: 332 | 333 | ./configure CC=/usr/local2/bin/gcc 334 | 335 | causes the specified `gcc' to be used as the C compiler (unless it is 336 | overridden in the site shell script). 337 | 338 | Unfortunately, this technique does not work for `CONFIG_SHELL' due to 339 | an Autoconf bug. Until the bug is fixed you can use this workaround: 340 | 341 | CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash 342 | 343 | `configure' Invocation 344 | ====================== 345 | 346 | `configure' recognizes the following options to control how it 347 | operates. 348 | 349 | `--help' 350 | `-h' 351 | Print a summary of all of the options to `configure', and exit. 352 | 353 | `--help=short' 354 | `--help=recursive' 355 | Print a summary of the options unique to this package's 356 | `configure', and exit. The `short' variant lists options used 357 | only in the top level, while the `recursive' variant lists options 358 | also present in any nested packages. 359 | 360 | `--version' 361 | `-V' 362 | Print the version of Autoconf used to generate the `configure' 363 | script, and exit. 364 | 365 | `--cache-file=FILE' 366 | Enable the cache: use and save the results of the tests in FILE, 367 | traditionally `config.cache'. FILE defaults to `/dev/null' to 368 | disable caching. 369 | 370 | `--config-cache' 371 | `-C' 372 | Alias for `--cache-file=config.cache'. 373 | 374 | `--quiet' 375 | `--silent' 376 | `-q' 377 | Do not print messages saying which checks are being made. To 378 | suppress all normal output, redirect it to `/dev/null' (any error 379 | messages will still be shown). 380 | 381 | `--srcdir=DIR' 382 | Look for the package's source code in directory DIR. Usually 383 | `configure' can determine that directory automatically. 384 | 385 | `--prefix=DIR' 386 | Use DIR as the installation prefix. *note Installation Names:: 387 | for more details, including other options available for fine-tuning 388 | the installation locations. 389 | 390 | `--no-create' 391 | `-n' 392 | Run the configure checks, but stop before creating any output 393 | files. 394 | 395 | `configure' also accepts some other, not widely useful, options. Run 396 | `configure --help' for more details. 397 | 398 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | CXXFLAGS = -O3 2 | 3 | SUBDIRS = src/ilo_credit src/credit_save src/restful scripts 4 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Nagios plugin for HP iLO RESTful Extension 2 | 3 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | # nagios-hpeilo-restful-extension 2 | Nagios Plug-in for iLO RESTful Extension 3 | ------------------------------------------ 4 | Nagios plug-in for HPE iLO RESTful Extension aims to automatically manage HPE 5 | ProLiant servers within the data center. With the help of the plug-in, 6 | the administator does not need to configure the nagios configuration file 7 | (/nagios_etc_path/conf.d) manually. The plug-in automatically writes the 8 | server configuration to the nagios configuration file 9 | (/nagios_etc_path/cfg_dir/ilo.cfg, for example: 10 | /usr/local/nagios/etc/ilo/ilo.cfg under Ubuntu 14.04) 11 | once any of HPE ProLiant servers is discovered within the data center. 12 | 13 | Requirements: 14 | ------------- 15 | SW: 16 | - curl,libcurl,libtdb,snmptrapd,python 17 | HW: 18 | - HPE ProLiant Server 19 | 20 | Features: 21 | ------------- 22 | 1) Discover and monitor HPE ProLiant servers within data center automatically. 23 | There are two alternatives to discover HPE ProLiant servers. 24 | 25 | 1.1) Active discovery: The active discovery scans all available servers 26 | in the network of the monitoring server. This 27 | approach can discovery all up and running servers 28 | with the data center. Note that this feature 29 | is a time-consuming process if your data center 30 | has lots of hosts/IP addresses to be discovered. 31 | 32 | 1.2) Passive discovery: The passive discovery discovers HPE ProLiant 33 | servers once receiving the cold start traps 34 | generated by those servers. The traps are 35 | generated when those servers get booted 36 | successfully, so this approach cannot discover 37 | the up and running servers within the data 38 | center. 39 | 40 | 2) Provide the high-level server status. 41 | 42 | 3) Display the server status in real-time if the status is changed. 43 | 44 | 4) Categorize the preferred servers into the same host group, 45 | and the preferred services into the same services group. 46 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the `curl' library (-lcurl). */ 10 | #undef HAVE_LIBCURL 11 | 12 | /* Define to 1 if you have the `tdb' library (-ltdb). */ 13 | #undef HAVE_LIBTDB 14 | 15 | /* Define to 1 if your system has a GNU libc compatible `malloc' function, and 16 | to 0 otherwise. */ 17 | #undef HAVE_MALLOC 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #undef HAVE_MEMORY_H 21 | 22 | /* Define to 1 if you have the `memset' function. */ 23 | #undef HAVE_MEMSET 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #undef HAVE_OPENSSL_BIO_H 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #undef HAVE_STDINT_H 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #undef HAVE_STDLIB_H 33 | 34 | /* Define to 1 if you have the `strdup' function. */ 35 | #undef HAVE_STRDUP 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #undef HAVE_STRINGS_H 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #undef HAVE_STRING_H 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #undef HAVE_SYS_STAT_H 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #undef HAVE_SYS_TYPES_H 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #undef HAVE_UNISTD_H 51 | 52 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 53 | */ 54 | #undef LT_OBJDIR 55 | 56 | /* Name of package */ 57 | #undef PACKAGE 58 | 59 | /* Define to the address where bug reports for this package should be sent. */ 60 | #undef PACKAGE_BUGREPORT 61 | 62 | /* Define to the full name of this package. */ 63 | #undef PACKAGE_NAME 64 | 65 | /* Define to the full name and version of this package. */ 66 | #undef PACKAGE_STRING 67 | 68 | /* Define to the one symbol short name of this package. */ 69 | #undef PACKAGE_TARNAME 70 | 71 | /* Define to the home page for this package. */ 72 | #undef PACKAGE_URL 73 | 74 | /* Define to the version of this package. */ 75 | #undef PACKAGE_VERSION 76 | 77 | /* Define to 1 if you have the ANSI C header files. */ 78 | #undef STDC_HEADERS 79 | 80 | /* Version number of package */ 81 | #undef VERSION 82 | 83 | /* Define to rpl_malloc if the replacement function should be used. */ 84 | #undef malloc 85 | 86 | /* Define to `unsigned int' if does not define. */ 87 | #undef size_t 88 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ([2.69]) 5 | AC_INIT(nagios-hpeilo-restful-extension, 1.0, ying.yang2@hpe.com) 6 | AC_CONFIG_SRCDIR([src/restful/nagios_hpilo_restful_engine.c]) 7 | AC_CONFIG_HEADERS([config.h]) 8 | AM_INIT_AUTOMAKE 9 | AC_CONFIG_MACRO_DIR([m4]) 10 | 11 | m4_include([m4/m4-ax_compare_version.m4]) 12 | 13 | AC_PREFIX_DEFAULT(/usr/local/nagios) 14 | 15 | # Checks for programs. 16 | AC_PROG_CC 17 | AC_PROG_CXX 18 | AC_PROG_LIBTOOL 19 | 20 | LT_INIT 21 | 22 | # Checks for libraries. 23 | #AC_CHECK_LIB(netsnmp, snmp_sess_init, [LIBS="$LIBS -lnetsnmp"], [AC_MSG_ERROR(Could not find net-snmp library.)]) 24 | AC_CHECK_LIB(curl, curl_easy_init, , AC_MSG_ERROR([curl library is required.])) 25 | AC_CHECK_LIB(tdb, tdb_open, , AC_MSG_ERROR([tdb library is required.])) 26 | 27 | # Checks for header files. 28 | AC_CHECK_HEADERS([stdlib.h string.h unistd.h]) 29 | AC_CHECK_HEADERS([openssl/bio.h],, AC_MSG_ERROR([libssl library is required.])) 30 | 31 | # Check the nmap utility 32 | NMAP_MIN_VERSION=5.20 33 | AC_SUBST(NMAP_MIN_VERSION) 34 | 35 | AC_PATH_PROG(NMAP_PATH, nmap, no) 36 | 37 | AM_CONDITIONAL([COMPILING_ON_64], [test "x`getconf LONG_BIT`"="x64"]) 38 | AM_CONDITIONAL([COMPILING_ON_DEBIAN], [test -f "/etc/debian_version"]) 39 | 40 | if test "x$NMAP_PATH" = "xno"; then 41 | AC_MSG_ERROR(Cannot find nmap.) 42 | else 43 | AC_MSG_CHECKING(for namp version >= $NMAP_MIN_VERSION) 44 | NMAP_VERSION=`$NMAP_PATH --version | grep version | cut -d ' ' -f3` 45 | AX_COMPARE_VERSION([$NMAP_VERSION], [ge], [$NMAP_MIN_VERSION], 46 | AC_MSG_RESULT(yes), 47 | AC_MSG_ERROR(your namp version is '$NMAP_VERSION'. Must be >= $NMAP_MIN_VERSION)) 48 | fi 49 | 50 | # Checks for typedefs, structures, and compiler characteristics. 51 | AC_TYPE_SIZE_T 52 | 53 | # Checks for library functions. 54 | AC_FUNC_MALLOC 55 | AC_CHECK_FUNCS([memset strdup]) 56 | AC_CONFIG_FILES([ 57 | Makefile 58 | src/ilo_credit/Makefile 59 | src/credit_save/Makefile 60 | src/restful/Makefile 61 | scripts/Makefile 62 | scripts/nagios_hpeilo_cfg_generator 63 | scripts/nagios_hpeilo_traps 64 | scripts/hpeilo_nagios_config 65 | scripts/hpeilo_snmp_service_set_tool 66 | ]) 67 | 68 | AC_OUTPUT 69 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2011-11-20.07; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # 'make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | nl=' 45 | ' 46 | IFS=" "" $nl" 47 | 48 | # set DOITPROG to echo to test this script 49 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. 51 | doit=${DOITPROG-} 52 | if test -z "$doit"; then 53 | doit_exec=exec 54 | else 55 | doit_exec=$doit 56 | fi 57 | 58 | # Put in absolute file names if you don't have them in your path; 59 | # or use environment vars. 60 | 61 | chgrpprog=${CHGRPPROG-chgrp} 62 | chmodprog=${CHMODPROG-chmod} 63 | chownprog=${CHOWNPROG-chown} 64 | cmpprog=${CMPPROG-cmp} 65 | cpprog=${CPPROG-cp} 66 | mkdirprog=${MKDIRPROG-mkdir} 67 | mvprog=${MVPROG-mv} 68 | rmprog=${RMPROG-rm} 69 | stripprog=${STRIPPROG-strip} 70 | 71 | posix_glob='?' 72 | initialize_posix_glob=' 73 | test "$posix_glob" != "?" || { 74 | if (set -f) 2>/dev/null; then 75 | posix_glob= 76 | else 77 | posix_glob=: 78 | fi 79 | } 80 | ' 81 | 82 | posix_mkdir= 83 | 84 | # Desired mode of installed file. 85 | mode=0755 86 | 87 | chgrpcmd= 88 | chmodcmd=$chmodprog 89 | chowncmd= 90 | mvcmd=$mvprog 91 | rmcmd="$rmprog -f" 92 | stripcmd= 93 | 94 | src= 95 | dst= 96 | dir_arg= 97 | dst_arg= 98 | 99 | copy_on_change=false 100 | no_target_directory= 101 | 102 | usage="\ 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 | or: $0 [OPTION]... -d DIRECTORIES... 107 | 108 | In the 1st form, copy SRCFILE to DSTFILE. 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 | In the 4th, create DIRECTORIES. 111 | 112 | Options: 113 | --help display this help and exit. 114 | --version display version info and exit. 115 | 116 | -c (ignored) 117 | -C install only if different (preserve the last data modification time) 118 | -d create directories instead of installing files. 119 | -g GROUP $chgrpprog installed files to GROUP. 120 | -m MODE $chmodprog installed files to MODE. 121 | -o USER $chownprog installed files to USER. 122 | -s $stripprog installed files. 123 | -t DIRECTORY install into DIRECTORY. 124 | -T report an error if DSTFILE is a directory. 125 | 126 | Environment variables override the default commands: 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 | RMPROG STRIPPROG 129 | " 130 | 131 | while test $# -ne 0; do 132 | case $1 in 133 | -c) ;; 134 | 135 | -C) copy_on_change=true;; 136 | 137 | -d) dir_arg=true;; 138 | 139 | -g) chgrpcmd="$chgrpprog $2" 140 | shift;; 141 | 142 | --help) echo "$usage"; exit $?;; 143 | 144 | -m) mode=$2 145 | case $mode in 146 | *' '* | *' '* | *' 147 | '* | *'*'* | *'?'* | *'['*) 148 | echo "$0: invalid mode: $mode" >&2 149 | exit 1;; 150 | esac 151 | shift;; 152 | 153 | -o) chowncmd="$chownprog $2" 154 | shift;; 155 | 156 | -s) stripcmd=$stripprog;; 157 | 158 | -t) dst_arg=$2 159 | # Protect names problematic for 'test' and other utilities. 160 | case $dst_arg in 161 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 162 | esac 163 | shift;; 164 | 165 | -T) no_target_directory=true;; 166 | 167 | --version) echo "$0 $scriptversion"; exit $?;; 168 | 169 | --) shift 170 | break;; 171 | 172 | -*) echo "$0: invalid option: $1" >&2 173 | exit 1;; 174 | 175 | *) break;; 176 | esac 177 | shift 178 | done 179 | 180 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 181 | # When -d is used, all remaining arguments are directories to create. 182 | # When -t is used, the destination is already specified. 183 | # Otherwise, the last argument is the destination. Remove it from $@. 184 | for arg 185 | do 186 | if test -n "$dst_arg"; then 187 | # $@ is not empty: it contains at least $arg. 188 | set fnord "$@" "$dst_arg" 189 | shift # fnord 190 | fi 191 | shift # arg 192 | dst_arg=$arg 193 | # Protect names problematic for 'test' and other utilities. 194 | case $dst_arg in 195 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 196 | esac 197 | done 198 | fi 199 | 200 | if test $# -eq 0; then 201 | if test -z "$dir_arg"; then 202 | echo "$0: no input file specified." >&2 203 | exit 1 204 | fi 205 | # It's OK to call 'install-sh -d' without argument. 206 | # This can happen when creating conditional directories. 207 | exit 0 208 | fi 209 | 210 | if test -z "$dir_arg"; then 211 | do_exit='(exit $ret); exit $ret' 212 | trap "ret=129; $do_exit" 1 213 | trap "ret=130; $do_exit" 2 214 | trap "ret=141; $do_exit" 13 215 | trap "ret=143; $do_exit" 15 216 | 217 | # Set umask so as not to create temps with too-generous modes. 218 | # However, 'strip' requires both read and write access to temps. 219 | case $mode in 220 | # Optimize common cases. 221 | *644) cp_umask=133;; 222 | *755) cp_umask=22;; 223 | 224 | *[0-7]) 225 | if test -z "$stripcmd"; then 226 | u_plus_rw= 227 | else 228 | u_plus_rw='% 200' 229 | fi 230 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 231 | *) 232 | if test -z "$stripcmd"; then 233 | u_plus_rw= 234 | else 235 | u_plus_rw=,u+rw 236 | fi 237 | cp_umask=$mode$u_plus_rw;; 238 | esac 239 | fi 240 | 241 | for src 242 | do 243 | # Protect names problematic for 'test' and other utilities. 244 | case $src in 245 | -* | [=\(\)!]) src=./$src;; 246 | esac 247 | 248 | if test -n "$dir_arg"; then 249 | dst=$src 250 | dstdir=$dst 251 | test -d "$dstdir" 252 | dstdir_status=$? 253 | else 254 | 255 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 256 | # might cause directories to be created, which would be especially bad 257 | # if $src (and thus $dsttmp) contains '*'. 258 | if test ! -f "$src" && test ! -d "$src"; then 259 | echo "$0: $src does not exist." >&2 260 | exit 1 261 | fi 262 | 263 | if test -z "$dst_arg"; then 264 | echo "$0: no destination specified." >&2 265 | exit 1 266 | fi 267 | dst=$dst_arg 268 | 269 | # If destination is a directory, append the input filename; won't work 270 | # if double slashes aren't ignored. 271 | if test -d "$dst"; then 272 | if test -n "$no_target_directory"; then 273 | echo "$0: $dst_arg: Is a directory" >&2 274 | exit 1 275 | fi 276 | dstdir=$dst 277 | dst=$dstdir/`basename "$src"` 278 | dstdir_status=0 279 | else 280 | # Prefer dirname, but fall back on a substitute if dirname fails. 281 | dstdir=` 282 | (dirname "$dst") 2>/dev/null || 283 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 284 | X"$dst" : 'X\(//\)[^/]' \| \ 285 | X"$dst" : 'X\(//\)$' \| \ 286 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 287 | echo X"$dst" | 288 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 289 | s//\1/ 290 | q 291 | } 292 | /^X\(\/\/\)[^/].*/{ 293 | s//\1/ 294 | q 295 | } 296 | /^X\(\/\/\)$/{ 297 | s//\1/ 298 | q 299 | } 300 | /^X\(\/\).*/{ 301 | s//\1/ 302 | q 303 | } 304 | s/.*/./; q' 305 | ` 306 | 307 | test -d "$dstdir" 308 | dstdir_status=$? 309 | fi 310 | fi 311 | 312 | obsolete_mkdir_used=false 313 | 314 | if test $dstdir_status != 0; then 315 | case $posix_mkdir in 316 | '') 317 | # Create intermediate dirs using mode 755 as modified by the umask. 318 | # This is like FreeBSD 'install' as of 1997-10-28. 319 | umask=`umask` 320 | case $stripcmd.$umask in 321 | # Optimize common cases. 322 | *[2367][2367]) mkdir_umask=$umask;; 323 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 324 | 325 | *[0-7]) 326 | mkdir_umask=`expr $umask + 22 \ 327 | - $umask % 100 % 40 + $umask % 20 \ 328 | - $umask % 10 % 4 + $umask % 2 329 | `;; 330 | *) mkdir_umask=$umask,go-w;; 331 | esac 332 | 333 | # With -d, create the new directory with the user-specified mode. 334 | # Otherwise, rely on $mkdir_umask. 335 | if test -n "$dir_arg"; then 336 | mkdir_mode=-m$mode 337 | else 338 | mkdir_mode= 339 | fi 340 | 341 | posix_mkdir=false 342 | case $umask in 343 | *[123567][0-7][0-7]) 344 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 345 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 346 | ;; 347 | *) 348 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 349 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 350 | 351 | if (umask $mkdir_umask && 352 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 353 | then 354 | if test -z "$dir_arg" || { 355 | # Check for POSIX incompatibilities with -m. 356 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 357 | # other-writable bit of parent directory when it shouldn't. 358 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 359 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 360 | case $ls_ld_tmpdir in 361 | d????-?r-*) different_mode=700;; 362 | d????-?--*) different_mode=755;; 363 | *) false;; 364 | esac && 365 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 366 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 367 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 368 | } 369 | } 370 | then posix_mkdir=: 371 | fi 372 | rmdir "$tmpdir/d" "$tmpdir" 373 | else 374 | # Remove any dirs left behind by ancient mkdir implementations. 375 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 376 | fi 377 | trap '' 0;; 378 | esac;; 379 | esac 380 | 381 | if 382 | $posix_mkdir && ( 383 | umask $mkdir_umask && 384 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 385 | ) 386 | then : 387 | else 388 | 389 | # The umask is ridiculous, or mkdir does not conform to POSIX, 390 | # or it failed possibly due to a race condition. Create the 391 | # directory the slow way, step by step, checking for races as we go. 392 | 393 | case $dstdir in 394 | /*) prefix='/';; 395 | [-=\(\)!]*) prefix='./';; 396 | *) prefix='';; 397 | esac 398 | 399 | eval "$initialize_posix_glob" 400 | 401 | oIFS=$IFS 402 | IFS=/ 403 | $posix_glob set -f 404 | set fnord $dstdir 405 | shift 406 | $posix_glob set +f 407 | IFS=$oIFS 408 | 409 | prefixes= 410 | 411 | for d 412 | do 413 | test X"$d" = X && continue 414 | 415 | prefix=$prefix$d 416 | if test -d "$prefix"; then 417 | prefixes= 418 | else 419 | if $posix_mkdir; then 420 | (umask=$mkdir_umask && 421 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 422 | # Don't fail if two instances are running concurrently. 423 | test -d "$prefix" || exit 1 424 | else 425 | case $prefix in 426 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 427 | *) qprefix=$prefix;; 428 | esac 429 | prefixes="$prefixes '$qprefix'" 430 | fi 431 | fi 432 | prefix=$prefix/ 433 | done 434 | 435 | if test -n "$prefixes"; then 436 | # Don't fail if two instances are running concurrently. 437 | (umask $mkdir_umask && 438 | eval "\$doit_exec \$mkdirprog $prefixes") || 439 | test -d "$dstdir" || exit 1 440 | obsolete_mkdir_used=true 441 | fi 442 | fi 443 | fi 444 | 445 | if test -n "$dir_arg"; then 446 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 447 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 448 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 449 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 450 | else 451 | 452 | # Make a couple of temp file names in the proper directory. 453 | dsttmp=$dstdir/_inst.$$_ 454 | rmtmp=$dstdir/_rm.$$_ 455 | 456 | # Trap to clean up those temp files at exit. 457 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 458 | 459 | # Copy the file name to the temp name. 460 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 461 | 462 | # and set any options; do chmod last to preserve setuid bits. 463 | # 464 | # If any of these fail, we abort the whole thing. If we want to 465 | # ignore errors from any of these, just make sure not to ignore 466 | # errors from the above "$doit $cpprog $src $dsttmp" command. 467 | # 468 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 469 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 470 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 471 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 472 | 473 | # If -C, don't bother to copy if it wouldn't change the file. 474 | if $copy_on_change && 475 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 476 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 477 | 478 | eval "$initialize_posix_glob" && 479 | $posix_glob set -f && 480 | set X $old && old=:$2:$4:$5:$6 && 481 | set X $new && new=:$2:$4:$5:$6 && 482 | $posix_glob set +f && 483 | 484 | test "$old" = "$new" && 485 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 486 | then 487 | rm -f "$dsttmp" 488 | else 489 | # Rename the file to the real destination. 490 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 491 | 492 | # The rename failed, perhaps because mv can't rename something else 493 | # to itself, or perhaps because mv is so ancient that it does not 494 | # support -f. 495 | { 496 | # Now remove or move aside any old file at destination location. 497 | # We try this two ways since rm can't unlink itself on some 498 | # systems and the destination file might be busy for other 499 | # reasons. In this case, the final cleanup might fail but the new 500 | # file should still install successfully. 501 | { 502 | test ! -f "$dst" || 503 | $doit $rmcmd -f "$dst" 2>/dev/null || 504 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 505 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 506 | } || 507 | { echo "$0: cannot unlink or rename $dst" >&2 508 | (exit 1); exit 1 509 | } 510 | } && 511 | 512 | # Now rename the file to the real destination. 513 | $doit $mvcmd "$dsttmp" "$dst" 514 | } 515 | fi || exit 1 516 | 517 | trap '' 0 518 | fi 519 | done 520 | 521 | # Local variables: 522 | # eval: (add-hook 'write-file-hooks 'time-stamp) 523 | # time-stamp-start: "scriptversion=" 524 | # time-stamp-format: "%:y-%02m-%02d.%02H" 525 | # time-stamp-time-zone: "UTC" 526 | # time-stamp-end: "; # UTC" 527 | # End: 528 | -------------------------------------------------------------------------------- /m4/m4-ax_compare_version.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_compare_version.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # This macro compares two version strings. Due to the various number of 12 | # minor-version numbers that can exist, and the fact that string 13 | # comparisons are not compatible with numeric comparisons, this is not 14 | # necessarily trivial to do in a autoconf script. This macro makes doing 15 | # these comparisons easy. 16 | # 17 | # The six basic comparisons are available, as well as checking equality 18 | # limited to a certain number of minor-version levels. 19 | # 20 | # The operator OP determines what type of comparison to do, and can be one 21 | # of: 22 | # 23 | # eq - equal (test A == B) 24 | # ne - not equal (test A != B) 25 | # le - less than or equal (test A <= B) 26 | # ge - greater than or equal (test A >= B) 27 | # lt - less than (test A < B) 28 | # gt - greater than (test A > B) 29 | # 30 | # Additionally, the eq and ne operator can have a number after it to limit 31 | # the test to that number of minor versions. 32 | # 33 | # eq0 - equal up to the length of the shorter version 34 | # ne0 - not equal up to the length of the shorter version 35 | # eqN - equal up to N sub-version levels 36 | # neN - not equal up to N sub-version levels 37 | # 38 | # When the condition is true, shell commands ACTION-IF-TRUE are run, 39 | # otherwise shell commands ACTION-IF-FALSE are run. The environment 40 | # variable 'ax_compare_version' is always set to either 'true' or 'false' 41 | # as well. 42 | # 43 | # Examples: 44 | # 45 | # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) 46 | # AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) 47 | # 48 | # would both be true. 49 | # 50 | # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) 51 | # AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) 52 | # 53 | # would both be false. 54 | # 55 | # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) 56 | # 57 | # would be true because it is only comparing two minor versions. 58 | # 59 | # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) 60 | # 61 | # would be true because it is only comparing the lesser number of minor 62 | # versions of the two values. 63 | # 64 | # Note: The characters that separate the version numbers do not matter. An 65 | # empty string is the same as version 0. OP is evaluated by autoconf, not 66 | # configure, so must be a string, not a variable. 67 | # 68 | # The author would like to acknowledge Guido Draheim whose advice about 69 | # the m4_case and m4_ifvaln functions make this macro only include the 70 | # portions necessary to perform the specific comparison specified by the 71 | # OP argument in the final configure script. 72 | # 73 | # LICENSE 74 | # 75 | # Copyright (c) 2008 Tim Toolan 76 | # 77 | # Copying and distribution of this file, with or without modification, are 78 | # permitted in any medium without royalty provided the copyright notice 79 | # and this notice are preserved. This file is offered as-is, without any 80 | # warranty. 81 | 82 | #serial 11 83 | 84 | dnl ######################################################################### 85 | AC_DEFUN([AX_COMPARE_VERSION], [ 86 | AC_REQUIRE([AC_PROG_AWK]) 87 | 88 | # Used to indicate true or false condition 89 | ax_compare_version=false 90 | 91 | # Convert the two version strings to be compared into a format that 92 | # allows a simple string comparison. The end result is that a version 93 | # string of the form 1.12.5-r617 will be converted to the form 94 | # 0001001200050617. In other words, each number is zero padded to four 95 | # digits, and non digits are removed. 96 | AS_VAR_PUSHDEF([A],[ax_compare_version_A]) 97 | A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ 98 | -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ 99 | -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ 100 | -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ 101 | -e 's/[[^0-9]]//g'` 102 | 103 | AS_VAR_PUSHDEF([B],[ax_compare_version_B]) 104 | B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ 105 | -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ 106 | -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ 107 | -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ 108 | -e 's/[[^0-9]]//g'` 109 | 110 | dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary 111 | dnl # then the first line is used to determine if the condition is true. 112 | dnl # The sed right after the echo is to remove any indented white space. 113 | m4_case(m4_tolower($2), 114 | [lt],[ 115 | ax_compare_version=`echo "x$A 116 | x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` 117 | ], 118 | [gt],[ 119 | ax_compare_version=`echo "x$A 120 | x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` 121 | ], 122 | [le],[ 123 | ax_compare_version=`echo "x$A 124 | x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` 125 | ], 126 | [ge],[ 127 | ax_compare_version=`echo "x$A 128 | x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` 129 | ],[ 130 | dnl Split the operator from the subversion count if present. 131 | m4_bmatch(m4_substr($2,2), 132 | [0],[ 133 | # A count of zero means use the length of the shorter version. 134 | # Determine the number of characters in A and B. 135 | ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` 136 | ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` 137 | 138 | # Set A to no more than B's length and B to no more than A's length. 139 | A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` 140 | B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` 141 | ], 142 | [[0-9]+],[ 143 | # A count greater than zero means use only that many subversions 144 | A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` 145 | B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` 146 | ], 147 | [.+],[ 148 | AC_WARNING( 149 | [illegal OP numeric parameter: $2]) 150 | ],[]) 151 | 152 | # Pad zeros at end of numbers to make same length. 153 | ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" 154 | B="$B`echo $A | sed 's/./0/g'`" 155 | A="$ax_compare_version_tmp_A" 156 | 157 | # Check for equality or inequality as necessary. 158 | m4_case(m4_tolower(m4_substr($2,0,2)), 159 | [eq],[ 160 | test "x$A" = "x$B" && ax_compare_version=true 161 | ], 162 | [ne],[ 163 | test "x$A" != "x$B" && ax_compare_version=true 164 | ],[ 165 | AC_WARNING([illegal OP parameter: $2]) 166 | ]) 167 | ]) 168 | 169 | AS_VAR_POPDEF([A])dnl 170 | AS_VAR_POPDEF([B])dnl 171 | 172 | dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. 173 | if test "$ax_compare_version" = "true" ; then 174 | m4_ifvaln([$4],[$4],[:])dnl 175 | m4_ifvaln([$5],[else $5])dnl 176 | fi 177 | ]) dnl AX_COMPARE_VERSION 178 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common wrapper for a few potentially missing GNU programs. 3 | 4 | scriptversion=2013-10-28.13; # UTC 5 | 6 | # Copyright (C) 1996-2013 Free Software Foundation, Inc. 7 | # Originally written by Fran,cois Pinard , 1996. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | if test $# -eq 0; then 28 | echo 1>&2 "Try '$0 --help' for more information" 29 | exit 1 30 | fi 31 | 32 | case $1 in 33 | 34 | --is-lightweight) 35 | # Used by our autoconf macros to check whether the available missing 36 | # script is modern enough. 37 | exit 0 38 | ;; 39 | 40 | --run) 41 | # Back-compat with the calling convention used by older automake. 42 | shift 43 | ;; 44 | 45 | -h|--h|--he|--hel|--help) 46 | echo "\ 47 | $0 [OPTION]... PROGRAM [ARGUMENT]... 48 | 49 | Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50 | to PROGRAM being missing or too old. 51 | 52 | Options: 53 | -h, --help display this help and exit 54 | -v, --version output version information and exit 55 | 56 | Supported PROGRAM values: 57 | aclocal autoconf autoheader autom4te automake makeinfo 58 | bison yacc flex lex help2man 59 | 60 | Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61 | 'g' are ignored when checking the name. 62 | 63 | Send bug reports to ." 64 | exit $? 65 | ;; 66 | 67 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68 | echo "missing $scriptversion (GNU Automake)" 69 | exit $? 70 | ;; 71 | 72 | -*) 73 | echo 1>&2 "$0: unknown '$1' option" 74 | echo 1>&2 "Try '$0 --help' for more information" 75 | exit 1 76 | ;; 77 | 78 | esac 79 | 80 | # Run the given program, remember its exit status. 81 | "$@"; st=$? 82 | 83 | # If it succeeded, we are done. 84 | test $st -eq 0 && exit 0 85 | 86 | # Also exit now if we it failed (or wasn't found), and '--version' was 87 | # passed; such an option is passed most likely to detect whether the 88 | # program is present and works. 89 | case $2 in --version|--help) exit $st;; esac 90 | 91 | # Exit code 63 means version mismatch. This often happens when the user 92 | # tries to use an ancient version of a tool on a file that requires a 93 | # minimum version. 94 | if test $st -eq 63; then 95 | msg="probably too old" 96 | elif test $st -eq 127; then 97 | # Program was missing. 98 | msg="missing on your system" 99 | else 100 | # Program was found and executed, but failed. Give up. 101 | exit $st 102 | fi 103 | 104 | perl_URL=http://www.perl.org/ 105 | flex_URL=http://flex.sourceforge.net/ 106 | gnu_software_URL=http://www.gnu.org/software 107 | 108 | program_details () 109 | { 110 | case $1 in 111 | aclocal|automake) 112 | echo "The '$1' program is part of the GNU Automake package:" 113 | echo "<$gnu_software_URL/automake>" 114 | echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115 | echo "<$gnu_software_URL/autoconf>" 116 | echo "<$gnu_software_URL/m4/>" 117 | echo "<$perl_URL>" 118 | ;; 119 | autoconf|autom4te|autoheader) 120 | echo "The '$1' program is part of the GNU Autoconf package:" 121 | echo "<$gnu_software_URL/autoconf/>" 122 | echo "It also requires GNU m4 and Perl in order to run:" 123 | echo "<$gnu_software_URL/m4/>" 124 | echo "<$perl_URL>" 125 | ;; 126 | esac 127 | } 128 | 129 | give_advice () 130 | { 131 | # Normalize program name to check for. 132 | normalized_program=`echo "$1" | sed ' 133 | s/^gnu-//; t 134 | s/^gnu//; t 135 | s/^g//; t'` 136 | 137 | printf '%s\n' "'$1' is $msg." 138 | 139 | configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140 | case $normalized_program in 141 | autoconf*) 142 | echo "You should only need it if you modified 'configure.ac'," 143 | echo "or m4 files included by it." 144 | program_details 'autoconf' 145 | ;; 146 | autoheader*) 147 | echo "You should only need it if you modified 'acconfig.h' or" 148 | echo "$configure_deps." 149 | program_details 'autoheader' 150 | ;; 151 | automake*) 152 | echo "You should only need it if you modified 'Makefile.am' or" 153 | echo "$configure_deps." 154 | program_details 'automake' 155 | ;; 156 | aclocal*) 157 | echo "You should only need it if you modified 'acinclude.m4' or" 158 | echo "$configure_deps." 159 | program_details 'aclocal' 160 | ;; 161 | autom4te*) 162 | echo "You might have modified some maintainer files that require" 163 | echo "the 'autom4te' program to be rebuilt." 164 | program_details 'autom4te' 165 | ;; 166 | bison*|yacc*) 167 | echo "You should only need it if you modified a '.y' file." 168 | echo "You may want to install the GNU Bison package:" 169 | echo "<$gnu_software_URL/bison/>" 170 | ;; 171 | lex*|flex*) 172 | echo "You should only need it if you modified a '.l' file." 173 | echo "You may want to install the Fast Lexical Analyzer package:" 174 | echo "<$flex_URL>" 175 | ;; 176 | help2man*) 177 | echo "You should only need it if you modified a dependency" \ 178 | "of a man page." 179 | echo "You may want to install the GNU Help2man package:" 180 | echo "<$gnu_software_URL/help2man/>" 181 | ;; 182 | makeinfo*) 183 | echo "You should only need it if you modified a '.texi' file, or" 184 | echo "any other file indirectly affecting the aspect of the manual." 185 | echo "You might want to install the Texinfo package:" 186 | echo "<$gnu_software_URL/texinfo/>" 187 | echo "The spurious makeinfo call might also be the consequence of" 188 | echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189 | echo "want to install GNU make:" 190 | echo "<$gnu_software_URL/make/>" 191 | ;; 192 | *) 193 | echo "You might have modified some files without having the proper" 194 | echo "tools for further handling them. Check the 'README' file, it" 195 | echo "often tells you about the needed prerequisites for installing" 196 | echo "this package. You may also peek at any GNU archive site, in" 197 | echo "case some other package contains this missing '$1' program." 198 | ;; 199 | esac 200 | } 201 | 202 | give_advice "$1" | sed -e '1s/^/WARNING: /' \ 203 | -e '2,$s/^/ /' >&2 204 | 205 | # Propagate the correct exit status (expected to be 127 for a program 206 | # not found, 63 for a program that failed due to version mismatch). 207 | exit $st 208 | 209 | # Local variables: 210 | # eval: (add-hook 'write-file-hooks 'time-stamp) 211 | # time-stamp-start: "scriptversion=" 212 | # time-stamp-format: "%:y-%02m-%02d.%02H" 213 | # time-stamp-time-zone: "UTC" 214 | # time-stamp-end: "; # UTC" 215 | # End: 216 | -------------------------------------------------------------------------------- /scripts/Makefile.am: -------------------------------------------------------------------------------- 1 | libexec_SCRIPTS = nagios_hpeilo_cfg_generator nagios_hpeilo_traps hpeilo_nagios_config hpeilo_snmp_service_set_tool 2 | -------------------------------------------------------------------------------- /scripts/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.14.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | 17 | VPATH = @srcdir@ 18 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 19 | am__make_running_with_option = \ 20 | case $${target_option-} in \ 21 | ?) ;; \ 22 | *) echo "am__make_running_with_option: internal error: invalid" \ 23 | "target option '$${target_option-}' specified" >&2; \ 24 | exit 1;; \ 25 | esac; \ 26 | has_opt=no; \ 27 | sane_makeflags=$$MAKEFLAGS; \ 28 | if $(am__is_gnu_make); then \ 29 | sane_makeflags=$$MFLAGS; \ 30 | else \ 31 | case $$MAKEFLAGS in \ 32 | *\\[\ \ ]*) \ 33 | bs=\\; \ 34 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 35 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 36 | esac; \ 37 | fi; \ 38 | skip_next=no; \ 39 | strip_trailopt () \ 40 | { \ 41 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 42 | }; \ 43 | for flg in $$sane_makeflags; do \ 44 | test $$skip_next = yes && { skip_next=no; continue; }; \ 45 | case $$flg in \ 46 | *=*|--*) continue;; \ 47 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 48 | -*I?*) strip_trailopt 'I';; \ 49 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 50 | -*O?*) strip_trailopt 'O';; \ 51 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 52 | -*l?*) strip_trailopt 'l';; \ 53 | -[dEDm]) skip_next=yes;; \ 54 | -[JT]) skip_next=yes;; \ 55 | esac; \ 56 | case $$flg in \ 57 | *$$target_option*) has_opt=yes; break;; \ 58 | esac; \ 59 | done; \ 60 | test $$has_opt = yes 61 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 62 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 63 | pkgdatadir = $(datadir)/@PACKAGE@ 64 | pkgincludedir = $(includedir)/@PACKAGE@ 65 | pkglibdir = $(libdir)/@PACKAGE@ 66 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 67 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 68 | install_sh_DATA = $(install_sh) -c -m 644 69 | install_sh_PROGRAM = $(install_sh) -c 70 | install_sh_SCRIPT = $(install_sh) -c 71 | INSTALL_HEADER = $(INSTALL_DATA) 72 | transform = $(program_transform_name) 73 | NORMAL_INSTALL = : 74 | PRE_INSTALL = : 75 | POST_INSTALL = : 76 | NORMAL_UNINSTALL = : 77 | PRE_UNINSTALL = : 78 | POST_UNINSTALL = : 79 | build_triplet = @build@ 80 | host_triplet = @host@ 81 | subdir = scripts 82 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ 83 | $(srcdir)/nagios_hpeilo_cfg_generator.in \ 84 | $(srcdir)/nagios_hpeilo_traps.in \ 85 | $(srcdir)/hpeilo_nagios_config.in \ 86 | $(srcdir)/hpeilo_snmp_service_set_tool.in 87 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 88 | am__aclocal_m4_deps = $(top_srcdir)/m4/m4-ax_compare_version.m4 \ 89 | $(top_srcdir)/configure.ac 90 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 91 | $(ACLOCAL_M4) 92 | mkinstalldirs = $(install_sh) -d 93 | CONFIG_HEADER = $(top_builddir)/config.h 94 | CONFIG_CLEAN_FILES = nagios_hpeilo_cfg_generator nagios_hpeilo_traps \ 95 | hpeilo_nagios_config hpeilo_snmp_service_set_tool 96 | CONFIG_CLEAN_VPATH_FILES = 97 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 98 | am__vpath_adj = case $$p in \ 99 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 100 | *) f=$$p;; \ 101 | esac; 102 | am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; 103 | am__install_max = 40 104 | am__nobase_strip_setup = \ 105 | srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` 106 | am__nobase_strip = \ 107 | for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" 108 | am__nobase_list = $(am__nobase_strip_setup); \ 109 | for p in $$list; do echo "$$p $$p"; done | \ 110 | sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ 111 | $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ 112 | if (++n[$$2] == $(am__install_max)) \ 113 | { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ 114 | END { for (dir in files) print dir, files[dir] }' 115 | am__base_list = \ 116 | sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ 117 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' 118 | am__uninstall_files_from_dir = { \ 119 | test -z "$$files" \ 120 | || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ 121 | || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ 122 | $(am__cd) "$$dir" && rm -f $$files; }; \ 123 | } 124 | am__installdirs = "$(DESTDIR)$(libexecdir)" 125 | SCRIPTS = $(libexec_SCRIPTS) 126 | AM_V_P = $(am__v_P_@AM_V@) 127 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 128 | am__v_P_0 = false 129 | am__v_P_1 = : 130 | AM_V_GEN = $(am__v_GEN_@AM_V@) 131 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 132 | am__v_GEN_0 = @echo " GEN " $@; 133 | am__v_GEN_1 = 134 | AM_V_at = $(am__v_at_@AM_V@) 135 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 136 | am__v_at_0 = @ 137 | am__v_at_1 = 138 | SOURCES = 139 | DIST_SOURCES = 140 | am__can_run_installinfo = \ 141 | case $$AM_UPDATE_INFO_DIR in \ 142 | n|no|NO) false;; \ 143 | *) (install-info --version) >/dev/null 2>&1;; \ 144 | esac 145 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 146 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 147 | ACLOCAL = @ACLOCAL@ 148 | AMTAR = @AMTAR@ 149 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 150 | AR = @AR@ 151 | AUTOCONF = @AUTOCONF@ 152 | AUTOHEADER = @AUTOHEADER@ 153 | AUTOMAKE = @AUTOMAKE@ 154 | AWK = @AWK@ 155 | CC = @CC@ 156 | CCDEPMODE = @CCDEPMODE@ 157 | CFLAGS = @CFLAGS@ 158 | CPP = @CPP@ 159 | CPPFLAGS = @CPPFLAGS@ 160 | CXX = @CXX@ 161 | CXXCPP = @CXXCPP@ 162 | CXXDEPMODE = @CXXDEPMODE@ 163 | CXXFLAGS = @CXXFLAGS@ 164 | CYGPATH_W = @CYGPATH_W@ 165 | DEFS = @DEFS@ 166 | DEPDIR = @DEPDIR@ 167 | DLLTOOL = @DLLTOOL@ 168 | DSYMUTIL = @DSYMUTIL@ 169 | DUMPBIN = @DUMPBIN@ 170 | ECHO_C = @ECHO_C@ 171 | ECHO_N = @ECHO_N@ 172 | ECHO_T = @ECHO_T@ 173 | EGREP = @EGREP@ 174 | EXEEXT = @EXEEXT@ 175 | FGREP = @FGREP@ 176 | GREP = @GREP@ 177 | INSTALL = @INSTALL@ 178 | INSTALL_DATA = @INSTALL_DATA@ 179 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 180 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 181 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 182 | LD = @LD@ 183 | LDFLAGS = @LDFLAGS@ 184 | LIBOBJS = @LIBOBJS@ 185 | LIBS = @LIBS@ 186 | LIBTOOL = @LIBTOOL@ 187 | LIPO = @LIPO@ 188 | LN_S = @LN_S@ 189 | LTLIBOBJS = @LTLIBOBJS@ 190 | MAKEINFO = @MAKEINFO@ 191 | MANIFEST_TOOL = @MANIFEST_TOOL@ 192 | MKDIR_P = @MKDIR_P@ 193 | NM = @NM@ 194 | NMAP_MIN_VERSION = @NMAP_MIN_VERSION@ 195 | NMAP_PATH = @NMAP_PATH@ 196 | NMEDIT = @NMEDIT@ 197 | OBJDUMP = @OBJDUMP@ 198 | OBJEXT = @OBJEXT@ 199 | OTOOL = @OTOOL@ 200 | OTOOL64 = @OTOOL64@ 201 | PACKAGE = @PACKAGE@ 202 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 203 | PACKAGE_NAME = @PACKAGE_NAME@ 204 | PACKAGE_STRING = @PACKAGE_STRING@ 205 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 206 | PACKAGE_URL = @PACKAGE_URL@ 207 | PACKAGE_VERSION = @PACKAGE_VERSION@ 208 | PATH_SEPARATOR = @PATH_SEPARATOR@ 209 | RANLIB = @RANLIB@ 210 | SED = @SED@ 211 | SET_MAKE = @SET_MAKE@ 212 | SHELL = @SHELL@ 213 | STRIP = @STRIP@ 214 | VERSION = @VERSION@ 215 | abs_builddir = @abs_builddir@ 216 | abs_srcdir = @abs_srcdir@ 217 | abs_top_builddir = @abs_top_builddir@ 218 | abs_top_srcdir = @abs_top_srcdir@ 219 | ac_ct_AR = @ac_ct_AR@ 220 | ac_ct_CC = @ac_ct_CC@ 221 | ac_ct_CXX = @ac_ct_CXX@ 222 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 223 | am__include = @am__include@ 224 | am__leading_dot = @am__leading_dot@ 225 | am__quote = @am__quote@ 226 | am__tar = @am__tar@ 227 | am__untar = @am__untar@ 228 | bindir = @bindir@ 229 | build = @build@ 230 | build_alias = @build_alias@ 231 | build_cpu = @build_cpu@ 232 | build_os = @build_os@ 233 | build_vendor = @build_vendor@ 234 | builddir = @builddir@ 235 | datadir = @datadir@ 236 | datarootdir = @datarootdir@ 237 | docdir = @docdir@ 238 | dvidir = @dvidir@ 239 | exec_prefix = @exec_prefix@ 240 | host = @host@ 241 | host_alias = @host_alias@ 242 | host_cpu = @host_cpu@ 243 | host_os = @host_os@ 244 | host_vendor = @host_vendor@ 245 | htmldir = @htmldir@ 246 | includedir = @includedir@ 247 | infodir = @infodir@ 248 | install_sh = @install_sh@ 249 | libdir = @libdir@ 250 | libexecdir = @libexecdir@ 251 | localedir = @localedir@ 252 | localstatedir = @localstatedir@ 253 | mandir = @mandir@ 254 | mkdir_p = @mkdir_p@ 255 | oldincludedir = @oldincludedir@ 256 | pdfdir = @pdfdir@ 257 | prefix = @prefix@ 258 | program_transform_name = @program_transform_name@ 259 | psdir = @psdir@ 260 | sbindir = @sbindir@ 261 | sharedstatedir = @sharedstatedir@ 262 | srcdir = @srcdir@ 263 | sysconfdir = @sysconfdir@ 264 | target_alias = @target_alias@ 265 | top_build_prefix = @top_build_prefix@ 266 | top_builddir = @top_builddir@ 267 | top_srcdir = @top_srcdir@ 268 | libexec_SCRIPTS = nagios_hpeilo_cfg_generator nagios_hpeilo_traps hpeilo_nagios_config hpeilo_snmp_service_set_tool 269 | all: all-am 270 | 271 | .SUFFIXES: 272 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 273 | @for dep in $?; do \ 274 | case '$(am__configure_deps)' in \ 275 | *$$dep*) \ 276 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 277 | && { if test -f $@; then exit 0; else break; fi; }; \ 278 | exit 1;; \ 279 | esac; \ 280 | done; \ 281 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Makefile'; \ 282 | $(am__cd) $(top_srcdir) && \ 283 | $(AUTOMAKE) --gnu scripts/Makefile 284 | .PRECIOUS: Makefile 285 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 286 | @case '$?' in \ 287 | *config.status*) \ 288 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 289 | *) \ 290 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 291 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 292 | esac; 293 | 294 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 295 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 296 | 297 | $(top_srcdir)/configure: $(am__configure_deps) 298 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 299 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 300 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 301 | $(am__aclocal_m4_deps): 302 | nagios_hpeilo_cfg_generator: $(top_builddir)/config.status $(srcdir)/nagios_hpeilo_cfg_generator.in 303 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 304 | nagios_hpeilo_traps: $(top_builddir)/config.status $(srcdir)/nagios_hpeilo_traps.in 305 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 306 | hpeilo_nagios_config: $(top_builddir)/config.status $(srcdir)/hpeilo_nagios_config.in 307 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 308 | hpeilo_snmp_service_set_tool: $(top_builddir)/config.status $(srcdir)/hpeilo_snmp_service_set_tool.in 309 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 310 | install-libexecSCRIPTS: $(libexec_SCRIPTS) 311 | @$(NORMAL_INSTALL) 312 | @list='$(libexec_SCRIPTS)'; test -n "$(libexecdir)" || list=; \ 313 | if test -n "$$list"; then \ 314 | echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ 315 | $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ 316 | fi; \ 317 | for p in $$list; do \ 318 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 319 | if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ 320 | done | \ 321 | sed -e 'p;s,.*/,,;n' \ 322 | -e 'h;s|.*|.|' \ 323 | -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ 324 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ 325 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 326 | if ($$2 == $$4) { files[d] = files[d] " " $$1; \ 327 | if (++n[d] == $(am__install_max)) { \ 328 | print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ 329 | else { print "f", d "/" $$4, $$1 } } \ 330 | END { for (d in files) print "f", d, files[d] }' | \ 331 | while read type dir files; do \ 332 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 333 | test -z "$$files" || { \ 334 | echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ 335 | $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ 336 | } \ 337 | ; done 338 | 339 | uninstall-libexecSCRIPTS: 340 | @$(NORMAL_UNINSTALL) 341 | @list='$(libexec_SCRIPTS)'; test -n "$(libexecdir)" || exit 0; \ 342 | files=`for p in $$list; do echo "$$p"; done | \ 343 | sed -e 's,.*/,,;$(transform)'`; \ 344 | dir='$(DESTDIR)$(libexecdir)'; $(am__uninstall_files_from_dir) 345 | 346 | mostlyclean-libtool: 347 | -rm -f *.lo 348 | 349 | clean-libtool: 350 | -rm -rf .libs _libs 351 | tags TAGS: 352 | 353 | ctags CTAGS: 354 | 355 | cscope cscopelist: 356 | 357 | 358 | distdir: $(DISTFILES) 359 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 360 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 361 | list='$(DISTFILES)'; \ 362 | dist_files=`for file in $$list; do echo $$file; done | \ 363 | sed -e "s|^$$srcdirstrip/||;t" \ 364 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 365 | case $$dist_files in \ 366 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 367 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 368 | sort -u` ;; \ 369 | esac; \ 370 | for file in $$dist_files; do \ 371 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 372 | if test -d $$d/$$file; then \ 373 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 374 | if test -d "$(distdir)/$$file"; then \ 375 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 376 | fi; \ 377 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 378 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 379 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 380 | fi; \ 381 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 382 | else \ 383 | test -f "$(distdir)/$$file" \ 384 | || cp -p $$d/$$file "$(distdir)/$$file" \ 385 | || exit 1; \ 386 | fi; \ 387 | done 388 | check-am: all-am 389 | check: check-am 390 | all-am: Makefile $(SCRIPTS) 391 | installdirs: 392 | for dir in "$(DESTDIR)$(libexecdir)"; do \ 393 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 394 | done 395 | install: install-am 396 | install-exec: install-exec-am 397 | install-data: install-data-am 398 | uninstall: uninstall-am 399 | 400 | install-am: all-am 401 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 402 | 403 | installcheck: installcheck-am 404 | install-strip: 405 | if test -z '$(STRIP)'; then \ 406 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 407 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 408 | install; \ 409 | else \ 410 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 411 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 412 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 413 | fi 414 | mostlyclean-generic: 415 | 416 | clean-generic: 417 | 418 | distclean-generic: 419 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 420 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 421 | 422 | maintainer-clean-generic: 423 | @echo "This command is intended for maintainers to use" 424 | @echo "it deletes files that may require special tools to rebuild." 425 | clean: clean-am 426 | 427 | clean-am: clean-generic clean-libtool mostlyclean-am 428 | 429 | distclean: distclean-am 430 | -rm -f Makefile 431 | distclean-am: clean-am distclean-generic 432 | 433 | dvi: dvi-am 434 | 435 | dvi-am: 436 | 437 | html: html-am 438 | 439 | html-am: 440 | 441 | info: info-am 442 | 443 | info-am: 444 | 445 | install-data-am: 446 | 447 | install-dvi: install-dvi-am 448 | 449 | install-dvi-am: 450 | 451 | install-exec-am: install-libexecSCRIPTS 452 | 453 | install-html: install-html-am 454 | 455 | install-html-am: 456 | 457 | install-info: install-info-am 458 | 459 | install-info-am: 460 | 461 | install-man: 462 | 463 | install-pdf: install-pdf-am 464 | 465 | install-pdf-am: 466 | 467 | install-ps: install-ps-am 468 | 469 | install-ps-am: 470 | 471 | installcheck-am: 472 | 473 | maintainer-clean: maintainer-clean-am 474 | -rm -f Makefile 475 | maintainer-clean-am: distclean-am maintainer-clean-generic 476 | 477 | mostlyclean: mostlyclean-am 478 | 479 | mostlyclean-am: mostlyclean-generic mostlyclean-libtool 480 | 481 | pdf: pdf-am 482 | 483 | pdf-am: 484 | 485 | ps: ps-am 486 | 487 | ps-am: 488 | 489 | uninstall-am: uninstall-libexecSCRIPTS 490 | 491 | .MAKE: install-am install-strip 492 | 493 | .PHONY: all all-am check check-am clean clean-generic clean-libtool \ 494 | cscopelist-am ctags-am distclean distclean-generic \ 495 | distclean-libtool distdir dvi dvi-am html html-am info info-am \ 496 | install install-am install-data install-data-am install-dvi \ 497 | install-dvi-am install-exec install-exec-am install-html \ 498 | install-html-am install-info install-info-am \ 499 | install-libexecSCRIPTS install-man install-pdf install-pdf-am \ 500 | install-ps install-ps-am install-strip installcheck \ 501 | installcheck-am installdirs maintainer-clean \ 502 | maintainer-clean-generic mostlyclean mostlyclean-generic \ 503 | mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ 504 | uninstall-am uninstall-libexecSCRIPTS 505 | 506 | 507 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 508 | # Otherwise a system limit (for SysV at least) may be exceeded. 509 | .NOEXPORT: 510 | -------------------------------------------------------------------------------- /scripts/hpeilo_nagios_config.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # hpeilo_nagios_config -- The script aims to generate nagios 3 | # configuration file for discovering the 4 | # HPE ProLiant Servers. 5 | # (C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P. 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of version 2 of the GNU General Public License as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | # 15 | # See the GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to: 19 | # Free Software Foundation, Inc. 20 | # 51 Franklin Street, Fifth Floor 21 | # Boston, MA 02110-1301, USA. 22 | # 23 | # Written by Maple Yang . 24 | 25 | CLEARSCREEN=$(/usr/bin/tput clear) 26 | Nagios_iLO_Plugins_Path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 27 | 28 | HP_iLO_NAGIOS_INTRO="The \"hpeilo_nagios_config\" configuration script will help you to create HPE iLO restful extension nagios plugin\nconfiguration file which is later can used for active/passive HPE iLO host servers discovery and configure the nagios configuration file on monitoring host.\n\nFollowing are the parameters,user has to configur to get \"nagios-hpeilo-restful-extension\" to work efficiently.\n\n" 29 | HP_iLO_NAGIOS_INTRO_1="\e[1mActive discovery: \e[0mActive discovery scans all reachable HPE iLO servers in the network of the monitoring server. This approach can discover all HPE iLO servers in a given network ip range or network subnet.\nNote: Active discovery is a time-consuming process and it depends on total number of hosts in a network subnet or IP range.\n\nYou have to enable to do active discovery in HPE iLO nagios plugin configuration file to scan all HPE iLO servers one time.\n\n" 30 | HP_iLO_NAGIOS_INTRO_2="\e[1mPassive discovery: \e[0mPassive discovery discovers HPE iLO servers once receiving the cold start traps generated by those servers.\nThe traps are generated when those servers get booted successfully, so this approach cannot discover the up and running servers.\nAlso it is required to add \"traphandle\" command and community string in \"snmptrapd.conf\" file as mentioned in the below example.\n\t\"authCommunity log,execute,net \"\n\t\"traphandle 1.3.6.1.6.3.1.1.5.1 ${Nagios_iLO_Plugins_Path}/nagios_hpeilo_cfg_generator -m 2 \n\t${Nagios_iLO_Plugins_Path}/hpeilo_nagios_config.cfg\"\n\t\"traphandle 1.3.6.1.4.1.232.0.* ${Nagios_iLO_Plugins_Path}/nagios_hpeilo_traps\".\nThe \"snmptrapd\" service will be restarted once its configured.\n\nYou have to enable Passive discovery in HPE iLO restful extension configuration file to add the HPE iLO server on receiving cold trap.\n" 31 | 32 | HP_iLO_NAGIOS_INTRO_3="\e[1mHPE iLO server Host Group: \e[0mA HPE iLO server Host Group is used to group one or more HPE iLO servers together under one group.\nIt consists of \"Group Name\",\"IP address range or Network subnet or IP address\" and \"Community string\".\nThese data are used to configure nagios \"Host Group\" Directives for simplifying configuration with display purposes.\nAn example of HPE iLO HOst Group is as below\n\t\"HOSTGROUP:HP_iLO_Group_1,192.1.10.20-192.1.10.200,public\"\n\nYou have to add at least one Host Group to discover the HPE iLO servers using any of the above mentioned discovery method.\nNote: Default generic host group will be created and the discovered HPE iLO servers will be added to this group if the discovered HPE iLO server IP does not belongs to any of the configured host groups.\n\n" 33 | 34 | HP_iLO_NAGIOS_INTRO_4="\e[1mcheck_interval: \e[0mIt is used to configure check interval of HPE iLO servers. Default value is set to 5 minute.\n\n" 35 | 36 | HP_iLO_NAGIOS_INTRO_5="\e[1mHPE iLO Credential: \e[0mHPE iLO user and password are used to send HPE iLO RESTful API request. HPE iLO RESTful API will return the services status. Make sure you have the access to the monitering HPE iLO server.\nWe recommended users to add a dedicated ilo user account with \e[1mNon\e[0m Administrator Privileges.\n\n" 37 | 38 | HP_iLO_NAGIOS_INTRO_n="You may press now to exit if needed.\n\n" 39 | HP_iLO_NAGIOS_PASSIVE_DISC_INTRO="Configuring HPE iLO restful extension for passive discovery.\nPassive discovery enable monitoring host to add a HPE iLO host server to host group on receiving SNMP cold trap.it requires adding \"traphandle\" in \"snmptrapd\" configuration file for SNMP cold trap OID and system health trap OID\n" 40 | 41 | HP_iLO_NAGIOS_ACTIVE_DISC_INTRO="Configuring HPE iLO nagios plugin for active discovery.\nActive discovery will do network scan for all the HPE iLO hosts which are configured in the host group and add to the nagios host group with respective host group name.\nIt requires to executing the \"nagios_hpeilo_cfg_generator\" script at least one time to complete the network scan for the hosts.\n" 42 | 43 | HP_iLO_NAGIOS_NET_INTERFACE_INTRO="Active discovery requires network interface to scan all HPE iLO host's over the network.\nYou can find the network interface by running the command \"ifconfig -a\".\nMake sure network interface is up and ip is mapped to the HPE iLO host group ip range specified while configuring HPE iLO host group.\n" 44 | 45 | HP_iLO_NAGIOS_HOSTS_INTRO="HPE iLO host group configuration.\nHPE iLO host groups can be created with a range of IP address or a IP address.\nYou can also create host group based on SNMP read only community string.\nDefault generic host group will be created if host group is not configured or if HPE iLO host which are discoved and not in the configured host group\nIP range will be added with default \"public\" SNMP read-only community to the default host group name.\n" 46 | 47 | HP_iLO_NAGIOS_HOSTGROUP_INTRO="HPE iLO host group configuration requires host group name, host group IP range address and SNMP read-only community string as example below.\nhost group name: Data_center-A,Note:no space allowed\nhost group valid IP range : 192.10.10.2/24 or 192.10.10.20-192.10.10.200 or 192.10.10.15 .\nValid SNMP read-only community string configured in the HPE iLO page, default value is \"public\" if not specified.\n" 48 | 49 | DEFAULT_CONFIG_FILE_NAME="hpeilo_nagios_config.cfg" 50 | CONFIG_FLAG= 51 | iLO_CFGFILE="ilo/ilo.cfg" 52 | ILOCFG= 53 | 54 | function get_hpiLO_nagios_install_path { 55 | local iLO_nagios_plugin="nagios_hpeilo_restful_engine" 56 | NAGIOS_INST_PATH="${Nagios_iLO_Plugins_Path}" 57 | #NAGIOS_INST_PATH=`find /usr/ -name $iLO_nagios_plugin | xargs dirname` 58 | #echo $NAGIOS_INST_PATH 59 | } 60 | 61 | #Function to display configuration script info message 62 | # $1 contains display message 63 | # $2 contains the TTY device node 64 | # $3 contains NOBLANK or CLSCR 65 | #always return 0 66 | 67 | function displayIntro() 68 | { 69 | if [ "$3" != "NOCLSCR" ]; then 70 | echo "$CLEARSCREEN" > $2 71 | fi 72 | #printf "$1" "" 2> $2 -exec grep -H {} \ 73 | printf "$1" 2> $2 |grep -w -oE '.{1,120}' 74 | #| sed 's/^/\t/' 75 | return 0 76 | } 77 | 78 | 79 | get_tty() 80 | { 81 | # $1 contains the ENV for tty 82 | # Return 0 when succeed 83 | TMP=/dev/tty 84 | <$TMP >/dev/null 2>&1 85 | if [ $? = 0 ]; then 86 | eval $1="$TMP" 87 | return 0 88 | fi 89 | eval $1="" 90 | return 1 91 | } 92 | 93 | get_installmode() 94 | { 95 | get_tty TMPTTY 96 | if [ ! -z "$TMPTTY" ]; then 97 | eval $1="$TMPTTY" 98 | fi 99 | } 100 | 101 | # $1 contains Data 102 | # $2 contains NOBLANK or BLANKOK 103 | # $3 contains NOSPACE or SPACEOK or YESNO 104 | validate_data () 105 | { 106 | [ $2 = "NOBLANK" -a -z "$1" ] && return 1 107 | if [ $3 = "NOSPACE" ]; then 108 | echo $ANS | egrep ' | ' >/dev/null 2>&1 109 | [ $? = 0 ] && return 2 110 | fi 111 | if [ $3 = "YESNO" ]; then 112 | if [ ! -z "`echo $ANS | tr -d 'yn'`" ]; then 113 | return 3 114 | fi 115 | fi 116 | return 0 117 | } 118 | 119 | # Verify an IP Address: 120 | function is_IP() { 121 | if [ `echo $1 | grep -o '\.' | wc -l` -ne 3 ]; then 122 | return 1; 123 | elif [ `echo $1 | tr '.' ' ' | wc -w` -ne 4 ]; then 124 | return 1; 125 | else 126 | for OCTET in `echo $1 | tr '.' ' '`; do 127 | if ! [[ $OCTET =~ ^[0-9]+$ ]]; then 128 | return 1; 129 | elif [[ $OCTET -lt 0 || $OCTET -gt 255 ]]; then 130 | return 1; 131 | fi 132 | done 133 | fi 134 | 135 | return 0; 136 | } 137 | 138 | function is_valid_range() 139 | { 140 | local bool=0 141 | local ip1= 142 | local ip2= 143 | OIFS=$IFS 144 | IFS='.' 145 | ip1=($1) 146 | ip2=($2) 147 | IFS=$OIFS 148 | #check first octet 149 | if [[ ${ip1[0]} -ne ${ip2[0]} ]]; then 150 | # echo "${ip1[0]} != ${ip2[0]}" 151 | bool=1 152 | elif [[ ${ip1[0]} -eq ${ip2[0]} ]] && [[ ${ip1[1]} -gt ${ip2[1]} ]]; then 153 | # echo "${ip1[1]} < ${ip2[1]}" 154 | bool=1 155 | elif [[ ${ip1[1]} -eq ${ip2[1]} ]] && [[ ${ip1[2]} -gt ${ip2[2]} ]]; then 156 | # echo "${ip1[2]} < ${ip2[2]}" 157 | bool=1 158 | elif [[ ${ip1[2]} -eq ${ip2[2]} ]] && [[ ${ip1[3]} -gt ${ip2[3]} ]]; then 159 | # echo "${ip1[3]} < ${ip2[3]}" 160 | bool=1 161 | fi 162 | echo $bool 163 | } 164 | 165 | 166 | function getSubnetMask() 167 | { 168 | local i 169 | local subnetmask="" 170 | local full_octets=$(($1/8)) 171 | local partial_octet=$(($1%8)) 172 | for ((i=0;i<4;i+=1)); do 173 | if [ $i -lt $full_octets ]; then 174 | subnetmask+=255 175 | elif [ $i -eq $full_octets ]; then 176 | subnetmask+=$((256 - 2**(8-$partial_octet))) 177 | else 178 | subnetmask+=0 179 | fi 180 | [ $i -lt 3 ] && subnetmask+=. 181 | done 182 | 183 | echo $subnetmask 184 | } 185 | 186 | function valid_ip_range() 187 | { 188 | local ip_1=`echo $1 | awk -F '/' '{print $1}'` 189 | local ip_2=`echo $1 | awk -F '-' '{print $2}'` 190 | local subnet_mask_bits=`echo $1 | awk -F '/' '{print $2}'` 191 | local stat=1 192 | local check_range=1 193 | local ip_addr[0]=`echo $ip_1 | awk -F '-' '{print $1}'` 194 | if [ "x${ip_2}" != "x" ];then 195 | ip_addr[1]=$ip_2 196 | check_range=0 197 | elif [ "x${subnet_mask_bits}" != "x" ];then 198 | num='^[0-9]+$' 199 | if ! [[ $subnet_mask_bits =~ $num ]] ; then 200 | return 1 201 | else 202 | ip_2=$(getSubnetMask $subnet_mask_bits) 203 | fi 204 | ip_addr[1]=$ip_2 205 | fi 206 | for((idx=0;idx<${#ip_addr[@]};idx++)); do 207 | local ip=${ip_addr[$idx]} 208 | #echo $ip 209 | if is_IP $ip; then 210 | stat=0 211 | else 212 | stat=1 213 | fi 214 | done 215 | 216 | if [[ $stat -eq 0 ]] && [[ $check_range -eq 0 ]]; then 217 | stat=$(is_valid_range ${ip_addr[0]} ${ip_addr[1]}) 218 | fi 219 | 220 | return $stat 221 | } 222 | 223 | #$1 array of elements 224 | function isduplicate_value() 225 | { 226 | local stat=0 227 | local values=("$@") 228 | local num_ele=${#values[@]} 229 | if [ $num_ele -gt 1 ]; then 230 | num_ele=$(($num_ele-1)) 231 | local key=${values[$num_ele]} 232 | stat=`echo "${values[@]:0:$num_ele}" | grep -c -w "^$key"` 233 | fi 234 | return $stat 235 | } 236 | # $1 contains the user prompt 237 | # $2 contains the TTY device node 238 | # $3 contains NOBLANK or BLANKOK 239 | # $4 contains NOSPACE or SPACEOK 240 | # $5 contains ECHO or NOECHO 241 | # $6 contains CLSCR or NOCLSCR 242 | # Always return 0 243 | get_userinput () 244 | { 245 | # echo "" > $2 246 | if [ "$5" = NOECHO ]; then 247 | stty -F $2 -echo 248 | printf "\nNOTE: keyboard input echo has been turned off." > $2 249 | fi 250 | while true; do 251 | while true; do 252 | if [ "$6" != "NOCLSCR" ]; then 253 | echo "$CLEARSCREEN" > $2 254 | fi 255 | printf "$1" "" > $2 256 | read ANS < $2 257 | [ "$5" = NOECHO ] && echo "" > $2 258 | validate_data "$ANS" "$3" "$4" 259 | case "$?" in 260 | 1) 261 | continue 262 | ;; 263 | 2) 264 | echo -n "ERROR: Space and tab are not allowed, press ENTER to continue ..." > $2 265 | read ANS < $2 266 | [ "$5" = NOECHO ] && echo "" > $2 267 | continue 268 | ;; 269 | 3) 270 | echo -n "ERROR: You must type 'y' or 'n', press ENTER to continue ..." > $2 271 | read ANS < $2 272 | [ "$5" = NOECHO ] && echo "" > $2 273 | continue 274 | esac 275 | break 276 | done 277 | [ ! "$5" = NOECHO ] && break 278 | [ -z "$ANS" ] && break 279 | printf "Re-enter the same input to confirm: " > $2 280 | read ANS1 < $2 281 | echo "" > $2 282 | if [ "$ANS1" = "$ANS" ]; then 283 | printf "ACCEPTED: inputs match!\n\n" > $2 284 | break 285 | fi 286 | printf "ERROR: inputs mismatch! Press ENTER to try again." > $2 287 | read ANS < $2 288 | done 289 | if [ "$5" = NOECHO ]; then 290 | stty -F $2 echo 291 | # echo "NOTE: keyboard input echo has been turned on." > $2 292 | fi 293 | echo $ANS 294 | return 0 295 | } 296 | 297 | 298 | 299 | function cfg_passive_enable_value() 300 | { 301 | local temp=$(get_userinput "\nDo you wish to enable passive HPE iLO host discovery (y/n) (Blank is y): " $TTY BLANKOK YESNO ECHO NOCLSCR) 302 | if [ "$temp" = "n" ]; then 303 | PASSIVE_DISCOVERY=0 304 | else 305 | PASSIVE_DISCOVERY=1 306 | fi 307 | } 308 | 309 | 310 | function cfg_active_enable_value() { 311 | local temp=$(get_userinput "\nDo you wish to enable active discovery (y/n) (Blank is y): " $TTY BLANKOK YESNO ECHO NOCLSCR) 312 | if [ "$temp" = "n" ]; then 313 | ACTIVE_DISCOVERY=0 314 | else 315 | ACTIVE_DISCOVERY=1 316 | fi 317 | } 318 | 319 | function cfg_hostgroup() 320 | { 321 | local host_entries=0 322 | local flag= 323 | hostgreoup_name=() 324 | local arr_tmp_ele= 325 | #displayIntro "\n$HP_iLO_NAGIOS_HOSTS_INTRO" $TTY NOCLSCR 326 | local temp=$(get_userinput "\nDo you wish to configure host groups (y/n) (Blank is y): " $TTY BLANKOK YESNO ECHO NOCLSCR) 327 | if [ "$temp" != "n" ]; then 328 | displayIntro "\n$HP_iLO_NAGIOS_HOSTGROUP_INTRO" $TTY NOCLSCR 329 | while true; do 330 | while true;do 331 | hostgreoup_name[$host_entries]=$(get_userinput "\nEnter host group name: " $TTY NOBLANK NOSPACE ECHO NOCLSCR) 332 | arr_tmp_ele=${hostgreoup_name[$host_entries]} 333 | if isduplicate_value ${hostgreoup_name[@]}; then 334 | break 335 | else 336 | displayIntro "\n\t\"$arr_tmp_ele\" is already exists" $TTY NOCLSCR 337 | fi 338 | done 339 | while true; do 340 | hostgroup_ip[$host_entries]=$(get_userinput "\nEnter host group \"${hostgreoup_name[$host_entries]}\" IP range: " $TTY NOBLANK NOSPACE ECHO NOCLSCR) 341 | if valid_ip_range $hostgroup_ip; then 342 | arr_tmp_ele=${hostgroup_ip[$host_entries]} 343 | if isduplicate_value ${hostgroup_ip[@]}; then 344 | break; 345 | else 346 | displayIntro "\n\t\"$arr_tmp_ele\" is already exists" $TTY NOCLSCR 347 | fi 348 | 349 | else 350 | displayIntro "\n\t\"${hostgroup_ip[$host_entries]}\" is not valide IP or IP range" $TTY NOCLSCR 351 | fi 352 | done 353 | hostgrp_read_comm[$host_entries]=$(get_userinput "\nEnter host group \"${hostgreoup_name[$host_entries]}\" SNMP read-only community string (Blank default value public): " $TTY BLANKOK NOSPACE NOECHO NOCLSCR) 354 | hostgrp_trap_comm[$host_entries]=$(get_userinput "\nEnter host group \"${hostgreoup_name[$host_entries]}\" SNMP Trap community string (Blank default value public): " $TTY BLANKOK NOSPACE NOECHO NOCLSCR) 355 | 356 | if [ "x${hostgrp_read_comm[$host_entries]}" = "x" ]; then 357 | hostgrp_read_comm[$host_entries]="public" 358 | fi 359 | 360 | if [ "x${hostgrp_trap_comm[$host_entries]}" = "x" ]; then 361 | hostgrp_trap_comm[$host_entries]="public" 362 | fi 363 | 364 | temp=$(get_userinput "\nDo you wish to add one more host group (y/n) (Blank is n): " $TTY BLANKOK YESNO ECHO NOCLSCR) 365 | if [ "$temp" != "y" ]; then 366 | break 367 | fi 368 | host_entries=$(($host_entries+1)) 369 | done 370 | fi 371 | 372 | } 373 | 374 | function cfg_check_interval() 375 | { 376 | while true; do 377 | temp=$(get_userinput "\nEnter host group check interval time in minutes (Blank default value - 5 minutes ): " $TTY BLANKOK NOSPACE ECHO NOCLSCR) 378 | if [ "y$temp" = "y" ]; then 379 | check_interval=5 380 | break 381 | else 382 | if [[ $temp =~ ^[0-9]+$ ]]; then 383 | check_interval=$temp 384 | break; 385 | else 386 | displayIntro "\n\t\"$temp\" is not number" $TTY NOCLSCR 387 | fi 388 | fi 389 | done 390 | 391 | } 392 | 393 | function cfg_check_ilopw() 394 | { 395 | local credit_save="credit_save" 396 | echo 397 | displayIntro "\nEnter default iLO credential you have set on the HPE iLO servers being managed.\nDefault credential will be saved for HPE iLO RESTful api request." $TTY NOCLSCR 398 | $NAGIOS_INST_PATH/$credit_save -H default 399 | 400 | # for((idx=0;idx<${#hostgreoup_name[@]};idx++)); do 401 | # temp=$(get_userinput "\nDo you wish to configure iLO Credencial for HOSTGROUP if there're different with the default iLO credential: ${hostgreoup_name[$idx]},${hostgroup_ip[$idx]} (y/n) (Blank for n):" $TTY BLANKOK NOSPACE ECHO NOCLSCR) 402 | # if [ "y$temp" = "y" ] || [ "y$temp" = "yn" ]; then 403 | # continue 404 | # else 405 | # $NAGIOS_INST_PATH/$credit_save -H ${hostgreoup_name[$idx]} 406 | # fi 407 | # done 408 | 409 | temp=$(get_userinput "\nDo you wish to configure iLO credential for single server if there're different with\n the default iLO credential (y/n) (Blank is n): " $TTY BLANKOK NOSPACE ECHO NOCLSCR) 410 | while true; do 411 | if [ "y$temp" = "y" ] || [ "y$temp" = "yn" ]; then 412 | printf "\nPlease run \"$NAGIOS_INST_PATH/$credit_save -H [default|\$hostip]\" script manually to set\niLO credential for default account or single server, if you wish to add individual credentical info.\n" 2>$TTY 413 | break 414 | else 415 | while true; do 416 | temp=$(get_userinput "\nEnter HPE iLO IP: " $TTY BLANKOK NOSPACE ECHO NOCLSCR) 417 | if [ "y$temp" != "y" ]; then 418 | $NAGIOS_INST_PATH/$credit_save -H $temp 419 | break 420 | fi 421 | done 422 | fi 423 | temp=$(get_userinput "\nDo you wish to set credential for one more host (y/n) (Blank is n):" $TTY BLANKOK NOSPACE ECHO NOCLSCR) 424 | done 425 | } 426 | 427 | function write_config_file { 428 | local config_gen_file="nagios_hpeilo_cfg_generator" 429 | get_hpiLO_nagios_install_path 430 | if [ -f $NAGIOS_INST_PATH/$config_gen_file ]; then 431 | if [ "$1" = "" ]; then 432 | nagios_hpilo_cfg_file=$NAGIOS_INST_PATH/$DEFAULT_CONFIG_FILE_NAME 433 | else 434 | if [[ $CONFIG_FLAG == "1" ]]; then 435 | nagios_hpilo_cfg_file=$NAGIOS_INST_PATH/$USER_CONFIG_FILE_NAME.cfg 436 | else 437 | nagios_hpilo_cfg_file=$NAGIOS_INST_PATH/$USER_CONFIG_FILE_NAME 438 | fi 439 | fi 440 | 441 | echo -e "\n" 442 | echo -e "\t\t**************Configured Data****************" 443 | echo -e "\t\t PASSIVE_DISCOVERY $PASSIVE_DISCOVERY" 444 | echo -e "\t\t ACTIVE_DISCOVERY $ACTIVE_DISCOVERY" 445 | for((idx=0;idx<${#hostgreoup_name[@]};idx++)); do 446 | echo -e "\t\t HOSTGROUP: ${hostgreoup_name[$idx]},${hostgroup_ip[$idx]},${hostgrp_read_comm[$idx]},${hostgrp_trap_comm[$idx]}" 447 | done 448 | 449 | echo -e "\t\t CHECK_INTERVAL $check_interval" 450 | echo -e "\t\t*********************************************" 451 | local tmp=$(get_userinput "\nDo you wish to write above configured data to host-group configuration file. (y/n) (Blank is y):" $TTY BLANKOK YESNO ECHO NOCLSCR) 452 | 453 | if [ "$tmp" != "n" ]; then 454 | touch $nagios_hpilo_cfg_file 455 | echo "PASSIVE_DISCOVERY $PASSIVE_DISCOVERY" > $nagios_hpilo_cfg_file 456 | echo "ACTIVE_DISCOVERY $ACTIVE_DISCOVERY" >> $nagios_hpilo_cfg_file 457 | for((idx=0;idx<${#hostgreoup_name[@]};idx++)); do 458 | echo "HOSTGROUP: ${hostgreoup_name[$idx]},${hostgroup_ip[$idx]},${hostgrp_read_comm[$idx]},${hostgrp_trap_comm[$idx]}" >> $nagios_hpilo_cfg_file 459 | done 460 | echo "CHECK_INTERVAL $check_interval" >> $nagios_hpilo_cfg_file 461 | displayIntro "\nHPE iLO host-group configuration file saved at $nagios_hpilo_cfg_file.\n" $TTY NOCLSCR 462 | else 463 | echo "Run configuration 'hpeilo_nagios_config' script to setup passive/active discovery" 464 | exit 1 465 | fi 466 | #Check ilo.cfg 467 | Chk_iLOCfgFile 468 | local temp=$(get_userinput "\nDo you wish to run configuration file to complete the process (y/n) (Blank is y): " $TTY BLANKOK YESNO ECHO NOCLSCR) 469 | if [ "$temp" != "n" ]; then 470 | displayIntro "\nRunning configuration file ....\n" $TTY NOCLSCR 471 | if [ "$ILOCFG" = "1" ]; then 472 | $NAGIOS_INST_PATH/$config_gen_file -m 3 -s $nagios_hpilo_cfg_file 473 | printf "\nYou can find the old ilo.cfg file in $nagios_conf_path/ilo/.backup folder.\n" 474 | else 475 | $NAGIOS_INST_PATH/$config_gen_file -m 3 -s $nagios_hpilo_cfg_file -o 476 | fi 477 | else 478 | if [ "$ILOCFG" = "1" ]; then 479 | printf "\nPlease run \"$NAGIOS_INST_PATH/$config_gen_file -m 3 -s $nagios_hpilo_cfg_file \" \nscript manualy to complete the configuration\n" 2>$TTY 480 | else 481 | printf "\nPlease run \"$NAGIOS_INST_PATH/$config_gen_file -m 3 -s $nagios_hpilo_cfg_file -o\" \nscript manualy to complete the configuration\n" 2>$TTY 482 | fi 483 | fi 484 | else 485 | echo 486 | echo "HPE iLO nagios plugin not installed.Please install and configure." 487 | fi 488 | } 489 | function display_all_intru() 490 | { 491 | displayIntro "$HP_iLO_NAGIOS_INTRO" $TTY CLSCR 492 | echo 493 | displayIntro "$HP_iLO_NAGIOS_INTRO_1" $TTY NOCLSCR 494 | echo 495 | displayIntro "$HP_iLO_NAGIOS_INTRO_2" $TTY NOCLSCR 496 | echo 497 | displayIntro "$HP_iLO_NAGIOS_INTRO_3" $TTY NOCLSCR 498 | echo 499 | displayIntro "$HP_iLO_NAGIOS_INTRO_4" $TTY NOCLSCR 500 | echo 501 | displayIntro "$HP_iLO_NAGIOS_INTRO_5" $TTY NOCLSCR 502 | echo 503 | displayIntro "$HP_iLO_NAGIOS_INTRO_n" $TTY NOCLSCR 504 | 505 | } 506 | 507 | function get_nagios_cfg_file() { 508 | local nagios_cfg= 509 | 510 | 511 | # The format might be like: 512 | # 1) NagiosIloCfgFile=${prefix}/etc/nagios.cfg 513 | # 2) NAGIOSCFG="/etc/nagios3/nagios.cfg" 514 | nagios_cfg=`grep -E "=.*etc.*nagios.cfg" /etc/init.d/nagios* | \ 515 | cut -d '=' -f 2` 516 | 517 | # trim double quotes 518 | nagios_cfg=`echo $nagios_cfg | tr -d '"'` 519 | 520 | if [[ $nagios_cfg = *prefix* ]]; then 521 | # The /etc/init.d/nagios* has the fomrat like this: 522 | # NagiosIloCfgFile=${prefix}/etc/nagios.cfg 523 | # So, we need to replace ${prefix} with the actual value 524 | 525 | # Find the nagios prefix path 526 | local nagios_prefix=`grep -i "^prefix=" /etc/init.d/nagios* | \ 527 | cut -d '=' -f 2` 528 | 529 | # ${prefix}/etc/nagios.cfg -> will be etc/nagios.cfg 530 | local nagios_suffix=`echo $nagios_cfg | cut -d '/' -f 2-` 531 | 532 | nagios_cfg="${nagios_prefix}/$nagios_suffix" 533 | nagios_cfg=`echo $nagios_cfg | sed -r 's/\/\//\//g'` 534 | fi 535 | 536 | echo "$nagios_cfg" 537 | 538 | } 539 | 540 | #Check ilo.cfg file exist or not 541 | function Chk_iLOCfgFile() 542 | { 543 | local nagios_cfg=$(get_nagios_cfg_file) 544 | 545 | nagios_conf_path=`dirname $nagios_cfg` 546 | 547 | if [ -f $nagios_conf_path/$iLO_CFGFILE ]; then 548 | local tmp=$(get_userinput "\nHPE iLO Hosts/Services discovered configuration file is existing:$nagios_conf_path/$iLO_CFGFILE\nDo you wish to replace it?(y/n) (Blank is y): " $TTY BLANKOK YESNO ECHO NOCLSCR) 549 | fi 550 | if [[ "$tmp" = "n" ]]; then 551 | ILOCFG=1 #update the ilo.cfg file 552 | fi 553 | } 554 | 555 | function chk_cfg_file() 556 | { 557 | local iLO_nagios_cfg_plugin="nagios_hpeilo_cfg_generator" 558 | get_hpiLO_nagios_install_path 559 | if [ -f $NAGIOS_INST_PATH/$DEFAULT_CONFIG_FILE_NAME ]; then 560 | local temp=$(get_userinput "\nDefault: \"$DEFAULT_CONFIG_FILE_NAME\" Already Exists.\nDo you wish to replace it? (y/n)(Blank is n): " $TTY BLANKOK YESNO ECHO NOCLSCR) 561 | if [ "$temp" != "y" ]; then 562 | echo "Enter new config file name [Note: No space allowed]" 563 | 564 | while read USER_CONFIG_FILE_NAME 565 | do 566 | # ignore the space line 567 | if [ "x${USER_CONFIG_FILE_NAME}" = "x" ]; then 568 | continue 569 | fi 570 | 571 | # ignore the comment lines 572 | if [ "x$(echo -n $USER_CONFIG_FILE_NAME | grep -E \"^#\")" != "x" ]; then 573 | echo "Special characters are not allowed " 574 | continue 575 | fi 576 | 577 | if [ -f "$USER_CONFIG_FILE_NAME" ] 578 | then 579 | echo "The file '$USER_CONFIG_FILE_NAME' exists.Try another name" 580 | continue 581 | else 582 | break 583 | fi 584 | done 585 | if [[ $USER_CONFIG_FILE_NAME != "*.cfg" ]]; then 586 | CONFIG_FLAG=1 587 | fi 588 | main_func 589 | write_config_file $USER_CONFIG_FILE_NAME 590 | 591 | else 592 | cat /dev/null > $NAGIOS_INST_PATH/$DEFAULT_CONFIG_FILE_NAME 593 | main_func 594 | write_config_file 595 | fi 596 | else 597 | main_func 598 | write_config_file 599 | fi 600 | } 601 | 602 | function main_func() 603 | { 604 | cfg_passive_enable_value 605 | cfg_active_enable_value 606 | cfg_hostgroup 607 | cfg_check_interval 608 | cfg_check_ilopw 609 | } 610 | 611 | #main 612 | echo $COLUMNS 613 | get_installmode TTY 614 | display_all_intru 615 | chk_cfg_file 616 | -------------------------------------------------------------------------------- /scripts/hpeilo_snmp_service_set_tool.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright 2016 Hewlett Packard Enterprise Development Company, L.P. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | # not use this file except in compliance with the License. You may obtain 6 | # a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | # License for the specific language governing permissions and limitations 14 | # under the License. 15 | 16 | import ssl 17 | import urllib2 18 | from urlparse import urlparse 19 | import httplib 20 | import base64 21 | import json 22 | import hashlib 23 | import gzip 24 | import StringIO 25 | import sys 26 | from ctypes import * 27 | import os 28 | 29 | # REST operation generic handler 30 | def rest_op(operation, host, suburi, request_headers, request_body, ilocred, x_auth_token=None, enforce_SSL=True): 31 | 32 | url = urlparse('https://' + host + suburi) 33 | #url = urlparse('http://' + host + suburi) 34 | 35 | if request_headers is None: 36 | request_headers = dict() 37 | # if X-Auth-Token specified, supply it instead of basic auth 38 | if x_auth_token is not None: 39 | request_headers['X-Auth-Token'] = x_auth_token 40 | # else use iLO_loginname/iLO_password and Basic Auth 41 | elif ilocred is not None: 42 | request_headers['Authorization'] = "BASIC " + ilocred 43 | 44 | redir_count = 4 45 | while redir_count: 46 | conn = None 47 | if url.scheme == 'https': 48 | # New in Python 2.7.9, SSL enforcement is defaulted on, but can be opted-out of. 49 | # The below case is the Opt-Out condition and should be used with GREAT caution. 50 | if( sys.version_info >= (2,7,9) and 51 | enforce_SSL == False): 52 | cont=ssl.SSLContext(ssl.PROTOCOL_TLSv1) 53 | cont.verify_mode = ssl.CERT_NONE 54 | conn = httplib.HTTPSConnection(host=url.netloc, strict=True, context=cont) 55 | else: 56 | conn = httplib.HTTPSConnection(host=url.netloc, strict=True) 57 | elif url.scheme == 'http': 58 | conn = httplib.HTTPConnection(host=url.netloc, strict=True) 59 | else: 60 | assert(False) 61 | conn.request(operation, url.path, headers=request_headers, body=json.dumps(request_body)) 62 | resp = conn.getresponse() 63 | body = resp.read() 64 | 65 | # NOTE: Do not assume every HTTP operation will return a JSON body. For example, ExtendedError structures 66 | # are only required for HTTP 400 errors and are optional elsewhere as they are mostly redundant for many of the 67 | # other HTTP status code. In particular, 200 OK responses should not have to return any body. 68 | 69 | # NOTE: this makes sure the headers names are all lower cases because HTTP says they are case insensitive 70 | headers = dict((x.lower(), y) for x, y in resp.getheaders()) 71 | 72 | # Follow HTTP redirect 73 | if resp.status == 301 and 'location' in headers: 74 | url = urlparse(headers['location']) 75 | redir_count -= 1 76 | elif resp.status == 401: 77 | print('Credential Error, please update host credential by \"./credit_save -H ' + host +'\".') 78 | sys.exit(1) 79 | else: 80 | break 81 | 82 | response = dict() 83 | try: 84 | response = json.loads(body.decode('utf-8')) 85 | except ValueError: # if it doesn't decode as json 86 | # NOTE: resources may return gzipped content 87 | # try to decode as gzip (we should check the headers for Content-Encoding=gzip) 88 | try: 89 | gzipper = gzip.GzipFile(fileobj=StringIO.StringIO(body)) 90 | uncompressed_string = gzipper.read().decode('UTF-8') 91 | response = json.loads(uncompressed_string) 92 | uncompressed_string = gzipper.read().decode('UTF-8') 93 | response = json.loads(uncompressed_string) 94 | except: 95 | pass 96 | 97 | # return empty 98 | pass 99 | 100 | return resp.status, headers, response 101 | 102 | # REST GET 103 | def rest_get(host, suburi, request_headers, ilocred): 104 | return rest_op('GET', host, suburi, request_headers, None, ilocred) 105 | # NOTE: be prepared for various HTTP responses including 500, 404, etc. 106 | 107 | # REST PATCH 108 | def rest_patch(server, suburi, request_headers, request_body, ilocred): 109 | if not isinstance(request_headers, dict): request_headers = dict() 110 | request_headers['Content-Type'] = 'application/json' 111 | return rest_op('PATCH', server, suburi, request_headers, request_body, ilocred) 112 | # NOTE: be prepared for various HTTP responses including 500, 404, 202 etc. 113 | 114 | # this is a generator that returns collection members 115 | def collection(host, collection_uri, request_headers, ilocred): 116 | 117 | # get the collection 118 | status, headers, thecollection = rest_get(host, collection_uri, request_headers, ilocred) 119 | 120 | while status < 300: 121 | 122 | # verify expected type 123 | 124 | # NOTE: Because of the Redfish standards effort, we have versioned many things at 0 in anticipation of 125 | # them being ratified for version 1 at some point. So this code makes the (unguarranteed) assumption 126 | # throughout that version 0 and 1 are both legitimate at this point. Don't write code requiring version 0 as 127 | 128 | # we will bump to version 1 at some point. 129 | 130 | # hint: don't limit to version 0 here as we will rev to 1.0 at some point hopefully with minimal changes 131 | assert(get_type(thecollection) == 'Collection.0' or get_type(thecollection) == 'Collection.1') 132 | 133 | # if this collection has inline items, return those 134 | 135 | # NOTE: Collections are very flexible in how the represent members. They can be inline in the collection 136 | # as members of the 'Items' array, or they may be href links in the links/Members array. The could actually 137 | # be both. Typically, iLO implements the inline (Items) for only when the collection is read only. We have 138 | # to render it with the href links when an array contains PATCHable items because its complex to PATCH 139 | # inline collection members. 140 | # A client may wish to pass in a boolean flag favoring the href links vs. the Items in case a collection 141 | # contains both. 142 | 143 | if 'Items' in thecollection: 144 | 145 | # iterate items 146 | for item in thecollection['Items']: 147 | # if the item has a self uri pointer, supply that for convenience 148 | memberuri = None 149 | if 'links' in item and 'self' in item['links']: 150 | memberuri = item['links']['self']['href'] 151 | 152 | # Read up on Python generator functions to understand what this does. 153 | yield 200, None, item, memberuri 154 | 155 | # else walk the member links 156 | elif 'links' in thecollection and 'Member' in thecollection['links']: 157 | 158 | # iterate members 159 | for memberuri in thecollection['links']['Member']: 160 | # for each member return the resource indicated by the member link 161 | status, headers, member = rest_get(host, memberuri['href'], request_headers, ilocred) 162 | 163 | # Read up on Python generator functions to understand what this does. 164 | yield status, headers, member, memberuri['href'] 165 | 166 | # page forward if there are more pages in the collection 167 | if 'links' in thecollection and 'NextPage' in thecollection['links']: 168 | next_link_uri = collection_uri + '?page=' + str(thecollection['links']['NextPage']['page']) 169 | status, headers, thecollection = rest_get(host, next_link_uri, request_headers, ilocred) 170 | 171 | # else we are finished iterating the collection 172 | else: 173 | break 174 | 175 | # return the type of an object (down to the major version, skipping minor, and errata) 176 | def get_type(obj): 177 | typever = obj['Type'] 178 | typesplit = typever.split('.') 179 | return typesplit[0] + '.' + typesplit[1] 180 | 181 | # checks HTTP response headers for specified operation (e.g. 'GET' or 'PATCH') 182 | def operation_allowed(headers_dict, operation): 183 | if 'allow' in headers_dict: 184 | if headers_dict['allow'].find(operation) != -1: 185 | return True 186 | return False 187 | 188 | # Message registry support 189 | message_registries = {} 190 | 191 | # Build a list of decoded messages from the extended_error using the message registries 192 | # An ExtendedError JSON object is a response from the with its own schema. This function knows 193 | # how to parse the ExtendedError object and, using any loaded message registries, render an array of 194 | # plain language strings that represent the response. 195 | def render_extended_error_message_list(extended_error): 196 | messages = [] 197 | if isinstance(extended_error, dict): 198 | if 'Type' in extended_error and extended_error['Type'].startswith('ExtendedError.'): 199 | for msg in extended_error['Messages']: 200 | MessageID = msg['MessageID'] 201 | x = MessageID.split('.') 202 | registry = x[0] 203 | msgkey = x[len(x) - 1] 204 | 205 | # if the correct message registry is loaded, do string resolution 206 | if registry in message_registries: 207 | if registry in message_registries and msgkey in message_registries[registry]['Messages']: 208 | msg_dict = message_registries[registry]['Messages'][msgkey] 209 | 210 | for argn in range(0, msg_dict['NumberOfArgs']): 211 | subst = '%' + str(argn+1) 212 | msg_str = msg_str.replace(subst, str(msg['MessageArgs'][argn])) 213 | 214 | if 'Resolution' in msg_dict and msg_dict['Resolution'] != 'None': 215 | msg_str += ' ' + msg_dict['Resolution'] 216 | 217 | messages.append(msg_str) 218 | else: # no message registry, simply return the msg object in string form 219 | messages.append('Return Info: '+ str(msg)) 220 | 221 | return messages 222 | 223 | # Print a list of decoded messages from the extended_error using the message registries 224 | def print_extended_error(extended_error): 225 | messages = render_extended_error_message_list(extended_error) 226 | msgcnt = 0 227 | for msg in messages: 228 | print('\t' + msg) 229 | msgcnt += 1 230 | if msgcnt == 0: # add a spacer 231 | print 232 | 233 | def configure_SNMP(host, ilocred, snmp_mode, snmp_alerts, ReadCommunities, TrapCommunities, AlertDestinations): 234 | 235 | # for each system in the systems collection at /rest/v1/Systems 236 | for status, headers, manager, memberuri in collection(host, '/rest/v1/Managers', None, ilocred): 237 | 238 | # verify expected type 239 | # hint: don't limit to version 0 here as we will rev to 1.0 at some point hopefully with minimal changes 240 | assert(get_type(manager) == 'Manager.0' or get_type(manager) == 'Manager.1') 241 | 242 | # get the Network Service resource 243 | status, headers, network_service = rest_get(host, manager['links']['NetworkService']['href'], None, ilocred) 244 | assert(get_type(network_service) == 'ManagerNetworkService.0' or get_type(network_service) == 'ManagerNetworkService.1') 245 | 246 | # get the SNMP resource 247 | if 'SNMPService' not in network_service['links']: 248 | print('\tSNMPService not found in manager network service links') 249 | continue 250 | 251 | status, headers, snmp_service = rest_get(host, network_service['links']['SNMPService']['href'], None, ilocred) 252 | assert(get_type(snmp_service) == 'SnmpService.0' or get_type(snmp_service) == 'SnmpService.1') 253 | 254 | config = {'Mode': snmp_mode, 'AlertsEnabled': snmp_alerts, 'ReadCommunities': ReadCommunities, 'TrapCommunities': TrapCommunities, 'AlertDestinations': AlertDestinations} 255 | 256 | # perform the POST 257 | print('RESTful PATCH Request: ' + json.dumps(config) + ' to ' + network_service['links']['SNMPService']['href']) 258 | status, headers, response = rest_patch(host, network_service['links']['SNMPService']['href'], None, config, ilocred) 259 | print_extended_error(response) 260 | #assert(status == 200) 261 | if status == 200: 262 | print('Operation Successed.') 263 | else: 264 | print('Operation failed.') 265 | 266 | # Run the tests 267 | 268 | def print_help(): 269 | print(' Usage: ' + sys.argv[0] + ' iLO_ip:[*.*.*.*] snmp_setting[True|False] [snmp_read_community_string[public] snmp_trap_community_string[public]] alert_destination_ip:[*.*.*.*] ') 270 | print(' Set snmp on iLO through RESTful API. ') 271 | 272 | # commonly needed function values (typically would be passed in by argument) 273 | if __name__ == "__main__": 274 | if len(sys.argv) < 3 or len(sys.argv) > 6: 275 | print_help() 276 | sys.exit(1) 277 | else: 278 | host = sys.argv[1] 279 | snmpenable = sys.argv[2] 280 | 281 | if len(sys.argv) == 3: 282 | snmpenable = sys.argv[2] 283 | if snmpenable != 'False': 284 | print_help() 285 | sys.exit(1) 286 | 287 | if len(sys.argv) == 4: 288 | read_str = 'public' 289 | trap_str = 'public' 290 | alertdest = sys.argv[3] 291 | 292 | if len(sys.argv) > 4: 293 | read_str = sys.argv[3] 294 | trap_str = sys.argv[4] 295 | alertdest = sys.argv[5] 296 | 297 | libilo = cdll.LoadLibrary(os.getcwd() + '/libilocrst.so') 298 | get_cred = libilo.get_cred 299 | get_cred.argtypes = [POINTER(c_char)] 300 | get_cred.restype = c_char_p 301 | ilocred = get_cred(host) 302 | 303 | if ilocred == '': 304 | print('Please check if host credential is saved.') 305 | sys.exit(1) 306 | 307 | # SNMP Configuration 308 | #if False: 309 | if snmpenable == 'True': 310 | configure_SNMP(host, ilocred, snmp_mode='Agentless', snmp_alerts=True, ReadCommunities=[read_str], TrapCommunities=[trap_str], AlertDestinations=[alertdest]) 311 | else: 312 | configure_SNMP(host, ilocred, snmp_mode='Agentless', snmp_alerts=True, ReadCommunities=[''],TrapCommunities=[''],AlertDestinations=['']) 313 | -------------------------------------------------------------------------------- /scripts/nagios_hpeilo_traps.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # nagios_hpeilo_traps -- The script aims to collect the SNMP traps 4 | # received from HPE ProLiant Server and to 5 | # update the corresponding status in real-time 6 | # 7 | # (C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of version 2 of the GNU General Public License as 11 | # published by the Free Software Foundation. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | # 17 | # See the GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to: 21 | # Free Software Foundation, Inc. 22 | # 51 Franklin Street, Fifth Floor 23 | # Boston, MA 02110-1301, USA. 24 | # 25 | # Written by Maple Yang . 26 | 27 | prefix=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 28 | 29 | NagiosLibexec="${prefix}" 30 | NagiosHpiloEngine="nagios_hpeilo_restful_engine" 31 | 32 | HpiloLogFile="/var/log/nagios_hpeilo_traps.log" 33 | HpiloServices=("System Status" "Fans" "Memory" "Network" "Power Supplies" "Processors" "Storage" "Temperatures") 34 | Status_Array_Element=("System Status" "Total Aggregate" "Processors" "Memory" "Fans" "Temperatures" "Power Supplies" "ProLiant Logs" "ASR" "Storage" "SCSI" "Storage Enclosures" "IDE" "FC" "Network" "MP") 35 | 36 | #declare -A status_key_value 37 | #status_key_value["NA"]=3 38 | #status_key_value+=( ["Other"]=3 ["OK"]=0 ["WARNING"]=1 ["Critical"]=2 ) 39 | 40 | declare -i RestfulSystem_index 41 | RestfulSystem_index=(0 2 5) 42 | 43 | declare -i RestfulThermal_index 44 | RestfulThermal_index=(1 7) 45 | 46 | SnmpTrapOid="iso.3.6.1.6.3.1.1.4.1.0" 47 | 48 | HlthStatusChgTrap="HlthStuatsChangeTrap" 49 | 50 | function get_hlth_service_type () { 51 | case $1 in 52 | 603[5-9] | 6055 ) # Fan Group Trap 53 | echo "${HpiloServices[1]}" 54 | ;; 55 | 603[0-4] | 604[8-9] | 6050 | 605[4-5] ) # Power Supply Group Trap 56 | echo "${HpiloServices[4]}" 57 | ;; 58 | 604[0-2] ) # Temperature Group Trap 59 | echo "${HpiloServices[7]}" 60 | ;; 61 | 602[3-4] ) # Processors Group Trap 62 | echo "${HpiloServices[5]}" 63 | ;; 64 | 11020 ) # Health Status Array Change Trap 65 | echo "$HlthStatusChgTrap" 66 | ;; 67 | *) 68 | echo "None" 69 | ;; 70 | esac 71 | } 72 | 73 | # argument 1 ($1): the iLO IP which generated the trap this time 74 | # argument 2 ($2): service type 75 | # argument 3 ($3): service status (NAGIOS_OK or NAGIOS_WARNING or ...) 76 | # argument 4 ($4): status information 77 | function nagios_passive_check () { 78 | 79 | 80 | write_log "PROCESS_SERVICE_CHECK_RESULT;$1;$2;$3;$4" 81 | 82 | now=$((`date +%s`)) 83 | printf "[%lu] PROCESS_SERVICE_CHECK_RESULT;$1;$2;$3;$4\n" $now > $NagiosCmdFile 84 | 85 | } 86 | 87 | # argument 1 ($1): The data to be logged 88 | function write_log () { 89 | if [ "$VerboseMode" = "1" ] 90 | then 91 | echo -e "[`date "+%b %d %T"`] $1" >> $HpiloLogFile 92 | fi 93 | } 94 | 95 | function get_nagios_cfg_file() { 96 | local nagios_cfg= 97 | 98 | 99 | # The format might be like: 100 | # 1) NagiosIloCfgFile=${prefix}/etc/nagios.cfg 101 | # 2) NAGIOSCFG="/etc/nagios3/nagios.cfg" 102 | nagios_cfg=`grep -E "=.*etc.*nagios.cfg" /etc/init.d/nagios* | \ 103 | cut -d '=' -f 2` 104 | 105 | # trim double quotes 106 | nagios_cfg=`echo $nagios_cfg | tr -d '"'` 107 | 108 | if [[ $nagios_cfg = *prefix* ]]; then 109 | # The /etc/init.d/nagios* has the fomrat like this: 110 | # NagiosIloCfgFile=${prefix}/etc/nagios.cfg 111 | # So, we need to replace ${prefix} with the actual value 112 | 113 | # Find the nagios prefix path 114 | local nagios_prefix=`grep -i "^prefix=" /etc/init.d/nagios* | \ 115 | cut -d '=' -f 2` 116 | 117 | # ${prefix}/etc/nagios.cfg -> will be etc/nagios.cfg 118 | local nagios_suffix=`echo $nagios_cfg | cut -d '/' -f 2-` 119 | 120 | nagios_cfg="${nagios_prefix}/$nagios_suffix" 121 | fi 122 | 123 | echo "$nagios_cfg" 124 | 125 | } 126 | 127 | function get_nagios_ilo_cfg_path() { 128 | local nagios_cfg=$(get_nagios_cfg_file) 129 | local nagios_path=`dirname $nagios_cfg` 130 | local NagiosIloCfgFile="$nagios_path/ilo/ilo.cfg" 131 | echo $NagiosIloCfgFile 132 | } 133 | 134 | # argument 1 ($1): the iLO IP which generated the trap this time 135 | # argument 2 ($2): the iLO IP trap number 136 | # argument 3 ($3): service type 137 | function update_hlth_status () { 138 | local nagios_cfg_file=$(get_nagios_cfg_file) 139 | local oid_idx= 140 | local nagios_service_status= 141 | 142 | write_log "$nagios_cfg_file" 143 | 144 | NagiosCmdFile=`grep -r command_file $nagios_cfg_file | \ 145 | awk -F = '{print $2}'` 146 | 147 | 148 | for((idx=0;idx<${#HpiloServices[@]};idx++)) 149 | do 150 | if [ "$3" = "${HpiloServices[$idx]}" ]; then 151 | oid_idx=$idx 152 | break 153 | fi 154 | done 155 | 156 | # The oid_idx must be increased by 1 since the oid index of the 157 | # NagiosHpiloEngine is started from 1 rather than 0. 158 | write_log "$NagiosLibexec/$NagiosHpiloEngine -H $IloIP -o $((oid_idx+1))" 159 | output=`$NagiosLibexec/$NagiosHpiloEngine -H $IloIP -o $((oid_idx+1)) 2>&1` 160 | 161 | nagios_service_status=$? 162 | 163 | nagios_passive_check "$1" "$2" "$nagios_service_status" "$output" 164 | 165 | 166 | } 167 | 168 | function get_status_value_by_status_key () { 169 | if [[ $1 =~ ":" ]]; then 170 | IFS=':' read -a status_key<<< "$1" 171 | else 172 | status_key=$1 173 | fi 174 | case $status_key in 175 | "OK") status_value=0 ;; 176 | "WARNING" | "Warning") status_value=1 ;; 177 | "CRITICAL" | "Critical") status_value=2 ;; 178 | "NA" | "Other") status_value=3 ;; 179 | *) status_value=3 ;; 180 | esac 181 | return $status_value 182 | } 183 | # argument 1 ($1): the iLO IP 184 | # argument 2 ($2): the iLO IP RO community string 185 | function update_hlth_status_from_status_array () { 186 | local nagios_cfg_file=$(get_nagios_cfg_file) 187 | local oid_idx=$2 188 | local curr_oid_idx=$2 189 | local curr_odi_status= 190 | local curr_oid_disc= 191 | nagios_service_status=0 192 | local hlth_array_count=0 193 | write_log "$nagios_cfg_file" 194 | 195 | NagiosCmdFile=`grep -r command_file $nagios_cfg_file | \ 196 | awk -F = '{print $2}'` 197 | 198 | 199 | # The oid_idx must be increased by 1 since the oid index of the 200 | # NagiosHpiloEngine is started from 1 rather than 0. 201 | if (( $curr_oid_idx < 3 )); then 202 | write_log "$NagiosLibexec/$NagiosHpiloEngine -H $1 -o $((oid_idx))" 203 | output=`$NagiosLibexec/$NagiosHpiloEngine -H $1 -o $oid_idx 2>&1` 204 | nagios_service_status=$? 205 | 206 | write_log "${HpiloServices[0]} nagios_service_status : $nagios_service_status - $output" 207 | IFS=';' read -a hlth_status_array <<< "$output" 208 | hlth_array_count=${#hlth_status_array[@]} 209 | #echo "hlth_array : $hlth_array_count : ${hlth_status_array[@]}" 210 | item=1 211 | output=${hlth_status_array[0]} 212 | #nagios_service_status=${status_key_value[$output]} 213 | get_status_value_by_status_key $output 214 | nagios_service_status=$? 215 | 216 | if (( $hlth_array_count < 2 )); then 217 | status_key=${hlth_status_array[0]} 218 | #status_value=${status_key_value["Other"]} 219 | get_status_value_by_status_key "Other" 220 | status_value=$? 221 | write_log "status_key : $status_key" 222 | item=$hlth_array_count 223 | else 224 | while (( $item < $hlth_array_count )) 225 | do 226 | write_log "hlth_array_count : $hlth_array_count" 227 | status_key=${hlth_status_array[$item]} 228 | #status_value=${status_key_value[$status_key]} 229 | if [[ "x$status_key" != "x" ]]; then 230 | get_status_value_by_status_key $status_key 231 | status_value=$? 232 | else 233 | status_key="Check iLO credit is correct saved.(/usr/local/nagios/libexec/credit_save -H $1)" 234 | status_value=3 235 | fi 236 | #echo "$status_key :$status_value" 237 | if (( $curr_oid_idx == 1 )); then 238 | if [[ "$status_value" != "0" ]] || (( ${RestfulSystem_index[$item]} == 2 )); then 239 | status_key=`$NagiosLibexec/$NagiosHpiloEngine -H $1 -o $((${RestfulSystem_index[$item]}+1)) 2>&1` 240 | nagios_passive_check "$1" "${HpiloServices[${RestfulSystem_index[$item]}]}" "$status_value" "$status_key" 241 | else 242 | #echo nagios_passive_check "$1 ${HpiloServices[${RestfulSystem_index[$item]}]} $status_value $status_key" 243 | nagios_passive_check "$1" "${HpiloServices[${RestfulSystem_index[$item]}]}" "$status_value" "$status_key" 244 | fi 245 | 246 | elif (( $curr_oid_idx == 2 )); then 247 | #echo nagios_passive_check "$1 ${HpiloServices[${RestfulThermal_index[$item]}]} $status_value $status_key" 248 | nagios_passive_check "$1" "${HpiloServices[${RestfulThermal_index[$item]}]}" "$status_value" "$status_key" 249 | fi 250 | sleep 0.001 251 | item=$(($item+1)) 252 | done 253 | fi 254 | else 255 | write_log "$NagiosLibexec/$NagiosHpiloEngine -H $1 -o $oid_idx" 256 | output=`$NagiosLibexec/$NagiosHpiloEngine -H $1 -o $oid_idx 2>&1` 257 | nagios_service_status=$? 258 | if (( $nagios_service_status == 3 )) && [[ "x$output" == "x" ]]; then 259 | if (( $oid_idx == 4 )); then 260 | output="Other: Not implemented" 261 | elif (( $oid_idx == 5 )); then 262 | output="Other: Verify status on OA for Power Supplies of blade server" 263 | fi 264 | fi 265 | 266 | fi 267 | 268 | } 269 | 270 | 271 | # $1: file name 272 | # $2: search pattern 273 | function search_string() { 274 | local str= 275 | 276 | if [ -f $1 ]; then 277 | str=`grep "$2" -A 1 $1` 278 | fi 279 | echo $str 280 | } 281 | 282 | #start here 283 | 284 | VerboseMode=0 285 | ActiveMode=0 286 | 287 | 288 | # parse the arguments 289 | while [ "x$1" != "x" ]; do 290 | option=$1 291 | 292 | case $option in 293 | -H) 294 | 295 | # Get the Host IP 296 | shift 297 | 298 | host_ip=$1 299 | ;; 300 | 301 | -o) 302 | # Get the OID 303 | shift 304 | oid_id=$1 305 | 306 | ;; 307 | 308 | -v) 309 | # enable verbose mode 310 | VerboseMode=1 311 | ;; 312 | 313 | -A) 314 | # Active mode: Get Health Status Array and Update to web page 315 | ActiveMode=1 316 | ;; 317 | *) 318 | echo "ERROR: unknown option $option" 319 | 320 | exit 1 321 | ;; 322 | 323 | esac 324 | shift 325 | done 326 | 327 | 328 | if [ "$ActiveMode" = "0" ] 329 | then 330 | 331 | read IloIP 332 | read protocol 333 | 334 | # Get the iLO trap ID 335 | while read oid val 336 | do 337 | if [ "$oid" = "$SnmpTrapOid" ]; then 338 | # get the iLO trap ID 339 | IloTrapNumber=`echo $val | awk -F . '{print $NF}'` 340 | break; 341 | fi 342 | done 343 | 344 | 345 | ServiceType=$(get_hlth_service_type $IloTrapNumber) 346 | 347 | write_log "ilo_ip: $IloIP trap_number: $IloTrapNumber, type: $ServiceType" 348 | 349 | 350 | NagiosIloCfgFile=$(get_nagios_ilo_cfg_path) 351 | has_configured=$(search_string $NagiosIloCfgFile $IloIP) 352 | 353 | if [ "$ServiceType" != "None" ] 354 | then 355 | 356 | if [ "$ServiceType" != "$HlthStatusChgTrap" ] 357 | then 358 | update_hlth_status $IloIP $IloTrapNumber "$ServiceType" 359 | fi 360 | 361 | # update system health status 362 | update_hlth_status $IloIP $IloTrapNumber "${HpiloServices[0]}" 363 | fi 364 | else 365 | 366 | write_log "host_ip : $host_ip oid_idx: $oid_id" 367 | #if [ "$oid_id" = "1" ]; then 368 | write_log "Active Schedule Mode" 369 | update_hlth_status_from_status_array $host_ip $oid_id 370 | if [[ "x$output" != "x" ]]; then 371 | printf "$output\n" 372 | exit $nagios_service_status 373 | else 374 | printf "Check iLO credit is correct saved.($NagiosLibexec/credit_save -H $host_ip)\n" 375 | exit 3 376 | fi 377 | #fi 378 | 379 | fi 380 | -------------------------------------------------------------------------------- /src/credit_save/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS=foreign 2 | 3 | AM_LDFLAGS = -L$(top_srcdir)/src/ilo_credit/.libs/ -lm -lilocrst -ldl -lcrypto 4 | 5 | AM_CPPFLAGS = -I$(top_srcdir)/src/include 6 | 7 | AM_CFLAGS = 8 | 9 | libexec_PROGRAMS = credit_save 10 | 11 | credit_save_SOURCES = credit_save.c 12 | -------------------------------------------------------------------------------- /src/credit_save/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.14.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | 17 | VPATH = @srcdir@ 18 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 19 | am__make_running_with_option = \ 20 | case $${target_option-} in \ 21 | ?) ;; \ 22 | *) echo "am__make_running_with_option: internal error: invalid" \ 23 | "target option '$${target_option-}' specified" >&2; \ 24 | exit 1;; \ 25 | esac; \ 26 | has_opt=no; \ 27 | sane_makeflags=$$MAKEFLAGS; \ 28 | if $(am__is_gnu_make); then \ 29 | sane_makeflags=$$MFLAGS; \ 30 | else \ 31 | case $$MAKEFLAGS in \ 32 | *\\[\ \ ]*) \ 33 | bs=\\; \ 34 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 35 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 36 | esac; \ 37 | fi; \ 38 | skip_next=no; \ 39 | strip_trailopt () \ 40 | { \ 41 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 42 | }; \ 43 | for flg in $$sane_makeflags; do \ 44 | test $$skip_next = yes && { skip_next=no; continue; }; \ 45 | case $$flg in \ 46 | *=*|--*) continue;; \ 47 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 48 | -*I?*) strip_trailopt 'I';; \ 49 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 50 | -*O?*) strip_trailopt 'O';; \ 51 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 52 | -*l?*) strip_trailopt 'l';; \ 53 | -[dEDm]) skip_next=yes;; \ 54 | -[JT]) skip_next=yes;; \ 55 | esac; \ 56 | case $$flg in \ 57 | *$$target_option*) has_opt=yes; break;; \ 58 | esac; \ 59 | done; \ 60 | test $$has_opt = yes 61 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 62 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 63 | pkgdatadir = $(datadir)/@PACKAGE@ 64 | pkgincludedir = $(includedir)/@PACKAGE@ 65 | pkglibdir = $(libdir)/@PACKAGE@ 66 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 67 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 68 | install_sh_DATA = $(install_sh) -c -m 644 69 | install_sh_PROGRAM = $(install_sh) -c 70 | install_sh_SCRIPT = $(install_sh) -c 71 | INSTALL_HEADER = $(INSTALL_DATA) 72 | transform = $(program_transform_name) 73 | NORMAL_INSTALL = : 74 | PRE_INSTALL = : 75 | POST_INSTALL = : 76 | NORMAL_UNINSTALL = : 77 | PRE_UNINSTALL = : 78 | POST_UNINSTALL = : 79 | build_triplet = @build@ 80 | host_triplet = @host@ 81 | libexec_PROGRAMS = credit_save$(EXEEXT) 82 | subdir = src/credit_save 83 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ 84 | $(top_srcdir)/depcomp 85 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 86 | am__aclocal_m4_deps = $(top_srcdir)/m4/m4-ax_compare_version.m4 \ 87 | $(top_srcdir)/configure.ac 88 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 89 | $(ACLOCAL_M4) 90 | mkinstalldirs = $(install_sh) -d 91 | CONFIG_HEADER = $(top_builddir)/config.h 92 | CONFIG_CLEAN_FILES = 93 | CONFIG_CLEAN_VPATH_FILES = 94 | am__installdirs = "$(DESTDIR)$(libexecdir)" 95 | PROGRAMS = $(libexec_PROGRAMS) 96 | am_credit_save_OBJECTS = credit_save.$(OBJEXT) 97 | credit_save_OBJECTS = $(am_credit_save_OBJECTS) 98 | credit_save_LDADD = $(LDADD) 99 | AM_V_lt = $(am__v_lt_@AM_V@) 100 | am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) 101 | am__v_lt_0 = --silent 102 | am__v_lt_1 = 103 | AM_V_P = $(am__v_P_@AM_V@) 104 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 105 | am__v_P_0 = false 106 | am__v_P_1 = : 107 | AM_V_GEN = $(am__v_GEN_@AM_V@) 108 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 109 | am__v_GEN_0 = @echo " GEN " $@; 110 | am__v_GEN_1 = 111 | AM_V_at = $(am__v_at_@AM_V@) 112 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 113 | am__v_at_0 = @ 114 | am__v_at_1 = 115 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 116 | depcomp = $(SHELL) $(top_srcdir)/depcomp 117 | am__depfiles_maybe = depfiles 118 | am__mv = mv -f 119 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 120 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 121 | LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 122 | $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ 123 | $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ 124 | $(AM_CFLAGS) $(CFLAGS) 125 | AM_V_CC = $(am__v_CC_@AM_V@) 126 | am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) 127 | am__v_CC_0 = @echo " CC " $@; 128 | am__v_CC_1 = 129 | CCLD = $(CC) 130 | LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 131 | $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ 132 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ 133 | AM_V_CCLD = $(am__v_CCLD_@AM_V@) 134 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) 135 | am__v_CCLD_0 = @echo " CCLD " $@; 136 | am__v_CCLD_1 = 137 | SOURCES = $(credit_save_SOURCES) 138 | DIST_SOURCES = $(credit_save_SOURCES) 139 | am__can_run_installinfo = \ 140 | case $$AM_UPDATE_INFO_DIR in \ 141 | n|no|NO) false;; \ 142 | *) (install-info --version) >/dev/null 2>&1;; \ 143 | esac 144 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 145 | # Read a list of newline-separated strings from the standard input, 146 | # and print each of them once, without duplicates. Input order is 147 | # *not* preserved. 148 | am__uniquify_input = $(AWK) '\ 149 | BEGIN { nonempty = 0; } \ 150 | { items[$$0] = 1; nonempty = 1; } \ 151 | END { if (nonempty) { for (i in items) print i; }; } \ 152 | ' 153 | # Make sure the list of sources is unique. This is necessary because, 154 | # e.g., the same source file might be shared among _SOURCES variables 155 | # for different programs/libraries. 156 | am__define_uniq_tagged_files = \ 157 | list='$(am__tagged_files)'; \ 158 | unique=`for i in $$list; do \ 159 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 160 | done | $(am__uniquify_input)` 161 | ETAGS = etags 162 | CTAGS = ctags 163 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 164 | ACLOCAL = @ACLOCAL@ 165 | AMTAR = @AMTAR@ 166 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 167 | AR = @AR@ 168 | AUTOCONF = @AUTOCONF@ 169 | AUTOHEADER = @AUTOHEADER@ 170 | AUTOMAKE = @AUTOMAKE@ 171 | AWK = @AWK@ 172 | CC = @CC@ 173 | CCDEPMODE = @CCDEPMODE@ 174 | CFLAGS = @CFLAGS@ 175 | CPP = @CPP@ 176 | CPPFLAGS = @CPPFLAGS@ 177 | CXX = @CXX@ 178 | CXXCPP = @CXXCPP@ 179 | CXXDEPMODE = @CXXDEPMODE@ 180 | CXXFLAGS = @CXXFLAGS@ 181 | CYGPATH_W = @CYGPATH_W@ 182 | DEFS = @DEFS@ 183 | DEPDIR = @DEPDIR@ 184 | DLLTOOL = @DLLTOOL@ 185 | DSYMUTIL = @DSYMUTIL@ 186 | DUMPBIN = @DUMPBIN@ 187 | ECHO_C = @ECHO_C@ 188 | ECHO_N = @ECHO_N@ 189 | ECHO_T = @ECHO_T@ 190 | EGREP = @EGREP@ 191 | EXEEXT = @EXEEXT@ 192 | FGREP = @FGREP@ 193 | GREP = @GREP@ 194 | INSTALL = @INSTALL@ 195 | INSTALL_DATA = @INSTALL_DATA@ 196 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 197 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 198 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 199 | LD = @LD@ 200 | LDFLAGS = @LDFLAGS@ 201 | LIBOBJS = @LIBOBJS@ 202 | LIBS = @LIBS@ 203 | LIBTOOL = @LIBTOOL@ 204 | LIPO = @LIPO@ 205 | LN_S = @LN_S@ 206 | LTLIBOBJS = @LTLIBOBJS@ 207 | MAKEINFO = @MAKEINFO@ 208 | MANIFEST_TOOL = @MANIFEST_TOOL@ 209 | MKDIR_P = @MKDIR_P@ 210 | NM = @NM@ 211 | NMAP_MIN_VERSION = @NMAP_MIN_VERSION@ 212 | NMAP_PATH = @NMAP_PATH@ 213 | NMEDIT = @NMEDIT@ 214 | OBJDUMP = @OBJDUMP@ 215 | OBJEXT = @OBJEXT@ 216 | OTOOL = @OTOOL@ 217 | OTOOL64 = @OTOOL64@ 218 | PACKAGE = @PACKAGE@ 219 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 220 | PACKAGE_NAME = @PACKAGE_NAME@ 221 | PACKAGE_STRING = @PACKAGE_STRING@ 222 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 223 | PACKAGE_URL = @PACKAGE_URL@ 224 | PACKAGE_VERSION = @PACKAGE_VERSION@ 225 | PATH_SEPARATOR = @PATH_SEPARATOR@ 226 | RANLIB = @RANLIB@ 227 | SED = @SED@ 228 | SET_MAKE = @SET_MAKE@ 229 | SHELL = @SHELL@ 230 | STRIP = @STRIP@ 231 | VERSION = @VERSION@ 232 | abs_builddir = @abs_builddir@ 233 | abs_srcdir = @abs_srcdir@ 234 | abs_top_builddir = @abs_top_builddir@ 235 | abs_top_srcdir = @abs_top_srcdir@ 236 | ac_ct_AR = @ac_ct_AR@ 237 | ac_ct_CC = @ac_ct_CC@ 238 | ac_ct_CXX = @ac_ct_CXX@ 239 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 240 | am__include = @am__include@ 241 | am__leading_dot = @am__leading_dot@ 242 | am__quote = @am__quote@ 243 | am__tar = @am__tar@ 244 | am__untar = @am__untar@ 245 | bindir = @bindir@ 246 | build = @build@ 247 | build_alias = @build_alias@ 248 | build_cpu = @build_cpu@ 249 | build_os = @build_os@ 250 | build_vendor = @build_vendor@ 251 | builddir = @builddir@ 252 | datadir = @datadir@ 253 | datarootdir = @datarootdir@ 254 | docdir = @docdir@ 255 | dvidir = @dvidir@ 256 | exec_prefix = @exec_prefix@ 257 | host = @host@ 258 | host_alias = @host_alias@ 259 | host_cpu = @host_cpu@ 260 | host_os = @host_os@ 261 | host_vendor = @host_vendor@ 262 | htmldir = @htmldir@ 263 | includedir = @includedir@ 264 | infodir = @infodir@ 265 | install_sh = @install_sh@ 266 | libdir = @libdir@ 267 | libexecdir = @libexecdir@ 268 | localedir = @localedir@ 269 | localstatedir = @localstatedir@ 270 | mandir = @mandir@ 271 | mkdir_p = @mkdir_p@ 272 | oldincludedir = @oldincludedir@ 273 | pdfdir = @pdfdir@ 274 | prefix = @prefix@ 275 | program_transform_name = @program_transform_name@ 276 | psdir = @psdir@ 277 | sbindir = @sbindir@ 278 | sharedstatedir = @sharedstatedir@ 279 | srcdir = @srcdir@ 280 | sysconfdir = @sysconfdir@ 281 | target_alias = @target_alias@ 282 | top_build_prefix = @top_build_prefix@ 283 | top_builddir = @top_builddir@ 284 | top_srcdir = @top_srcdir@ 285 | AUTOMAKE_OPTIONS = foreign 286 | AM_LDFLAGS = -L$(top_srcdir)/src/ilo_credit/.libs/ -lm -lilocrst -ldl -lcrypto 287 | AM_CPPFLAGS = -I$(top_srcdir)/src/include 288 | AM_CFLAGS = 289 | credit_save_SOURCES = credit_save.c 290 | all: all-am 291 | 292 | .SUFFIXES: 293 | .SUFFIXES: .c .lo .o .obj 294 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 295 | @for dep in $?; do \ 296 | case '$(am__configure_deps)' in \ 297 | *$$dep*) \ 298 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 299 | && { if test -f $@; then exit 0; else break; fi; }; \ 300 | exit 1;; \ 301 | esac; \ 302 | done; \ 303 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/credit_save/Makefile'; \ 304 | $(am__cd) $(top_srcdir) && \ 305 | $(AUTOMAKE) --foreign src/credit_save/Makefile 306 | .PRECIOUS: Makefile 307 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 308 | @case '$?' in \ 309 | *config.status*) \ 310 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 311 | *) \ 312 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 313 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 314 | esac; 315 | 316 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 317 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 318 | 319 | $(top_srcdir)/configure: $(am__configure_deps) 320 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 321 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 322 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 323 | $(am__aclocal_m4_deps): 324 | install-libexecPROGRAMS: $(libexec_PROGRAMS) 325 | @$(NORMAL_INSTALL) 326 | @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ 327 | if test -n "$$list"; then \ 328 | echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ 329 | $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ 330 | fi; \ 331 | for p in $$list; do echo "$$p $$p"; done | \ 332 | sed 's/$(EXEEXT)$$//' | \ 333 | while read p p1; do if test -f $$p \ 334 | || test -f $$p1 \ 335 | ; then echo "$$p"; echo "$$p"; else :; fi; \ 336 | done | \ 337 | sed -e 'p;s,.*/,,;n;h' \ 338 | -e 's|.*|.|' \ 339 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ 340 | sed 'N;N;N;s,\n, ,g' | \ 341 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ 342 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 343 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ 344 | else { print "f", $$3 "/" $$4, $$1; } } \ 345 | END { for (d in files) print "f", d, files[d] }' | \ 346 | while read type dir files; do \ 347 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 348 | test -z "$$files" || { \ 349 | echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ 350 | $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ 351 | } \ 352 | ; done 353 | 354 | uninstall-libexecPROGRAMS: 355 | @$(NORMAL_UNINSTALL) 356 | @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ 357 | files=`for p in $$list; do echo "$$p"; done | \ 358 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 359 | -e 's/$$/$(EXEEXT)/' \ 360 | `; \ 361 | test -n "$$list" || exit 0; \ 362 | echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ 363 | cd "$(DESTDIR)$(libexecdir)" && rm -f $$files 364 | 365 | clean-libexecPROGRAMS: 366 | @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ 367 | echo " rm -f" $$list; \ 368 | rm -f $$list || exit $$?; \ 369 | test -n "$(EXEEXT)" || exit 0; \ 370 | list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ 371 | echo " rm -f" $$list; \ 372 | rm -f $$list 373 | 374 | credit_save$(EXEEXT): $(credit_save_OBJECTS) $(credit_save_DEPENDENCIES) $(EXTRA_credit_save_DEPENDENCIES) 375 | @rm -f credit_save$(EXEEXT) 376 | $(AM_V_CCLD)$(LINK) $(credit_save_OBJECTS) $(credit_save_LDADD) $(LIBS) 377 | 378 | mostlyclean-compile: 379 | -rm -f *.$(OBJEXT) 380 | 381 | distclean-compile: 382 | -rm -f *.tab.c 383 | 384 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/credit_save.Po@am__quote@ 385 | 386 | .c.o: 387 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 388 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 389 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 390 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 391 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< 392 | 393 | .c.obj: 394 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 395 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 396 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 397 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 398 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 399 | 400 | .c.lo: 401 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 402 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo 403 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ 404 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 405 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< 406 | 407 | mostlyclean-libtool: 408 | -rm -f *.lo 409 | 410 | clean-libtool: 411 | -rm -rf .libs _libs 412 | 413 | ID: $(am__tagged_files) 414 | $(am__define_uniq_tagged_files); mkid -fID $$unique 415 | tags: tags-am 416 | TAGS: tags 417 | 418 | tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 419 | set x; \ 420 | here=`pwd`; \ 421 | $(am__define_uniq_tagged_files); \ 422 | shift; \ 423 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 424 | test -n "$$unique" || unique=$$empty_fix; \ 425 | if test $$# -gt 0; then \ 426 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 427 | "$$@" $$unique; \ 428 | else \ 429 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 430 | $$unique; \ 431 | fi; \ 432 | fi 433 | ctags: ctags-am 434 | 435 | CTAGS: ctags 436 | ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 437 | $(am__define_uniq_tagged_files); \ 438 | test -z "$(CTAGS_ARGS)$$unique" \ 439 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 440 | $$unique 441 | 442 | GTAGS: 443 | here=`$(am__cd) $(top_builddir) && pwd` \ 444 | && $(am__cd) $(top_srcdir) \ 445 | && gtags -i $(GTAGS_ARGS) "$$here" 446 | cscopelist: cscopelist-am 447 | 448 | cscopelist-am: $(am__tagged_files) 449 | list='$(am__tagged_files)'; \ 450 | case "$(srcdir)" in \ 451 | [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 452 | *) sdir=$(subdir)/$(srcdir) ;; \ 453 | esac; \ 454 | for i in $$list; do \ 455 | if test -f "$$i"; then \ 456 | echo "$(subdir)/$$i"; \ 457 | else \ 458 | echo "$$sdir/$$i"; \ 459 | fi; \ 460 | done >> $(top_builddir)/cscope.files 461 | 462 | distclean-tags: 463 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 464 | 465 | distdir: $(DISTFILES) 466 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 467 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 468 | list='$(DISTFILES)'; \ 469 | dist_files=`for file in $$list; do echo $$file; done | \ 470 | sed -e "s|^$$srcdirstrip/||;t" \ 471 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 472 | case $$dist_files in \ 473 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 474 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 475 | sort -u` ;; \ 476 | esac; \ 477 | for file in $$dist_files; do \ 478 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 479 | if test -d $$d/$$file; then \ 480 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 481 | if test -d "$(distdir)/$$file"; then \ 482 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 483 | fi; \ 484 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 485 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 486 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 487 | fi; \ 488 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 489 | else \ 490 | test -f "$(distdir)/$$file" \ 491 | || cp -p $$d/$$file "$(distdir)/$$file" \ 492 | || exit 1; \ 493 | fi; \ 494 | done 495 | check-am: all-am 496 | check: check-am 497 | all-am: Makefile $(PROGRAMS) 498 | installdirs: 499 | for dir in "$(DESTDIR)$(libexecdir)"; do \ 500 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 501 | done 502 | install: install-am 503 | install-exec: install-exec-am 504 | install-data: install-data-am 505 | uninstall: uninstall-am 506 | 507 | install-am: all-am 508 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 509 | 510 | installcheck: installcheck-am 511 | install-strip: 512 | if test -z '$(STRIP)'; then \ 513 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 514 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 515 | install; \ 516 | else \ 517 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 518 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 519 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 520 | fi 521 | mostlyclean-generic: 522 | 523 | clean-generic: 524 | 525 | distclean-generic: 526 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 527 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 528 | 529 | maintainer-clean-generic: 530 | @echo "This command is intended for maintainers to use" 531 | @echo "it deletes files that may require special tools to rebuild." 532 | clean: clean-am 533 | 534 | clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ 535 | mostlyclean-am 536 | 537 | distclean: distclean-am 538 | -rm -rf ./$(DEPDIR) 539 | -rm -f Makefile 540 | distclean-am: clean-am distclean-compile distclean-generic \ 541 | distclean-tags 542 | 543 | dvi: dvi-am 544 | 545 | dvi-am: 546 | 547 | html: html-am 548 | 549 | html-am: 550 | 551 | info: info-am 552 | 553 | info-am: 554 | 555 | install-data-am: 556 | 557 | install-dvi: install-dvi-am 558 | 559 | install-dvi-am: 560 | 561 | install-exec-am: install-libexecPROGRAMS 562 | 563 | install-html: install-html-am 564 | 565 | install-html-am: 566 | 567 | install-info: install-info-am 568 | 569 | install-info-am: 570 | 571 | install-man: 572 | 573 | install-pdf: install-pdf-am 574 | 575 | install-pdf-am: 576 | 577 | install-ps: install-ps-am 578 | 579 | install-ps-am: 580 | 581 | installcheck-am: 582 | 583 | maintainer-clean: maintainer-clean-am 584 | -rm -rf ./$(DEPDIR) 585 | -rm -f Makefile 586 | maintainer-clean-am: distclean-am maintainer-clean-generic 587 | 588 | mostlyclean: mostlyclean-am 589 | 590 | mostlyclean-am: mostlyclean-compile mostlyclean-generic \ 591 | mostlyclean-libtool 592 | 593 | pdf: pdf-am 594 | 595 | pdf-am: 596 | 597 | ps: ps-am 598 | 599 | ps-am: 600 | 601 | uninstall-am: uninstall-libexecPROGRAMS 602 | 603 | .MAKE: install-am install-strip 604 | 605 | .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ 606 | clean-libexecPROGRAMS clean-libtool cscopelist-am ctags \ 607 | ctags-am distclean distclean-compile distclean-generic \ 608 | distclean-libtool distclean-tags distdir dvi dvi-am html \ 609 | html-am info info-am install install-am install-data \ 610 | install-data-am install-dvi install-dvi-am install-exec \ 611 | install-exec-am install-html install-html-am install-info \ 612 | install-info-am install-libexecPROGRAMS install-man \ 613 | install-pdf install-pdf-am install-ps install-ps-am \ 614 | install-strip installcheck installcheck-am installdirs \ 615 | maintainer-clean maintainer-clean-generic mostlyclean \ 616 | mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ 617 | pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ 618 | uninstall-libexecPROGRAMS 619 | 620 | 621 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 622 | # Otherwise a system limit (for SysV at least) may be exceeded. 623 | .NOEXPORT: 624 | -------------------------------------------------------------------------------- /src/credit_save/credit_save.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /*(C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P.*/ 3 | 4 | #define CURL_STATICLIB 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "ilo-credit-store.h" 11 | #include "credit_save.h" 12 | #include "base64.h" 13 | 14 | /* The official name of this program (e.g., no 'g' prefix). */ 15 | #define PROGRAM_NAME "credit_save" 16 | #define PROGRAM_VERSION "1.0" 17 | #define MAX_RETRY_TIMES 3 18 | 19 | #define ECHOFLAGS (ECHO | ECHOE | ECHOK | ECHONL) 20 | 21 | // If option=0, set display mode close 22 | int set_disp_mode(int fd,int option) 23 | { 24 | int err; 25 | struct termios term; 26 | if(tcgetattr(fd,&term)==-1){ 27 | perror("Cannot get the attribution of the terminal"); 28 | return 1; 29 | } 30 | if(option) 31 | term.c_lflag|=ECHOFLAGS; 32 | else 33 | term.c_lflag &=~ECHOFLAGS; 34 | err=tcsetattr(fd,TCSAFLUSH,&term); 35 | if(err==-1 && err==EINTR){ 36 | perror("Cannot set the attribution of the terminal"); 37 | return 1; 38 | } 39 | return 0; 40 | } 41 | 42 | int getpasswd(char* passwd, int size) 43 | { 44 | int c; 45 | int n = 0; 46 | if (!passwd) 47 | return 1; 48 | 49 | do{ 50 | c=getchar(); 51 | if (c != '\n'|c!='\r'){ 52 | passwd[n++] = c; 53 | } 54 | }while(c != '\n' && c !='\r' && n < (size - 1)); 55 | passwd[n] = '\0'; 56 | return n; 57 | } 58 | 59 | static void 60 | print_version (void) 61 | { 62 | printf("%s version - %s\n", PROGRAM_NAME, PROGRAM_VERSION); 63 | return ; 64 | } 65 | 66 | /* Print the usage information */ 67 | 68 | static void 69 | usage (void) 70 | { 71 | struct option *opt_ptr = NULL; 72 | 73 | printf("Usage: %s ", PROGRAM_NAME); 74 | 75 | for (opt_ptr=long_options;opt_ptr->name != NULL;opt_ptr++) 76 | { 77 | if (opt_ptr->has_arg == no_argument) 78 | printf("[-%c] ", opt_ptr->val); 79 | else if (opt_ptr->has_arg == required_argument) 80 | printf("-%c <%s> ", opt_ptr->val, opt_ptr->name); 81 | } 82 | 83 | printf("\n"); 84 | 85 | return ; 86 | } 87 | 88 | static void 89 | print_help (void) 90 | { 91 | int i, j; 92 | 93 | usage(); 94 | 95 | printf("\n"); 96 | 97 | for (i=0;i 5 | #include 6 | #include 7 | #include 8 | #include "base64.h" 9 | 10 | int base64_encode(const unsigned char* buffer, size_t length, char** b64text) { //Encodes a binary safe base 64 string 11 | BIO *bio, *b64; 12 | BUF_MEM *bufferPtr; 13 | 14 | b64 = BIO_new(BIO_f_base64()); 15 | bio = BIO_new(BIO_s_mem()); 16 | bio = BIO_push(b64, bio); 17 | 18 | BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); //Ignore newlines - write everything in one line 19 | if (buffer) 20 | BIO_write(bio, buffer, length); 21 | else 22 | return 1;//error 23 | BIO_flush(bio); 24 | BIO_get_mem_ptr(bio, &bufferPtr); 25 | BIO_set_close(bio, BIO_NOCLOSE); 26 | BIO_free_all(bio); 27 | BIO_free_all(b64); 28 | 29 | if (b64text) 30 | *b64text=(*bufferPtr).data; 31 | else 32 | return 1;//error 33 | 34 | return (0); //success 35 | } 36 | -------------------------------------------------------------------------------- /src/ilo_credit/ilo-credit-store.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /*(C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P.*/ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "base64.h" 18 | #include "ilo-credit-store.h" 19 | #include "nagios_hpilo_common.h" 20 | 21 | #define PROGRAM_NAME "ilo-credit-store" 22 | #define PROGRAM_VERSION 1.0 23 | #define TDBDIR "/etc/nagios" 24 | #define TDBFILE "/etc/nagios/.nagios_restful_credential.tdb" 25 | 26 | using namespace std; 27 | 28 | TDB_CONTEXT *_tdb; // Handle on tdb protected by lock 29 | 30 | int storeString(const string &key, const string &value) 31 | { 32 | TDB_DATA k, v; 33 | 34 | k.dptr = (unsigned char *)key.c_str(); 35 | k.dsize = key.length(); 36 | 37 | v.dptr = (unsigned char *)value.c_str(); 38 | v.dsize = value.length(); 39 | 40 | int result = tdb_store(_tdb, k, v, TDB_REPLACE); 41 | 42 | return result; 43 | } 44 | 45 | string fetchString(const string &key) 46 | { 47 | TDB_DATA k; 48 | 49 | k.dptr = (unsigned char *)key.c_str(); 50 | k.dsize = key.length(); 51 | 52 | TDB_DATA v; 53 | 54 | v = tdb_fetch(_tdb, k); 55 | 56 | if (v.dptr == NULL) 57 | return string(); 58 | 59 | string result((char *)v.dptr, v.dsize); 60 | 61 | free(v.dptr); 62 | 63 | return result; 64 | } 65 | 66 | bool remove(const string &key) 67 | { 68 | TDB_DATA k; 69 | 70 | k.dptr = (unsigned char *)key.c_str(); 71 | k.dsize = key.length(); 72 | 73 | bool result = (tdb_delete(_tdb, k) == 0); 74 | 75 | return result; 76 | } 77 | 78 | bool exists(const string &key) 79 | { 80 | TDB_DATA k; 81 | 82 | k.dptr = (unsigned char *)key.c_str(); 83 | k.dsize = key.length(); 84 | 85 | bool result = tdb_exists(_tdb, k); 86 | 87 | return result; 88 | } 89 | 90 | extern "C" 91 | char * 92 | get_cred(char * host) 93 | { 94 | const char * encode_credential; 95 | string key, value; 96 | size_t test; 97 | int option_instruction = NAGIOS_OPTION_NOP; 98 | 99 | if (host) 100 | key=host; 101 | else 102 | return NULL; 103 | 104 | _tdb = tdb_open_ex(TDBFILE, 0, 0, O_RDWR, 0600, NULL, NULL); 105 | 106 | if (!_tdb) { 107 | cout<<"Could not open "<pw_uid; 179 | int nagios_gid=nagios_pw->pw_gid; 180 | status = chown(TDBFILE,nagios_uid,nagios_gid); 181 | if (status != 0) { 182 | cout<<"chown for the tdbfile error"<>cred_data.user; 245 | } 246 | 247 | printf("Enter password:"); 248 | cin>>cred_data.passwd; 249 | 250 | if((_textf = fopen(file.c_str(), "r+" )) == NULL) 251 | _tdb = tdb_open_ex(file.c_str(), 252 | 0, // hash_size 253 | 0, // tdb_flags 254 | O_CREAT|O_RDWR, // open_flags 255 | 0600, // mode 256 | NULL, // log_fn 257 | NULL); // hash_fn 258 | else 259 | _tdb = tdb_open_ex(file.c_str(), 0, 0, O_RDWR, 0600, NULL, NULL); 260 | 261 | if (!_tdb) { 262 | cout<<"Could not create "</dev/null \ 25 | | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ 26 | *) \ 27 | for am__flg in $$MAKEFLAGS; do \ 28 | case $$am__flg in \ 29 | *=*|--*) ;; \ 30 | *n*) am__dry=yes; break;; \ 31 | esac; \ 32 | done;; \ 33 | esac; \ 34 | test $$am__dry = yes; \ 35 | } 36 | pkgdatadir = $(datadir)/@PACKAGE@ 37 | pkgincludedir = $(includedir)/@PACKAGE@ 38 | pkglibdir = $(libdir)/@PACKAGE@ 39 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 40 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 41 | install_sh_DATA = $(install_sh) -c -m 644 42 | install_sh_PROGRAM = $(install_sh) -c 43 | install_sh_SCRIPT = $(install_sh) -c 44 | INSTALL_HEADER = $(INSTALL_DATA) 45 | transform = $(program_transform_name) 46 | NORMAL_INSTALL = : 47 | PRE_INSTALL = : 48 | POST_INSTALL = : 49 | NORMAL_UNINSTALL = : 50 | PRE_UNINSTALL = : 51 | POST_UNINSTALL = : 52 | libexec_PROGRAMS = ilo-credit-store$(EXEEXT) 53 | subdir = src 54 | DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 55 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 56 | am__aclocal_m4_deps = $(top_srcdir)/m4/m4-ax_compare_version.m4 \ 57 | $(top_srcdir)/configure.ac 58 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 59 | $(ACLOCAL_M4) 60 | mkinstalldirs = $(install_sh) -d 61 | CONFIG_HEADER = $(top_builddir)/config.h 62 | CONFIG_CLEAN_FILES = 63 | CONFIG_CLEAN_VPATH_FILES = 64 | am__installdirs = "$(DESTDIR)$(libexecdir)" 65 | PROGRAMS = $(libexec_PROGRAMS) 66 | am_ilo-credit-store_OBJECTS = ilo-credit-store.$(OBJEXT) \ 67 | base64.$(OBJEXT) 68 | ilo-credit-store_OBJECTS = $(am_ilo-credit-store_OBJECTS) 69 | ilo-credit-store_LDADD = $(LDADD) 70 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 71 | depcomp = $(SHELL) $(top_srcdir)/depcomp 72 | am__depfiles_maybe = depfiles 73 | am__mv = mv -f 74 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 75 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 76 | CCLD = $(CC) 77 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 78 | SOURCES = $(ilo-credit-store_SOURCES) 79 | DIST_SOURCES = $(ilo-credit-store_SOURCES) 80 | am__can_run_installinfo = \ 81 | case $$AM_UPDATE_INFO_DIR in \ 82 | n|no|NO) false;; \ 83 | *) (install-info --version) >/dev/null 2>&1;; \ 84 | esac 85 | ETAGS = etags 86 | CTAGS = ctags 87 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 88 | ACLOCAL = @ACLOCAL@ 89 | AMTAR = @AMTAR@ 90 | AUTOCONF = @AUTOCONF@ 91 | AUTOHEADER = @AUTOHEADER@ 92 | AUTOMAKE = @AUTOMAKE@ 93 | AWK = @AWK@ 94 | CC = @CC@ 95 | CCDEPMODE = @CCDEPMODE@ 96 | CFLAGS = @CFLAGS@ 97 | CPP = @CPP@ 98 | CPPFLAGS = @CPPFLAGS@ 99 | CYGPATH_W = @CYGPATH_W@ 100 | DEFS = @DEFS@ 101 | DEPDIR = @DEPDIR@ 102 | ECHO_C = @ECHO_C@ 103 | ECHO_N = @ECHO_N@ 104 | ECHO_T = @ECHO_T@ 105 | EGREP = @EGREP@ 106 | EXEEXT = @EXEEXT@ 107 | GREP = @GREP@ 108 | INSTALL = @INSTALL@ 109 | INSTALL_DATA = @INSTALL_DATA@ 110 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 111 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 112 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 113 | LDFLAGS = @LDFLAGS@ 114 | LIBOBJS = @LIBOBJS@ 115 | LIBS = @LIBS@ 116 | LTLIBOBJS = @LTLIBOBJS@ 117 | MAKEINFO = @MAKEINFO@ 118 | MKDIR_P = @MKDIR_P@ 119 | NMAP_MIN_VERSION = @NMAP_MIN_VERSION@ 120 | NMAP_PATH = @NMAP_PATH@ 121 | OBJEXT = @OBJEXT@ 122 | PACKAGE = @PACKAGE@ 123 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 124 | PACKAGE_NAME = @PACKAGE_NAME@ 125 | PACKAGE_STRING = @PACKAGE_STRING@ 126 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 127 | PACKAGE_URL = @PACKAGE_URL@ 128 | PACKAGE_VERSION = @PACKAGE_VERSION@ 129 | PATH_SEPARATOR = @PATH_SEPARATOR@ 130 | SET_MAKE = @SET_MAKE@ 131 | SHELL = @SHELL@ 132 | STRIP = @STRIP@ 133 | VERSION = @VERSION@ 134 | abs_builddir = @abs_builddir@ 135 | abs_srcdir = @abs_srcdir@ 136 | abs_top_builddir = @abs_top_builddir@ 137 | abs_top_srcdir = @abs_top_srcdir@ 138 | ac_ct_CC = @ac_ct_CC@ 139 | am__include = @am__include@ 140 | am__leading_dot = @am__leading_dot@ 141 | am__quote = @am__quote@ 142 | am__tar = @am__tar@ 143 | am__untar = @am__untar@ 144 | bindir = @bindir@ 145 | build_alias = @build_alias@ 146 | builddir = @builddir@ 147 | datadir = @datadir@ 148 | datarootdir = @datarootdir@ 149 | docdir = @docdir@ 150 | dvidir = @dvidir@ 151 | exec_prefix = @exec_prefix@ 152 | host_alias = @host_alias@ 153 | htmldir = @htmldir@ 154 | includedir = @includedir@ 155 | infodir = @infodir@ 156 | install_sh = @install_sh@ 157 | libdir = @libdir@ 158 | libexecdir = @libexecdir@ 159 | localedir = @localedir@ 160 | localstatedir = @localstatedir@ 161 | mandir = @mandir@ 162 | mkdir_p = @mkdir_p@ 163 | oldincludedir = @oldincludedir@ 164 | pdfdir = @pdfdir@ 165 | prefix = @prefix@ 166 | program_transform_name = @program_transform_name@ 167 | psdir = @psdir@ 168 | sbindir = @sbindir@ 169 | sharedstatedir = @sharedstatedir@ 170 | srcdir = @srcdir@ 171 | sysconfdir = @sysconfdir@ 172 | target_alias = @target_alias@ 173 | top_build_prefix = @top_build_prefix@ 174 | top_builddir = @top_builddir@ 175 | top_srcdir = @top_srcdir@ 176 | AM_CPPFLAGS = -I$(top_srcdir)/src/include 177 | AM_CFLAGS = 178 | ilo-credit-store_SOURCES = ilo-credit-store.c base64.c 179 | all: all-am 180 | 181 | .SUFFIXES: 182 | .SUFFIXES: .c .o .obj 183 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 184 | @for dep in $?; do \ 185 | case '$(am__configure_deps)' in \ 186 | *$$dep*) \ 187 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 188 | && { if test -f $@; then exit 0; else break; fi; }; \ 189 | exit 1;; \ 190 | esac; \ 191 | done; \ 192 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ 193 | $(am__cd) $(top_srcdir) && \ 194 | $(AUTOMAKE) --gnu src/Makefile 195 | .PRECIOUS: Makefile 196 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 197 | @case '$?' in \ 198 | *config.status*) \ 199 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 200 | *) \ 201 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 202 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 203 | esac; 204 | 205 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 206 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 207 | 208 | $(top_srcdir)/configure: $(am__configure_deps) 209 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 210 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 211 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 212 | $(am__aclocal_m4_deps): 213 | install-libexecPROGRAMS: $(libexec_PROGRAMS) 214 | @$(NORMAL_INSTALL) 215 | @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ 216 | if test -n "$$list"; then \ 217 | echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ 218 | $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ 219 | fi; \ 220 | for p in $$list; do echo "$$p $$p"; done | \ 221 | sed 's/$(EXEEXT)$$//' | \ 222 | while read p p1; do if test -f $$p; \ 223 | then echo "$$p"; echo "$$p"; else :; fi; \ 224 | done | \ 225 | sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ 226 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ 227 | sed 'N;N;N;s,\n, ,g' | \ 228 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ 229 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 230 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ 231 | else { print "f", $$3 "/" $$4, $$1; } } \ 232 | END { for (d in files) print "f", d, files[d] }' | \ 233 | while read type dir files; do \ 234 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 235 | test -z "$$files" || { \ 236 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ 237 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ 238 | } \ 239 | ; done 240 | 241 | uninstall-libexecPROGRAMS: 242 | @$(NORMAL_UNINSTALL) 243 | @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ 244 | files=`for p in $$list; do echo "$$p"; done | \ 245 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 246 | -e 's/$$/$(EXEEXT)/' `; \ 247 | test -n "$$list" || exit 0; \ 248 | echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ 249 | cd "$(DESTDIR)$(libexecdir)" && rm -f $$files 250 | 251 | clean-libexecPROGRAMS: 252 | -test -z "$(libexec_PROGRAMS)" || rm -f $(libexec_PROGRAMS) 253 | ilo-credit-store$(EXEEXT): $(ilo-credit-store_OBJECTS) $(ilo-credit-store_DEPENDENCIES) $(EXTRA_ilo-credit-store_DEPENDENCIES) 254 | @rm -f ilo-credit-store$(EXEEXT) 255 | $(LINK) $(ilo-credit-store_OBJECTS) $(ilo-credit-store_LDADD) $(LIBS) 256 | 257 | mostlyclean-compile: 258 | -rm -f *.$(OBJEXT) 259 | 260 | distclean-compile: 261 | -rm -f *.tab.c 262 | 263 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ilo-credit-store.Po@am__quote@ 264 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Po@am__quote@ 265 | 266 | .c.o: 267 | @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 268 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 269 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 270 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 271 | @am__fastdepCC_FALSE@ $(COMPILE) -c $< 272 | 273 | .c.obj: 274 | @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 275 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 276 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 277 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 278 | @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` 279 | 280 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 281 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 282 | unique=`for i in $$list; do \ 283 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 284 | done | \ 285 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 286 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 287 | mkid -fID $$unique 288 | tags: TAGS 289 | 290 | TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 291 | $(TAGS_FILES) $(LISP) 292 | set x; \ 293 | here=`pwd`; \ 294 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 295 | unique=`for i in $$list; do \ 296 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 297 | done | \ 298 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 299 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 300 | shift; \ 301 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 302 | test -n "$$unique" || unique=$$empty_fix; \ 303 | if test $$# -gt 0; then \ 304 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 305 | "$$@" $$unique; \ 306 | else \ 307 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 308 | $$unique; \ 309 | fi; \ 310 | fi 311 | ctags: CTAGS 312 | CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 313 | $(TAGS_FILES) $(LISP) 314 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 315 | unique=`for i in $$list; do \ 316 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 317 | done | \ 318 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 319 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 320 | test -z "$(CTAGS_ARGS)$$unique" \ 321 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 322 | $$unique 323 | 324 | GTAGS: 325 | here=`$(am__cd) $(top_builddir) && pwd` \ 326 | && $(am__cd) $(top_srcdir) \ 327 | && gtags -i $(GTAGS_ARGS) "$$here" 328 | 329 | distclean-tags: 330 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 331 | 332 | distdir: $(DISTFILES) 333 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 334 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 335 | list='$(DISTFILES)'; \ 336 | dist_files=`for file in $$list; do echo $$file; done | \ 337 | sed -e "s|^$$srcdirstrip/||;t" \ 338 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 339 | case $$dist_files in \ 340 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 341 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 342 | sort -u` ;; \ 343 | esac; \ 344 | for file in $$dist_files; do \ 345 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 346 | if test -d $$d/$$file; then \ 347 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 348 | if test -d "$(distdir)/$$file"; then \ 349 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 350 | fi; \ 351 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 352 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 353 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 354 | fi; \ 355 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 356 | else \ 357 | test -f "$(distdir)/$$file" \ 358 | || cp -p $$d/$$file "$(distdir)/$$file" \ 359 | || exit 1; \ 360 | fi; \ 361 | done 362 | check-am: all-am 363 | check: check-am 364 | all-am: Makefile $(PROGRAMS) 365 | installdirs: 366 | for dir in "$(DESTDIR)$(libexecdir)"; do \ 367 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 368 | done 369 | install: install-am 370 | install-exec: install-exec-am 371 | install-data: install-data-am 372 | uninstall: uninstall-am 373 | 374 | install-am: all-am 375 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 376 | 377 | installcheck: installcheck-am 378 | install-strip: 379 | if test -z '$(STRIP)'; then \ 380 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 381 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 382 | install; \ 383 | else \ 384 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 385 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 386 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 387 | fi 388 | mostlyclean-generic: 389 | 390 | clean-generic: 391 | 392 | distclean-generic: 393 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 394 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 395 | 396 | maintainer-clean-generic: 397 | @echo "This command is intended for maintainers to use" 398 | @echo "it deletes files that may require special tools to rebuild." 399 | clean: clean-am 400 | 401 | clean-am: clean-generic clean-libexecPROGRAMS mostlyclean-am 402 | 403 | distclean: distclean-am 404 | -rm -rf ./$(DEPDIR) 405 | -rm -f Makefile 406 | distclean-am: clean-am distclean-compile distclean-generic \ 407 | distclean-tags 408 | 409 | dvi: dvi-am 410 | 411 | dvi-am: 412 | 413 | html: html-am 414 | 415 | html-am: 416 | 417 | info: info-am 418 | 419 | info-am: 420 | 421 | install-data-am: 422 | 423 | install-dvi: install-dvi-am 424 | 425 | install-dvi-am: 426 | 427 | install-exec-am: install-libexecPROGRAMS 428 | 429 | install-html: install-html-am 430 | 431 | install-html-am: 432 | 433 | install-info: install-info-am 434 | 435 | install-info-am: 436 | 437 | install-man: 438 | 439 | install-pdf: install-pdf-am 440 | 441 | install-pdf-am: 442 | 443 | install-ps: install-ps-am 444 | 445 | install-ps-am: 446 | 447 | installcheck-am: 448 | 449 | maintainer-clean: maintainer-clean-am 450 | -rm -rf ./$(DEPDIR) 451 | -rm -f Makefile 452 | maintainer-clean-am: distclean-am maintainer-clean-generic 453 | 454 | mostlyclean: mostlyclean-am 455 | 456 | mostlyclean-am: mostlyclean-compile mostlyclean-generic 457 | 458 | pdf: pdf-am 459 | 460 | pdf-am: 461 | 462 | ps: ps-am 463 | 464 | ps-am: 465 | 466 | uninstall-am: uninstall-libexecPROGRAMS 467 | 468 | .MAKE: install-am install-strip 469 | 470 | .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ 471 | clean-libexecPROGRAMS ctags distclean distclean-compile \ 472 | distclean-generic distclean-tags distdir dvi dvi-am html \ 473 | html-am info info-am install install-am install-data \ 474 | install-data-am install-dvi install-dvi-am install-exec \ 475 | install-exec-am install-html install-html-am install-info \ 476 | install-info-am install-libexecPROGRAMS install-man \ 477 | install-pdf install-pdf-am install-ps install-ps-am \ 478 | install-strip installcheck installcheck-am installdirs \ 479 | maintainer-clean maintainer-clean-generic mostlyclean \ 480 | mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ 481 | tags uninstall uninstall-am uninstall-libexecPROGRAMS 482 | 483 | 484 | %.o: %.cpp 485 | $(CXX) -shared -fPIC -ltdb $< $(CFLAGS) $(IFLAGS) 486 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 487 | # Otherwise a system limit (for SysV at least) may be exceeded. 488 | .NOEXPORT: 489 | -------------------------------------------------------------------------------- /src/include/base64.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | int base64_encode(const unsigned char*, size_t, char**); 7 | int base64_decode(char*, char**); 8 | 9 | #ifdef __cplusplus 10 | } 11 | #endif 12 | -------------------------------------------------------------------------------- /src/include/cJSON.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009 Dave Gamble 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #ifndef cJSON__h 24 | #define cJSON__h 25 | 26 | #ifdef __cplusplus 27 | extern "C" 28 | { 29 | #endif 30 | 31 | /* cJSON Types: */ 32 | #define cJSON_False 0 33 | #define cJSON_True 1 34 | #define cJSON_NULL 2 35 | #define cJSON_Number 3 36 | #define cJSON_String 4 37 | #define cJSON_Array 5 38 | #define cJSON_Object 6 39 | 40 | #define cJSON_IsReference 256 41 | #define cJSON_StringIsConst 512 42 | 43 | /* The cJSON structure: */ 44 | typedef struct cJSON { 45 | struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ 46 | struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ 47 | 48 | int type; /* The type of the item, as above. */ 49 | 50 | char *valuestring; /* The item's string, if type==cJSON_String */ 51 | int valueint; /* The item's number, if type==cJSON_Number */ 52 | double valuedouble; /* The item's number, if type==cJSON_Number */ 53 | 54 | char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ 55 | } cJSON; 56 | 57 | typedef struct cJSON_Hooks { 58 | void *(*malloc_fn)(size_t sz); 59 | void (*free_fn)(void *ptr); 60 | } cJSON_Hooks; 61 | 62 | /* Supply malloc, realloc and free functions to cJSON */ 63 | extern void cJSON_InitHooks(cJSON_Hooks* hooks); 64 | 65 | 66 | /* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */ 67 | extern cJSON *cJSON_Parse(const char *value); 68 | /* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */ 69 | extern char *cJSON_Print(cJSON *item); 70 | /* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */ 71 | extern char *cJSON_PrintUnformatted(cJSON *item); 72 | /* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */ 73 | extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt); 74 | /* Delete a cJSON entity and all subentities. */ 75 | extern void cJSON_Delete(cJSON *c); 76 | 77 | /* Returns the number of items in an array (or object). */ 78 | extern int cJSON_GetArraySize(cJSON *array); 79 | /* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */ 80 | extern cJSON *cJSON_GetArrayItem(cJSON *array,int item); 81 | /* Get item "string" from object. Case insensitive. */ 82 | extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string); 83 | 84 | /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ 85 | extern const char *cJSON_GetErrorPtr(void); 86 | 87 | /* These calls create a cJSON item of the appropriate type. */ 88 | extern cJSON *cJSON_CreateNull(void); 89 | extern cJSON *cJSON_CreateTrue(void); 90 | extern cJSON *cJSON_CreateFalse(void); 91 | extern cJSON *cJSON_CreateBool(int b); 92 | extern cJSON *cJSON_CreateNumber(double num); 93 | extern cJSON *cJSON_CreateString(const char *string); 94 | extern cJSON *cJSON_CreateArray(void); 95 | extern cJSON *cJSON_CreateObject(void); 96 | 97 | /* These utilities create an Array of count items. */ 98 | extern cJSON *cJSON_CreateIntArray(const int *numbers,int count); 99 | extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count); 100 | extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count); 101 | extern cJSON *cJSON_CreateStringArray(const char **strings,int count); 102 | 103 | /* Append item to the specified array/object. */ 104 | extern void cJSON_AddItemToArray(cJSON *array, cJSON *item); 105 | extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item); 106 | extern void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */ 107 | /* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ 108 | extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); 109 | extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item); 110 | 111 | /* Remove/Detatch items from Arrays/Objects. */ 112 | extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which); 113 | extern void cJSON_DeleteItemFromArray(cJSON *array,int which); 114 | extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string); 115 | extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string); 116 | 117 | /* Update array items. */ 118 | extern void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem); /* Shifts pre-existing items to the right. */ 119 | extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem); 120 | extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); 121 | 122 | /* Duplicate a cJSON item */ 123 | extern cJSON *cJSON_Duplicate(cJSON *item,int recurse); 124 | /* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will 125 | need to be released. With recurse!=0, it will duplicate any children connected to the item. 126 | The item->next and ->prev pointers are always zero on return from Duplicate. */ 127 | 128 | /* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ 129 | extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated); 130 | 131 | extern void cJSON_Minify(char *json); 132 | 133 | /* Macros for creating things quickly. */ 134 | #define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) 135 | #define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) 136 | #define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) 137 | #define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b)) 138 | #define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n)) 139 | #define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s)) 140 | 141 | /* When assigning an integer value, it needs to be propagated to valuedouble too. */ 142 | #define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val)) 143 | #define cJSON_SetNumberValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val)) 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | #endif 150 | -------------------------------------------------------------------------------- /src/include/credit_save.h: -------------------------------------------------------------------------------- 1 | /* credit_setting.h -- types and prototypes used by nagios iLO engine 2 | (C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P. 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of version 2 of the GNU General Public License as 6 | published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to: 16 | Free Software Foundation, Inc. 17 | 51 Franklin Street, Fifth Floor 18 | Boston, MA 02110-1301, USA. */ 19 | 20 | 21 | #ifndef CREDIT_SETTING_H 22 | #define CREDIT_SETTING_H 23 | 24 | #include "nagios_hpilo_common.h" 25 | 26 | /* Macro definition */ 27 | #define USAGE "-H [-V] [-h]" 28 | 29 | /* Available options for this plugin. */ 30 | #define SHORT_OPTIONS "hVH:" 31 | 32 | /* The required the number of arguments for this plugin. */ 33 | #define NAGIOS_ILO_REQUIRE_ARGC 1 34 | 35 | /* Strings for help menu. */ 36 | static char help_string[][128] = 37 | {"-H, --hostip=ip_address\n\tHP iLO IP address or \"default\" for all servers", 38 | "-V, --version\n\tprint the version number", 39 | "-h, --help\n\tprint this help menu" 40 | }; 41 | 42 | /* options for arguments. */ 43 | static struct option long_options[] = 44 | { 45 | {"hostname", required_argument, 0, 'H'}, 46 | {"version", no_argument, 0, 'V'}, 47 | {"help", no_argument, 0, 'h'}, 48 | {0, 0, 0, 0} 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/include/ilo-credit-store.h: -------------------------------------------------------------------------------- 1 | #ifndef _ILOCREDITSO_H 2 | #define _ILOCREDITSO_H 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | int set_cred(char * host, char * user, char * passwd); 10 | char *get_cred(char * host); 11 | int exist_cred(char * host); 12 | typedef int set_cred_t(char *, char *, char *); 13 | typedef char *get_cred_t(char *); 14 | typedef int exist_cred_t(char *); 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/include/nagios_hpilo_common.h: -------------------------------------------------------------------------------- 1 | /* nagios_hpilo_common.h -- types and prototypes used by nagios iLO plug-in 2 | (C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P. 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of version 2 of the GNU General Public License as 6 | published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to: 16 | Free Software Foundation, Inc. 17 | 51 Franklin Street, Fifth Floor 18 | Boston, MA 02110-1301, USA. */ 19 | 20 | /* Written by Maple Yang . */ 21 | 22 | #ifndef NAGIOS_HPILO_COMMON_H 23 | #define NAGIOS_HPILO_COMMON_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "cJSON.h" 32 | 33 | #define TRUE 1 34 | #define FALSE 0 35 | 36 | /* Internal status. */ 37 | #define NAGIOS_ILO_SUCCESS_STATUS 0 38 | #define NAGIOS_ILO_FAIL_STATUS -1 39 | 40 | #define NUM_ELEMENTS(array) \ 41 | (sizeof(array) / sizeof(typeof(array[0]))) 42 | 43 | /* Return status defined by Nagios. */ 44 | enum Nagios_status 45 | { 46 | NAGIOS_OK, 47 | NAGIOS_WARNING, 48 | NAGIOS_CRITICAL, 49 | NAGIOS_UNKNOWN 50 | }; 51 | 52 | /* Option operation. */ 53 | enum 54 | { 55 | NAGIOS_OPTION_NOP, 56 | NAGIOS_OPTION_PRINT_VERSION, 57 | NAGIOS_OPTION_PRINT_HELP 58 | }; 59 | 60 | /* Error Debug Macro. */ 61 | #define ILO_ERR_DEBUG(ppError, fmt, args...) \ 62 | if (*ppError == NULL) { \ 63 | asprintf(ppError, "[Error]: " fmt, ## args); \ 64 | } else { \ 65 | char buf[strlen(*ppError) + 1]; \ 66 | sprintf(buf, "%s", *ppError); \ 67 | free(*ppError); \ 68 | asprintf(ppError, "%s[Error]: " fmt, buf, ##args); \ 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/include/nagios_hpilo_engine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HewlettPackard/nagios-hpeilo-restful-extension/97f96dc4b57a83f71b608f58043e37058fb4b86e/src/include/nagios_hpilo_engine.h -------------------------------------------------------------------------------- /src/include/nagios_hpilo_restful_engine.h: -------------------------------------------------------------------------------- 1 | /* nagios_hpilo_restful_engine.h -- types and prototypes used by nagios iLO engine 2 | (C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P. 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of version 2 of the GNU General Public License as 6 | published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to: 16 | Free Software Foundation, Inc. 17 | 51 Franklin Street, Fifth Floor 18 | Boston, MA 02110-1301, USA. */ 19 | 20 | /* Written by Adrian Huang . */ 21 | 22 | #ifndef NAGIOS_HPILO_ENGINE_H 23 | #define NAGIOS_HPILO_ENGINE_H 24 | 25 | #include "nagios_hpilo_common.h" 26 | 27 | /* Macro definition */ 28 | #define USAGE "-H -o [-h] [-V]" 29 | 30 | /* Available options for this plugin. */ 31 | #define SHORT_OPTIONS "hVH:o:" 32 | 33 | /* The required the number of arguments for this plugin. */ 34 | #define NAGIOS_ILO_REQUIRE_ARGC 2 35 | 36 | #define IDX_OUT_OF_RANGE(idx, array) \ 37 | ((idx < 0 || idx > NUM_ELEMENTS(array)) ? TRUE : FALSE) 38 | 39 | #define ILO_OID_NAME_LEN 24 40 | 41 | #define MAX_OID_INFO_ENTRIES 2 42 | 43 | /* Health group OID. 44 | For example: Fans, power supplies and so on. */ 45 | #define HLTH_GROUP_OID 0 46 | 47 | /* Health component OID info 48 | For example: Fan 1, Fan 2.....Fan n 49 | Sensor 1, Sensor 2.....Sensor n. */ 50 | #define HLTH_COMP_OID 1 51 | 52 | #define ILO_SERVICE_URL_LEN 50 53 | 54 | #define ILO_SERVICE_SUB_URL_LEN 50 55 | 56 | #define ILO_SERVICE_TYPE_LEN 35 57 | 58 | #define ILO_SERVICE_NAME_LEN 15 59 | 60 | /* Strings for help menu. */ 61 | static char help_string[][128] = 62 | {"-H, --hostname=ip_address\n\tHost name or IP address to connect with", 63 | "-o, --sid=sid_index\n\tSevice index", 64 | "-V, --version\n\tprint the version number", 65 | "-h, --help\n\tprint this help menu" 66 | }; 67 | 68 | /* options for arguments. */ 69 | static struct option long_options[] = 70 | { 71 | {"hostname", required_argument, 0, 'H'}, 72 | {"sid", required_argument, 0, 'o'}, 73 | {"version", no_argument, 0, 'V'}, 74 | {"help", no_argument, 0, 'h'}, 75 | {0, 0, 0, 0} 76 | }; 77 | 78 | 79 | /* iLO health status. */ 80 | enum 81 | { 82 | ILO_HLTH_STATUS_NA, 83 | ILO_HLTH_STATUS_OTHER, 84 | ILO_HLTH_STATUS_OK, 85 | ILO_HLTH_STATUS_DEGRADED, 86 | ILO_HLTH_STATUS_FAILED, 87 | }; 88 | 89 | /* iLO Redundant status. */ 90 | enum 91 | { 92 | ILO_RED_STATUS_OTHER = 1, 93 | ILO_RED_STATUS_NOT_RED, 94 | ILO_RED_STATUS_RED, 95 | }; 96 | 97 | /* A variety of OID types. */ 98 | enum 99 | { 100 | /* The array index of the system overall condition. */ 101 | ILO_SYS_OVERALL_COND, 102 | 103 | ILO_HLTH_TYPE, 104 | 105 | ILO_HLTH_STR_TYPE, 106 | 107 | ILO_REDUNDANT_TYPE, 108 | 109 | /* The array index of NIC condition (232.18.1.3:cpqNicMibCondition). */ 110 | ILO_NIC_MIB_COND = 14, 111 | }; 112 | 113 | /* Generic Service info. */ 114 | struct generic_service_info 115 | { 116 | /* Root URL. */ 117 | char service_root_url[ILO_SERVICE_URL_LEN]; 118 | 119 | /* Sub URL. */ 120 | char service_sub_url[ILO_SERVICE_SUB_URL_LEN]; 121 | 122 | /* Service type. */ 123 | char service_type[ILO_SERVICE_TYPE_LEN]; 124 | 125 | /* OID Length. */ 126 | char service_name[ILO_SERVICE_NAME_LEN]; 127 | }; 128 | 129 | /* Data structure to store options via the argument list of the command 130 | line. */ 131 | struct ilo_restful_options 132 | { 133 | /* Pointer to host name (IP address). */ 134 | char *host; 135 | 136 | /* Pointer to admin name. */ 137 | char *admin; 138 | 139 | /* Pointer to admin passwd. */ 140 | char *passwd; 141 | 142 | /* Index to the iLO restful service number. */ 143 | int service_idx; 144 | }; 145 | 146 | /* Data structure to store OID information retrieved from a specific OID. */ 147 | struct ilo_cJSON_list 148 | { 149 | /* Json root. */ 150 | cJSON *root; 151 | 152 | /* Pointer to the next entry. */ 153 | struct ilo_cJSON_list *next; 154 | 155 | }; 156 | 157 | /* Private data for this plugin. */ 158 | struct restful_requests 159 | { 160 | /* Pointer to Json array. */ 161 | struct ilo_cJSON_list cJSON_list; 162 | struct ilo_cJSON_list* head; 163 | 164 | /* Nagios status */ 165 | enum Nagios_status n_status; 166 | 167 | }; 168 | 169 | #endif 170 | -------------------------------------------------------------------------------- /src/restful/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS=foreign 2 | 3 | AM_LDFLAGS = -L$(top_srcdir)/src/ilo_credit/.libs/ -lcurl -lm -lilocrst -ldl -lcrypto 4 | 5 | AM_CPPFLAGS = -I$(top_srcdir)/src/include 6 | 7 | AM_CFLAGS = 8 | 9 | libexec_PROGRAMS = nagios_hpeilo_restful_engine 10 | 11 | nagios_hpeilo_restful_engine_SOURCES= nagios_hpilo_restful_engine.c base64.c cJSON.c 12 | 13 | -------------------------------------------------------------------------------- /src/restful/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.14.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | 17 | VPATH = @srcdir@ 18 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 19 | am__make_running_with_option = \ 20 | case $${target_option-} in \ 21 | ?) ;; \ 22 | *) echo "am__make_running_with_option: internal error: invalid" \ 23 | "target option '$${target_option-}' specified" >&2; \ 24 | exit 1;; \ 25 | esac; \ 26 | has_opt=no; \ 27 | sane_makeflags=$$MAKEFLAGS; \ 28 | if $(am__is_gnu_make); then \ 29 | sane_makeflags=$$MFLAGS; \ 30 | else \ 31 | case $$MAKEFLAGS in \ 32 | *\\[\ \ ]*) \ 33 | bs=\\; \ 34 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 35 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 36 | esac; \ 37 | fi; \ 38 | skip_next=no; \ 39 | strip_trailopt () \ 40 | { \ 41 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 42 | }; \ 43 | for flg in $$sane_makeflags; do \ 44 | test $$skip_next = yes && { skip_next=no; continue; }; \ 45 | case $$flg in \ 46 | *=*|--*) continue;; \ 47 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 48 | -*I?*) strip_trailopt 'I';; \ 49 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 50 | -*O?*) strip_trailopt 'O';; \ 51 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 52 | -*l?*) strip_trailopt 'l';; \ 53 | -[dEDm]) skip_next=yes;; \ 54 | -[JT]) skip_next=yes;; \ 55 | esac; \ 56 | case $$flg in \ 57 | *$$target_option*) has_opt=yes; break;; \ 58 | esac; \ 59 | done; \ 60 | test $$has_opt = yes 61 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 62 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 63 | pkgdatadir = $(datadir)/@PACKAGE@ 64 | pkgincludedir = $(includedir)/@PACKAGE@ 65 | pkglibdir = $(libdir)/@PACKAGE@ 66 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 67 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 68 | install_sh_DATA = $(install_sh) -c -m 644 69 | install_sh_PROGRAM = $(install_sh) -c 70 | install_sh_SCRIPT = $(install_sh) -c 71 | INSTALL_HEADER = $(INSTALL_DATA) 72 | transform = $(program_transform_name) 73 | NORMAL_INSTALL = : 74 | PRE_INSTALL = : 75 | POST_INSTALL = : 76 | NORMAL_UNINSTALL = : 77 | PRE_UNINSTALL = : 78 | POST_UNINSTALL = : 79 | build_triplet = @build@ 80 | host_triplet = @host@ 81 | libexec_PROGRAMS = nagios_hpeilo_restful_engine$(EXEEXT) 82 | subdir = src/restful 83 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ 84 | $(top_srcdir)/depcomp 85 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 86 | am__aclocal_m4_deps = $(top_srcdir)/m4/m4-ax_compare_version.m4 \ 87 | $(top_srcdir)/configure.ac 88 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 89 | $(ACLOCAL_M4) 90 | mkinstalldirs = $(install_sh) -d 91 | CONFIG_HEADER = $(top_builddir)/config.h 92 | CONFIG_CLEAN_FILES = 93 | CONFIG_CLEAN_VPATH_FILES = 94 | am__installdirs = "$(DESTDIR)$(libexecdir)" 95 | PROGRAMS = $(libexec_PROGRAMS) 96 | am_nagios_hpeilo_restful_engine_OBJECTS = \ 97 | nagios_hpilo_restful_engine.$(OBJEXT) base64.$(OBJEXT) \ 98 | cJSON.$(OBJEXT) 99 | nagios_hpeilo_restful_engine_OBJECTS = \ 100 | $(am_nagios_hpeilo_restful_engine_OBJECTS) 101 | nagios_hpeilo_restful_engine_LDADD = $(LDADD) 102 | AM_V_lt = $(am__v_lt_@AM_V@) 103 | am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) 104 | am__v_lt_0 = --silent 105 | am__v_lt_1 = 106 | AM_V_P = $(am__v_P_@AM_V@) 107 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 108 | am__v_P_0 = false 109 | am__v_P_1 = : 110 | AM_V_GEN = $(am__v_GEN_@AM_V@) 111 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 112 | am__v_GEN_0 = @echo " GEN " $@; 113 | am__v_GEN_1 = 114 | AM_V_at = $(am__v_at_@AM_V@) 115 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 116 | am__v_at_0 = @ 117 | am__v_at_1 = 118 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 119 | depcomp = $(SHELL) $(top_srcdir)/depcomp 120 | am__depfiles_maybe = depfiles 121 | am__mv = mv -f 122 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 123 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 124 | LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 125 | $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ 126 | $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ 127 | $(AM_CFLAGS) $(CFLAGS) 128 | AM_V_CC = $(am__v_CC_@AM_V@) 129 | am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) 130 | am__v_CC_0 = @echo " CC " $@; 131 | am__v_CC_1 = 132 | CCLD = $(CC) 133 | LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 134 | $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ 135 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ 136 | AM_V_CCLD = $(am__v_CCLD_@AM_V@) 137 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) 138 | am__v_CCLD_0 = @echo " CCLD " $@; 139 | am__v_CCLD_1 = 140 | SOURCES = $(nagios_hpeilo_restful_engine_SOURCES) 141 | DIST_SOURCES = $(nagios_hpeilo_restful_engine_SOURCES) 142 | am__can_run_installinfo = \ 143 | case $$AM_UPDATE_INFO_DIR in \ 144 | n|no|NO) false;; \ 145 | *) (install-info --version) >/dev/null 2>&1;; \ 146 | esac 147 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 148 | # Read a list of newline-separated strings from the standard input, 149 | # and print each of them once, without duplicates. Input order is 150 | # *not* preserved. 151 | am__uniquify_input = $(AWK) '\ 152 | BEGIN { nonempty = 0; } \ 153 | { items[$$0] = 1; nonempty = 1; } \ 154 | END { if (nonempty) { for (i in items) print i; }; } \ 155 | ' 156 | # Make sure the list of sources is unique. This is necessary because, 157 | # e.g., the same source file might be shared among _SOURCES variables 158 | # for different programs/libraries. 159 | am__define_uniq_tagged_files = \ 160 | list='$(am__tagged_files)'; \ 161 | unique=`for i in $$list; do \ 162 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 163 | done | $(am__uniquify_input)` 164 | ETAGS = etags 165 | CTAGS = ctags 166 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 167 | ACLOCAL = @ACLOCAL@ 168 | AMTAR = @AMTAR@ 169 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 170 | AR = @AR@ 171 | AUTOCONF = @AUTOCONF@ 172 | AUTOHEADER = @AUTOHEADER@ 173 | AUTOMAKE = @AUTOMAKE@ 174 | AWK = @AWK@ 175 | CC = @CC@ 176 | CCDEPMODE = @CCDEPMODE@ 177 | CFLAGS = @CFLAGS@ 178 | CPP = @CPP@ 179 | CPPFLAGS = @CPPFLAGS@ 180 | CXX = @CXX@ 181 | CXXCPP = @CXXCPP@ 182 | CXXDEPMODE = @CXXDEPMODE@ 183 | CXXFLAGS = @CXXFLAGS@ 184 | CYGPATH_W = @CYGPATH_W@ 185 | DEFS = @DEFS@ 186 | DEPDIR = @DEPDIR@ 187 | DLLTOOL = @DLLTOOL@ 188 | DSYMUTIL = @DSYMUTIL@ 189 | DUMPBIN = @DUMPBIN@ 190 | ECHO_C = @ECHO_C@ 191 | ECHO_N = @ECHO_N@ 192 | ECHO_T = @ECHO_T@ 193 | EGREP = @EGREP@ 194 | EXEEXT = @EXEEXT@ 195 | FGREP = @FGREP@ 196 | GREP = @GREP@ 197 | INSTALL = @INSTALL@ 198 | INSTALL_DATA = @INSTALL_DATA@ 199 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 200 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 201 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 202 | LD = @LD@ 203 | LDFLAGS = @LDFLAGS@ 204 | LIBOBJS = @LIBOBJS@ 205 | LIBS = @LIBS@ 206 | LIBTOOL = @LIBTOOL@ 207 | LIPO = @LIPO@ 208 | LN_S = @LN_S@ 209 | LTLIBOBJS = @LTLIBOBJS@ 210 | MAKEINFO = @MAKEINFO@ 211 | MANIFEST_TOOL = @MANIFEST_TOOL@ 212 | MKDIR_P = @MKDIR_P@ 213 | NM = @NM@ 214 | NMAP_MIN_VERSION = @NMAP_MIN_VERSION@ 215 | NMAP_PATH = @NMAP_PATH@ 216 | NMEDIT = @NMEDIT@ 217 | OBJDUMP = @OBJDUMP@ 218 | OBJEXT = @OBJEXT@ 219 | OTOOL = @OTOOL@ 220 | OTOOL64 = @OTOOL64@ 221 | PACKAGE = @PACKAGE@ 222 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 223 | PACKAGE_NAME = @PACKAGE_NAME@ 224 | PACKAGE_STRING = @PACKAGE_STRING@ 225 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 226 | PACKAGE_URL = @PACKAGE_URL@ 227 | PACKAGE_VERSION = @PACKAGE_VERSION@ 228 | PATH_SEPARATOR = @PATH_SEPARATOR@ 229 | RANLIB = @RANLIB@ 230 | SED = @SED@ 231 | SET_MAKE = @SET_MAKE@ 232 | SHELL = @SHELL@ 233 | STRIP = @STRIP@ 234 | VERSION = @VERSION@ 235 | abs_builddir = @abs_builddir@ 236 | abs_srcdir = @abs_srcdir@ 237 | abs_top_builddir = @abs_top_builddir@ 238 | abs_top_srcdir = @abs_top_srcdir@ 239 | ac_ct_AR = @ac_ct_AR@ 240 | ac_ct_CC = @ac_ct_CC@ 241 | ac_ct_CXX = @ac_ct_CXX@ 242 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 243 | am__include = @am__include@ 244 | am__leading_dot = @am__leading_dot@ 245 | am__quote = @am__quote@ 246 | am__tar = @am__tar@ 247 | am__untar = @am__untar@ 248 | bindir = @bindir@ 249 | build = @build@ 250 | build_alias = @build_alias@ 251 | build_cpu = @build_cpu@ 252 | build_os = @build_os@ 253 | build_vendor = @build_vendor@ 254 | builddir = @builddir@ 255 | datadir = @datadir@ 256 | datarootdir = @datarootdir@ 257 | docdir = @docdir@ 258 | dvidir = @dvidir@ 259 | exec_prefix = @exec_prefix@ 260 | host = @host@ 261 | host_alias = @host_alias@ 262 | host_cpu = @host_cpu@ 263 | host_os = @host_os@ 264 | host_vendor = @host_vendor@ 265 | htmldir = @htmldir@ 266 | includedir = @includedir@ 267 | infodir = @infodir@ 268 | install_sh = @install_sh@ 269 | libdir = @libdir@ 270 | libexecdir = @libexecdir@ 271 | localedir = @localedir@ 272 | localstatedir = @localstatedir@ 273 | mandir = @mandir@ 274 | mkdir_p = @mkdir_p@ 275 | oldincludedir = @oldincludedir@ 276 | pdfdir = @pdfdir@ 277 | prefix = @prefix@ 278 | program_transform_name = @program_transform_name@ 279 | psdir = @psdir@ 280 | sbindir = @sbindir@ 281 | sharedstatedir = @sharedstatedir@ 282 | srcdir = @srcdir@ 283 | sysconfdir = @sysconfdir@ 284 | target_alias = @target_alias@ 285 | top_build_prefix = @top_build_prefix@ 286 | top_builddir = @top_builddir@ 287 | top_srcdir = @top_srcdir@ 288 | AUTOMAKE_OPTIONS = foreign 289 | AM_LDFLAGS = -L$(top_srcdir)/src/ilo_credit/.libs/ -lcurl -lm -lilocrst -ldl -lcrypto 290 | AM_CPPFLAGS = -I$(top_srcdir)/src/include 291 | AM_CFLAGS = 292 | nagios_hpeilo_restful_engine_SOURCES = nagios_hpilo_restful_engine.c base64.c cJSON.c 293 | all: all-am 294 | 295 | .SUFFIXES: 296 | .SUFFIXES: .c .lo .o .obj 297 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 298 | @for dep in $?; do \ 299 | case '$(am__configure_deps)' in \ 300 | *$$dep*) \ 301 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 302 | && { if test -f $@; then exit 0; else break; fi; }; \ 303 | exit 1;; \ 304 | esac; \ 305 | done; \ 306 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/restful/Makefile'; \ 307 | $(am__cd) $(top_srcdir) && \ 308 | $(AUTOMAKE) --foreign src/restful/Makefile 309 | .PRECIOUS: Makefile 310 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 311 | @case '$?' in \ 312 | *config.status*) \ 313 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 314 | *) \ 315 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 316 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 317 | esac; 318 | 319 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 320 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 321 | 322 | $(top_srcdir)/configure: $(am__configure_deps) 323 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 324 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 325 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 326 | $(am__aclocal_m4_deps): 327 | install-libexecPROGRAMS: $(libexec_PROGRAMS) 328 | @$(NORMAL_INSTALL) 329 | @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ 330 | if test -n "$$list"; then \ 331 | echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ 332 | $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ 333 | fi; \ 334 | for p in $$list; do echo "$$p $$p"; done | \ 335 | sed 's/$(EXEEXT)$$//' | \ 336 | while read p p1; do if test -f $$p \ 337 | || test -f $$p1 \ 338 | ; then echo "$$p"; echo "$$p"; else :; fi; \ 339 | done | \ 340 | sed -e 'p;s,.*/,,;n;h' \ 341 | -e 's|.*|.|' \ 342 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ 343 | sed 'N;N;N;s,\n, ,g' | \ 344 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ 345 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 346 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ 347 | else { print "f", $$3 "/" $$4, $$1; } } \ 348 | END { for (d in files) print "f", d, files[d] }' | \ 349 | while read type dir files; do \ 350 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 351 | test -z "$$files" || { \ 352 | echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ 353 | $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ 354 | } \ 355 | ; done 356 | 357 | uninstall-libexecPROGRAMS: 358 | @$(NORMAL_UNINSTALL) 359 | @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ 360 | files=`for p in $$list; do echo "$$p"; done | \ 361 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 362 | -e 's/$$/$(EXEEXT)/' \ 363 | `; \ 364 | test -n "$$list" || exit 0; \ 365 | echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ 366 | cd "$(DESTDIR)$(libexecdir)" && rm -f $$files 367 | 368 | clean-libexecPROGRAMS: 369 | @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ 370 | echo " rm -f" $$list; \ 371 | rm -f $$list || exit $$?; \ 372 | test -n "$(EXEEXT)" || exit 0; \ 373 | list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ 374 | echo " rm -f" $$list; \ 375 | rm -f $$list 376 | 377 | nagios_hpeilo_restful_engine$(EXEEXT): $(nagios_hpeilo_restful_engine_OBJECTS) $(nagios_hpeilo_restful_engine_DEPENDENCIES) $(EXTRA_nagios_hpeilo_restful_engine_DEPENDENCIES) 378 | @rm -f nagios_hpeilo_restful_engine$(EXEEXT) 379 | $(AM_V_CCLD)$(LINK) $(nagios_hpeilo_restful_engine_OBJECTS) $(nagios_hpeilo_restful_engine_LDADD) $(LIBS) 380 | 381 | mostlyclean-compile: 382 | -rm -f *.$(OBJEXT) 383 | 384 | distclean-compile: 385 | -rm -f *.tab.c 386 | 387 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Po@am__quote@ 388 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cJSON.Po@am__quote@ 389 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nagios_hpilo_restful_engine.Po@am__quote@ 390 | 391 | .c.o: 392 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 393 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 394 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 395 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 396 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< 397 | 398 | .c.obj: 399 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 400 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 401 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 402 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 403 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 404 | 405 | .c.lo: 406 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 407 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo 408 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ 409 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 410 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< 411 | 412 | mostlyclean-libtool: 413 | -rm -f *.lo 414 | 415 | clean-libtool: 416 | -rm -rf .libs _libs 417 | 418 | ID: $(am__tagged_files) 419 | $(am__define_uniq_tagged_files); mkid -fID $$unique 420 | tags: tags-am 421 | TAGS: tags 422 | 423 | tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 424 | set x; \ 425 | here=`pwd`; \ 426 | $(am__define_uniq_tagged_files); \ 427 | shift; \ 428 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 429 | test -n "$$unique" || unique=$$empty_fix; \ 430 | if test $$# -gt 0; then \ 431 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 432 | "$$@" $$unique; \ 433 | else \ 434 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 435 | $$unique; \ 436 | fi; \ 437 | fi 438 | ctags: ctags-am 439 | 440 | CTAGS: ctags 441 | ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 442 | $(am__define_uniq_tagged_files); \ 443 | test -z "$(CTAGS_ARGS)$$unique" \ 444 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 445 | $$unique 446 | 447 | GTAGS: 448 | here=`$(am__cd) $(top_builddir) && pwd` \ 449 | && $(am__cd) $(top_srcdir) \ 450 | && gtags -i $(GTAGS_ARGS) "$$here" 451 | cscopelist: cscopelist-am 452 | 453 | cscopelist-am: $(am__tagged_files) 454 | list='$(am__tagged_files)'; \ 455 | case "$(srcdir)" in \ 456 | [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 457 | *) sdir=$(subdir)/$(srcdir) ;; \ 458 | esac; \ 459 | for i in $$list; do \ 460 | if test -f "$$i"; then \ 461 | echo "$(subdir)/$$i"; \ 462 | else \ 463 | echo "$$sdir/$$i"; \ 464 | fi; \ 465 | done >> $(top_builddir)/cscope.files 466 | 467 | distclean-tags: 468 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 469 | 470 | distdir: $(DISTFILES) 471 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 472 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 473 | list='$(DISTFILES)'; \ 474 | dist_files=`for file in $$list; do echo $$file; done | \ 475 | sed -e "s|^$$srcdirstrip/||;t" \ 476 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 477 | case $$dist_files in \ 478 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 479 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 480 | sort -u` ;; \ 481 | esac; \ 482 | for file in $$dist_files; do \ 483 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 484 | if test -d $$d/$$file; then \ 485 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 486 | if test -d "$(distdir)/$$file"; then \ 487 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 488 | fi; \ 489 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 490 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 491 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 492 | fi; \ 493 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 494 | else \ 495 | test -f "$(distdir)/$$file" \ 496 | || cp -p $$d/$$file "$(distdir)/$$file" \ 497 | || exit 1; \ 498 | fi; \ 499 | done 500 | check-am: all-am 501 | check: check-am 502 | all-am: Makefile $(PROGRAMS) 503 | installdirs: 504 | for dir in "$(DESTDIR)$(libexecdir)"; do \ 505 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 506 | done 507 | install: install-am 508 | install-exec: install-exec-am 509 | install-data: install-data-am 510 | uninstall: uninstall-am 511 | 512 | install-am: all-am 513 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 514 | 515 | installcheck: installcheck-am 516 | install-strip: 517 | if test -z '$(STRIP)'; then \ 518 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 519 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 520 | install; \ 521 | else \ 522 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 523 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 524 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 525 | fi 526 | mostlyclean-generic: 527 | 528 | clean-generic: 529 | 530 | distclean-generic: 531 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 532 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 533 | 534 | maintainer-clean-generic: 535 | @echo "This command is intended for maintainers to use" 536 | @echo "it deletes files that may require special tools to rebuild." 537 | clean: clean-am 538 | 539 | clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ 540 | mostlyclean-am 541 | 542 | distclean: distclean-am 543 | -rm -rf ./$(DEPDIR) 544 | -rm -f Makefile 545 | distclean-am: clean-am distclean-compile distclean-generic \ 546 | distclean-tags 547 | 548 | dvi: dvi-am 549 | 550 | dvi-am: 551 | 552 | html: html-am 553 | 554 | html-am: 555 | 556 | info: info-am 557 | 558 | info-am: 559 | 560 | install-data-am: 561 | 562 | install-dvi: install-dvi-am 563 | 564 | install-dvi-am: 565 | 566 | install-exec-am: install-libexecPROGRAMS 567 | 568 | install-html: install-html-am 569 | 570 | install-html-am: 571 | 572 | install-info: install-info-am 573 | 574 | install-info-am: 575 | 576 | install-man: 577 | 578 | install-pdf: install-pdf-am 579 | 580 | install-pdf-am: 581 | 582 | install-ps: install-ps-am 583 | 584 | install-ps-am: 585 | 586 | installcheck-am: 587 | 588 | maintainer-clean: maintainer-clean-am 589 | -rm -rf ./$(DEPDIR) 590 | -rm -f Makefile 591 | maintainer-clean-am: distclean-am maintainer-clean-generic 592 | 593 | mostlyclean: mostlyclean-am 594 | 595 | mostlyclean-am: mostlyclean-compile mostlyclean-generic \ 596 | mostlyclean-libtool 597 | 598 | pdf: pdf-am 599 | 600 | pdf-am: 601 | 602 | ps: ps-am 603 | 604 | ps-am: 605 | 606 | uninstall-am: uninstall-libexecPROGRAMS 607 | 608 | .MAKE: install-am install-strip 609 | 610 | .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ 611 | clean-libexecPROGRAMS clean-libtool cscopelist-am ctags \ 612 | ctags-am distclean distclean-compile distclean-generic \ 613 | distclean-libtool distclean-tags distdir dvi dvi-am html \ 614 | html-am info info-am install install-am install-data \ 615 | install-data-am install-dvi install-dvi-am install-exec \ 616 | install-exec-am install-html install-html-am install-info \ 617 | install-info-am install-libexecPROGRAMS install-man \ 618 | install-pdf install-pdf-am install-ps install-ps-am \ 619 | install-strip installcheck installcheck-am installdirs \ 620 | maintainer-clean maintainer-clean-generic mostlyclean \ 621 | mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ 622 | pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ 623 | uninstall-libexecPROGRAMS 624 | 625 | 626 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 627 | # Otherwise a system limit (for SysV at least) may be exceeded. 628 | .NOEXPORT: 629 | -------------------------------------------------------------------------------- /src/restful/base64.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /*(C) Copyright [2016] Hewlett Packard Enterprise Development Company, L.P.*/ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "base64.h" 11 | 12 | size_t calcDecodeLength(const char* b64input) { //Calculates the length of a decoded string 13 | size_t len = strlen(b64input), 14 | padding = 0; 15 | 16 | if (b64input[len-1] == '=' && b64input[len-2] == '=') //last two chars are = 17 | padding = 2; 18 | else if (b64input[len-1] == '=') //last char is = 19 | padding = 1; 20 | 21 | return (len*3)/4 - padding; 22 | } 23 | 24 | 25 | int base64_decode(char* b64message, char** buffer) { //Decodes a base64 encoded string 26 | BIO *bio, *b64; 27 | int decodeLen = calcDecodeLength(b64message), 28 | len = 0; 29 | *buffer = (char*)malloc(1024); 30 | FILE* stream = fmemopen(b64message, strlen(b64message), "r"); 31 | 32 | b64 = BIO_new(BIO_f_base64()); 33 | bio = BIO_new_fp(stream, BIO_NOCLOSE); 34 | bio = BIO_push(b64, bio); 35 | BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer 36 | len = BIO_read(bio, *buffer, 1024); 37 | //Can test here if len == decodeLen - if not, then return an error 38 | (*buffer)[len] = '\0'; 39 | 40 | BIO_free_all(bio); 41 | fclose(stream); 42 | 43 | return; //success 44 | } 45 | --------------------------------------------------------------------------------