Reason: (noSuchName) There is no such variable name in this MIB - centos

I am using centos Operating System.
i am trying to get the memory statistics of localhost through snmpget command, i am getting this error.
snmpget -v 1 -c public localhost .1.3.6.1.4.1.2021.4.6
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: UCD-SNMP-MIB::memAvailReal
But, if i fire this one .. i am getting the output..
snmpget -v 1 -c public localhost .1.3.6.1.2.1.1.3.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (58756) 0:09:47.56
I am not getting what I am doing wrong. I exported the path of /usr/share/snmp/mibs/ to $PATH variable.
can any one help me out.

You'd better read the FAQ page of net-snmp,
http://www.net-snmp.org/wiki/index.php/FAQ:Applications_09
You should use
snmpget -v 1 -c public localhost .1.3.6.1.4.1.2021.4.6.0.

snmpwalk -v 1 -c public localhost iso.1.3.6.1.4.1.2021.4.6
Use this.

Related

Why does psql only works when I pass in a string?

This fails with tlsv1 alert unknown ca
psql -h localhost -p 4566 -d dev -U root --set=sslmode=disable
This works:
psql "port=4566 host=localhost user=root dbname=dev sslmode=disable"
Why? Why does one work when the other does not? Is the --set ignored?
Is this a bug or a feature?
The --set is not ignored, it just doesn't do anything meaningful. It tells psql to set the psql variable named 'sslmode', but that variable is not in charge of anything. If you could connect and you then ran select :'sslmode';, you find that it had indeed been set, but since it isn't in charge of anything this doesn't really matter much.
TheA way to do this correctly, assuming you are using bash, is:
PGSSLMODE=disable psql -h localhost -p 4566 -d dev -U root
https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
The second one works. Because (sslmode=disable) is part of the connection string key words.
psql --help returns:
-s, --single-step single-step mode (confirm each query)
-S, --single-line single-line mode (end of line terminates SQL command)
also if you psql --help | grep ssl, there is zero result. which mean you cannot use simple use
psql -h localhost -p 4566 -d dev -U root --sslmode=disable .
jjanes's answer works because: https://www.postgresql.org/docs/current/libpq-envars.html

What does Usage: psql [wait] mean?

I'm trying to use psql version 9.6 on Mac OSX 10.11 and installed from the EnterpriseDB installer but I'm getting the following error:
MacBook-Pro:local me$ which psql
/usr/local/bin/psql
MacBook-Pro:local me$ /usr/local/bin/psql -h localhost; echo "Error code: $?"
Usage: /usr/local/bin/psql [wait]
Error code: 127
As you can see, I'm simply trying to connect to localhost and I'm getting a usage error despite following the syntax from the manual.
What is happening here?
Your bash is returning the error code 127: command not found.
See 127 Return code from $? for more details about this bash code.
Make sure that psql is in the directory you're trying to access.
Simple mistake - /usr/local/bin/psql was a symlink for /Library/PostgreSQL/9.6/scripts/runpsql.sh which doesn't accept any arguments... it's basically EnterpriseDB's shell script wrapper around the actual actual binary which is /Library/PostgreSQL/9.6/bin/psql.
I just needed to point psql to the real executable and not that shell script.

How to Dump Mysql database using Command line?

When I tried to dump database using command line, it gave me following error.
Command:
D:\TOOLS\MySQL\MySQL Server 5.6\bin>mysqldump -u root -p webchat > tut_backup.sql
Error:
mysqldump: unknown option '--no-beep'
Add host-name in your command, like:
D:\TOOLS\MySQL\MySQL Server 5.6\bin>mysqldump -h localhost -u root -p webchat > tut_backup.sql
Replace localhost with your host-name if it is different.
I consider webchat is your database name and you will have to type password explicitly after firing this command.
And of course you have to remove --no-beep (as suggested by Mark Setchell ) from mysql configuration file.
Hope it helps, thanks.

How to set up cron using curl command?

After apache rebuilt my cron jobs stopped working.
I used the following command:
wget -O - -q -t 1 http://example.com/cgi-bin/loki/autobonus.pl
Now my DC support suggests me to change the wget method to curl. What would be the correct value in this case?
-O - is equivalent to curl's default behavior, so that's easy.
-q is curl's -s (or --silent)
--retry N will substitute for wget's -t N
All in all:
curl -s --retry 1 http://example.com/cgi-bin/loki/autobonus.pl
try run change with the full path of wget
/usr/bin/wget -O - -q -t 1 http://example.com/cgi-bin/loki/autobonus.pl
you can find the full path with:
which wget
and more, check if you can reach the destination domain with ping or other methods:
ping example.com
Update:
based on the comments, seems to be caused by the line in /etc/hosts:
127.0.0.1 example.com #change example.com to the real domain
It seems that you have restricted options in terms that on the server where the cron should run you have the domain pinned to 127.0.0.1 but the virtual host configuration does not work with that.
What you can do is to let wget connect by IP but send the Host header so that the virtual host matching would work:
wget -O - -q -t 1 --header 'Host: example.com' http://xx.xx.35.162/cgi-bin/loki/autobonus.pl
Update
Also probably you don't need to run this over the web server, so why not just run:
perl /path/to/your/script/autobonus.pl

how to suppress FATAL output from ssh on perl using the "system" call?

I'm trying to write a simple script that uses ssh, but I want to test that ssh is working first -if it doesnt work I want to know why it's not working.
Here is what I'm trying:
my $output = system("ssh -q -o ConnectionTimeout=3 -o BatchMode=yes $host \"echo $host\"");
my $real_output = $output/256;
if($real_output == 2){print "RESPONSE: $host is not working, No address associated to the name \n";}
elsif($real_output == 255){print "RESPONSE: $host is not working (connection timed out after 3 secs, it exists but does not respond) \n";}
This works: it collects the error and tests the connection, but when I run it; it shows the following when the name of the host does not exist:
./testMachines --n invalid_host
warning: Connecting to invalid_host failed: No address associated to the name
RESPONSE: invalid_host is not working, No address associated to the name
or when the host name does exist but it's timing out:
./testMachines --n timeout_host
ssh: FATAL: Connection timed out. No protocol greeting received in 10 seconds.
RESPONSE: timeout_host is not working (connection timed out after 3 secs, it exists but does not respond)
How do I suppress the "ssh: FATAL" and "warning" messages? I was under the impression that the '-q' option for ssh will do the trick, but it didnt.
I've also tried the '-q -q' option on ssh (as suggested on the man pages) but no luck.
I've also tried this:
my $output = system("ssh -q -o ConnectionTimeout=3 -o BatchMode=yes $host \"echo 2>&1\"");
without any luck... any ideas?
Basically what I want is the output to be like this (without the FATAL and warning ssh messages):
# ./testMachines -n host
RESPONSE: host is not working (connection timed out after 3 secs, it exists but does not respond)
Thanks a lot!!!
Dan
Not sure how you got the idea to add all that escaping, but this should work:
my $output = system("ssh -q -o ConnectionTimeout=3 -o BatchMode=yes $host \"echo $host\" 2>/dev/null");