https://github.com/OCSInventory-NG/OCSInventory-ocsreports/issues/1045
https://github.com/OCSInventory-NG/OCSInventory-ocsreports/issues/1045
I observe strange behaviour of the reported inventories from some 2.8 Windows Agents.
Some works fine, some not... There is a growing difference between the known machines in dashbord and the realy known machine in the machine list...
I had found out, that some agents get ein html 200 and started to collect inventory data, but when they send it there will result in an html 500 error...
Example:
172.17.1.134 - - [12/Nov/2020:16:32:28 +0100] "POST /ocsinventory HTTP/1.1" 200 235 "-""OCS-NG_WINDOWS_AGENT_v2.7.0.1"
172.17.1.134 - - [12/Nov/2020:16:34:08 +0100] "POST /ocsinventory HTTP/1.1" 500 527 "-""OCS-NG_WINDOWS_AGENT_v2.7.0.1"
10.242.2.15 - - [12/Nov/2020:16:34:52 +0100] "POST /ocsinventory HTTP/1.1" 200 235 "-""OCS-NG_WINDOWS_AGENT_v2.8.0.0"
10.242.2.15 - - [12/Nov/2020:16:36:15 +0100] "POST /ocsinventory HTTP/1.1" 500 527 "-""OCS-NG_WINDOWS_AGENT_v2.8.0.0"
Agent-Log: https://dpaste.org/hYWq
Everytime when in access_log a 500 appears, then this apears in error_log:
DBD::mysql::db do failed: Table 'ocs.softwares' doesn't exist at /usr/local/share/perl5/5.32/Apache/Ocsinventory/Server/Inventory/Cache.pm line 77.
DBD::mysql::db do failed: Table 'ocs.softwares' doesn't exist at /usr/local/share/perl5/5.32/Apache/Ocsinventory/Server/Inventory/Cache.pm line 79.
DBD::mysql::st execute failed: Table 'ocs.softwares' doesn't exist at /usr/local/share/perl5/5.32/Apache/Ocsinventory/Server/Inventory/Update.pm line 108.
Database works well, the password(s) in config files set well, most other clients/agents can send inventory w/o problem...
How can I debug that and find out where the Data is lost???
OCS Reports from Repo for Fedora 33:
Bonjour !
Lors d'un inventaire SNMP d'une imprimante HP, j'ai observé des problèmes d'encodage des réponses SNMP dans le fichier XML envoyé au serveur ( formatage des réponses au format octetstring dans les balises XML ) et retour d'un code 500 du serveur OCS
Mon serveur ( V2.8 sur Centos 7.8 2003 ) est configuré avec le modèle d'équipement SNMP suivant :
label + OID suivant :
Imprimante HP | Description | 1.3.6.1.2.1.1.1.0 | ||
Imprimante HP | uptime | 1.3.6.1.2.1.1.3.0 | ||
Imprimante HP | Model Name | 1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.1.0 | ||
Imprimante HP | Serial Number | 1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0 | Yes |
Les traces ci-dessous sont issues des logs d'un agent ocs inventory V2.8 sur une Centos 7.8 2003 , version de perl v5.16.3
La MiB HP (HP-LASERJET-COMMON-MIB.mib) est bien le répertoire "/usr/share/snmp/mibs", les droits d'accès sont OK ( similaire au autre mibs )
On peut voir que les balises XML Model Name et Serial Number sont au format OctetString et donc probablement dans le format attendu
On peut observer à la fin des log que le serveur OCS renvoie un code "500 Internal Server Error"
Les logs :
[Fri Nov 13 22:45:38 2020][debug] sending: <?xml version="1.0" encoding="UTF-8"?>
<REQUEST>
<CONTENT>
<snmp_imprimante_hp>
<Description>HP ETHERNET MULTI-ENVIRONMENT,SN:VNC3S88888,FN:8G44X2Z,SVCID:30157,PID:HP LaserJet MFP M28w</Description>
<Model Name>01:15:57:32:47:35:35:41</Model Name>
<Serial Number>01:15:56:4E:43:33:53:38:38:38:38:38</Serial Number>
<uptime>8 days, 03:58:42.74</uptime>
</snmp_imprimante_hp>
</CONTENT>
<DEVICEID>agentocs-2020-11-13-18-50-24</DEVICEID>
<QUERY>SNMP</QUERY>
</REQUEST>
[Fri Nov 13 22:45:38 2020][error] Cannot establish communication : 500 Internal Server Error
[Fri Nov 13 22:45:38 2020][debug] [snmpscan] End snmp_end_handler :)
Proposition de modification du code des modules
j'ai testé une modification du code perl de la configuration du paramètre "-translate" de l'objet Net::SNMP avec la configuration suivante dans les modules SnmpScan.pm et Snmp.pm
-translate => [-nosuchinstance => 0, -nosuchobject => 0, -octetstring => 0]
code d'origine :
-translate => [-nosuchinstance => 0, -nosuchobject => 0, ]
voici un exemple :
# We have an older version v2c ou v1
($session, $error) = Net::SNMP->session(
-retries => 1 ,
-timeout => 3,
-version => 'snmpv'.$comm->{VERSION},
-hostname => $device->{IPADDR},
-community => $comm->{NAME},
-translate => [-nosuchinstance => 0, -nosuchobject => 0, -octetstring => 0],
j'ai réalise les modifications 2 fois ( fonction snmp V1/V2 et snmp V3 ) dans les modules SnmpScan.pm et Snmp.pm
Après la modification ,le résultats est le suivant dans le fichier de log :
le formatage des réponses SNMP dans les balises XML est correcte ...Toutefois, la réponse du serveur est toujours "Cannot establish communication : 500 Internal Server"
<REQUEST>
<CONTENT>
<snmp_imprimante_hp>
<Description>HP ETHERNET MULTI-ENVIRONMENT,SN:VNC3S88888,FN:8G44X2Z,SVCID:30157,PID:HP LaserJet MFP M28w</Description>
<Model Name>W2G55A</Model Name>
<Serial Number>VNC3S88888</Serial Number>
<uptime>8 days, 06:06:36.83</uptime>
</snmp_imprimante_hp>
</CONTENT>
<DEVICEID>agentocs-2020-11-13-18-50-24</DEVICEID>
<QUERY>SNMP</QUERY>
</REQUEST>
[Sat Nov 14 00:53:33 2020][error] Cannot establish communication : 500 Internal Server Error
[Sat Nov 14 00:53:33 2020][debug] [snmpscan] End snmp_end_handler :
Les logs sur le serveur OCS
[Sat Nov 14 00:53:33.029221 2020] [perl:error] [pid 1837] [client 192.168.0.26:44192] \nnot well-formed (invalid token) at line 6, column 17, byte 228 at /usr/lib64/perl5/vendor_perl/XML/Parser.pm line 187.\n
Pouvez-vous regarder le problème d'encodage des réponses SNMP dans le fichier XML du client OCS et l'erreur 500 du serveur, et peut être aussi ma proposition de modification du code !
Cordialement !
Hullo,
I think this type of problem/issue correlates with this one, but still I have no idea what the heck is going wrong:
Hosts increase in dash, but not in the host list.
I've the same issue. Most of the functionality is in the function "getSoftwareInformations" in /usr/share/ocsinventory-reports/ocsreports/require/cve/Cve.php.
There are two nested loops: The outer loop goes through all publisher and the inner loop through all software (from the publishers) on all computers.
Since the table "software" has a row for each software/hardware combination (see mysql: describe software;), the loop run through for each computer/software combination.
I fixed it by adding a "DISTINCT" to the SQL query (Line 133 in Cve.php):
$sql_soft = "SELECT DISTINCT n.NAME, v.VERSION, s.NAME_ID, s.VERSION_ID
FROM software_name n LEFT JOIN software s ON s.NAME_ID = n.ID
LEFT JOIN software_version v ON v.ID = s.VERSION_ID
WHERE s.PUBLISHER_ID = %s AND s.VERSION_ID != 1";
I haven't tested it yet.A test with the local cve-search is in progress. The number of request are reduced and it looks like, that there only one request per software and version and not per computer on which the software is installed.
Hello Colleagues! I have a question / problem: Does OCS inventory show no change status? Example: suppose I need to format a computer, then it would have to be removed from inventory, right? Does ocs have this function?