Discussion:
[Check_mk (english)] Plugin powershell
dominique Arpin
2016-03-18 12:50:59 UTC
Permalink
Hi,

I write a local Powershell script in the local directory of checkmk.

If a test locally with check_mk_agent.exe test, everything work fine.
However, from my server, I got empty value. I tried also with a telnet .

I use Get-Counter to retrieve values from my exchange server. The script
took 17 seconds to run. It's a French version, but I tried with only
non-accent counter with same result.

Regards,

Dominique
Andreas Döhler
2016-03-22 23:07:34 UTC
Permalink
Hi Dominique,

do you also tested with the same account the agent is running as a service?
In a normal setup the agent run as local system and also inside this
context.
Test the agent service with a normal account and look if the script is
returning something.

For actual version of agent you can also setup to run scripts with
different users then the service is running.

Best regards
Andreas
Post by dominique Arpin
Hi,
I write a local Powershell script in the local directory of checkmk.
If a test locally with check_mk_agent.exe test, everything work fine.
However, from my server, I got empty value. I tried also with a telnet .
I use Get-Counter to retrieve values from my exchange server. The script
took 17 seconds to run. It's a French version, but I tried with only
non-accent counter with same result.
Regards,
Dominique
_______________________________________________
checkmk-en mailing list
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
dominique Arpin
2016-03-23 22:53:20 UTC
Permalink
Hi Andreas,

thanks for your help, I changed the user and everything is working fine.
Could you give me more info how to run my script with different credentials?

Regards,

Dominique
Post by Andreas Döhler
Hi Dominique,
do you also tested with the same account the agent is running as a service?
In a normal setup the agent run as local system and also inside this
context.
Test the agent service with a normal account and look if the script is
returning something.
For actual version of agent you can also setup to run scripts with
different users then the service is running.
Best regards
Andreas
Post by dominique Arpin
Hi,
I write a local Powershell script in the local directory of checkmk.
If a test locally with check_mk_agent.exe test, everything work fine.
However, from my server, I got empty value. I tried also with a telnet .
I use Get-Counter to retrieve values from my exchange server. The script
took 17 seconds to run. It's a French version, but I tried with only
non-accent counter with same result.
Regards,
Dominique
_______________________________________________
checkmk-en mailing list
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
Andreas Döhler
2016-03-24 11:02:25 UTC
Permalink
Hi Dominique,

at the moment there are only documentation how to do it with MRPE checks.
But inside source code of agent you find the same function also for local
checks and plugins under Windows.

Best regards
Andreas
Post by dominique Arpin
Hi Andreas,
thanks for your help, I changed the user and everything is working fine.
Could you give me more info how to run my script with different credentials?
Regards,
Dominique
Post by Andreas Döhler
Hi Dominique,
do you also tested with the same account the agent is running as a service?
In a normal setup the agent run as local system and also inside this
context.
Test the agent service with a normal account and look if the script is
returning something.
For actual version of agent you can also setup to run scripts with
different users then the service is running.
Best regards
Andreas
Post by dominique Arpin
Hi,
I write a local Powershell script in the local directory of checkmk.
If a test locally with check_mk_agent.exe test, everything work fine.
However, from my server, I got empty value. I tried also with a telnet .
I use Get-Counter to retrieve values from my exchange server. The
script took 17 seconds to run. It's a French version, but I tried with only
non-accent counter with same result.
Regards,
Dominique
_______________________________________________
checkmk-en mailing list
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
Etienne, Christophe (RTS)
2018-11-29 10:03:37 UTC
Permalink
Hello,

I have a same example of this issue:

Locally, cmd -> “check_mk_agent.exe test” result :

<<<local>>>
0 CheckSMB_access Access=1;; Access ok

And in the diagnostic window from the web site:
<<<local>>>
<<<local>>>
0 CheckSMB_access Access=0;; NO ACCESS
<<<local>>>

Running with the same account in the service account and in the command line


Best regards,

Christophe

