Skip to content

Commit

Permalink
properly handles channel undeployment and connectors deactivation bet…
Browse files Browse the repository at this point in the history
…ween discovery cycles
  • Loading branch information
cboyer committed Nov 24, 2018
1 parent c7f7625 commit 79fa433
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 39 deletions.
46 changes: 31 additions & 15 deletions Mirth/Mirthix_channel.xml
Expand Up @@ -6,10 +6,10 @@
https://github.com/cboyer/mirth-zabbix</description>
<enabled>true</enabled>
<lastModified>
<time>1542929482492</time>
<time>1543072726639</time>
<timezone>America/Toronto</timezone>
</lastModified>
<revision>445</revision>
<revision>514</revision>
<sourceConnector version="3.2.1">
<metaDataId>0</metaDataId>
<name>sourceConnector</name>
Expand Down Expand Up @@ -38,7 +38,7 @@ https://github.com/cboyer/mirth-zabbix</description>
<remotePort></remotePort>
<overrideLocalBinding>false</overrideLocalBinding>
<reconnectInterval>5000</reconnectInterval>
<receiveTimeout>0</receiveTimeout>
<receiveTimeout>500</receiveTimeout>
<bufferSize>65536</bufferSize>
<maxConnections>1000</maxConnections>
<keepConnectionOpen>true</keepConnectionOpen>
Expand Down Expand Up @@ -187,7 +187,7 @@ return Packages.org.apache.commons.codec.binary.Base64.encodeBase64String(zabbix
* Released under the GNU General Public License v3 (GPLv3)
*/

var agent_version = &apos;1.0.0&apos;;
var agent_version = &apos;1.0.1&apos;;
var item_requested = msg.toString();
//logger.info(&quot;Zabbix requested: &quot; + item_requested); //Debug

Expand Down Expand Up @@ -251,7 +251,13 @@ switch (item_requested) {

case &apos;mirth.deployementdate&apos;:
var controller = com.mirth.connect.server.controllers.ControllerFactory.getFactory().createEngineController();
msg = controller.getChannelStatus(channel_id).getDeployedDate().getTime().toString();
var channel_status = controller.getChannelStatus(channel_id);

if (channel_status == null)
msg = &quot;ZBX_NOTSUPPORTED\x00Item became not available&quot;;
else
msg = channel_status.getDeployedDate().getTime().toString();

//logger.info(&quot;Deployment date: &quot; + channel_id + &quot; &quot; + msg); //Debug
break;

Expand Down Expand Up @@ -280,11 +286,16 @@ switch (item_requested) {
default:
msg = &quot;ZBX_NOTSUPPORTED\x00Metric not implemented in Mirthix: &quot; + msg;
}

if (msg == null)
msg = &quot;ZBX_NOTSUPPORTED\x00Item became not available&quot;;

break;

case &apos;mirth.channel.status&apos;:
case &apos;mirth.connector.status&apos;:
var item_status = &apos;&apos;;

if (item_requested == &apos;mirth.connector.status&apos;)
item_status = ChannelUtil.getConnectorState(channel_id, connector_id) + &quot;&quot;; //toString() not effective in switch

Expand Down Expand Up @@ -316,11 +327,8 @@ switch (item_requested) {
case &apos;Undeploying&apos;:
msg = 7;
break;
case null:
msg = 8;
break;
default:
msg = 9;
msg = &quot;ZBX_NOTSUPPORTED\x00Item became not available&quot;;
}

//logger.info(&quot;Status: &quot; + msg); //Debug
Expand Down Expand Up @@ -414,7 +422,7 @@ switch (item_requested) {
* Released under the GNU General Public License v3 (GPLv3)
*/

var agent_version = &apos;1.0.0&apos;;
var agent_version = &apos;1.0.1&apos;;
var item_requested = msg.toString();
//logger.info(&quot;Zabbix requested: &quot; + item_requested); //Debug

Expand Down Expand Up @@ -478,7 +486,13 @@ switch (item_requested) {

case &apos;mirth.deployementdate&apos;:
var controller = com.mirth.connect.server.controllers.ControllerFactory.getFactory().createEngineController();
msg = controller.getChannelStatus(channel_id).getDeployedDate().getTime().toString();
var channel_status = controller.getChannelStatus(channel_id);

if (channel_status == null)
msg = &quot;ZBX_NOTSUPPORTED\x00Item became not available&quot;;
else
msg = channel_status.getDeployedDate().getTime().toString();

//logger.info(&quot;Deployment date: &quot; + channel_id + &quot; &quot; + msg); //Debug
break;

Expand Down Expand Up @@ -507,11 +521,16 @@ switch (item_requested) {
default:
msg = &quot;ZBX_NOTSUPPORTED\x00Metric not implemented in Mirthix: &quot; + msg;
}

if (msg == null)
msg = &quot;ZBX_NOTSUPPORTED\x00Item became not available&quot;;

break;

case &apos;mirth.channel.status&apos;:
case &apos;mirth.connector.status&apos;:
var item_status = &apos;&apos;;

if (item_requested == &apos;mirth.connector.status&apos;)
item_status = ChannelUtil.getConnectorState(channel_id, connector_id) + &quot;&quot;; //toString() not effective in switch

Expand Down Expand Up @@ -543,11 +562,8 @@ switch (item_requested) {
case &apos;Undeploying&apos;:
msg = 7;
break;
case null:
msg = 8;
break;
default:
msg = 9;
msg = &quot;ZBX_NOTSUPPORTED\x00Item became not available&quot;;
}

//logger.info(&quot;Status: &quot; + msg); //Debug
Expand Down
10 changes: 1 addition & 9 deletions Zabbix/Zabbix_template.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.4</version>
<date>2018-11-22T23:46:46Z</date>
<date>2018-11-24T04:39:02Z</date>
<groups>
<group>
<name>Templates</name>
Expand Down Expand Up @@ -594,14 +594,6 @@ Unknown = 8</description>
<value>7</value>
<newvalue>Undeploying</newvalue>
</mapping>
<mapping>
<value>8</value>
<newvalue>Disabled</newvalue>
</mapping>
<mapping>
<value>9</value>
<newvalue>Unknown</newvalue>
</mapping>
</mappings>
</value_map>
</value_maps>
Expand Down
10 changes: 1 addition & 9 deletions Zabbix/Zabbix_valuemap.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.4</version>
<date>2018-11-18T22:56:54Z</date>
<date>2018-11-24T04:39:37Z</date>
<value_maps>
<value_map>
<name>Mirth channel status</name>
Expand Down Expand Up @@ -38,14 +38,6 @@
<value>7</value>
<newvalue>Undeploying</newvalue>
</mapping>
<mapping>
<value>8</value>
<newvalue>Disabled</newvalue>
</mapping>
<mapping>
<value>9</value>
<newvalue>Unknown</newvalue>
</mapping>
</mappings>
</value_map>
</value_maps>
Expand Down
20 changes: 14 additions & 6 deletions src/destination_transformer.js
Expand Up @@ -9,7 +9,7 @@
* Released under the GNU General Public License v3 (GPLv3)
*/

var agent_version = '1.0.0';
var agent_version = '1.0.1';
var item_requested = msg.toString();
//logger.info("Zabbix requested: " + item_requested); //Debug

Expand Down Expand Up @@ -73,7 +73,13 @@ switch (item_requested) {

case 'mirth.deployementdate':
var controller = com.mirth.connect.server.controllers.ControllerFactory.getFactory().createEngineController();
msg = controller.getChannelStatus(channel_id).getDeployedDate().getTime().toString();
var channel_status = controller.getChannelStatus(channel_id);

if (channel_status == null)
msg = "ZBX_NOTSUPPORTED\x00Item became not available";
else
msg = channel_status.getDeployedDate().getTime().toString();

//logger.info("Deployment date: " + channel_id + " " + msg); //Debug
break;

Expand Down Expand Up @@ -102,11 +108,16 @@ switch (item_requested) {
default:
msg = "ZBX_NOTSUPPORTED\x00Metric not implemented in Mirthix: " + msg;
}

if (msg == null)
msg = "ZBX_NOTSUPPORTED\x00Item became not available";

break;

case 'mirth.channel.status':
case 'mirth.connector.status':
var item_status = '';

if (item_requested == 'mirth.connector.status')
item_status = ChannelUtil.getConnectorState(channel_id, connector_id) + ""; //toString() not effective in switch

Expand Down Expand Up @@ -138,11 +149,8 @@ switch (item_requested) {
case 'Undeploying':
msg = 7;
break;
case null:
msg = 8;
break;
default:
msg = 9;
msg = "ZBX_NOTSUPPORTED\x00Item became not available";
}

//logger.info("Status: " + msg); //Debug
Expand Down

0 comments on commit 79fa433

Please sign in to comment.