Procedimiento para agregar un nuevo dispositivo en opConfig

Propósito

Se desea extraer la ejecución del comando cmd8e1 -temperature en cada uno de los RTGs , esto durante cada hora y que se alerte si hay algún cambio en el threshold que el cliente proporcionarán para cada equipo en específico. De igual forma, desean graficar los datos.

Requisito

Ya se puede acceder a cada uno de los equipos vía consola y ejecutar el comando mencionado:

[root@cc_Opmantek ~]# ssh root@192.168.83.131

root@192.168.83.131's password:

Last login: Mon May 20 10:02:03 2019 from 172.24.249.14

root@cdcarmen_rtg8_1 ~ # cmd8e1 -temperature

[cmd8e1] Ambient temperature : 28?C

[cmd8e1] CPU temperature : 26?C

Configuración

A continuación, desarrollaremos los pasos a seguir para implementar un plugin en opConfig:

1.- Antes de agregar los equipos a NMIS, comprobamos que sí tenemos acceso vía SSH con las credenciales correspondientes (en donde nos aparece el mensaje ‘Are you sure…’ escribimos yes y damos enter):



2.- Agregamos los equipos a NMIS y, en opConfig, importamos los equipos desde NMIS:


3.- Agregamos las credenciales en opConfig > Edit Credential Sets y guardamos.


4.- Después, en /usr/local/omk/conf/OS_Rules.nmis aplicamos una regla para los nuevos equipos, usando los datos que aparecen en NMIS:

Y el campo ‘Personality’ que detecta en opConfig:

120 =>  {

                'IF' => {

                        'nodeVendor' => qr/net-snmp/,

                        'sysDescr' => 'Linux cdcarmen_rtg8',

                },

                'SET' => {

                        'os_info.os' => 'LinuxRTG',

                        'connection_info.personality' => 'bash',                                                     

                BREAK => 'true',

                }

               },


5.- Después, creamos un nuevo archivo en /usr/local/omk/conf/command_sets.d/linuxrtg.nmis con el comando que se va a ejecutar, en este caso será cada hora:


# command sets for RTGs-linux systems

%hash = (

 

  #'LINUXRTGS_HOURLY' => {

  'collect_with_plugin' => {

    'os_info' => {

      'os' => '/(LinuxRTG)/'

    },

    'purging_policy' => {

      'keep_last' => 1000,

      'purge_older_than' => 2592000, # 30 days

      'autoprotect_first_revision' => 'true',

    },

 

    'scheduling_info' => {

      'run_commands_on_separate_connection' => 'false',

    },

    'commands' => [

      {

        'privileged' => 'false',

        'command' => 'cmd8e1 -temperature',

        #'tags' => [ 'HOURLY', 'temperatura', 'detect-change', 'report-change' ],

        'tags' => [ 'HOURLY', 'temperatura', 'detect-change'],

        #use_collection_plugin => "RTGPlugin",

      },

    ],

  },

);


6.- Una vez que tengamos todo listo, configuramos cada uno de los nodos en opConfig con los datos que hemos colocado en los dos archivos anteriores:


*Modificamos el Os a LinuxRTG como lo hemos puesto en ambos archivos.

7.- Ahora, en consola aplicamos un run_command_sets para comprobar que se ejecute el comando deseado:

[root@cc_Opmantek ~]# /usr/local/omk/bin/opconfig-cli.exe act=run_command_sets node=cdcarmen_rtg8_1 debug=true

opconfig-cli.pl Version 3.1.0


Copyright (C) 2015 Opmantek Limited (www.opmantek.com)

This program comes with ABSOLUTELY NO WARRANTY;

See www.opmantek.com or email contact@opmantek.com

 

Internal NOC, Mexico City


[Fri May 17 17:48:43 2019] [info] cli[15139] opconfig-cli running command sets, with mthread=1, max_procs=10

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/asa.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/externals.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/extremexos.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/file_store.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/fortinet.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/ios.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/iosxe.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/iosxr.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/juniper.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/linuxrtg.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/mikrotik.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/nxos.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/qnap.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/redback.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Loading command sets from /usr/local/omk/conf/command_sets.d/screenos.nmis

[Fri May 17 17:48:43 2019] [debug] cli[15139] Found suitable plugin HighBandwidthPlugin

[Fri May 17 17:48:43 2019] [error] cli[15139] Ignoring plugin RTGPlugin.pm: doesn't have correct "package" declaration

[Fri May 17 17:48:43 2019] [debug] cli[15139] starting run_and_store_commands for node cdcarmen_rtg8_1 and commands cmd8e1 -temperature

[Fri May 17 17:48:43 2019] [debug] cli[15139] Getting session for node cdcarmen_rtg8_1

[Fri May 17 17:48:44 2019] [debug] cli[15139] run_and_store_command: Running command "cmd8e1 -temperature" on cdcarmen_rtg8_1 (192.168.83.131)

[Fri May 17 17:48:44 2019] [debug] cli[15139] Storing first revision for cdcarmen_rtg8_1 (192.168.83.131), command "cmd8e1 -temperature"

[Fri May 17 17:48:44 2019] [debug] cli[15139] run_and_store_commands node cdcarmen_rtg8_1 done, result success

[Fri May 17 17:48:44 2019] [debug] cli[15139] run_many_commands is done, waiting for children to finish

[Fri May 17 17:48:44 2019] [debug] cli[15139] found child process 15141 has finished with status 65280


8.- Y comenzaremos a ver el comando requerido en opConfig (el cual se ejecutará cada hora):