· Nov 7, 2017

Is there a report of ports configured by services?


Is there a report of ports configured by services?

We have a lot of services, across multiple namespaces, and it would be useful to know what ports are configured, even for disabled services. 


Discussion (2)0
Log in or sign up to continue
$ ccontrol qlist

CACHE1^/opt/cache1^2015.1.4.803.0.16768^running, since Fri Sep 15 18:44:33 2017^cache.cpf^1972^57772^62972^ok^
CACHE2^/opt/cache2^2015.1.4.803.0.16768^running, since Mon Jul 24 08:43:47 2017^cache.cpf^56773^57773^62973^ok^
CACHE3^/opt/cache3^2015.1.4.803.0.16768^down, last used Thu Jul 27 18:02:03 2017^cache.cpf^56774^57774^62974^^

Windows analogue exists as well.

Hi Stephen,

This can be done with a custom query. See below for some sample code that takes the form of a stored procedure. This stored procedure only handles items in a single namespace, but you could adapt it to run across multiple namespaces.

To call the stored procedure from a SQL query tool:
call Sample.Util_SettingsByName('Port')

The parameter you pass is the name (or names, comma-separated) of the setting(s) you want to get a list of. Leave it blank to get a list of all settings.


Class Sample.Util Extends %RegisteredObject

         *                 ** N O T I C E **                 *
         *               - TEST/DEMO SOFTWARE -              *
         * This and related items are not supported by       *
         * InterSystems as part of any released product.     *
         * It is supplied by InterSystems as a demo/test     *
         * tool for a specific product and version.          *
         * The user or customer is fully responsible for     *
         * the maintenance of this software after delivery,  *
         * and InterSystems shall bear no responsibility nor *
         * liabilities for errors or misuse of this item.    *
         *                                                   *
Query SettingsByName(SettingName As %String) As %Query(ROWSPEC = "BusinessHost:%String,SettingName:%String,SettingValue:%String") [ SqlProc ]

ClassMethod SettingsByNameExecute(ByRef qHandle As %Binary, SettingNames As %String = "") As %Status
    s qHandle=##class(%ArrayOfObjects).%New()

    &sql(select %DLIST(id) into :tHostIDs from ENS_Config.Item order by Name desc)
    s tHostIDList=##class(%Library.ListOfDataTypes).%New()
    s tSC=tHostIDList.InsertList(tHostIDs)
    s tSC=qHandle.SetAt(tHostIDList,"HostIDs")

    s tSC=qHandle.SetAt(##class(%ArrayOfDataTypes).%New(),"Counters")
    s tSC=qHandle.GetAt("Counters").SetAt(0,"CurrHost")
    s tSC=qHandle.GetAt("Counters").SetAt(0,"CurrSetting")
    if ($L(SettingNames)>1) {
        s SettingNames=$ZCONVERT(SettingNames,"U")
        s tFilterList=##class(%Library.ListOfDataTypes).%New()
        s tSC=tFilterList.InsertList($LISTFROMSTRING(SettingNames))
         s tSC=qHandle.SetAt(tFilterList,"FilterList")

    Quit $$$OK

ClassMethod SettingsByNameClose(ByRef qHandle As %Binary) As %Status [ PlaceAfter = SettingsByNameExecute ]
    Quit $$$OK

ClassMethod SettingsByNameFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = SettingsByNameExecute ]
    s tCurrHost=qHandle.GetAt("Counters").GetAt("CurrHost")
    s tCurrSetting=qHandle.GetAt("Counters").GetAt("CurrSetting")
    s tHostIDs=qHandle.GetAt("HostIDs")
    s tFilterList=qHandle.GetAt("FilterList")
    s oHost=qHandle.GetAt("Host")

    do {
        if ('$IsObject(oHost)||(oHost.VirtualSettings.Count()<tCurrSetting)) {
            if (tCurrHost=tHostIDs.Count()) {
                s AtEnd=1

            s tCurrHost=tCurrHost+1
            s tCurrSetting=1
            s tHostID=tHostIDs.GetAt(tCurrHost)
            s oHost=##class(Ens.Config.Item).%OpenId(tHostID,0)
            s tSC=oHost.PopulateVirtualSettings()

            s tSC=qHandle.SetAt(oHost,"Host")                
            s tSC=qHandle.GetAt("Counters").SetAt(tCurrHost,"CurrHost")

        s tSettings=oHost.VirtualSettings
        s tSetting=tSettings.GetAt(tCurrSetting)
        s tStngName=$LISTGET(tSetting,2)
        s tStngValue=$LISTGET(tSetting,3)
        s tCurrSetting=tCurrSetting+1
    } while ($IsObject(tFilterList)&&('tFilterList.Find($ZCONVERT(tStngName,"U"))))
    if ('AtEnd) {
        s Row=$LB(oHost.Name,tStngName,tStngValue)
    s tSC=qHandle.GetAt("Counters").SetAt(tCurrSetting,"CurrSetting")
    Quit $$$OK