Monday, July 20, 2020

install collectd on amazon linux

Problem:

# ./start_cloudwatch_agent.sh 
/opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source file:/opt/aws/amazon-cloudwatch-agent/bin/config.json --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp
Start configuration validation...
/opt/aws/amazon-cloudwatch-agent/bin/config-translator --input /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --input-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
2020/07/20 18:28:55 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp ...
Valid Json input schema.
I! Detecting runasuser...
No csm configuration found.
Configuration validation first phase succeeded
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent -schematest -config /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml
Configuration validation second phase failed
======== Error Log ========
2020/07/20 18:28:55 I! AmazonCloudWatchAgent Version 1.246396.0.
2020/07/20 18:28:55 E! Error parsing /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml, open /usr/share/collectd/types.db: no such file or directory
[root@ip-172-31-4-188 ~]# ls -l /usr/share/collectd/
ls: cannot access /usr/share/collectd/: No such file or directory

Cause:
collectd is not installed.

Solution:

  1. Download collectd from https://collectd.org/download.shtml
  2. Unzip the downloaded file
  3. Install dependencies required in README
  4. From the unzipped folder, run command:
    # ./configure --prefix=/usr
  5. Compile and install
    # make install

 

Sunday, July 12, 2020

GCP: Policy update access denied., forbidden


Error: Request "Create IAM Members roles/logging.logWriter serviceAccount:tf-gke-rain-gke-1-xga7@hello-world-261715.iam.gserviceaccount.com for \"project \\\"hello-world-261715\\\"\"" returned error: Error applying IAM policy for project "hello-world-261715": Error setting IAM policy for project "hello-world-261715": googleapi: Error 403: Policy update access denied., forbidden

Solution:

Goto IAM -> Choose 924140772978-compute@developer.gserviceaccount.com, Edit by click the pencil at the end of the line.
In the Role Dropdown menu, choose project, then choose owner.

Wednesday, July 8, 2020

SSH: Disable Strict Host Key Checking


When you first time ssh to a server, it always to ask your confirm to continue like below:
$ ssh 10.128.15.213The authenticity of host '10.128.15.213 (10.128.15.213)' can't be established.ECDSA key fingerprint is SHA256:jMk2r6vp9wb/QUf2abx7D7F5DMnhKaqA7+bpcAEtIRg.ECDSA key fingerprint is MD5:b9:05:d6:bd:97:80:dd:0f:a0:cb:10:34:1f:3e:19:10.Are you sure you want to continue connecting (yes/no)?
Add below entries into ~/.ssh/config to stop the message:
Host *
    StrictHostKeyChecking no

Monday, July 6, 2020

Powershell: ng.ps1 cannot be loaded because running scripts is disabled on this system.

https://stackoverflow.com/questions/58032631/why-powershell-does-not-run-angular-commands

Problem:
PS D:\angular\my-dream-app> ng serve --host 0.0.0.0
ng : File C:\Users\arthu\AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system. For more
At line:1 char:1
+ ng serve --host 0.0.0.0
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

Solution:

Remove ng.ps1 from the directory C:\Users\%username%\AppData\Roaming\npm\ then try clearing the npm cache at C:\Users\%username%\AppData\Roaming\npm-cache\