Monitor Windows Service stats from Linux

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

Moderators: Developers, Moderators

Post Reply
johnyrotton
Posts: 11
Joined: Wed Nov 08, 2006 9:51 pm

Post by johnyrotton »

Hmmmm, Well here is an interesting development. I deleted the host that was not graphing the win services. The I waited three polling cycles, recreated the host only this time I completely change the host name. When I created the graphs I created just one win services to start. Waited for it to poll and as soon as I saw it was graphing I created the rest in one step and saved them. RRD issue maybe? Feedback?
johnyrotton
Posts: 11
Joined: Wed Nov 08, 2006 9:51 pm

Post by johnyrotton »

I created another host and the graphs are there no data again.. Where is the 0 or 1 flag gettin set in the db? I think if you get a 1 set on the record set the rest will populate. Anyone?
johnyrotton
Posts: 11
Joined: Wed Nov 08, 2006 9:51 pm

Post by johnyrotton »

I think I got it now.. I'm running CactiEZ V2, I downloaded the source from this thread, Here is what appears to be happening. Cigamit fixed the DB table sytax, but the PHP script still has the wrong text. Which if you hit it just right (it uses the 2nd sub set call) it will execute the query and start graphing. Change the call to this (which is posted in the thread as well).

" if (substr($return_arr[$i]['oid'],0,4) == "SNMP")
print substr($return_arr[$i]['oid'],36) . "\n";
else
print substr($return_arr[$i]['oid'],26) . "\n";
-----
i changed the values 36 and 26 to 35 and 25 in both occurences, recreated some graphs and they are working now. "

This works really well and ties in niceely with the manage plugin. :D
danwdoo
Cacti User
Posts: 50
Joined: Thu Oct 26, 2006 11:42 pm

Can this be forced to whole numbers?

Post by danwdoo »

Hello,
I just installed this and got it working (after correcting the known bug) and it seems to be working well. The one thing I would like to change is that the graph seems to be averaging the values to some extent. Instead of just 1 and 0 I get .380 or .880 when going down or coming back up. Since my THOLD values are set to alarm if below 1 it takes longer to reset. Is there a way to force everything to whole numbers? I changed the graph template to "exact numbers" and that seems to have changed the legend display but not the graph itself (and what THOLD looks at).

Thanks!
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

I'd guess you just need to use a CDEF to recalculate the figures as whole nos...
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
doughall
Posts: 8
Joined: Tue Nov 21, 2006 8:27 am

Post by doughall »

Worked a treat. thanks
Teecee
Posts: 34
Joined: Tue Feb 28, 2006 1:25 pm

Post by Teecee »

Scipio wrote: So here is the fix:
In the table poller_item, the field arg1 is a varchar(250). I changed it to TEXT. Then in cacti I cleared the poller cache. Then It was working :)

I dont know if this fix generate some troubles with the rest of cacti but I saw nothing wrong for the moment.

How do I do this?
Mika2006
Cacti User
Posts: 178
Joined: Thu May 03, 2007 2:25 am

Post by Mika2006 »

hello i have little probleme :
he says parsing xml?
and he dn't find something someone can help me please?
Attachments
Some error with service template
Some error with service template
00.jpg (86.79 KiB) Viewed 14155 times
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Mika2006 wrote:hello i have little probleme :
he says parsing xml?
and he dn't find something someone can help me please?
Your XML file is corrupt, redownload it, also check as to whether you transferred it using binary or ascii mode if you transferred via ftp.
Mika2006
Cacti User
Posts: 178
Joined: Thu May 03, 2007 2:25 am

Post by Mika2006 »

no change i download via mozilla
|Cacti Version - 0.8.6j||Plugin Architecture - 1.1||Poller Type - CMD.php|
|os - Red hat 4es | |Web Server - Apache/2.0.52 (Red Hat)|
|PHP - 4.3.9| |MySQL - 4.1.20| |RRDTool - 1.2.13||SNMP - 5.1.2|
|Plugins| Host Info (hostinfo - v0.1)
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Please post it here.
Mika2006
Cacti User
Posts: 178
Joined: Thu May 03, 2007 2:25 am

Post by Mika2006 »

i import this file on cacti webInterface
cacti_data_query_win_services.xml

