简体   繁体   中英

how to get uptime of GCP VM instance

I need to know the uptime of GCP VM instances (windows and Linux both) and based on the time I need to stop the VM. Somehow, I am not getting any simpler way to get the uptime of my all GCP VMs which are like 100 in numbers and will be increasing.

I went through below answer but even there it is not answered, I could not add comment so had to ask new question. Get vm uptime data from stackdriver-agent in gcp?

In the python code snippet at below link, there is no module available for instance uptime all we have is creating uptime check for service availability. https://github.com/GoogleCloudPlatform/python-docs-samples

How can I get uptime of all GCP VM instances ?

Assuming that you can adjust process of starting VMs, I think solution below is viable:

  1. When VM is started, add a custom tag with current timestamp ( API reference )
  2. Use this tag's value to determine actual instance's uptime

I realize that it sounds overcomplicated, but I don't see any better OS-independent solution.

Update:
The feature you need is already requested in Google's issue tracker. You can check the progress and\\or "start" it here: https://issuetracker.google.com/issues/136105125
Note: the issue referenced above is marked as blocked by another one, non-public

  1. Go to GCP console
  2. Select monitoring
  3. Click Uptime checks.
  4. Click Create Uptime check.

for more info check the below document

https://cloud.google.com/monitoring/uptime-checks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM