The other day our shadow server stopped working without any visible reason. So I was looking for an easy way to monitor the server. We are using Nagios as the monitoring solution. The problem was how to get the necessary information from the remote system and put it into Nagios. The plan was to trak the latency and the status of the shadow server. To be honest, I am not an application programmer and have no knowledge on how to write CSPs. I found a source on the internet, that explained a wee bit of how to request information in a macro. After hours of trial and error and bothering one of our developers, I finally wrote this script:
OnGetLatency() #include %occOptions #include %occStatus s rs = ##class(%ResultSet).%New() s rs.ClassName="SYS.Shadowing.Shadow" s rs.QueryName = "List" d rs.Execute() while (rs.Next()) { s name = rs.GetData(1) s status = rs.GetData(2) s dStatus = ##class(%ShadowState).LogicalToDisplay(status) s host = rs.GetData(3) s port = rs.GetData(4) if (status = 1) { s latency = ##class(SYS.Shadowing.Shadow).GetLatency(name) s tLatency = ##class(SYS.Shadowing.Shadow).TranslateLatency(latency) w "Lat: ",tLatency,"#" w " ",! w "Stat: ",dStatus,"#" } else { s tLatency = "N/A" } } q
It returns the latency and the status in a format like the one below:
%SYS>d ^shadtest
Lat: 6 minutes#
Stat: processing#
I added the # to make it easier for me to separate the data in a bash script that I wrote as a plugin for Nagios nrpe.
Inside my bash script I am using this command line to execute the shadtest macro:
OUTPUT=`echo -e "USERNAME\nPASSWORD\nd ^shadtest\nh\n" | csession INSTNCENAME -U NAMESPACE`
You should have defined a user for this monitoring tasks with adapted permissions.
Now everything you need is in your OUTPUT variable and can be treated by a shell script or whatever you prefer.
I am sure that there are better ways to get these values, but I am fine with my solution and hope that it will help others.
Good web site! I truly love how it is simple on my eyes and the data are well written. I am wondering how I might be notified when a new post has been made. I’ve subscribed to your RSS feed which must do the trick! Have a great day!
find out
Superb Juergen – many thanks – was just looking for a way to do this for ourselves (NHS A&A!) – this popped up on google (4th result!) – and will save me hours of work trying to figure it out myself!
This is very attention-grabbing, You are an overly skilled blogger.
I’ve joined your rss feed and stay up for in search
of extra of your great post. Also, I have shared your website in my social networks
thanks for this article , good for read..
this blog is very good and very useful .. thanks you for the information that has been given to me ..
thank you also for being allowed to comment here ^^