Code: Select all

<cacti>	
	<hash_04001231620ded0790e4d6691449abb74174ac>
		<name>Win Services</name>
		<description>Windows services</description>
		<xml_path><path_cacti>/resource/script_server/win_services.xml</xml_path>
		<data_input_id>hash_030012332111d8b54ac8ce939af87a7eac0c06</data_input_id>
		<graphs>
			<hash_110012930f753aa55efa573212ec8c3f018622>
				<name>Win Services</name>
				<graph_template_id>hash_0000121dd684d6e77e7276e7e27c37b3d2f8b8</graph_template_id>
				<rrd>
					<item_000>
						<snmp_field_name>ServiceState</snmp_field_name>
						<data_template_id>hash_010012ce5e522013999d902afcbd1c93e9afa6</data_template_id>
						<data_template_rrd_id>hash_0800127176219b3a0b0a51487bba2019acd230</data_template_rrd_id>
					</item_000>
				</rrd>
				<sv_graph>
					<hash_12001228ab9b8eb5aeb08369f84205221fbecc>
						<field_name>title</field_name>
						<sequence>4</sequence>
						<text>|host_description| - Service State - |query_ServiceIndex|</text>
					</hash_12001228ab9b8eb5aeb08369f84205221fbecc>
				</sv_graph>
				<sv_data_source>
					<hash_130012584ef22294307be9a29d9a3aefc04b77>
						<field_name>name</field_name>
						<data_template_id>hash_010012ce5e522013999d902afcbd1c93e9afa6</data_template_id>
						<sequence>4</sequence>
						<text>|host_description| - Service State - |query_ServiceIndex|</text>
					</hash_130012584ef22294307be9a29d9a3aefc04b77>
				</sv_data_source>
			</hash_110012930f753aa55efa573212ec8c3f018622>
		</graphs>
	</hash_04001231620ded0790e4d6691449abb74174ac>
	<hash_030012332111d8b54ac8ce939af87a7eac0c06>
		<name>Get Script Server Data (Indexed)</name>
		<type_id>6</type_id>
		<input_string></input_string>
		<fields>
			<hash_070012172b4b0eacee4948c6479f587b62e512>
				<name>Index Type</name>
				<update_rra></update_rra>
				<regexp_match></regexp_match>
				<allow_nulls></allow_nulls>
				<type_code>index_type</type_code>
				<input_output>in</input_output>
				<data_name>index_type</data_name>
			</hash_070012172b4b0eacee4948c6479f587b62e512>
			<hash_07001230fb5d5bcf3d66bb5abe88596f357c26>
				<name>Index Value</name>
				<update_rra></update_rra>
				<regexp_match></regexp_match>
				<allow_nulls></allow_nulls>
				<type_code>index_value</type_code>
				<input_output>in</input_output>
				<data_name>index_value</data_name>
			</hash_07001230fb5d5bcf3d66bb5abe88596f357c26>
			<hash_07001231112c85ae4ff821d3b288336288818c>
				<name>Output Type ID</name>
				<update_rra></update_rra>
				<regexp_match></regexp_match>
				<allow_nulls></allow_nulls>
				<type_code>output_type</type_code>
				<input_output>in</input_output>
				<data_name>output_type</data_name>
			</hash_07001231112c85ae4ff821d3b288336288818c>
			<hash_0700125be8fa85472d89c621790b43510b5043>
				<name>Output Value</name>
				<update_rra>on</update_rra>
				<regexp_match></regexp_match>
				<allow_nulls></allow_nulls>
				<type_code></type_code>
				<input_output>out</input_output>
				<data_name>output</data_name>
			</hash_0700125be8fa85472d89c621790b43510b5043>
		</fields>
	</hash_030012332111d8b54ac8ce939af87a7eac0c06>
	<hash_0000121dd684d6e77e7276e7e27c37b3d2f8b8>
		<name>Win Services</name>
		<graph>
			<t_title>on</t_title>
			<title>|host_description| - Services -</title>
			<t_image_format_id></t_image_format_id>
			<image_format_id>1</image_format_id>
			<t_height></t_height>
			<height>120</height>
			<t_width></t_width>
			<width>500</width>
			<t_auto_scale></t_auto_scale>
			<auto_scale>on</auto_scale>
			<t_auto_scale_opts></t_auto_scale_opts>
			<auto_scale_opts>2</auto_scale_opts>
			<t_auto_scale_log></t_auto_scale_log>
			<auto_scale_log></auto_scale_log>
			<t_auto_scale_rigid></t_auto_scale_rigid>
			<auto_scale_rigid></auto_scale_rigid>
			<t_auto_padding></t_auto_padding>
			<auto_padding>on</auto_padding>
			<t_export></t_export>
			<export>on</export>
			<t_upper_limit></t_upper_limit>
			<upper_limit>1</upper_limit>
			<t_lower_limit></t_lower_limit>
			<lower_limit>0</lower_limit>
			<t_base_value></t_base_value>
			<base_value>1000</base_value>
			<t_unit_value></t_unit_value>
			<unit_value></unit_value>
			<t_unit_exponent_value></t_unit_exponent_value>
			<unit_exponent_value></unit_exponent_value>
			<t_vertical_label></t_vertical_label>
			<vertical_label></vertical_label>
		</graph>
		<items>
			<hash_100012d381f8cf89b1311eb18241194a63e952>
				<task_item_id>hash_0800127176219b3a0b0a51487bba2019acd230</task_item_id>
				<color_id>EA8F00</color_id>
				<graph_type_id>7</graph_type_id>
				<consolidation_function_id>4</consolidation_function_id>
				<cdef_id>0</cdef_id>
				<value></value>
				<gprint_id>hash_060012e9c43831e54eca8069317a2ce8c6f751</gprint_id>
				<text_format>Service State</text_format>
				<hard_return></hard_return>
				<sequence>1</sequence>
			</hash_100012d381f8cf89b1311eb18241194a63e952>
			<hash_100012c102315246fd0cf354aeeed4ac59e384>
				<task_item_id>hash_0800127176219b3a0b0a51487bba2019acd230</task_item_id>
				<color_id>0</color_id>
				<graph_type_id>9</graph_type_id>
				<consolidation_function_id>4</consolidation_function_id>
				<cdef_id>0</cdef_id>
				<value></value>
				<gprint_id>hash_06001219414480d6897c8731c7dc6c5310653e</gprint_id>
				<text_format></text_format>
				<hard_return>on</hard_return>
				<sequence>2</sequence>
			</hash_100012c102315246fd0cf354aeeed4ac59e384>
			<hash_100012ed51402ff26042a819d9339a4906f3ec>
				<task_item_id>0</task_item_id>
				<color_id>0</color_id>
				<graph_type_id>1</graph_type_id>
				<consolidation_function_id>1</consolidation_function_id>
				<cdef_id>0</cdef_id>
				<value></value>
				<gprint_id>hash_060012e9c43831e54eca8069317a2ce8c6f751</gprint_id>
				<text_format>(1 = Running, 0 = Stopped)</text_format>
				<hard_return></hard_return>
				<sequence>3</sequence>
			</hash_100012ed51402ff26042a819d9339a4906f3ec>
		</items>
		<inputs>
			<hash_090012998365f537fc20c18617a9e6d092cbef>
				<name>Data Source [service_state]</name>
				<description>show service state</description>
				<column_name>task_item_id</column_name>
				<items>hash_000012d381f8cf89b1311eb18241194a63e952|hash_000012c102315246fd0cf354aeeed4ac59e384</items>
			</hash_090012998365f537fc20c18617a9e6d092cbef>
		</inputs>
	</hash_0000121dd684d6e77e7276e7e27c37b3d2f8b8>
	<hash_010012ce5e522013999d902afcbd1c93e9afa6>
		<name>Win Services</name>
		<ds>
			<t_name>on</t_name>
			<name>|host_description| - Services</name>
			<data_input_id>hash_030012332111d8b54ac8ce939af87a7eac0c06</data_input_id>
			<t_rra_id></t_rra_id>
			<t_rrd_step></t_rrd_step>
			<rrd_step>300</rrd_step>
			<t_active></t_active>
			<active>on</active>
			<rra_items>hash_150012c21df5178e5c955013591239eb0afd46|hash_1500120d9c0af8b8acdc7807943937b3208e29|hash_1500126fc2d038fb42950138b0ce3e9874cc60|hash_150012e36f3adb9f152adfa5dc50fd2b23337e</rra_items>
		</ds>
		<items>
			<hash_0800127176219b3a0b0a51487bba2019acd230>
				<t_data_source_name></t_data_source_name>
				<data_source_name>service_state</data_source_name>
				<t_rrd_minimum></t_rrd_minimum>
				<rrd_minimum>0</rrd_minimum>
				<t_rrd_maximum></t_rrd_maximum>
				<rrd_maximum>0</rrd_maximum>
				<t_data_source_type_id></t_data_source_type_id>
				<data_source_type_id>1</data_source_type_id>
				<t_rrd_heartbeat></t_rrd_heartbeat>
				<rrd_heartbeat>600</rrd_heartbeat>
				<t_data_input_field_id></t_data_input_field_id>
				<data_input_field_id>0</data_input_field_id>
			</hash_0800127176219b3a0b0a51487bba2019acd230>
		</items>
		<data>
			<item_000>
				<data_input_field_id>hash_070012172b4b0eacee4948c6479f587b62e512</data_input_field_id>
				<t_value>on</t_value>
				<value></value>
			</item_000>
			<item_001>
				<data_input_field_id>hash_07001230fb5d5bcf3d66bb5abe88596f357c26</data_input_field_id>
				<t_value>on</t_value>
				<value></value>
			</item_001>
			<item_002>
				<data_input_field_id>hash_07001231112c85ae4ff821d3b288336288818c</data_input_field_id>
				<t_value>on</t_value>
				<value></value>
			</item_002>
		</data>
	</hash_010012ce5e522013999d902afcbd1c93e9afa6>
	<hash_150012c21df5178e5c955013591239eb0afd46>
		<name>Daily (5 Minute Average)</name>
		<x_files_factor>0.5</x_files_factor>
		<steps>1</steps>
		<rows>25920</rows>
		<timespan>86400</timespan>
		<cf_items>1|2|3|4</cf_items>
	</hash_150012c21df5178e5c955013591239eb0afd46>
	<hash_1500120d9c0af8b8acdc7807943937b3208e29>
		<name>Weekly (30 Minute Average)</name>
		<x_files_factor>0.5</x_files_factor>
		<steps>6</steps>
		<rows>9000</rows>
		<timespan>604800</timespan>
		<cf_items>1|2|3|4</cf_items>
	</hash_1500120d9c0af8b8acdc7807943937b3208e29>
	<hash_1500126fc2d038fb42950138b0ce3e9874cc60>
		<name>Monthly (2 Hour Average)</name>
		<x_files_factor>0.5</x_files_factor>
		<steps>24</steps>
		<rows>2250</rows>
		<timespan>2592000</timespan>
		<cf_items>1|2|3|4</cf_items>
	</hash_1500126fc2d038fb42950138b0ce3e9874cc60>
	<hash_150012e36f3adb9f152adfa5dc50fd2b23337e>
		<name>Yearly (1 Day Average)</name>
		<x_files_factor>0.5</x_files_factor>
		<steps>288</steps>
		<rows>797</rows>
		<timespan>33053184</timespan>
		<cf_items>1|2|3|4</cf_items>
	</hash_150012e36f3adb9f152adfa5dc50fd2b23337e>
	<hash_060012e9c43831e54eca8069317a2ce8c6f751>
		<name>Normal</name>
		<gprint_text>%8.2lf %s</gprint_text>
	</hash_060012e9c43831e54eca8069317a2ce8c6f751>
	<hash_06001219414480d6897c8731c7dc6c5310653e>
		<name>Exact Numbers</name>
		<gprint_text>%8.0lf</gprint_text>
	</hash_06001219414480d6897c8731c7dc6c5310653e>
