ChimeraEntertainment / monit-windows-agent

LEGACY: monit agent for Windows
MIT License
49 stars 8 forks source link

Problem with XML control file #15

Open vinceroi opened 7 years ago

vinceroi commented 7 years ago

Hi I am struggling to start the Monitor Windows Agent.

D:\Program Files (x86)\monit-windows-agent>MonitWindowsAgent.exe -c "D:\Program Files (x86)\monit-windows-agent\MonitWindowsAgentConfig.xml" -l "D:\Program File s (x86)\monit-windows-agent\MonitWindowsAgent.log" start all

Unhandled Exception: System.Exception: Invalid argument at ChMonitoring.Program.do_action(ServiceController ctl, String[] args) at ChMonitoring.Program.Main(String[] args)

in the log file "MonitWindowsAgent.log": 2017-08-16 15:44:26,177 [1] INFO MonitWindowsAgent [(null)] - MonitWindowsAgent Main 2017-08-16 15:44:26,646 [1] ERROR MonitWindowsAgent [(null)] - warning: No ActionRate defined for Service: c:\ 2017-08-16 15:44:30,568 [1] ERROR MonitWindowsAgent [(null)] - Invalid argument -- D:\Program Files (x86)\monit-windows-agent\MonitWindowsAgentConfig.xml (-h will show valid arguments)

m4x1202 commented 7 years ago

Hey,

i'm afraid the -l and -c command line options are not yet implemented. I can see from your command though that you are using the default configuration and log files. Therefore you can just leave them out of your command. D:\Program Files (x86)\monit-windows-agent>MonitWindowsAgent.exe start all would suffice.

Unfortunately this tool is not being actively maintained from our company anymore, therefore if you need to specify those command line options please feel free to implement them and assign the pull request to me.

vinceroi commented 7 years ago

Thanks for your response! It is really appreciated.

Following your advice, I now have less error in the log:

2017-08-21 16:40:10,874 [1] INFO  MonitWindowsAgent [(null)] - MonitWindowsAgent Main
2017-08-21 16:40:11,374 [1] ERROR MonitWindowsAgent [(null)] - warning: No ActionRate defined for Service: c:\

I think this error (+ the fact it does not register to our central M/MONIT) is due to errors in my MonitWindowsAgentConfig.xml. Would you have I a concrete example for this config file? I am trying to monitor my C: drive:

<?xml version="1.0"?>
<MonitWindowsAgentConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Period>10</Period>
  <DisplayName>ch06chuma6096</DisplayName>
  <Services>
    <Process Name="test-service-name-1">
      <ActionRate Count="3" Cycle="5" ActionType="5"></ActionRate>
      <Resources>
        <Resource Type="1" ComparisonOperator=">" Limit="800" ActionType="2" />
      </Resources>
    </Process>
    <Process Name="test-service-name-2">
      <ActionRate Count="3" Cycle="5" ActionType="5"></ActionRate>
      <Resources>
        <Resource Type="1" ComparisonOperator=">" Limit="800" ActionType="2" />
      </Resources>
    </Process>
    <Filesystem Name="c:\">
      <Filesystems>
        <Filesystem Type="11" ComparisonOperator=">" LimitPercent="90" ActionType="2" />
      </Filesystems>
    </Filesystem>
  </Services>
  <FailedStarts>5</FailedStarts>
  <MMonits>
    <MMonit Url="https://10.XX.XX.XX:8443/collector" Username="monit" Password="XXXX" />
  </MMonits>
  <Httpd BindIp="127.0.0.1" Port="2812" Username="admin" Password="monit" SSL="false" />
</MonitWindowsAgentConfig>

If I manage to make it work, I'll check if I know someone who knows C++ or C# and could look at implementing this.

m4x1202 commented 7 years ago

Hey,

after reviewing the code again (it has been some time :)) i figured out your Filesystem name is incorrect.

The name has to be the the name you gave your Hard Disk, this for example is my setup:

<Services>
  <Filesystem Name="Local Disk">
    <Filesystems>
      <Filesystem Type="11" ComparisonOperator=">" LimitPercent="90" ActionType="2" />
    </Filesystems>
  </Filesystem>
</Services>

image

vinceroi commented 7 years ago

Thanks for your response! I followed your advice but got the similar error:

2017-08-22 12:09:06,520 [1] INFO  MonitWindowsAgent [(null)] - MonitWindowsAgent Main
2017-08-22 12:09:06,958 [1] ERROR MonitWindowsAgent [(null)] - warning: No ActionRate defined for Service: Local Disk

Then I decided to comment this part about filesystems in the XML file, to remove the error and see if the agent was registered to the central M/MONIT but I don't see the new host in the list of M/MONIT hosts.

windware-ono commented 4 years ago

Adding "ActionRate" from the sample did send to m/monit, though I'm not sure what the parameters actually mean and it sent the data quite excessively as in like 10 times a second but must be one of the parameters there.

https://github.com/ChimeraEntertainment/monit-windows-agent/blob/develop/ChMonitWindowsAgent/Resources/MonitWindowsAgentConfig.xml