server status reporting via iocsh

This commit is contained in:
Michael Davidsaver
2017-11-05 15:42:46 -06:00
parent dc99e2ae4c
commit 47332fdf90
7 changed files with 60 additions and 31 deletions

View File

@@ -88,7 +88,7 @@ void stopPVAServer()
}
}
void statusPVAServer()
void pvasr(int lvl)
{
try {
pvd::Lock G(the_server_lock);
@@ -96,7 +96,7 @@ void statusPVAServer()
std::cout<<"PVA server not running\n";
return;
} else {
the_server->printInfo();
the_server->printInfo(lvl);
}
}catch(std::exception& e){
std::cout<<"Error: "<<e.what()<<"\n";
@@ -118,8 +118,8 @@ void initStartPVAServer(initHookState state)
void registerStartPVAServer(void)
{
epics::iocshRegister<const char*, &startPVAServer>("startPVAServer", "provider names");
epics::iocshRegister<&statusPVAServer>("statusPVAServer");
epics::iocshRegister<&stopPVAServer>("stopPVAServer");
epics::iocshRegister<int, &pvasr>("pvasr", "detail");
initHookRegister(&initStartPVAServer);
}

View File

@@ -1464,10 +1464,10 @@ BlockingServerTCPTransportCodec::getChannel(pvAccessID sid) {
}
int BlockingServerTCPTransportCodec::getChannelCount() {
size_t BlockingServerTCPTransportCodec::getChannelCount() const {
Lock lock(_channelsMutex);
return static_cast<int>(_channels.size());
return _channels.size();
}

View File

@@ -363,7 +363,7 @@ public:
}
virtual epics::pvData::int8 getRevision() const OVERRIDE FINAL {
return PVA_PROTOCOL_REVISION;
return std::min(PVA_PROTOCOL_REVISION, _remoteTransportRevision);
}
@@ -548,7 +548,7 @@ public:
virtual ServerChannel::shared_pointer getChannel(pvAccessID sid) OVERRIDE FINAL;
virtual int getChannelCount() OVERRIDE FINAL;
virtual size_t getChannelCount() const OVERRIDE FINAL;
virtual bool verify(epics::pvData::int32 timeoutMs) OVERRIDE FINAL {
@@ -600,7 +600,7 @@ private:
*/
std::map<pvAccessID, ServerChannel::shared_pointer> _channels;
epics::pvData::Mutex _channelsMutex;
mutable epics::pvData::Mutex _channelsMutex;
epics::pvData::Status _verificationStatus;
epics::pvData::Mutex _verificationStatusMutex;

View File

@@ -524,7 +524,7 @@ public:
* Get channel count.
* @return channel count.
*/
virtual int getChannelCount() = 0;
virtual size_t getChannelCount() const = 0;
};
/**

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;

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;

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()