De : checkmk-en-***@lists.mathias-kettner.de <checkmk-en-***@lists.mathias-kettner.de> De la part de dominique Arpin
Envoyé : vendredi, 18 mars 2016 13:55
À : checkmk-***@lists.mathias-kettner.de
Objet : [Check_mk (english)] Plugin powershell


Hi,

I write a local Powershell script in the local directory of checkmk.

If a test locally with check_mk_agent.exe test, everything work fine. However, from my server, I got empty value. I tried also with a telnet .

I use Get-Counter to retrieve values from my exchange server. The script took 17 seconds to run. It's a French version, but I tried with only non-accent counter with same result.

Regards,

Dominique
Andreas Döhler
2018-11-29 10:24:16 UTC
Permalink
Hi Christophe,

the result depends on what your script is doing. If you look for a mounted
filesystem then the outcome is correct as the service user don't see this
filesystem also if it is mounted under your user in your current session.
For a more qualified answer it is important to know what the script is
doing.

Best regards
Andreas

Am Do., 29. Nov. 2018 um 11:16 Uhr schrieb Etienne, Christophe (RTS) <
Post by Etienne, Christophe (RTS)
Hello,
<<<local>>>
0 CheckSMB_access Access=1;; Access ok
<<<local>>>
<<<local>>>
0 CheckSMB_access Access=0;; NO ACCESS
<<<local>>>
Running with the same account in the service account and in the command line
Best regards,
Christophe
Arpin
*Envoyé :* vendredi, 18 mars 2016 13:55
*Objet :* [Check_mk (english)] Plugin powershell
Hi,
I write a local Powershell script in the local directory of checkmk.
If a test locally with check_mk_agent.exe test, everything work fine.
However, from my server, I got empty value. I tried also with a telnet .
I use Get-Counter to retrieve values from my exchange server. The script
took 17 seconds to run. It's a French version, but I tried with only
non-accent counter with same result.
Regards,
Dominique
_______________________________________________
checkmk-en mailing list
Manage your subscription or unsubscribe
https://lists.mathias-kettner.de/cgi-bin/mailman/listinfo/checkmk-en
Etienne, Christophe (RTS)
2018-11-29 10:29:05 UTC
Permalink
Thx for your answer,
Sure, just a little function to check smb access. I’ve started my session with the same service account used to run the check_mk_agent service.



function SmbAccess {

Param(
$PathToCheck,
$ServiceName,
$servername
)


If (Test-Connection -ComputerName $servername -Quiet -Count 1){


If (Test-Path -Path $pathtocheck){ Write-Output "0 $ServiceName Access=1;; Access ok " }
Else { Write-Output "0 $ServiceName Access=0;; NO ACCESS " }

}

}
Christophe

De : Andreas Döhler <***@gmail.com>
Envoyé : jeudi, 29 novembre 2018 11:24
À : Etienne, Christophe (RTS) <***@rts.ch>
Cc : dominique Arpin <***@gmail.com>; <checkmk-***@lists.mathias-kettner.de> <checkmk-***@lists.mathias-kettner.de>
Objet : Re: [Check_mk (english)] Plugin powershell

Hi Christophe,

the result depends on what your script is doing. If you look for a mounted filesystem then the outcome is correct as the service user don't see this filesystem also if it is mounted under your user in your current session.
For a more qualified answer it is important to know what the script is doing.

Best regards
Andreas

Am Do., 29. Nov. 2018 um 11:16 Uhr schrieb Etienne, Christophe (RTS) <***@rts.ch<mailto:***@rts.ch>>:
Hello,

I have a same example of this issue:

Locally, cmd -> “check_mk_agent.exe test” result :

<<<local>>>
0 CheckSMB_access Access=1;; Access ok

And in the diagnostic window from the web site:
<<<local>>>
<<<local>>>
0 CheckSMB_access Access=0;; NO ACCESS
<<<local>>>

Running with the same account in the service account and in the command line


Best regards,

Christophe

De : checkmk-en-***@lists.mathias-kettner.de<mailto:checkmk-en-***@lists.mathias-kettner.de> <checkmk-en-***@lists.mathias-kettner.de<mailto:checkmk-en-***@lists.mathias-kettner.de>> De la part de dominique Arpin
Envoyé : vendredi, 18 mars 2016 13:55
À : checkmk-***@lists.mathias-kettner.de<mailto:checkmk-***@lists.mathias-kettner.de>
Objet : [Check_mk (english)] Plugin powershell


Hi,

I write a local Powershell script in the local directory of checkmk.

If a test locally with check_mk_agent.exe test, everything work fine. However, from my server, I got empty value. I tried also with a telnet .

I use Get-Counter to retrieve values from my exchange server. The script took 17 seconds to run. It's a French version, but I tried with only non-accent counter with same result.

Regards,

Dominique
_______________________________________________
checkmk-en mailing list
checkmk-***@lists.mathias-kettner.de<mailto:checkmk-***@lists.mathias-kettner.de>
Manage your subscription or unsubscribe
https://lists.mathias-kettner.de/cgi-bin/mailman/listinfo/checkmk-en
Andreas Döhler
2018-11-29 10:59:55 UTC
Permalink
I took a look at the internet and found some problems with the "Test-Path"
cmdlet.
A suggested solution looked like the following --> Test-Path
$('filesystem::\\Server\share$\file')
The problem is the complete UNC path not only the share name.

Best regards
Andreas