</cacti>
and i copy this file on .../cacti/resource/script_server/win_services.xml

Code: Select all

<interface>
	<name>Get Host MIB Partitions</name>
	<script_path>|path_cacti|/scripts/win_services.php</script_path>
	<script_function>win_services</script_function>
	<script_server>php</script_server>
	<arg_prepend>|host_hostname| |host_snmp_community| |host_snmp_version| |host_id|</arg_prepend>
	<arg_index>index</arg_index>
	<arg_query>query</arg_query>
	<arg_get>get</arg_get>
	<output_delimeter>!</output_delimeter>
	<index_order>ServiceIndex</index_order>
	<index_order_type>alphabetic</index_order_type>
	<index_title_format>|chosen_order_field|</index_title_format>

	<fields>
		<ServiceIndex>
			<name>Index</name>
			<direction>input</direction>
			<query_name>index</query_name>
		</ServiceIndex>

		<ServiceState>
			<name>Service State</name>
			<direction>output</direction>
			<query_name>servstate</query_name>
		</ServiceState>
	</fields>
</interface>
and i copy the files win_services.php in .../cacti/scripts/

Code: Select all

<?php
$no_http_headers = true;

/* display No errors */
error_reporting(E_ERROR);

include_once(dirname(__FILE__) . "/../include/config.php");
include_once(dirname(__FILE__) . "/../lib/snmp.php");

if (!isset($called_by_script_server)) {
	include_once(dirname(__FILE__) . "/../include/config.php");
	array_shift($_SERVER["argv"]);
	print call_user_func_array("win_services", $_SERVER["argv"]);
}

function win_services($hostname, $snmp_community, $snmp_version, $host_id, $cmd, $arg1 = "", $arg2 = "", $snmp_port = 161, $snmp_timeout = 500) {
	$oids = array(
		"index" => ".1.3.6.1.4.1.77.1.2.3.1.1",
		"servstate" => ".1.3.6.1.4.1.77.1.2.3.1.2"
		);
	if ((func_num_args() <= "9") && (func_num_args() >= "5")) {
		if ($cmd == "index") {
			/* this is where it is pulling the index */
			$return_arr = cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER);

			for ($i=0; $i < sizeof($return_arr); $i++) {
				if (substr($return_arr[$i]['oid'],0,4) == "SNMP")
					print substr($return_arr[$i]['oid'],36) . "\n";
				else
					print substr($return_arr[$i]['oid'],26) . "\n";
			}
		}elseif ($cmd == "query") {
			$arg = $arg1;
			$arr_index2 = array();
			$arr_index = cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER);
			for ($i = 0; $i < sizeof($arr_index); $i++) {
				if (substr($arr_index[$i]['oid'],0,4) == "SNMP")
					$arr_index2[$i] =  substr($arr_index[$i]['oid'],36);
				else
					$arr_index2[$i] =  substr($arr_index[$i]['oid'],26);
			}

			$arr = win_services_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER));
			for ($i = 0; $i < sizeof($arr_index2); $i++) {
				print $arr_index2[$i] . " !" . $arr[$i] . "\n";
			}
		}elseif ($cmd == "get") {
			$arg = $arg1;
			$index = trim($arg2);
			if ($arg == "servstate") {
				$x = cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . '.' . $index, $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER);
				if (trim($x) == '') $x = 0;
				if ($x < 4) $x = 0;
				if ($x == 4) $x = 1;
				return $x;
			}
		}
	} else {
		return "ERROR: Invalid Parameters\n";
	}
}

function win_services_reindex($arr) {
	$return_arr = array();

	for ($i=0;($i<sizeof($arr));$i++) {
		$return_arr[$i] = $arr[$i]["value"];
	}

	return $return_arr;
}

?>
|Cacti Version - 0.8.6j||Plugin Architecture - 1.1||Poller Type - CMD.php|
|os - Red hat 4es | |Web Server - Apache/2.0.52 (Red Hat)|
|PHP - 4.3.9| |MySQL - 4.1.20| |RRDTool - 1.2.13||SNMP - 5.1.2|
|Plugins| Host Info (hostinfo - v0.1)
ddouma
Posts: 49
Joined: Sun Aug 06, 2006 1:02 pm

Post by ddouma »

I get this error when I try to import the cacti_cata_query...xml:

Error: XML: Hash version does not exist.
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

What version of Cacti are you running?

TheWitness
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?
ddouma
Posts: 49
Joined: Sun Aug 06, 2006 1:02 pm

Post by ddouma »

the h version
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest