server status reporting via iocsh

This commit is contained in:
Michael Davidsaver
2017-11-05 15:59:01 -06:00
parent dc99e2ae4c
commit 47332fdf90
7 changed files with 60 additions and 31 deletions
+3 -2
View File
@@ -61,13 +61,14 @@ public:
/**
* Prints detailed information about the context to the standard output stream.
*/
void printInfo();
void printInfo(int lvl =0);
/**
* Prints detailed information about the context to the specified output stream.
* @param lvl detail level
* @param str stream to which to print the info
*/
virtual void printInfo(std::ostream& str) = 0;
virtual void printInfo(std::ostream& str, int lvl=0) = 0;
void dispose() EPICS_DEPRECATED;
+1 -1
View File
@@ -43,7 +43,7 @@ public:
void initialize();
void run(epics::pvData::uint32 seconds) OVERRIDE FINAL;
void shutdown() OVERRIDE FINAL;
void printInfo(std::ostream& str) OVERRIDE FINAL;
void printInfo(std::ostream& str, int lvl) OVERRIDE FINAL;
void setBeaconServerStatusProvider(BeaconServerStatusProvider::shared_pointer const & beaconServerStatusProvider) OVERRIDE FINAL;
//**************** derived from Context ****************//
epics::pvData::Timer::shared_pointer getTimer() OVERRIDE FINAL;
+47 -19
View File
@@ -15,6 +15,7 @@
#include <pv/responseHandlers.h>
#include <pv/logger.h>
#include <pv/serverContextImpl.h>
#include <pv/codec.h>
#include <pv/security.h>
using namespace std;
@@ -404,30 +405,57 @@ void ServerContextImpl::destroyAllTransports()
}
}
void ServerContext::printInfo()
void ServerContext::printInfo(int lvl)
{
printInfo(cout);
printInfo(cout, lvl);
}
void ServerContextImpl::printInfo(ostream& str)
void ServerContextImpl::printInfo(ostream& str, int lvl)
{
Lock guard(_mutex);
str << "VERSION : " << getVersion().getVersionString() << endl
<< "PROVIDER_NAMES : ";
for(std::vector<ChannelProvider::shared_pointer>::const_iterator it = _channelProviders.begin();
it != _channelProviders.end(); ++it)
{
str<<(*it)->getProviderName()<<", ";
if(lvl==0) {
Lock guard(_mutex);
str << "VERSION : " << getVersion().getVersionString() << endl
<< "PROVIDER_NAMES : ";
for(std::vector<ChannelProvider::shared_pointer>::const_iterator it = _channelProviders.begin();
it != _channelProviders.end(); ++it)
{
str<<(*it)->getProviderName()<<", ";
}
str << endl
<< "BEACON_ADDR_LIST : " << _beaconAddressList << endl
<< "AUTO_BEACON_ADDR_LIST : " << _autoBeaconAddressList << endl
<< "BEACON_PERIOD : " << _beaconPeriod << endl
<< "BROADCAST_PORT : " << _broadcastPort << endl
<< "SERVER_PORT : " << _serverPort << endl
<< "RCV_BUFFER_SIZE : " << _receiveBufferSize << endl
<< "IGNORE_ADDR_LIST: " << _ignoreAddressList << endl
<< "INTF_ADDR_LIST : " << inetAddressToString(_ifaceAddr, false) << endl;
} else {
// lvl > 0
TransportRegistry::transportVector_t transports;
_transportRegistry.toArray(transports);
str<<"Clients:\n";
for(TransportRegistry::transportVector_t::const_iterator it(transports.begin()), end(transports.end());
it!=end; ++it)
{
const Transport::shared_pointer& transport(*it);
str<<"client "<<transport->getType()<<"://"<<transport->getRemoteName()
<<" ver="<<unsigned(transport->getRevision())
<<" "<<(transport->isClosed()?"closed!":"");
const detail::BlockingServerTCPTransportCodec *casTransport = dynamic_cast<const detail::BlockingServerTCPTransportCodec*>(transport.get());
if(casTransport) {
str<<" "<<(casTransport ? casTransport->getChannelCount() : size_t(-1))<<" channels";
}
str<<"\n";
}
}
str << endl
<< "BEACON_ADDR_LIST : " << _beaconAddressList << endl
<< "AUTO_BEACON_ADDR_LIST : " << _autoBeaconAddressList << endl
<< "BEACON_PERIOD : " << _beaconPeriod << endl
<< "BROADCAST_PORT : " << _broadcastPort << endl
<< "SERVER_PORT : " << _serverPort << endl
<< "RCV_BUFFER_SIZE : " << _receiveBufferSize << endl
<< "IGNORE_ADDR_LIST: " << _ignoreAddressList << endl
<< "INTF_ADDR_LIST : " << inetAddressToString(_ifaceAddr, false) << endl;
}
void ServerContext::dispose()