7941ee5bbb
This update introduces a new Link Monitor daemon to the Mtce flock of daemons and disable rmon's interface monitoring. This new daemon parses the platform.conf file and using the interface names assigned to each monitored network (mgmt, infra and oam) queries the kernel for their physical, bonded and vlan interface names and then registers to listen for netlink events. All link/interface state change (netlink) events that correspond to any of the interfaces or links assiciated with the monitored networks are tracked by this new daemon. This new daemon then also implements an http listener for localhost initiated GET requests targeted to /mtce/lmond on port 2122 and responds with a json link_info string that contains a summary of monitored networks, links and their current Up/Down status. lmond behavioral summary: 1. learn interface/port model, 2. load initial link status for learned links, 3. listen for link status change events 4. provide link status info to http GET Query requests. Another update to stx-integ implements the collectd interface plugin that periodically issues the Link Status GET requests for the purponse of alarming port and interface Down conditions, clearing alarms on Up state changes, and storing sample data that represents the percentage of active links for each monitored network. Test Plan: PASS: Verify lmond process startup PASS: Verify lmond logging and log rotation PASS: Verify lmond process monitoring by pmon PASS: Verify lmond interface learning on process startup PASS: Verify lmond port learning on process startup PASS: Verify lmond handling of vlan and bond interface types PASS: Verify lmond http link info GET Query handling PASS: Verify lmond has no memory leak during normal and eventfull operation Change-Id: I58915644e60f31e3a12c3b451399c4f76ec2ea37 Story: 2002823 Task: 28635 Depends-On: Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
146 lines
3.4 KiB
C++
146 lines
3.4 KiB
C++
/*
|
|
* Copyright (c) 2019 Wind River Systems, Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* Starling-X Maintenance Link Monitor Initialization
|
|
*/
|
|
|
|
#include "lmon.h"
|
|
|
|
/** Daemon Configuration Structure - Allocation and get pointer
|
|
* @see daemon_common.h for daemon_config_type struct format. */
|
|
static daemon_config_type lmon_config ;
|
|
daemon_config_type * daemon_get_cfg_ptr () { return &lmon_config ; }
|
|
|
|
/* read config label values */
|
|
static int lmon_config_handler ( void * user,
|
|
const char * section,
|
|
const char * name,
|
|
const char * value)
|
|
{
|
|
daemon_config_type* config_ptr = (daemon_config_type*)user;
|
|
|
|
if (MATCH("client", "audit_period"))
|
|
{
|
|
config_ptr->audit_period = atoi(value);
|
|
ilog ("Audit Period: %d (secs)", config_ptr->audit_period );
|
|
}
|
|
else if (MATCH("client", "lmon_query_port"))
|
|
{
|
|
config_ptr->lmon_query_port = atoi(value);
|
|
ilog ("Status Query: %d (port)", config_ptr->lmon_query_port );
|
|
}
|
|
else if (MATCH("client", "daemon_log_port"))
|
|
{
|
|
config_ptr->daemon_log_port = atoi(value);
|
|
ilog ("Daemon Log : %d (port)", config_ptr->daemon_log_port );
|
|
}
|
|
else if (MATCH("client", "uri_path"))
|
|
{
|
|
config_ptr->uri_path = strdup(value);
|
|
}
|
|
|
|
return (PASS);
|
|
}
|
|
|
|
/*****************************************************************************
|
|
*
|
|
* Name : daemon_configure
|
|
*
|
|
* Purpose : Read process config file settings into the daemon configuration
|
|
*
|
|
* Configuration File */
|
|
|
|
#define CONFIG_FILE ((const char *)"/etc/mtc/lmond.conf")
|
|
|
|
/*****************************************************************************/
|
|
|
|
int daemon_configure ( void )
|
|
{
|
|
int rc = PASS ;
|
|
|
|
/* read config out of /etc/mtc/lmond.conf */
|
|
if (ini_parse( CONFIG_FILE, lmon_config_handler, &lmon_config) < 0)
|
|
{
|
|
elog("Can't load '%s'\n", CONFIG_FILE );
|
|
rc = FAIL_INI_CONFIG ;
|
|
}
|
|
else
|
|
{
|
|
get_debug_options ( CONFIG_FILE, &lmon_config );
|
|
}
|
|
return (rc);
|
|
}
|
|
|
|
/*****************************************************************************
|
|
*
|
|
* Name : daemon_init
|
|
*
|
|
* Purpose : Daemon Initialization
|
|
*
|
|
*****************************************************************************/
|
|
|
|
int daemon_init ( string iface, string nodetype_str )
|
|
{
|
|
int rc = PASS ;
|
|
|
|
UNUSED(iface);
|
|
UNUSED(nodetype_str);
|
|
|
|
if ( daemon_files_init ( ) != PASS )
|
|
{
|
|
elog ("Pid, log or other files could not be opened\n");
|
|
return ( FAIL_FILES_INIT ) ;
|
|
}
|
|
|
|
/* Bind signal handlers */
|
|
if ( daemon_signal_init () != PASS )
|
|
{
|
|
elog ("daemon_signal_init failed\n");
|
|
return ( FAIL_SIGNAL_INIT );
|
|
}
|
|
|
|
daemon_wait_for_file ( CONFIG_COMPLETE_FILE, 0);
|
|
daemon_wait_for_file ( PLATFORM_DIR, 0);
|
|
daemon_wait_for_file ( GOENABLED_MAIN_READY, 0);
|
|
|
|
/* Configure the daemon */
|
|
if ( (rc = daemon_configure ( )) != PASS )
|
|
{
|
|
elog ("Daemon service configuration failed (rc:%i)\n", rc );
|
|
rc = FAIL_DAEMON_CONFIG ;
|
|
}
|
|
|
|
return (rc);
|
|
}
|
|
|
|
|
|
void daemon_dump_info ( void )
|
|
{
|
|
|
|
|
|
}
|
|
|
|
void daemon_sigchld_hdlr ( void )
|
|
{
|
|
; /* dlog("Received SIGCHLD ... no action\n"); */
|
|
}
|
|
|
|
const char MY_DATA [100] = { "eieio\n" } ;
|
|
const char * daemon_stream_info ( void )
|
|
{
|
|
return (&MY_DATA[0]);
|
|
}
|
|
|
|
/** Teat Head Entry */
|
|
int daemon_run_testhead ( void )
|
|
{
|
|
// ilog ("Empty test head.\n");
|
|
return (PASS);
|
|
}
|