Monitor Windows Service stats from Linux

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
mrossTTX
Cacti User
Posts: 114
Joined: Wed Dec 07, 2022 12:49 pm

Re: Monitor Windows Service stats from Linux

Post by mrossTTX »

i have thold working to monitor a service.. HOWEVER.. it wont work if the service uses svchost.exe and it's many switches.
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

One of the reasons I despise certain OS'. Security through obscurity. What about WMI? Can you get better information from WMI?
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

You can run WMI queries from Cacti and store the table data in Cacti.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mrossTTX
Cacti User
Posts: 114
Joined: Wed Dec 07, 2022 12:49 pm

Re: Monitor Windows Service stats from Linux

Post by mrossTTX »

TheWitness wrote: Tue Jan 03, 2023 9:35 am You can run WMI queries from Cacti and store the table data in Cacti.
im trying to do that.. figured I'd give it a shot..
im using a WMI query tool to try to build the query, but in cacti, it tells me the WMI query doesnt exist
attached is the query screen shot in cacti, and a screen shot of the wmi explorer tool I am using.
Trying to get cacti to see the state is either running or not running, but cacti keeps telling me , when i look at the server im trying to query, "WMI Query Does Not Exist".
I know I am probably doing something wrong in the WMI query window in cacti.. but not sure what.
Attachments
WMIExplorer.JPG
WMIExplorer.JPG (57.84 KiB) Viewed 3112 times
WMIQuery.JPG
WMIQuery.JPG (57.2 KiB) Viewed 3112 times
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

Take a look at the WMI Plugin. I've not touched in a while. It would be nicer to be able to run a SQL query against a local database vs. all the latency across the WAN to deal with.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mrossTTX
Cacti User
Posts: 114
Joined: Wed Dec 07, 2022 12:49 pm

Re: Monitor Windows Service stats from Linux

Post by mrossTTX »

TheWitness wrote: Tue Jan 03, 2023 12:55 pm Take a look at the WMI Plugin. I've not touched in a while. It would be nicer to be able to run a SQL query against a local database vs. all the latency across the WAN to deal with.
thats the plug in i am using..
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

Example screen shot. It's pretty fast. I don't monitor big Windows farms, so I lost interest in completing this, or making it more tightly integrated into Cacti. But you can write a script server query that does a:

Code: Select all

select blah from blah blah where hostname='blah' and metric='blah';
Attachments
WMIQueryInterface.png
WMIQueryInterface.png (326.25 KiB) Viewed 3107 times
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mrossTTX
Cacti User
Posts: 114
Joined: Wed Dec 07, 2022 12:49 pm

Re: Monitor Windows Service stats from Linux

Post by mrossTTX »

yup.. i did that.. my query is
ROOT\cimv2


SELECT state FROM Win32_Service WHERE Name='Spooler'
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

mrossTTX wrote: Tue Jan 03, 2023 12:56 pm
TheWitness wrote: Tue Jan 03, 2023 12:55 pm Take a look at the WMI Plugin. I've not touched in a while. It would be nicer to be able to run a SQL query against a local database vs. all the latency across the WAN to deal with.
thats the plug in i am using..
Cool. Here is your table of interest... I'm pretty sure anyway.

Code: Select all

MariaDB [cacti]> desc host_wmi_cache;
+--------------+-----------------------+------+-----+---------------------+-------------------------------+
| Field        | Type                  | Null | Key | Default             | Extra                         |
+--------------+-----------------------+------+-----+---------------------+-------------------------------+
| host_id      | mediumint(8) unsigned | NO   | PRI | 0                   |                               |
| wmi_query_id | mediumint(8) unsigned | NO   | PRI | 0                   |                               |
| field_name   | varchar(50)           | NO   | PRI |                     |                               |
| field_value  | varchar(4086)         | YES  | MUL |                     |                               |
| wmi_index    | varchar(255)          | NO   | PRI |                     |                               |
| present      | tinyint(4)            | NO   | MUL | 1                   |                               |
| last_updated | timestamp             | NO   | MUL | current_timestamp() | on update current_timestamp() |
+--------------+-----------------------+------+-----+---------------------+-------------------------------+
7 rows in set (0.001 sec)
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

So, you graph that status as 0/1 values 'Stopped vs. Running' and then alert on 0, and send you command to start again.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mrossTTX
Cacti User
Posts: 114
Joined: Wed Dec 07, 2022 12:49 pm

Re: Monitor Windows Service stats from Linux

Post by mrossTTX »

FYI.. in Utilities , there is the WMI query tool.. assuming thats there to help you figure out the right syntax..
im running a simple one in there and getting nothing back, and in the cacti log i see

2023-01-03 12:13:40 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler())
2023-01-03 12:13:40 - ERROR PHP ERROR: Uncaught com_exception: Failed to create COM object `WbemScripting.SWwebLocator': Invalid syntax in C:\inetpub\wwwroot\cacti\plugins\wmi\wmi_tools.php:600 Stack trace: #0 C:\inetpub\wwwroot\cacti\plugins\wmi\wmi_tools.php(600): com->com() #1 C:\inetpub\wwwroot\cacti\plugins\wmi\wmi_tools.php(36): walk_host() #2 {main} thrown in file: C:\inetpub\wwwroot\cacti\plugins\wmi\wmi_tools.php on line: 600

my query there is namespace root\\CIMV2 , command SELECT * FROM Win32_Service
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

Okay, I never tested from a Windows server to a Windows server. So, I'm not surprised this is not working. Should work from Linux to Windows though.

If you know anything about PHP you might be able to do some debugging to fix this. If you do, a Pull request would be appreciated at the GitHub location.

It's likely an escaping issue associated the the darn backslashes.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mrossTTX
Cacti User
Posts: 114
Joined: Wed Dec 07, 2022 12:49 pm

Re: Monitor Windows Service stats from Linux

Post by mrossTTX »

ill try but im not that great at programing... lol
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

Just look at the lines in the error. My guess is that the back slashes in the namespace are causing some issues. Double them up maybe.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Monitor Windows Service stats from Linux

Post by TheWitness »

Hmm, looks even more fundamental than that. Spending 5 minutes on this.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest