<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sanxiago and other Daemons</title>
	<atom:link href="http://www.sanxiago.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sanxiago.com</link>
	<description>Software development, system administration and other daemons</description>
	<lastBuildDate>Tue, 12 Apr 2011 03:32:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Python vimrc</title>
		<link>http://www.sanxiago.com/blog/python-vimrc/</link>
		<comments>http://www.sanxiago.com/blog/python-vimrc/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 03:25:21 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[python vi linux]]></category>

		<guid isPermaLink="false">http://www.sanxiago.com/?p=121</guid>
		<description><![CDATA[A nice tip if you work with python under vi, use this vimrc config file. http://svn.python.org/projects/python/trunk/Misc/Vim/vimrc you can just copy it to your home directory wget http://svn.python.org/projects/python/trunk/Misc/Vim/vimrc ~/python_vimrc you can start vi with vi -u ~/python_vimrc Or make it your default .vimrc you will end with nice syntax highlighting]]></description>
			<content:encoded><![CDATA[<p>A nice tip if you work with python under vi, use this vimrc config file.</p>
<p>http://svn.python.org/projects/python/trunk/Misc/Vim/vimrc</p>
<p>you can just copy it to your home directory<br />
wget http://svn.python.org/projects/python/trunk/Misc/Vim/vimrc ~/python_vimrc</p>
<p>you can start vi with vi -u ~/python_vimrc </p>
<p>Or make it your default .vimrc you will end with nice syntax highlighting</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/blog/python-vimrc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios Acknowledge for the Masses</title>
		<link>http://www.sanxiago.com/sysadmin/nagios-acknowledge-for-the-masses/</link>
		<comments>http://www.sanxiago.com/sysadmin/nagios-acknowledge-for-the-masses/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 21:14:14 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[nagios perl acknowledge]]></category>

		<guid isPermaLink="false">http://www.sanxiago.com/?p=110</guid>
		<description><![CDATA[I made this simple perl script to help with the acknowledging of multiple alerts. When running in a large environment, and during a large maintenance alerts can flood the user and even with the use aid of servicegroups and hostgroups the alerts can overwhelm the user. The script lists any problem unacknowledged or without unscheduled [...]]]></description>
			<content:encoded><![CDATA[<p>I made this simple perl script to help with the acknowledging of multiple alerts.</p>
<p>When running in a large environment, and during a large maintenance alerts can flood the user and even with the use aid of servicegroups and hostgroups the alerts can overwhelm the user.</p>
<p>The script lists any problem unacknowledged or without unscheduled downtime.<br />
Similar to what this link does:<br />
<code><br />
/cgi-bin/status.cgi?host=all&#038;type=detail&#038;servicestatustypes=29&#038;hoststatustypes=15&#038;serviceprops=10<br />
</code></p>
<p>To setup the script, make sure you edit the paths to your nagios status.dat, and the command FIFO file.<br />
Script should be able to write to the FIFO file.</p>
<p>To use the script, run without arguments, in interactive mode.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#####################################################################################################</span>
<span style="color: #666666; font-style: italic;">#   This script provides help to acknowledge multiple services during a large maintenance</span>
<span style="color: #666666; font-style: italic;">#   Sometimes host groups and service groups do not suffice</span>
<span style="color: #666666; font-style: italic;">#      Script requires the setup of the location of the status.dat and the FIFO file</span>
<span style="color: #666666; font-style: italic;">#      Script should be able to write to the FIFO file</span>
<span style="color: #666666; font-style: italic;">#	Command is run interactively</span>
<span style="color: #666666; font-style: italic;">#      Santiago Velasco - sanxiago.com</span>
<span style="color: #666666; font-style: italic;">#########################################################################################</span>
&nbsp;
	my <span style="color: #007800;">$command_file</span> = <span style="color: #ff0000;">&quot;/usr/local/nagios/var/rw/nagios.cmd&quot;</span>;
	my <span style="color: #007800;">$status_file</span> = <span style="color: #ff0000;">&quot;/usr/local/nagios/var/status.dat&quot;</span>;
	my <span style="color: #007800;">$time</span> = <span style="color: #000000; font-weight: bold;">time</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
	my <span style="color: #000000; font-weight: bold;">%</span>state = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span> ,<span style="color: #ff0000;">'WARNING'</span>, <span style="color: #000000;">2</span>,<span style="color: #ff0000;">'CRITICAL'</span>, <span style="color: #000000;">3</span>,<span style="color: #ff0000;">'UNKNOWN'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
	my <span style="color: #007800;">$user</span> = <span style="color: #007800;">$ARGV</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
	my <span style="color: #007800;">$msg</span> = <span style="color: #007800;">$ARGV</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
	my <span style="color: #007800;">$search_string</span> = <span style="color: #007800;">$ARGV</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
&nbsp;
print STDERR <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>ACKNOWLEDGE AND SCHEDULE DOWNTIME FOR MULTIPLE SERVICES<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>defined<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$user</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> or <span style="color: #007800;">$user</span> =~ <span style="color: #000000; font-weight: bold;">/</span>\;<span style="color: #000000; font-weight: bold;">|</span>\<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">|</span>\<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>  or length<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$user</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
	print STDERR <span style="color: #ff0000;">&quot;Type in yout USER that acknowledges:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
	<span style="color: #007800;">$user</span> = <span style="color: #000000; font-weight: bold;">&lt;&gt;</span>;
	<span style="color: #007800;">$user</span> =~ s<span style="color: #000000; font-weight: bold;">/</span>\n<span style="color: #000000; font-weight: bold;">//</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>defined<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$msg</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> or <span style="color: #007800;">$msg</span> =~ <span style="color: #000000; font-weight: bold;">/</span>\;<span style="color: #000000; font-weight: bold;">|</span>\<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">|</span>\<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span> or length<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$msg</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
	print STDERR <span style="color: #ff0000;">&quot;Type in the MESSAGE that will be used for all acknowledges:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
	<span style="color: #007800;">$msg</span> = <span style="color: #000000; font-weight: bold;">&lt;&gt;</span>;
	<span style="color: #007800;">$msg</span> =~ s<span style="color: #000000; font-weight: bold;">/</span>\n<span style="color: #000000; font-weight: bold;">//</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>	
print STDERR <span style="color: #ff0000;">&quot;Type in a string that matches the service_description of the services you want to ack.<span style="color: #000099; font-weight: bold;">\n</span> Leave it blank to list all alerts):<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>; <span style="color: #007800;">$search_string</span> = <span style="color: #000000; font-weight: bold;">&lt;&gt;</span>; <span style="color: #007800;">$search_string</span> =~ s<span style="color: #000000; font-weight: bold;">/</span>\n<span style="color: #000000; font-weight: bold;">//</span>; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>length<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$search_string</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">$search_string</span>=<span style="color: #ff0000;">'.*'</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>-r <span style="color: #007800;">$status_file</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>	
	open <span style="color: #7a0874; font-weight: bold;">&#40;</span>STATUS, <span style="color: #007800;">$status_file</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	print STDERR <span style="color: #ff0000;">&quot;FAILED TO READ NAGIOS STATUS FILE<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #000000; font-weight: bold;">while</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&lt;</span>STATUS<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$_</span> =~ <span style="color: #000000; font-weight: bold;">/</span>service \<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">$is_service</span> = <span style="color: #000000;">1</span>;
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$_</span> =~ <span style="color: #000000; font-weight: bold;">/</span>\<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span> and <span style="color: #007800;">$service_description</span>=~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$search_string</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">$is_service</span> =<span style="color: #000000;">0</span>;
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>defined<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$current_state</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> and <span style="color: #007800;">$current_state</span> and <span style="color: #007800;">$acknowledged</span>==<span style="color: #000000;">0</span> and <span style="color: #007800;">$scheduled_downtime</span>==<span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
		<span style="color: #666666; font-style: italic;"># Command Format:</span>
		<span style="color: #666666; font-style: italic;"># [time] ACKNOWLEDGE_SVC_PROBLEM;&lt;host_name&gt;;&lt;service_description&gt;;&lt;sticky&gt;;&lt;notify&gt;;&lt;persistent&gt;;&lt;author&gt;;&lt;comment&gt;</span>
		<span style="color: #666666; font-style: italic;"># [time] SCHEDULE_SVC_DOWNTIME;&lt;host_name&gt;;&lt;service_desription&gt;&lt;start_time&gt;;&lt;end_time&gt;;&lt;fixed&gt;;&lt;trigger_id&gt;;&lt;duration&gt;;&lt;author&gt;;&lt;comment&gt;</span>
 		undef<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$ack_true</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
		print STDERR <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>---------------------------------------------------------<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
		print STDERR <span style="color: #ff0000;">&quot;Acknowledge <span style="color: #007800;">$service_description</span> @ <span style="color: #007800;">$host_name</span> <span style="color: #007800;">$current_state</span>&quot;</span>.<span style="color: #007800;">$state</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #007800;">$current_state</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>.<span style="color: #ff0000;">&quot;?<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #007800;">$plugin_output</span><span style="color: #000099; font-weight: bold;">\n</span>[y/n/s] (s followed by the number of minutes of scheduled downtime) (Enter to skip)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
		<span style="color: #007800;">$ack_true</span>=<span style="color: #000000; font-weight: bold;">&lt;&gt;</span>;
		<span style="color: #666666; font-style: italic;"># if acknowledge yes</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$ack_true</span>=~<span style="color: #000000; font-weight: bold;">/</span>^y<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>-w <span style="color: #007800;">$command_file</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span> print STDERR <span style="color: #ff0000;">&quot;FAILED TO OPEN FIFO FILE&quot;</span>; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
			open <span style="color: #7a0874; font-weight: bold;">&#40;</span>CMD, <span style="color: #ff0000;">'&gt;&gt;'</span>.<span style="color: #007800;">$command_file</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
			print CMD <span style="color: #ff0000;">&quot;[<span style="color: #007800;">$time</span>] ACKNOWLEDGE_SVC_PROBLEM;<span style="color: #007800;">$host_name</span>;<span style="color: #007800;">$service_description</span>;1;0;1;<span style="color: #007800;">$user</span>;<span style="color: #007800;">$msg</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
			close <span style="color: #7a0874; font-weight: bold;">&#40;</span>CMD<span style="color: #7a0874; font-weight: bold;">&#41;</span>;
		<span style="color: #666666; font-style: italic;"># if schedule downtime </span>
		<span style="color: #7a0874; font-weight: bold;">&#125;</span>elsif<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$ack_true</span>=~<span style="color: #000000; font-weight: bold;">/</span>^s<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
			my <span style="color: #007800;">$duration</span> = <span style="color: #007800;">$1</span>;
			<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$duration</span>=~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>^\d<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>-<span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>.<span style="color: #000000; font-weight: bold;">*/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#expect duration in minutes convert to seconds</span>
				<span style="color: #007800;">$duration</span>=int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">60</span>;
			<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
				<span style="color: #007800;">$duration</span>=<span style="color: #000000;">3600</span>;
			<span style="color: #7a0874; font-weight: bold;">&#125;</span>
                        my <span style="color: #007800;">$end_time</span> = <span style="color: #007800;">$time</span> + <span style="color: #007800;">$duration</span>;
&nbsp;
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>-w <span style="color: #007800;">$command_file</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span> print STDERR <span style="color: #ff0000;">&quot;FAILED TO OPEN FIFO FILE&quot;</span>; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
                        open <span style="color: #7a0874; font-weight: bold;">&#40;</span>CMD, <span style="color: #ff0000;">'&gt;&gt;'</span>.<span style="color: #007800;">$command_file</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
			print CMD <span style="color: #ff0000;">&quot;[<span style="color: #007800;">$time</span>] SCHEDULE_SVC_DOWNTIME;<span style="color: #007800;">$host_name</span>;<span style="color: #007800;">$service_description</span>;<span style="color: #007800;">$time</span>;<span style="color: #007800;">$end_time</span>;1;0;<span style="color: #007800;">$duration</span>;<span style="color: #007800;">$user</span>;<span style="color: #007800;">$msg</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
                        close <span style="color: #7a0874; font-weight: bold;">&#40;</span>CMD<span style="color: #7a0874; font-weight: bold;">&#41;</span>;
		<span style="color: #7a0874; font-weight: bold;">&#125;</span>
		<span style="color: #7a0874; font-weight: bold;">&#125;</span>
	undef<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$current_state</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
	undef<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$host_name</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$is_service</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$_</span>=~<span style="color: #000000; font-weight: bold;">/</span>host_name\=<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
		<span style="color: #007800;">$host_name</span>=<span style="color: #007800;">$1</span>;
		<span style="color: #7a0874; font-weight: bold;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$_</span>=~<span style="color: #000000; font-weight: bold;">/</span>service_description\=<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
		<span style="color: #007800;">$service_description</span>=<span style="color: #007800;">$1</span>;
		<span style="color: #7a0874; font-weight: bold;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$_</span>=~<span style="color: #000000; font-weight: bold;">/</span>current_state\=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>-<span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
                <span style="color: #007800;">$current_state</span>=<span style="color: #007800;">$1</span>;
                <span style="color: #7a0874; font-weight: bold;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$_</span>=~<span style="color: #000000; font-weight: bold;">/</span>problem_has_been_acknowledged\=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>-<span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
                <span style="color: #007800;">$acknowledged</span>=<span style="color: #007800;">$1</span>;
                <span style="color: #7a0874; font-weight: bold;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$_</span>=~<span style="color: #000000; font-weight: bold;">/</span>plugin_output\=<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
                <span style="color: #007800;">$plugin_output</span>=<span style="color: #007800;">$1</span>;
                <span style="color: #7a0874; font-weight: bold;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$_</span>=~<span style="color: #000000; font-weight: bold;">/</span>scheduled_downtime_depth\=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>-<span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
		<span style="color: #007800;">$scheduled_downtime</span>=<span style="color: #007800;">$1</span>;
		<span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
close<span style="color: #7a0874; font-weight: bold;">&#40;</span>STATUS<span style="color: #7a0874; font-weight: bold;">&#41;</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/sysadmin/nagios-acknowledge-for-the-masses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python object dump</title>
		<link>http://www.sanxiago.com/programming/python-object-dump/</link>
		<comments>http://www.sanxiago.com/programming/python-object-dump/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 21:12:57 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Data::Dumper print_r Python]]></category>

		<guid isPermaLink="false">http://www.sanxiago.com/?p=115</guid>
		<description><![CDATA[When working with objects and arrays there are times you need to debug a certain object or array and list all its contents. Most languages provide a functionality to do so, in the case of Perl you have Data::Dumper and in PHP you have print_r I was looking for something like that and found: Recipe [...]]]></description>
			<content:encoded><![CDATA[<p>When working with objects and arrays there are times you need to debug a certain object or array and list all its contents.<br />
Most languages provide a functionality to do so, in the case of Perl you have Data::Dumper and in PHP you have print_r</p>
<p>I was looking for something like that and found:</p>
<p><a href="http://code.activestate.com/recipes/137951-dump-all-the-attributes-of-an-object/">Recipe</a></p>
<p>I truly recommend it.<br />
It can be easily added as an extra module.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/programming/python-object-dump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>And Now for Something Completely Different</title>
		<link>http://www.sanxiago.com/blog/and-now-for-something-completely-different/</link>
		<comments>http://www.sanxiago.com/blog/and-now-for-something-completely-different/#comments</comments>
		<pubDate>Sat, 01 May 2010 03:50:24 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Monty Pythons Flying Circus]]></category>

		<guid isPermaLink="false">http://www.sanxiago.com/?p=101</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/TRU6tQdyYqQ&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/TRU6tQdyYqQ&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/blog/and-now-for-something-completely-different/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bank decreases security in attempt to increase password strength</title>
		<link>http://www.sanxiago.com/blog/bank-decreases-security-in-attempt-to-increase-password-strength/</link>
		<comments>http://www.sanxiago.com/blog/bank-decreases-security-in-attempt-to-increase-password-strength/#comments</comments>
		<pubDate>Sat, 01 May 2010 01:01:39 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[duh]]></category>

		<guid isPermaLink="false">http://www.sanxiago.com/?p=67</guid>
		<description><![CDATA[I was asked to set my phone password by my bank, following these rules: 1. Password must have 7 digits 2. No 2 digits can repeat in a password 3. Consecutive digits are not allowed Some security expert thought the best way to protect the "stupid" users from choosing easy passwords. Was to enforce rules [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked to set my phone password by my bank, following these rules:<br />
1. Password must have 7 digits<br />
2. No 2 digits can repeat in a password<br />
3. Consecutive digits are not allowed</p>
<p>Some security expert thought the best way to protect the "stupid" users from choosing easy passwords.<br />
Was to enforce rules 2 and 3.<br />
Lets keep in mind that without the rules 2 and 3 we had 9'999'999 possible passwords.</p>
<p>Rule 2 means you must pick 7 numbers out of the 9 digits without repeating any digit.<br />
Using simple math we have<br />
  nPr =    n! / (n-r)!<br />
Were n is 9 as there are 9 digits in a phone, as r is 7 as that is the digits we must pick out.<br />
We have:   9! / 2 = 181,440<br />
As a result we have only 181,440 Valid passwords.</p>
<p>*Rule 3, sequences of numbers are not allowed.<br />
NCm -   ( N – m + 1 )Cm<br />
We have:  6435  - 84  =  6351<br />
Thats 6351 passwords we are unable to use.<br />
181,440 - 6,351 = 175,089</p>
<p>Now the evil hacker who wants to access your account only has 175,089 passwords to guess from.<br />
Look at the common phone digits layout:<br />
1 2 3<br />
4 5 6<br />
7 8 9<br />
&nbsp; &nbsp;  0</p>
<p>My guess is probably most users when unable to pick the code they wanted because it was not compliant with rules 2 and 3 picked a password based on the phone layout.</p>
<p>Here is my guess on the top 4 passwords.<br />
1-4-7  3-6-9 - 0<br />
1-4-7  3-6-9 - 5<br />
2-5-8-0 1-4-7<br />
2-5-8-0 3-6-9</p>
<p>* http://www.albaiges.com/matematicas/combinatoria/combinacionesordenadas.htm</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/blog/bank-decreases-security-in-attempt-to-increase-password-strength/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python Logging Module</title>
		<link>http://www.sanxiago.com/programming/python-logging-module/</link>
		<comments>http://www.sanxiago.com/programming/python-logging-module/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 21:51:35 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://www.sanxiago.com/?p=71</guid>
		<description><![CDATA[I started using Python's logging module in my Python scripts. Below is an example on how I created a python logger object. First I created this constructor method to ease the logger object creation. The create_logger function receives the following parameters: logName This is the only parameter that is mandatory and does not have a [...]]]></description>
			<content:encoded><![CDATA[<p>I started using Python's <a href="http://docs.python.org/library/logging.html">logging module</a> in my Python scripts.</p>
<p>Below is an example on how I created a python logger object.</p>
<p>First I created this constructor method to ease the logger object creation.</p>
<blockquote><p>
The create_logger function receives the following parameters:</p>
<ul>
<li><strong>logName</strong></li>
<p> This is the only parameter that is mandatory and does not have a default value.</p>
<li><strong>logLevel='debug'</strong></li>
<p> This is the logging level in lower case</p>
<li><strong>logFile='test.log'</strong></li>
<p>  This is the log path/file were log will be written</p>
<li><strong>stream=0</strong></li>
<p>  0 no STDOUT, 1 print to STDOUT
</ul>
</blockquote>
<p>Hardcoded you will see the max size of the log before it rotates. Log rotation is done using <a href="http://docs.python.org/library/logging.html#logging.handlers.RotatingFileHandler">logging.handlers.RotatingFileHandler</a> if you do not want to use log rotation you would probably need to use <a href="http://docs.python.org/library/logging.html#logging.handlers.FileHandler">logging.handlers.FileHandler</a> instead.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#my_log.py</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">logging</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">logging</span>.<span style="color: black;">handlers</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> create_logger<span style="color: black;">&#40;</span>logName, logLevel=<span style="color: #483d8b;">'debug'</span>, logFile=<span style="color: #483d8b;">'test.log'</span>, stream=<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>:
	LOG_FILENAME=logFile
	<span style="color: #808080; font-style: italic;"># Files will rotate at 200MB</span>
	MAX_BYTES = <span style="color: #ff4500;">209715200</span>
	<span style="color: #808080; font-style: italic;"># Files versions to keep</span>
	BACKUP_COUNT = <span style="color: #ff4500;">10</span>
	LEVELS = <span style="color: black;">&#123;</span><span style="color: #483d8b;">'debug'</span>: <span style="color: #dc143c;">logging</span>.<span style="color: black;">DEBUG</span>,
        	  <span style="color: #483d8b;">'info'</span>: <span style="color: #dc143c;">logging</span>.<span style="color: black;">INFO</span>,
	          <span style="color: #483d8b;">'warning'</span>: <span style="color: #dc143c;">logging</span>.<span style="color: black;">WARNING</span>,
	          <span style="color: #483d8b;">'error'</span>: <span style="color: #dc143c;">logging</span>.<span style="color: black;">ERROR</span>,
	          <span style="color: #483d8b;">'critical'</span>: <span style="color: #dc143c;">logging</span>.<span style="color: black;">CRITICAL</span><span style="color: black;">&#125;</span>
        logLevel = LEVELS.<span style="color: black;">get</span><span style="color: black;">&#40;</span>logLevel, <span style="color: #dc143c;">logging</span>.<span style="color: black;">NOTSET</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;"># Set up a specific logger with our desired output level</span>
	my_logger = <span style="color: #dc143c;">logging</span>.<span style="color: black;">getLogger</span><span style="color: black;">&#40;</span>logName<span style="color: black;">&#41;</span>
	my_logger.<span style="color: black;">setLevel</span><span style="color: black;">&#40;</span>logLevel<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span><span style="color: black;">&#40;</span>logFile <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">0</span>  <span style="color: #ff7700;font-weight:bold;">and</span> logFile <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span>:
		<span style="color: #808080; font-style: italic;"># Add the log message handler to the logger</span>
		handler = <span style="color: #dc143c;">logging</span>.<span style="color: black;">handlers</span>.<span style="color: black;">RotatingFileHandler</span><span style="color: black;">&#40;</span>LOG_FILENAME, maxBytes=MAX_BYTES, backupCount=BACKUP_COUNT<span style="color: black;">&#41;</span>
	        <span style="color: #808080; font-style: italic;"># create formatter</span>
	        <span style="color: #dc143c;">formatter</span> = <span style="color: #dc143c;">logging</span>.<span style="color: black;">Formatter</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%(asctime)s - %(name)s - %(levelname)s - %(message)s&quot;</span><span style="color: black;">&#41;</span>
	        <span style="color: #808080; font-style: italic;"># add formatter to ch</span>
	        handler.<span style="color: black;">setFormatter</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">formatter</span><span style="color: black;">&#41;</span>
		my_logger.<span style="color: black;">addHandler</span><span style="color: black;">&#40;</span>handler<span style="color: black;">&#41;</span>
	<span style="color: #808080; font-style: italic;"># If required we print out stream, or if no logFile was specified</span>
	<span style="color: #ff7700;font-weight:bold;">if</span><span style="color: black;">&#40;</span>stream <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">0</span> <span style="color: #ff7700;font-weight:bold;">or</span> logFile == <span style="color: #ff4500;">0</span> <span style="color: #ff7700;font-weight:bold;">or</span> logFile == <span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span>:
	        handler = <span style="color: #dc143c;">logging</span>.<span style="color: black;">StreamHandler</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        	my_logger.<span style="color: black;">addHandler</span><span style="color: black;">&#40;</span>handler<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> my_logger</pre></div></div>

<p>This is a simple example on how the logging module is used:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#test_log.py</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> my_log.<span style="color: black;">py</span>
<span style="color: #808080; font-style: italic;"># We create the logger, using the script name sys.arv[0] and that is the logName, can be an arbitrary string.</span>
<span style="color: #808080; font-style: italic;"># Named arguments are optional, and all have default values if left undeclared</span>
my_logger=cacti_util.<span style="color: black;">create_logger</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>,stream=<span style="color: #ff4500;">1</span>,logFile=<span style="color: #483d8b;">'testing.log'</span>, logLevel=<span style="color: #483d8b;">'debug'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># We log the program start</span>
my_logger.<span style="color: black;">info</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">' started'</span><span style="color: black;">&#41;</span>
&nbsp;
i=<span style="color: #ff4500;">0</span>
<span style="color: #ff7700;font-weight:bold;">try</span>:
	<span style="color: #ff7700;font-weight:bold;">while</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: #66cc66;">&lt;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>:
		i = i + <span style="color: #ff4500;">1</span>
		my_logger.<span style="color: black;">warn</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'i = %d'</span> <span style="color: #66cc66;">%</span> i<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># this is an example warning in the log</span>
<span style="color: #ff7700;font-weight:bold;">except</span>:
    my_logger.<span style="color: black;">exception</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">exc_info</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># logger.exception is used to print full details on python exceptions</span>
    my_logger.<span style="color: black;">info</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">' died'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>This is an example of what would be written in the log.</p>
<p><code><br />
2010-04-30 16:47:33,200 - ping.py - INFO - ping.py started<br />
2010-04-30 16:47:33,201 - ping.py - WARNING - i = 1<br />
2010-04-30 16:47:33,201 - ping.py - WARNING - i = 2<br />
2010-04-30 16:47:33,201 - ping.py - WARNING - i = 3<br />
# ... AFTER SEVERAL LINES LATER I PRESS CTRL + C TO BREAK THE LOOP<br />
2010-04-30 16:47:33,254 - ping.py - WARNING - i = 407<br />
2010-04-30 16:47:33,254 - ping.py - ERROR - <type 'exceptions.KeyboardInterrupt'><br />
Traceback (most recent call last):<br />
  File "ping.py", line 14, in <module><br />
    my_logger.warn('i = %d' % i) # this is an example warning in the log<br />
  File "/usr/lib/python2.6/logging/__init__.py", line 1060, in warning<br />
    self._log(WARNING, msg, args, **kwargs)<br />
  File "/usr/lib/python2.6/logging/__init__.py", line 1165, in _log<br />
    self.handle(record)<br />
  File "/usr/lib/python2.6/logging/__init__.py", line 1175, in handle<br />
    self.callHandlers(record)<br />
  File "/usr/lib/python2.6/logging/__init__.py", line 1212, in callHandlers<br />
    hdlr.handle(record)<br />
  File "/usr/lib/python2.6/logging/__init__.py", line 673, in handle<br />
    self.emit(record)<br />
  File "/usr/lib/python2.6/logging/handlers.py", line 73, in emit<br />
    logging.FileHandler.emit(self, record)<br />
  File "/usr/lib/python2.6/logging/__init__.py", line 852, in emit<br />
    StreamHandler.emit(self, record)<br />
  File "/usr/lib/python2.6/logging/__init__.py", line 792, in emit<br />
    self.flush()<br />
  File "/usr/lib/python2.6/logging/__init__.py", line 754, in flush<br />
    self.stream.flush()<br />
KeyboardInterrupt<br />
2010-04-30 16:47:33,271 - ping.py - INFO - ping.py died<br />
</code></p>
<p>The logging module offers other features such as email logging.<br />
Here is a nice simple <a href="http://www.petersblog.org/node/268">example.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/programming/python-logging-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysql Innodb monitoring with nagios</title>
		<link>http://www.sanxiago.com/sysadmin/mysql-innodb-monitoring-with-nagios/</link>
		<comments>http://www.sanxiago.com/sysadmin/mysql-innodb-monitoring-with-nagios/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 01:49:39 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[deadlock]]></category>
		<category><![CDATA[innodb]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://sanxiago.comxa.com/blog/?p=48</guid>
		<description><![CDATA[I am building a full innodb nrpe plugin. We ran into a problem, the status gets trunctated and we are unable to plot all the correct values. A colleague pointed me to this link. http://www.mysqlperformanceblog.com/2008/10/31/full-innodb-status/ Below is a small script to get the full innodb status file using the hack discussed in the link above. [...]]]></description>
			<content:encoded><![CDATA[<p>I am building a full innodb nrpe plugin. </p>
<p>We ran into a problem, the status gets trunctated and we are unable to plot all the correct values.<br />
A colleague pointed me to this link.<br />
<a href="http://www.mysqlperformanceblog.com/2008/10/31/full-innodb-status/">http://www.mysqlperformanceblog.com/2008/10/31/full-innodb-status/</a></p>
<p>Below is a small script to get the full innodb status file using the hack discussed in the link above.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">mysql_port</span>=<span style="color: #000000;">3306</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">#Get PID of mysql_d running on $mysql_port</span>
<span style="color: #007800;">mysql_pid</span>=<span style="color: #000000; font-weight: bold;">`</span>pgrep <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;mysqld.*--port=<span style="color: #007800;">$mysql_port</span> &quot;</span><span style="color: #000000; font-weight: bold;">`</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">#If no PID was found, no mysqld instance is running on $mysql_port</span>
<span style="color: #000000; font-weight: bold;">if</span>  <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$mysql_pid</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: No Mysqld instance running on port <span style="color: #007800;">$mysql_port</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>;
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #666666; font-style: italic;"># We look for the full INNODB status file as described in:</span>
<span style="color: #666666; font-style: italic;"># http://www.mysqlperformanceblog.com/2008/10/31/full-innodb-status/</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$mysql_pid</span><span style="color: #000000; font-weight: bold;">/</span>fd <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> deleted <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $9}'</span><span style="color: #000000; font-weight: bold;">`</span>;
        <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${#innodb_status_file}</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">innodb_status_file</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-l</span> <span style="color: #ff0000;">&quot;INNODB MONITOR OUTPUT&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$mysql_pid</span><span style="color: #000000; font-weight: bold;">/</span>fd<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$i</span><span style="color: #000000; font-weight: bold;">`</span> ;
        <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">break</span>;
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>;
<span style="color: #666666; font-style: italic;"># If we did not find the file</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${#innodb_status_file}</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: unable to find INNODB MONITOR file&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>;
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$innodb_status_file</span>;</pre></td></tr></table></div>

<p>Today I found this project, I will test this out.<br />
<a href="http://www.xaprb.com/blog/2006/07/02/innotop-mysql-innodb-monitor/">http://www.xaprb.com/blog/2006/07/02/innotop-mysql-innodb-monitor/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/sysadmin/mysql-innodb-monitoring-with-nagios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thinking outside the box</title>
		<link>http://www.sanxiago.com/blog/thinking-outside-the-box/</link>
		<comments>http://www.sanxiago.com/blog/thinking-outside-the-box/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:06:46 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://sanxiago.comxa.com/blog/?p=43</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sanxiago.com/wp-content/uploads/2010/02/box1.png"><img src="http://www.sanxiago.com/wp-content/uploads/2010/02/box1.png" alt="" title="box" width="641" height="333" class="aligncenter size-full wp-image-42" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/blog/thinking-outside-the-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check IIS servers that require user authenticaction</title>
		<link>http://www.sanxiago.com/sysadmin/check-iis-servers-that-require-user-authenticaction/</link>
		<comments>http://www.sanxiago.com/sysadmin/check-iis-servers-that-require-user-authenticaction/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 06:49:25 +0000</pubDate>
		<dc:creator>sanxiago</dc:creator>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[ntlm]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://sanxiago.comxa.com/blog/?p=7</guid>
		<description><![CDATA[We needed to monitor a couple of IIS servers that required user authentication. We currently use nagios and cacti to monitor our servers. I cooked this simple script, that provides a method to check a IIS webserver page that require NTLM Authentication. Horse work is done entirely by curl, I tested 7.12.1 with libcurl/7.12.1 To [...]]]></description>
			<content:encoded><![CDATA[<p>We needed to monitor a couple of IIS servers that required user authentication.<br />
We currently use <a href="http://www.nagios.org">nagios</a> and <a href="http://www.cacti.net">cacti</a> to monitor our servers. </p>
<p>I cooked this simple script, that provides a method to check a IIS webserver page that require NTLM Authentication.<br />
Horse work is done entirely by <a href="http://curl.haxx.se/">curl</a>, I tested 7.12.1 with libcurl/7.12.1</p>
<p>To test if your current curl binary does the trick call curl like this</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl <span style="color: #660033;">-u</span> <span style="color: #007800;">$user</span>:<span style="color: #007800;">$pass</span> <span style="color: #660033;">--ntlm</span>  <span style="color: #660033;">--stderr</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #007800;">$uri</span>  <span style="color: #660033;">-i</span></pre></div></div>

<p>Examine the results, you should first see a page with a 401 unauthorized response, then you should see the authorization being sent over to the server, If the user and pass are correct and curl ntlm worked then you should see the end page with status code 200 OK or 302 Page Moved if its a redirect.</p>
<p>The script receives a URL as a parameter, logins to the IIS server using the curl binary, then it parses the output of the command and after it sees the authentication was sent, captures the response code. </p>
<p>Timeout pass and user values are hard-coded in the below example, the script currently only has handlers for some response codes, but a switch was used to add more in an easy way.<br />
Response code is found with regexp /HTTP/1.1 ([0-9]{3}) .*/<br />
if your server returns a different status code you might need to change that.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #666666; font-style: italic;">#       02/Feb/10                       nagios@sanxiago.com</span>
<span style="color: #666666; font-style: italic;">#  check_http page for IIS servers with ntlm authentication</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># this check receives a URL as a parameter, logins to the IIS server</span>
<span style="color: #666666; font-style: italic;"># using the curl binary, then it parses the output of the command</span>
<span style="color: #666666; font-style: italic;"># and captures the response code. Timeout pass and user values are currently hardcoded</span>
<span style="color: #666666; font-style: italic;"># script currently only has handlers for some response codes, but a switch was used to </span>
<span style="color: #666666; font-style: italic;"># add more in an easy way. Response code is found with regexp /HTTP\/1\.1 ([0-9]{3}) .*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> Switch<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Time<span style="color: #339933;">::</span><span style="color: #006600;">HiRes</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Getopt<span style="color: #339933;">::</span><span style="color: #006600;">Long</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> print_usage <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Usage: $0 --uri=&quot;</span>http<span style="color: #339933;">://</span>somepage<span style="color: #ff0000;">&quot; --user=DJohn --pass=p4ssw0rd<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
GetOptions<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;U|uri=s&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$uri</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;u|user=s&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$user</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;p|pass=s&quot;</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$pass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">and</span> <span style="color: #339933;">!</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$user</span> <span style="color: #b1b100;">and</span> <span style="color: #339933;">!</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$pass</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
print_usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">$timeout</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">;</span>            <span style="color: #666666; font-style: italic;"># Timeout in seconds</span>
&nbsp;
<span style="color: #0000ff;">$start</span> <span style="color: #339933;">=</span> Time<span style="color: #339933;">::</span><span style="color: #006600;">HiRes</span><span style="color: #339933;">::</span><span style="color: #000066;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
run_command<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;curl -u $user:$pass --ntlm  --stderr /dev/null $uri  -i &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$time</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%.2f&quot;</span><span style="color: #339933;">,</span>Time<span style="color: #339933;">::</span><span style="color: #006600;">HiRes</span><span style="color: #339933;">::</span><span style="color: #000066;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
switch <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$http_code</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">200</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #0000ff;">$time</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;s OK&quot;</span><span style="color: #339933;">;</span> <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">302</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #0000ff;">$time</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;s PAGE MOVED&quot;</span><span style="color: #339933;">;</span> <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">404</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #0000ff;">$time</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;s PAGE NOT FOUND&quot;</span><span style="color: #339933;">;</span> <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">500</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #0000ff;">$time</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;s SERVER ERROR&quot;</span><span style="color: #339933;">;</span> <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">401</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #0000ff;">$time</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;s UNAUTHORIZED&quot;</span><span style="color: #339933;">;</span> <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>     <span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #0000ff;">$time</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;s ERROR $output&quot;</span><span style="color: #339933;">;</span> <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> run_command <span style="color: #009900;">&#123;</span>
<span style="color: #0000ff;">$command</span><span style="color: #339933;">=</span><span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$pid</span> <span style="color: #339933;">=</span> <span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>PIPE<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;$command  |&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #0000ff;">$!</span><span style="color: #339933;">;</span>
<span style="color: #000066;">eval</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #0000ff;">$output</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
       <span style="color: #000066;">local</span> <span style="color: #0000ff;">$SIG</span><span style="color: #009900;">&#123;</span>ALRM<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;TIMEDOUT&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
       <span style="color: #000066;">alarm</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$timeout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009999;">&lt;PIPE&gt;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #339933;">=~/</span>HTTP\<span style="color: #339933;">/</span><span style="color: #cc66cc;">1</span>\<span style="color: #339933;">.</span>1 <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.*/</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$authentication_sent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #0000ff;">$http_code</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #339933;">=~/</span>WWW<span style="color: #339933;">-</span>Authenticate<span style="color: #339933;">/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #0000ff;">$authentication_sent</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #0000ff;">$output</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$output</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span>PIPE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$@</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">die</span> <span style="color: #0000ff;">$@</span> <span style="color: #b1b100;">unless</span> <span style="color: #0000ff;">$@</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/TIMEDOUT/</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;TIMEOUT&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">kill</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pid</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$?</span> <span style="color: #339933;">||=</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you will see this script can easily be edited to serve as a data input in cacti or other monitoring app.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sanxiago.com/sysadmin/check-iis-servers-that-require-user-authenticaction/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://stats.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->

