Xymon Mailing List Archive search

problem with ext script

7 messages in this thread

list Operaciones · Fri, 05 Jul 2013 15:43:57 +0200 ·
Hello Guy,

i have a small problem, i create a script for check the raid status on  
Intel mainboards that use the command:

dmraid -r

So, when i run the script with xymon, show the error:

ERROR: you must be root

Do you know how can i fix it?

Thank you very much.
list Paul Root · Fri, 5 Jul 2013 14:46:09 +0000 ·
Setuid the script
Sudo the command in the script
Run the script as root

Take your pick. The first one is not secure in the least.
The second one will require the xymon user to be in sudoers with permission to run the command without a password required. Or modifying the script to enter the password (which is not secure)
The last is pretty easy, but would be running outside of the tasks.cfg probably in cron. And so you would need to call the script, most likely, with xymoncmd to get the environment right.

Paul.
quoted from Operaciones


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Operaciones
Sent: Friday, July 05, 2013 8:44 AM
To: xymon at xymon.com
Subject: [Xymon] problem with ext script

Hello Guy,

i have a small problem, i create a script for check the raid status on  Intel mainboards that use the command:

dmraid -r

So, when i run the script with xymon, show the error:

ERROR: you must be root

Do you know how can i fix it?

Thank you very much.
list Operaciones · Fri, 05 Jul 2013 16:59:59 +0200 ·
Thank you Paul, i think that will choose the second option.

Best regards.
quoted from Paul Root

El 05/07/13 16:46, Root, Paul T escribió:
Setuid the script

Sudo the command in the script

Run the script as root

Take your pick. The first one is not secure in the least.

The second one will require the xymon user to be in sudoers with permission to run the command without a password required. Or modifying the script to enter the password (which is not secure)

The last is pretty easy, but would be running outside of the tasks.cfg probably in cron. And so you would need to call the script, most likely, with xymoncmd to get the environment right.

Paul.

*From:*Xymon [mailto:xymon-bounces at xymon.com] *On Behalf Of *Operaciones
quoted from Paul Root
*Sent:* Friday, July 05, 2013 8:44 AM
*To:* xymon at xymon.com
*Subject:* [Xymon] problem with ext script

Hello Guy,

i have a small problem, i create a script for check the raid status on  Intel mainboards that use the command:

dmraid -r

So, when i run the script with xymon, show the error:

ERROR: you must be root

Do you know how can i fix it?

Thank you very much.
list Jeremy Laidman · Mon, 8 Jul 2013 10:42:07 +1000 ·
quoted from Operaciones
On 5 July 2013 23:43, Operaciones <user-1e7642c06451@xymon.invalid> wrote:
So, when i run the script with xymon, show the error:

ERROR: you must be root

What I generally do in these cases is run the command from root's cron and
capture the output in a file that's readable by the Xymon user.  Like so:

*/5 * * * * /sbin/dmraid -r >/tmp/dmraid.out && chgrp xymon /tmp/dmraid.out
&& chmod 644 /tmp/dmraid.out

Then in the script, in place of "dmraid -r" you just do "cat
/tmp/dmraid.out".

J
list Paul Root · Mon, 8 Jul 2013 12:10:43 +0000 ·
Why not just send the output to the server with the xymon command?
quoted from Jeremy Laidman

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Jeremy Laidman
Sent: Sunday, July 07, 2013 7:42 PM
To: Operaciones
Cc: xymon at xymon.com
Subject: Re: [Xymon] problem with ext script

On 5 July 2013 23:43, Operaciones <user-1e7642c06451@xymon.invalid<mailto:user-1e7642c06451@xymon.invalid>> wrote:
So, when i run the script with xymon, show the error:

ERROR: you must be root

What I generally do in these cases is run the command from root's cron and capture the output in a file that's readable by the Xymon user.  Like so:

*/5 * * * * /sbin/dmraid -r >/tmp/dmraid.out && chgrp xymon /tmp/dmraid.out && chmod 644 /tmp/dmraid.out

Then in the script, in place of "dmraid -r" you just do "cat /tmp/dmraid.out".

J
list Operaciones Corpresa · Mon, 08 Jul 2013 14:35:40 +0200 ·
Hello Paul,

Thank you by your advice, finally i did some like Jeremy said.

Thank you very much to all.
quoted from Paul Root

El 08/07/2013 14:10, Root, Paul T escribió:
Why not just send the output to the server with the xymon command?

*From:*Xymon [mailto:xymon-bounces at xymon.com] *On Behalf Of *Jeremy Laidman
*Sent:* Sunday, July 07, 2013 7:42 PM
*To:* Operaciones
*Cc:* xymon at xymon.com
*Subject:* Re: [Xymon] problem with ext script

On 5 July 2013 23:43, Operaciones <user-1e7642c06451@xymon.invalid <mailto:user-1e7642c06451@xymon.invalid>> wrote:

    So, when i run the script with xymon, show the error:

    ERROR: you must be root


What I generally do in these cases is run the command from root's cron and capture the output in a file that's readable by the Xymon user.  Like so:

*/5 * * * * /sbin/dmraid -r >/tmp/dmraid.out && chgrp xymon /tmp/dmraid.out && chmod 644 /tmp/dmraid.out

Then in the script, in place of "dmraid -r" you just do "cat /tmp/dmraid.out".

J
list Jeremy Laidman · Mon, 8 Jul 2013 22:52:05 +1000 ·
quoted from Operaciones Corpresa
On Monday, 8 July 2013, Root, Paul T wrote:
 Why not just send the output to the server with the xymon command?
Yeah, I like this idea.  The command can be sent as a supplementary client
command like so:

*/5 * * * * ~xymon/client/bin/xymoncmd sh -c '{ echo client/dmraid
$MACHINE; echo "[dmraid]"; /sbin/dmraid -r; } | $XYMON $XYMSRV @'

Then a script on the Xymon server can pull the dmraid output from the
client data like so:

#!/bin/sh
DMRAID=`$XYMON $XYMSRV "clientlog name.of.host section=dmraid"`

This strategy means that all of the heavy lifting is done on the Xymon
server, and the client needs only a fairly simple one-liner in a crontab.
 Improvements to the script need only be applied to the Xymon server,
instead of having to perform updates to (for some of us) dozens or more
clients.

J