Am Do., 29. Nov. 2018 um 11:29 Uhr schrieb Etienne, Christophe (RTS) <
Post by Etienne, Christophe (RTS)
Thx for your answer,
Sure, just a little function to check smb access. I’ve started my session
with the same service account used to run the check_mk_agent service.
function SmbAccess {
Param(
$PathToCheck,
$ServiceName,
$servername
)
If (Test-Connection -ComputerName $servername -Quiet -Count 1){
If (Test-Path -Path $pathtocheck){ Write-Output "0 $ServiceName
Access=1;; Access ok " }
Else { Write-Output "0 $ServiceName Access=0;; NO ACCESS " }
}
}
Christophe
*Envoyé :* jeudi, 29 novembre 2018 11:24
*Objet :* Re: [Check_mk (english)] Plugin powershell
Hi Christophe,
the result depends on what your script is doing. If you look for a mounted
filesystem then the outcome is correct as the service user don't see this
filesystem also if it is mounted under your user in your current session.
For a more qualified answer it is important to know what the script is doing.
Best regards
Andreas
Am Do., 29. Nov. 2018 um 11:16 Uhr schrieb Etienne, Christophe (RTS) <
Hello,
<<<local>>>
0 CheckSMB_access Access=1;; Access ok
<<<local>>>
<<<local>>>
0 CheckSMB_access Access=0;; NO ACCESS
<<<local>>>
Running with the same account in the service account and in the command line
Best regards,
Christophe
Arpin
*Envoyé :* vendredi, 18 mars 2016 13:55
*Objet :* [Check_mk (english)] Plugin powershell
Hi,
I write a local Powershell script in the local directory of checkmk.
If a test locally with check_mk_agent.exe test, everything work fine.
However, from my server, I got empty value. I tried also with a telnet .
I use Get-Counter to retrieve values from my exchange server. The script
took 17 seconds to run. It's a French version, but I tried with only
non-accent counter with same result.
Regards,
Dominique
_______________________________________________
checkmk-en mailing list
Manage your subscription or unsubscribe
https://lists.mathias-kettner.de/cgi-bin/mailman/listinfo/checkmk-en
Etienne, Christophe (RTS)
2018-11-29 12:02:13 UTC
Permalink
Ok tanks a lot it’s working now,

I’m using another command to test the smb path

If (get-childitem $pathtocheck -ErrorAction SilentlyContinue){ Write-Output "0 $ServiceName Access=1;; Access ok " }
Else { Write-Output "0 $ServiceName Access=0;; NO ACCESS " }
Result locally and on check_mk website are same now

Have a nice day

Christophe

De : Andreas Döhler <***@gmail.com>
Envoyé : jeudi, 29 novembre 2018 12:00
À : Etienne, Christophe (RTS) <***@rts.ch>
Cc : dominique Arpin <***@gmail.com>; <checkmk-***@lists.mathias-kettner.de> <checkmk-***@lists.mathias-kettner.de>
Objet : Re: [Check_mk (english)] Plugin powershell

I took a look at the internet and found some problems with the "Test-Path" cmdlet.
A suggested solution looked like the following --> Test-Path $('filesystem::\\Server\share$\file')
The problem is the complete UNC path not only the share name.

Best regards
Andreas

Am Do., 29. Nov. 2018 um 11:29 Uhr schrieb Etienne, Christophe (RTS) <***@rts.ch<mailto:***@rts.ch>>:
Thx for your answer,
Sure, just a little function to check smb access. I’ve started my session with the same service account used to run the check_mk_agent service.



function SmbAccess {

Param(
$PathToCheck,
$ServiceName,
$servername
)


If (Test-Connection -ComputerName $servername -Quiet -Count 1){


If (Test-Path -Path $pathtocheck){ Write-Output "0 $ServiceName Access=1;; Access ok " }
Else { Write-Output "0 $ServiceName Access=0;; NO ACCESS " }

}

}
Christophe

De : Andreas Döhler <***@gmail.com<mailto:***@gmail.com>>
Envoyé : jeudi, 29 novembre 2018 11:24
À : Etienne, Christophe (RTS) <***@rts.ch<mailto:***@rts.ch>>
Cc : dominique Arpin <***@gmail.com<mailto:***@gmail.com>>; <checkmk-***@lists.mathias-kettner.de<mailto:checkmk-***@lists.mathias-kettner.de>> <checkmk-***@lists.mathias-kettner.de<mailto:checkmk-***@lists.mathias-kettner.de>>
Objet : Re: [Check_mk (english)] Plugin powershell

Hi Christophe,

the result depends on what your script is doing. If you look for a mounted filesystem then the outcome is correct as the service user don't see this filesystem also if it is mounted under your user in your current session.
For a more qualified answer it is important to know what the script is doing.

Best regards
Andreas

Am Do., 29. Nov. 2018 um 11:16 Uhr schrieb Etienne, Christophe (RTS) <***@rts.ch<mailto:***@rts.ch>>:
Hello,

I have a same example of this issue:

Locally, cmd -> “check_mk_agent.exe test” result :

<<<local>>>
0 CheckSMB_access Access=1;; Access ok

And in the diagnostic window from the web site:
<<<local>>>
<<<local>>>
0 CheckSMB_access Access=0;; NO ACCESS
<<<local>>>

Running with the same account in the service account and in the command line


Best regards,

Christophe

De : checkmk-en-***@lists.mathias-kettner.de<mailto:checkmk-en-***@lists.mathias-kettner.de> <checkmk-en-***@lists.mathias-kettner.de<mailto:checkmk-en-***@lists.mathias-kettner.de>> De la part de dominique Arpin
Envoyé : vendredi, 18 mars 2016 13:55
À : checkmk-***@lists.mathias-kettner.de<mailto:checkmk-***@lists.mathias-kettner.de>
Objet : [Check_mk (english)] Plugin powershell


Hi,

I write a local Powershell script in the local directory of checkmk.

If a test locally with check_mk_agent.exe test, everything work fine. However, from my server, I got empty value. I tried also with a telnet .

I use Get-Counter to retrieve values from my exchange server. The script took 17 seconds to run. It's a French version, but I tried with only non-accent counter with same result.

Regards,

Dominique
_______________________________________________
checkmk-en mailing list
checkmk-***@lists.mathias-kettner.de<mailto:checkmk-***@lists.mathias-kettner.de>
Manage your subscription or unsubscribe
https://lists.mathias-kettner.de/cgi-bin/mailman/listinfo/checkmk-en
Loading...