ricoberger / script_exporter

Prometheus exporter to execute scripts and collect metrics from the output or the exit status.
MIT License
354 stars 82 forks source link

Windows Powershell or CMD script example #41

Closed YulianSalo closed 2 years ago

YulianSalo commented 3 years ago

@ricoberger I would be grateful if you could provide some examples for Windows scripts (powershell/cmd)

m-marinka commented 3 years ago

@ricoberger I would like to get some examples for Windows scripts too if it is possible. It would help me a lot! Thank you in advance.

ricoberger commented 3 years ago

Hi @YulianSalo and @m-marinka, since the script_exporter is just running the given script / command via exec.Command I think sth. like shown here should work for for powershell.

Unfortunately I do not have a Windows system right now to test it.

@adjosan or @skpenpen were playing around with running the exporter on windows. Maybe they can help out with a proper example.

skpenpen commented 3 years ago
tls:
  enabled: false
  crt: server.crt
  key: server.key

basicAuth:
  enabled: false
  username: username
  password: password

bearerAuth:
  enabled: false
  signingKey: my_secret_key

scripts:

  - name: hello
    script: powershell -executionpolicy bypass -file C:/Prometheus/script_exporter/scripts/helloworld.ps1

  - name: hyperv
    script: powershell -executionpolicy bypass -file C:/Prometheus/script_exporter/scripts/hyperv.ps1

  - name: scheduled_tasks
    script: powershell -executionpolicy bypass -file C:/Prometheus/script_exporter/scripts/scheduled_tasks.ps1

  - name: certificats
    script: powershell -executionpolicy bypass -file C:/Prometheus/script_exporter/scripts/cert.ps1

  - name: synchronisation_ntp
    script: powershell -executionpolicy bypass -file C:/Prometheus/script_exporter/scripts/synchronisation_ntp.ps1 -ntpserver <ntpserver>
ricoberger commented 3 years ago

Thanks for sharing @skpenpen.

Does this help you @YulianSalo and @m-marinka?

ricoberger commented 2 years ago

Since the issue seems to be resolved, I would close it for now. If you need further help please let me know or if someone ones to add an example for PowerShell / CMD feel free to create a PR.